- Timestamp:
- Sep 25, 2013 1:00:44 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/initterm.h
r46583 r48681 49 49 /** We are sharing a process space, so we need to behave. */ 50 50 #define RTR3INIT_FLAGS_UNOBTRUSIVE RT_BIT(2) 51 /** The caller ensures that the argument bector is UTF-8. */ 52 #define RTR3INIT_FLAGS_UTF8_ARGV RT_BIT(3) 51 53 /** @} */ 52 54 -
trunk/src/VBox/Main/src-helper-apps/VBoxExtPackHelperApp.cpp
r46326 r48681 1768 1768 * Initialize IPRT and check that we're correctly installed. 1769 1769 */ 1770 #ifdef RT_OS_WINDOWS 1771 int rc = RTR3InitExe(argc, &argv, RTR3INIT_FLAGS_UTF8_ARGV); /* WinMain gives us UTF-8, see below. */ 1772 #else 1770 1773 int rc = RTR3InitExe(argc, &argv, 0); 1774 #endif 1771 1775 if (RT_FAILURE(rc)) 1772 1776 return RTMsgInitFailure(rc); -
trunk/src/VBox/Runtime/r3/init.cpp
r46593 r48681 278 278 } 279 279 280 /* 281 * Convert the arguments. 282 */ 283 char **papszArgs = (char **)RTMemAllocZ((cArgs + 1) * sizeof(char *)); 284 if (!papszArgs) 285 return VERR_NO_MEMORY; 280 if (!(fFlags & RTR3INIT_FLAGS_UTF8_ARGV)) 281 { 282 /* 283 * Convert the arguments. 284 */ 285 char **papszArgs = (char **)RTMemAllocZ((cArgs + 1) * sizeof(char *)); 286 if (!papszArgs) 287 return VERR_NO_MEMORY; 286 288 287 289 #ifdef RT_OS_WINDOWS 288 /* HACK ALERT! Try convert from unicode versions if possible. 289 Unfortunately for us, __wargv is only initialized if we have a 290 unicode main function. So, we have to use CommandLineToArgvW to get 291 something similar. It should do the same conversion... :-) */ 292 int cArgsW = -1; 293 PWSTR *papwszArgs = NULL; 294 if ( papszOrgArgs == __argv 295 && cArgs == __argc 296 && (papwszArgs = CommandLineToArgvW(GetCommandLineW(), &cArgsW)) != NULL ) 297 { 298 AssertMsg(cArgsW == cArgs, ("%d vs %d\n", cArgsW, cArgs)); 299 for (int i = 0; i < cArgs; i++) 290 /* HACK ALERT! Try convert from unicode versions if possible. 291 Unfortunately for us, __wargv is only initialized if we have a 292 unicode main function. So, we have to use CommandLineToArgvW to get 293 something similar. It should do the same conversion... :-) */ 294 int cArgsW = -1; 295 PWSTR *papwszArgs = NULL; 296 if ( papszOrgArgs == __argv 297 && cArgs == __argc 298 && (papwszArgs = CommandLineToArgvW(GetCommandLineW(), &cArgsW)) != NULL ) 300 299 { 301 int rc = RTUtf16ToUtf8(papwszArgs[i], &papszArgs[i]);302 if (RT_FAILURE(rc))300 AssertMsg(cArgsW == cArgs, ("%d vs %d\n", cArgsW, cArgs)); 301 for (int i = 0; i < cArgs; i++) 303 302 { 304 while (i--) 305 RTStrFree(papszArgs[i]); 306 RTMemFree(papszArgs); 307 LocalFree(papwszArgs); 308 return rc; 303 int rc = RTUtf16ToUtf8(papwszArgs[i], &papszArgs[i]); 304 if (RT_FAILURE(rc)) 305 { 306 while (i--) 307 RTStrFree(papszArgs[i]); 308 RTMemFree(papszArgs); 309 LocalFree(papwszArgs); 310 return rc; 311 } 312 } 313 LocalFree(papwszArgs); 314 } 315 else 316 #endif 317 { 318 for (int i = 0; i < cArgs; i++) 319 { 320 int rc = RTStrCurrentCPToUtf8(&papszArgs[i], papszOrgArgs[i]); 321 if (RT_FAILURE(rc)) 322 { 323 while (i--) 324 RTStrFree(papszArgs[i]); 325 RTMemFree(papszArgs); 326 return rc; 327 } 309 328 } 310 329 } 311 LocalFree(papwszArgs); 330 331 papszArgs[cArgs] = NULL; 332 333 g_papszrtOrgArgs = papszOrgArgs; 334 g_papszrtArgs = papszArgs; 335 g_crtArgs = cArgs; 336 337 *ppapszArgs = papszArgs; 312 338 } 313 339 else 314 #endif315 340 { 316 for (int i = 0; i < cArgs; i++) 317 { 318 int rc = RTStrCurrentCPToUtf8(&papszArgs[i], papszOrgArgs[i]); 319 if (RT_FAILURE(rc)) 320 { 321 while (i--) 322 RTStrFree(papszArgs[i]); 323 RTMemFree(papszArgs); 324 return rc; 325 } 326 } 341 /* 342 * The arguments are already UTF-8, no conversion needed. 343 */ 344 g_papszrtOrgArgs = papszOrgArgs; 345 g_papszrtArgs = papszOrgArgs; 346 g_crtArgs = cArgs; 327 347 } 328 329 papszArgs[cArgs] = NULL;330 331 g_papszrtOrgArgs = papszOrgArgs;332 g_papszrtArgs = papszArgs;333 g_crtArgs = cArgs;334 335 *ppapszArgs = papszArgs;336 348 } 337 349 … … 543 555 Assert(!(fFlags & ~( RTR3INIT_FLAGS_DLL 544 556 | RTR3INIT_FLAGS_SUPLIB 545 | RTR3INIT_FLAGS_UNOBTRUSIVE))); 557 | RTR3INIT_FLAGS_UNOBTRUSIVE 558 | RTR3INIT_FLAGS_UTF8_ARGV))); 546 559 Assert(!(fFlags & RTR3INIT_FLAGS_DLL) || cArgs == 0); 547 560
Note:
See TracChangeset
for help on using the changeset viewer.