Changeset 51655 in vbox
- Timestamp:
- Jun 18, 2014 8:36:51 PM (11 years ago)
- svn:sync-xref-src-repo-rev:
- 94419
- Location:
- trunk/src/VBox
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/OpenGL/include/cr_string.h
r48348 r51655 9 9 10 10 #include <iprt/cdefs.h> 11 #include <iprt/types.h> 11 12 12 13 RT_C_DECLS_BEGIN … … 61 62 62 63 DECLEXPORT(int) crStrParseGlVersion(const char * ver); 64 DECLEXPORT(int32_t) crStrParseI32(const char *pszStr, const int32_t defaultVal); 63 65 RT_C_DECLS_END 64 66 -
trunk/src/VBox/GuestHost/OpenGL/util/string.c
r48348 r51655 532 532 return iVer; 533 533 } 534 535 int32_t crStrParseI32(const char *pszStr, const int32_t defaultVal) 536 { 537 int32_t result = 0; 538 bool neg = false; 539 unsigned char iDigit = 0; 540 if (!pszStr || pszStr[0] == '\0') 541 return defaultVal; 542 543 for (;;) 544 { 545 if (pszStr[0] == '\0') 546 return defaultVal; 547 548 if (pszStr[0] == ' ' || pszStr[0] == '\t' || pszStr[0] == '\n') 549 { 550 ++pszStr; 551 continue; 552 } 553 554 if (pszStr[0] == '-') 555 { 556 if (neg) 557 return defaultVal; 558 559 neg = true; 560 ++pszStr; 561 continue; 562 } 563 564 break; 565 } 566 567 for (;;) 568 { 569 unsigned char digit; 570 if (pszStr[0] == '\0') 571 { 572 if (!iDigit) 573 return defaultVal; 574 break; 575 } 576 577 digit = pszStr[0] - '0'; 578 if (digit > 9) 579 return defaultVal; 580 581 result *= 10; 582 result += digit; 583 ++iDigit; 584 585 ++pszStr; 586 } 587 588 return !neg ? result : -result; 589 } -
trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server.h
r51356 r51655 371 371 372 372 void crServerInitTmpCtxDispatch(); 373 374 int crServerVBoxParseNumerics(const char *pszStr, const int defaultVal);375 373 376 374 typedef struct CR_FBMAP -
trunk/src/VBox/HostServices/SharedOpenGL/crserverlib/server_config.c
r51201 r51655 56 56 57 57 cr_server.pfnNotifyEventCB = NULL; 58 }59 60 int crServerVBoxParseNumerics(const char *pszStr, const int defaultVal)61 {62 int result = 0;63 bool neg = false;64 unsigned char iDigit = 0;65 if (!pszStr || pszStr[0] == '\0')66 return defaultVal;67 68 for (;;)69 {70 if (pszStr[0] == '\0')71 return defaultVal;72 73 if (pszStr[0] == ' ' || pszStr[0] == '\t' || pszStr[0] == '\n')74 {75 ++pszStr;76 continue;77 }78 79 if (pszStr[0] == '-')80 {81 if (neg)82 return defaultVal;83 84 neg = true;85 ++pszStr;86 continue;87 }88 89 break;90 }91 92 for (;;)93 {94 unsigned char digit;95 if (pszStr[0] == '\0')96 {97 if (!iDigit)98 return defaultVal;99 break;100 }101 102 digit = pszStr[0] - '0';103 if (digit > 9)104 return defaultVal;105 106 result *= 10;107 result += digit;108 ++iDigit;109 110 ++pszStr;111 }112 113 return !neg ? result : -result;114 58 } 115 59 … … 213 157 if (env != NULL && env[0] != '\0') 214 158 { 215 unsigned int bits = (unsigned int)crS erverVBoxParseNumerics(env, 0);159 unsigned int bits = (unsigned int)crStrParseI32(env, 0); 216 160 if (bits <= CR_ALL_BITS) 217 161 cr_server.fVisualBitsDefault = bits; … … 225 169 if (env && env[0] != '\0') 226 170 { 227 cr_server.u32Caps = crS erverVBoxParseNumerics(env, 0);171 cr_server.u32Caps = crStrParseI32(env, 0); 228 172 cr_server.u32Caps &= CR_VBOX_CAPS_ALL; 229 173 } … … 363 307 if (env != NULL && env[0] != '\0') 364 308 { 365 unsigned int bits = (unsigned int)crS erverVBoxParseNumerics(env, 0);309 unsigned int bits = (unsigned int)crStrParseI32(env, 0); 366 310 if (bits <= CR_ALL_BITS) 367 311 cr_server.fVisualBitsDefault = bits; … … 375 319 if (env && env[0] != '\0') 376 320 { 377 cr_server.u32Caps = crS erverVBoxParseNumerics(env, 0);321 cr_server.u32Caps = crStrParseI32(env, 0); 378 322 cr_server.u32Caps &= CR_VBOX_CAPS_ALL; 379 323 }
Note:
See TracChangeset
for help on using the changeset viewer.