- Timestamp:
- May 8, 2016 3:22:45 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/log/log.cpp
r57975 r60880 344 344 size_t cchInstr; /**< The size of the name. */ 345 345 uint32_t fFlag; /**< The corresponding destination flag. */ 346 } const s_aLogDst[] =346 } const g_aLogDst[] = 347 347 { 348 348 { RT_STR_TUPLE("file"), RTLOGDEST_FILE }, /* Must be 1st! */ … … 2202 2202 2203 2203 /** 2204 * Finds the end of a destination value. 2205 * 2206 * The value ends when we counter a ';' or a free standing word (space on both 2207 * from the g_aLogDst table. (If this is problematic for someone, we could 2208 * always do quoting and escaping.) 2209 * 2210 * @returns Value length in chars. 2211 * @param pszValue The first char after '=' or ':'. 2212 */ 2213 static size_t rtLogDestFindValueLength(const char *pszValue) 2214 { 2215 size_t off = 0; 2216 char ch; 2217 while ((ch = pszValue[off]) != '\0' && ch != ';') 2218 { 2219 if (!RT_C_IS_SPACE(ch)) 2220 off++; 2221 else 2222 { 2223 size_t cchThusFar = off; 2224 do 2225 off++; 2226 while ((ch = pszValue[off]) != '\0' && RT_C_IS_SPACE(ch)); 2227 if (ch == ';') 2228 return cchThusFar; 2229 2230 if (ch == 'n' && pszValue[off + 1] == 'o') 2231 off += 2; 2232 for (unsigned i = 0; i < RT_ELEMENTS(g_aLogDst); i++) 2233 if (!strncmp(&pszValue[off], g_aLogDst[i].pszInstr, g_aLogDst[i].cchInstr)) 2234 { 2235 ch = pszValue[off + g_aLogDst[i].cchInstr]; 2236 if (ch == '\0' || RT_C_IS_SPACE(ch) || ch == '=' || ch == ':' || ch == ';') 2237 return cchThusFar; 2238 } 2239 } 2240 } 2241 return off; 2242 } 2243 2244 2245 /** 2204 2246 * Updates the logger destination using the specified string. 2205 2247 * … … 2243 2285 2244 2286 /* instruction. */ 2245 for (i = 0; i < RT_ELEMENTS( s_aLogDst); i++)2246 { 2247 size_t cchInstr = strlen( s_aLogDst[i].pszInstr);2248 if (!strncmp(pszValue, s_aLogDst[i].pszInstr, cchInstr))2287 for (i = 0; i < RT_ELEMENTS(g_aLogDst); i++) 2288 { 2289 size_t cchInstr = strlen(g_aLogDst[i].pszInstr); 2290 if (!strncmp(pszValue, g_aLogDst[i].pszInstr, cchInstr)) 2249 2291 { 2250 2292 if (!fNo) 2251 pLogger->fDestFlags |= s_aLogDst[i].fFlag;2293 pLogger->fDestFlags |= g_aLogDst[i].fFlag; 2252 2294 else 2253 pLogger->fDestFlags &= ~ s_aLogDst[i].fFlag;2295 pLogger->fDestFlags &= ~g_aLogDst[i].fFlag; 2254 2296 pszValue += cchInstr; 2255 2297 … … 2259 2301 if (*pszValue == '=' || *pszValue == ':') 2260 2302 { 2261 const char *pszEnd;2262 2263 2303 pszValue++; 2264 pszEnd = strchr(pszValue, ';'); 2265 if (!pszEnd) 2266 pszEnd = strchr(pszValue, '\0'); 2267 size_t cch = pszEnd - pszValue; 2304 size_t cch = rtLogDestFindValueLength(pszValue); 2305 const char *pszEnd = pszValue + cch; 2306 2268 2307 # ifdef IN_RING3 2269 2308 char szTmp[sizeof(pLogger->pInt->szFilename)]; … … 2366 2405 else 2367 2406 AssertMsgFailedReturn(("Invalid destination value! %s%s doesn't take a value!\n", 2368 fNo ? "no" : "", s_aLogDst[i].pszInstr),2407 fNo ? "no" : "", g_aLogDst[i].pszInstr), 2369 2408 VERR_INVALID_PARAMETER); 2370 2409 … … 2382 2421 2383 2422 /* assert known instruction */ 2384 AssertMsgReturn(i < RT_ELEMENTS( s_aLogDst),2423 AssertMsgReturn(i < RT_ELEMENTS(g_aLogDst), 2385 2424 ("Invalid destination value! unknown instruction %.20s\n", pszValue), 2386 2425 VERR_INVALID_PARAMETER); … … 2429 2468 */ 2430 2469 fDestFlags = pLogger->fDestFlags; 2431 for (i = 6; i < RT_ELEMENTS( s_aLogDst); i++)2432 if ( s_aLogDst[i].fFlag & fDestFlags)2470 for (i = 6; i < RT_ELEMENTS(g_aLogDst); i++) 2471 if (g_aLogDst[i].fFlag & fDestFlags) 2433 2472 { 2434 2473 if (fNotFirst) … … 2438 2477 return rc; 2439 2478 } 2440 rc = RTStrCopyP(&pszBuf, &cchBuf, s_aLogDst[i].pszInstr);2479 rc = RTStrCopyP(&pszBuf, &cchBuf, g_aLogDst[i].pszInstr); 2441 2480 if (RT_FAILURE(rc)) 2442 2481 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.