Changeset 55494 in vbox for trunk/src/VBox/Runtime/common/misc
- Timestamp:
- Apr 28, 2015 7:18:15 PM (10 years ago)
- svn:sync-xref-src-repo-rev:
- 99844
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/misc/getoptargv.cpp
r44529 r55494 47 47 * require quoting of. 48 48 */ 49 static uint8_t const g_abmQuoteChars[RTGETOPTARGV_CNV_QUOTE_MASK + 1][128/8] = 50 { 51 { 0xfe, 0xff, 0x0f, 0x00, 0x65, 0x00, 0x00, 0x50 }, 52 { 0xfe, 0xff, 0x0f, 0x00, 0xd7, 0x07, 0x00, 0xd8 }, 49 static uint8_t 50 #ifndef IPRT_REGENERATE_QUOTE_CHARS 51 const 52 #endif 53 g_abmQuoteChars[RTGETOPTARGV_CNV_QUOTE_MASK + 1][16] = 54 { 55 { 0xfe, 0xff, 0xff, 0xff, 0x65, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10 }, 56 { 0xfe, 0xff, 0xff, 0xff, 0xd7, 0x07, 0x00, 0xd8, 0x00, 0x00, 0x00, 0x18, 0x01, 0x00, 0x00, 0x50 }, 53 57 }; 54 58 55 59 56 #if 0/* To re-generate the bitmaps. */57 # include <stdio.h>60 #ifdef IPRT_REGENERATE_QUOTE_CHARS /* To re-generate the bitmaps. */ 61 # include <stdio.h> 58 62 int main() 59 63 { … … 66 70 } while (0) 67 71 # define SET(ConstSuffix, ch) \ 68 ASMBitSet(&g_abmQuoteChars[RTGETOPTARGV_CNV_QUOTE_##ConstSuffix], (ch)); 72 do { \ 73 ASMBitSet(&g_abmQuoteChars[RTGETOPTARGV_CNV_QUOTE_##ConstSuffix], (ch)); \ 74 printf(#ConstSuffix ": %#x %d %c\n", (ch), (ch), (ch)); \ 75 } while (0) 69 76 70 77 /* just flag all the control chars as in need of quoting. */ … … 76 83 77 84 /* MS CRT / CMD.EXE: */ 78 SET(MS_CRT, '"') 79 SET(MS_CRT, '&') 80 SET(MS_CRT, '>') 81 SET(MS_CRT, '<') 82 SET(MS_CRT, '|') 83 SET(MS_CRT, '%') 85 SET(MS_CRT, '"'); 86 SET(MS_CRT, '&'); 87 SET(MS_CRT, '>'); 88 SET(MS_CRT, '<'); 89 SET(MS_CRT, '|'); 90 SET(MS_CRT, '%'); 84 91 85 92 /* Bourne shell: */ … … 105 112 { 106 113 printf(" {"); 107 for (size_t iByte = 0; iByte < 8; iByte++)114 for (size_t iByte = 0; iByte < 16; iByte++) 108 115 printf(iByte == 0 ? " 0x%02x" : ", 0x%02x", g_abmQuoteChars[iType][iByte]); 109 116 printf(" },\n"); … … 111 118 return 0; 112 119 } 113 #endif /* To re-generate the bitmaps. */ 114 120 121 #else /* !IPRT_REGENERATE_QUOTE_CHARS */ 115 122 116 123 /** … … 262 269 papszArgs[iArg++] = pszDst; 263 270 264 /* Parse and copy the string over. */ 271 /* 272 * Parse and copy the string over. 273 */ 265 274 RTUNICP CpQuote = 0; 266 275 RTUNICP Cp; … … 276 285 else if (rtGetOptIsCpInSet(Cp, pszSeparators, cchSeparators)) 277 286 break; 287 else if (Cp != '\\') 288 pszDst = RTStrPutCp(pszDst, Cp); 278 289 else 290 { 291 /* escaped char */ 292 rc = RTStrGetCpEx(&pszSrc, &Cp); 293 if (RT_FAILURE(rc) || !Cp) 294 break; 279 295 pszDst = RTStrPutCp(pszDst, Cp); 296 } 280 297 } 281 298 else if (CpQuote != Cp) 282 pszDst = RTStrPutCp(pszDst, Cp); 299 { 300 if (Cp != '\\' || CpQuote == '\'') 301 pszDst = RTStrPutCp(pszDst, Cp); 302 else 303 { 304 /* escaped char */ 305 rc = RTStrGetCpEx(&pszSrc, &Cp); 306 if (RT_FAILURE(rc) || !Cp) 307 break; 308 pszDst = RTStrPutCp(pszDst, Cp); 309 } 310 } 283 311 else 284 312 CpQuote = 0; … … 511 539 } 512 540 541 #endif /* !IPRT_REGENERATE_QUOTE_CHARS */ 542
Note:
See TracChangeset
for help on using the changeset viewer.