Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch cmdline-expansion Excluding Merge-Ins
This is equivalent to a diff from d091c609d2 to cc09cda247
2012-12-01
| ||
03:25 | Improvements to command-line argument glob expansion on windows. Globbing now works correctly when compiled with mingw-w64 and with msvc. It is mostly correct when compiled with mingw, but fails for some files with non-ascii names. check-in: 8205c01cd4 user: drh tags: trunk | |
03:18 | Make sure the SQLite memory allocator is initialized before trying to use it to convert MBCS into UTF8. Closed-Leaf check-in: cc09cda247 user: drh tags: cmdline-expansion | |
2012-11-30
| ||
21:03 | Bump the version number to 1.25 and add a change log in preparation for the next release. check-in: ed1e34c760 user: drh tags: trunk | |
16:59 | forgot makemake.tcl and Makefile.mingw.mistachkin changes check-in: 08802c4af4 user: jan.nijtmans tags: cmdline-expansion | |
16:43 | merge trunk. Add fallback mechanism for MinGW check-in: 2459ee7b71 user: jan.nijtmans tags: cmdline-expansion | |
16:09 | CSS changes: set the cursor to "pointer" on ticket reports. check-in: d091c609d2 user: drh tags: trunk | |
15:52 | Allow characters *[]? to appear in filenames. Tickets [46bf4baedce] and [d17d6e5b174bd6] and [10aee063c413c107] check-in: 647bb7b79f user: drh tags: trunk | |
Changes to src/main.c.
342 342 memset(&g.json, 0, sizeof(g.json)); 343 343 #endif 344 344 free(g.zErrMsg); 345 345 if(g.db){ 346 346 db_close(0); 347 347 } 348 348 } 349 - 350 -#if defined(_WIN32) && !defined(__MINGW32__) 351 -/* 352 -** Parse the command-line arguments passed to windows. We do this 353 -** ourselves to work around bugs in the command-line parsing of MinGW. 354 -** It is possible (in theory) to only use this routine when compiling 355 -** with MinGW and to use built-in command-line parsing for MSVC and 356 -** MinGW-64. However, the code is here, it is efficient, and works, and 357 -** by using it in all cases we do a better job of testing it. If you suspect 358 -** a bug in this code, test your theory by invoking "fossil test-echo". 359 -** 360 -** This routine is copied from TCL with some reformatting. 361 -** The original comment text follows: 362 -** 363 -** Parse the Windows command line string into argc/argv. Done here 364 -** because we don't trust the builtin argument parser in crt0. Windows 365 -** applications are responsible for breaking their command line into 366 -** arguments. 367 -** 368 -** 2N backslashes + quote -> N backslashes + begin quoted string 369 -** 2N + 1 backslashes + quote -> literal 370 -** N backslashes + non-quote -> literal 371 -** quote + quote in a quoted string -> single quote 372 -** quote + quote not in quoted string -> empty string 373 -** quote -> begin quoted string 374 -** 375 -** Results: 376 -** Fills argcPtr with the number of arguments and argvPtr with the array 377 -** of arguments. 378 -*/ 379 -#define wchar_isspace(X) ((X)==' ' || (X)=='\t') 380 -static void parse_windows_command_line( 381 - int *argcPtr, /* Filled with number of argument strings. */ 382 - void *argvPtr /* Filled with argument strings (malloc'd). */ 383 -){ 384 - WCHAR *cmdLine, *p, *arg, *argSpace; 385 - WCHAR **argv; 386 - int argc, size, inquote, copy, slashes; 387 - 388 - cmdLine = GetCommandLineW(); 389 - 390 - /* 391 - ** Precompute an overly pessimistic guess at the number of arguments in 392 - ** the command line by counting non-space spans. 393 - */ 394 - size = 2; 395 - for(p=cmdLine; *p!='\0'; p++){ 396 - if( wchar_isspace(*p) ){ 397 - size++; 398 - while( wchar_isspace(*p) ){ 399 - p++; 400 - } 401 - if( *p=='\0' ){ 402 - break; 403 - } 404 - } 405 - } 406 - 407 - argSpace = fossil_malloc(size * sizeof(char*) 408 - + (wcslen(cmdLine) * sizeof(WCHAR)) + sizeof(WCHAR)); 409 - argv = (WCHAR**)argSpace; 410 - argSpace += size*(sizeof(char*)/sizeof(WCHAR)); 411 - size--; 412 - 413 - p = cmdLine; 414 - for(argc=0; argc<size; argc++){ 415 - argv[argc] = arg = argSpace; 416 - while( wchar_isspace(*p) ){ 417 - p++; 418 - } 419 - if (*p == '\0') { 420 - break; 421 - } 422 - inquote = 0; 423 - slashes = 0; 424 - while(1){ 425 - copy = 1; 426 - while( *p=='\\' ){ 427 - slashes++; 428 - p++; 429 - } 430 - if( *p=='"' ){ 431 - if( (slashes&1)==0 ){ 432 - copy = 0; 433 - if( inquote && p[1]=='"' ){ 434 - p++; 435 - copy = 1; 436 - }else{ 437 - inquote = !inquote; 438 - } 439 - } 440 - slashes >>= 1; 441 - } 442 - while( slashes ){ 443 - *arg = '\\'; 444 - arg++; 445 - slashes--; 446 - } 447 - if( *p=='\0' || (!inquote && wchar_isspace(*p)) ){ 448 - break; 449 - } 450 - if( copy!=0 ){ 451 - *arg = *p; 452 - arg++; 453 - } 454 - p++; 455 - } 456 - *arg = '\0'; 457 - argSpace = arg + 1; 458 - } 459 - argv[argc] = NULL; 460 - *argcPtr = argc; 461 - *((WCHAR ***)argvPtr) = argv; 462 -} 463 -#endif /* defined(_WIN32) && !defined(__MINGW32__) */ 464 - 465 349 466 350 /* 467 351 ** Convert all arguments from mbcs (or unicode) to UTF-8. Then 468 352 ** search g.argv for arguments "--args FILENAME". If found, then 469 353 ** (1) remove the two arguments from g.argv 470 354 ** (2) Read the file FILENAME 471 355 ** (3) Use the contents of FILE to replace the two removed arguments: ................................................................................ 480 364 unsigned int nLine; /* Number of lines in the file*/ 481 365 unsigned int i, j, k; /* Loop counters */ 482 366 int n; /* Number of bytes in one line */ 483 367 char *z; /* General use string pointer */ 484 368 char **newArgv; /* New expanded g.argv under construction */ 485 369 char const * zFileName; /* input file name */ 486 370 FILE * zInFile; /* input FILE */ 487 -#if defined(_WIN32) && !defined(__MINGW32__) 371 +#if defined(_WIN32) 488 372 WCHAR buf[MAX_PATH]; 489 373 #endif 490 374 491 375 g.argc = argc; 492 376 g.argv = argv; 493 -#if defined(_WIN32) && !defined(__MINGW32__) 494 - parse_windows_command_line(&g.argc, &g.argv); 377 + sqlite3_initialize(); 378 +#if defined(_WIN32) && defined(BROKEN_MINGW_CMDLINE) 379 + for(i=0; i<g.argc; i++) g.argv[i] = fossil_mbcs_to_utf8(g.argv[i]); 380 +#else 381 + for(i=0; i<g.argc; i++) g.argv[i] = fossil_filename_to_utf8(g.argv[i]); 382 +#endif 383 +#if defined(_WIN32) 495 384 GetModuleFileNameW(NULL, buf, MAX_PATH); 496 385 g.nameOfExe = fossil_filename_to_utf8(buf); 497 - for(i=0; i<g.argc; i++) g.argv[i] = fossil_filename_to_utf8(g.argv[i]); 498 -#elif defined(__APPLE__) 499 - for(i=0; i<g.argc; i++) g.argv[i] = fossil_filename_to_utf8(g.argv[i]); 500 - g.nameOfExe = g.argv[0]; 501 386 #else 502 387 g.nameOfExe = g.argv[0]; 503 388 #endif 504 389 for(i=1; i<g.argc-1; i++){ 505 390 z = g.argv[i]; 506 391 if( z[0]!='-' ) continue; 507 392 z++; ................................................................................ 567 452 memset(zNewArgv, 0, sizeof(char*)*(argc+1)); 568 453 for(i=0; i<argc; i++){ 569 454 zNewArgv[i] = fossil_strdup(argv[i]); 570 455 } 571 456 return zNewArgv; 572 457 } 573 458 #endif 459 + 574 460 575 461 /* 576 462 ** This procedure runs first. 577 463 */ 464 +#if defined(_WIN32) && !defined(BROKEN_MINGW_CMDLINE) 465 +int _dowildcard = -1; /* This turns on command-line globbing in MinGW-w64 */ 466 +int wmain(int argc, wchar_t **argv) 467 +#else 578 468 int main(int argc, char **argv) 469 +#endif 579 470 { 580 471 const char *zCmdName = "unknown"; 581 472 int idx; 582 473 int rc; 583 474 584 475 sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0); 585 476 memset(&g, 0, sizeof(g));
Changes to src/makemake.tcl.
502 502 RCC += -DFOSSIL_ENABLE_JSON=1 503 503 endif 504 504 505 505 #### We add the -static option here so that we can build a static 506 506 # executable that will run in a chroot jail. 507 507 # 508 508 LIB = -static 509 + 510 +ifeq ($(PREFIX),) 511 +TCC += -DBROKEN_MINGW_CMDLINE 512 +else 513 +LIB += -municode 514 +endif 509 515 510 516 # OpenSSL: Add the necessary libraries required, if enabled. 511 517 ifdef FOSSIL_ENABLE_SSL 512 518 LIB += -lssl -lcrypto -lgdi32 513 519 endif 514 520 515 521 # Tcl: Add the necessary libraries required, if enabled. ................................................................................ 969 975 970 976 zlib: 971 977 @echo Building zlib from "$(ZLIBDIR)"... 972 978 @pushd "$(ZLIBDIR)" && nmake /f win32\Makefile.msc $(ZLIB) && popd 973 979 974 980 $(APPNAME) : translate$E mkindex$E headers $(OBJ) $(OX)\linkopts zlib 975 981 cd $(OX) 976 - link /NODEFAULTLIB:msvcrt -OUT:$@ $(LIBDIR) @linkopts 982 + link /NODEFAULTLIB:msvcrt -OUT:$@ $(LIBDIR) Wsetargv.obj @linkopts 977 983 978 984 $(OX)\linkopts: $B\win\Makefile.msc} 979 985 set redir {>} 980 986 foreach s [lsort [concat $src {shell sqlite3 th th_lang}]] { 981 987 writeln "\techo \$(OX)\\$s.obj $redir \$@" 982 988 set redir {>>} 983 989 }
Changes to win/Makefile.mingw.
172 172 RCC += -DFOSSIL_ENABLE_JSON=1 173 173 endif 174 174 175 175 #### We add the -static option here so that we can build a static 176 176 # executable that will run in a chroot jail. 177 177 # 178 178 LIB = -static 179 + 180 +ifeq ($(PREFIX),) 181 +TCC += -DBROKEN_MINGW_CMDLINE 182 +else 183 +LIB += -municode 184 +endif 179 185 180 186 # OpenSSL: Add the necessary libraries required, if enabled. 181 187 ifdef FOSSIL_ENABLE_SSL 182 188 LIB += -lssl -lcrypto -lgdi32 183 189 endif 184 190 185 191 # Tcl: Add the necessary libraries required, if enabled.
Changes to win/Makefile.mingw.mistachkin.
11 11 # This is a makefile for use on Windows/Linux/Darwin/Cygwin using MinGW or 12 12 # MinGW-w64. 13 13 # 14 14 15 15 #### Select one of MinGW, MinGW-64 (32-bit) or MinGW-w64 (64-bit) compilers. 16 16 # By default, this is an empty string (i.e. use the native compiler). 17 17 # 18 -PREFIX = 18 +# PREFIX = 19 19 # PREFIX = mingw32- 20 20 # PREFIX = i686-pc-mingw32- 21 -# PREFIX = i686-w64-mingw32- 21 +PREFIX = i686-w64-mingw32- 22 22 # PREFIX = x86_64-w64-mingw32- 23 23 24 24 #### The toplevel directory of the source tree. Fossil can be built 25 25 # in a directory that is separate from the source tree. Just change 26 26 # the following to point from the build directory to the src/ folder. 27 27 # 28 28 SRCDIR = src ................................................................................ 172 172 RCC += -DFOSSIL_ENABLE_JSON=1 173 173 endif 174 174 175 175 #### We add the -static option here so that we can build a static 176 176 # executable that will run in a chroot jail. 177 177 # 178 178 LIB = -static 179 + 180 +ifeq ($(PREFIX),) 181 +TCC += -DBROKEN_MINGW_CMDLINE 182 +else 183 +LIB += -municode 184 +endif 179 185 180 186 # OpenSSL: Add the necessary libraries required, if enabled. 181 187 ifdef FOSSIL_ENABLE_SSL 182 188 LIB += -lssl -lcrypto -lgdi32 183 189 endif 184 190 185 191 # Tcl: Add the necessary libraries required, if enabled.
Changes to win/Makefile.msc.
252 252 253 253 zlib: 254 254 @echo Building zlib from "$(ZLIBDIR)"... 255 255 @pushd "$(ZLIBDIR)" && nmake /f win32\Makefile.msc $(ZLIB) && popd 256 256 257 257 $(APPNAME) : translate$E mkindex$E headers $(OBJ) $(OX)\linkopts zlib 258 258 cd $(OX) 259 - link /NODEFAULTLIB:msvcrt -OUT:$@ $(LIBDIR) @linkopts 259 + link /NODEFAULTLIB:msvcrt -OUT:$@ $(LIBDIR) Wsetargv.obj @linkopts 260 260 261 261 $(OX)\linkopts: $B\win\Makefile.msc 262 262 echo $(OX)\add.obj > $@ 263 263 echo $(OX)\allrepo.obj >> $@ 264 264 echo $(OX)\attach.obj >> $@ 265 265 echo $(OX)\bag.obj >> $@ 266 266 echo $(OX)\bisect.obj >> $@