Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Fix ticket [906c533302]. If you want to replace the mingw command-line pa a better one (conforming to ms rules), compile with -DMINGW_BROKEN_MAINARGS. MinGW doesn't support unicode command line parsing (linker option -municode), so the option -DMINGW_BROKEN_MAINARGS can be used to fix that too. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | mingw-broken-cmdline |
| Files: | files | file ages | folders |
| SHA1: |
047dd626041159512720c5fd2d9663cf |
| User & Date: | jan.nijtmans 2012-09-09 20:53:48.927 |
Context
|
2012-09-09
| ||
| 22:06 | Reformat the windows command-line parser to following the Fossil style. Use the alternative command-line parser on all windows builds, not just for MinGW builds, to simplify the logic and so that the alternative parser code is testing more heavily. ... (check-in: f575af97b2 user: drh tags: mingw-broken-cmdline) | |
| 20:53 | Fix ticket [906c533302]. If you want to replace the mingw command-line pa a better one (conforming to ms rules), compile with -DMINGW_BROKEN_MAINARGS. MinGW doesn't support unicode command line parsing (linker option -municode), so the option -DMINGW_BROKEN_MAINARGS can be used to fix that too. ... (check-in: 047dd62604 user: jan.nijtmans tags: mingw-broken-cmdline) | |
|
2012-09-08
| ||
| 13:13 | Fix a harmless compiler warning. ... (check-in: c42408e15b user: drh tags: trunk) | |
Changes
Changes to src/main.c.
| ︙ | ︙ | |||
329 330 331 332 333 334 335 |
free(g.zErrMsg);
if(g.db){
db_close(0);
}
}
/*
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | | > > > > > > > | 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 |
free(g.zErrMsg);
if(g.db){
db_close(0);
}
}
/*
*-------------------------------------------------------------------------
*
* setargv --
*
* Parse the Windows command line string into argc/argv. Done here
* because we don't trust the builtin argument parser in crt0. Windows
* applications are responsible for breaking their command line into
* arguments.
*
* 2N backslashes + quote -> N backslashes + begin quoted string
* 2N + 1 backslashes + quote -> literal
* N backslashes + non-quote -> literal
* quote + quote in a quoted string -> single quote
* quote + quote not in quoted string -> empty string
* quote -> begin quoted string
*
* Results:
* Fills argcPtr with the number of arguments and argvPtr with the array
* of arguments.
*
* Side effects:
* Memory allocated.
*
*--------------------------------------------------------------------------
*/
#ifdef MINGW_BROKEN_MAINARGS
#include <tchar.h>
static void
setargv(
int *argcPtr, /* Filled with number of argument strings. */
void *argvPtr) /* Filled with argument strings (malloc'd). */
{
TCHAR *cmdLine, *p, *arg, *argSpace;
TCHAR **argv;
int argc, size, inquote, copy, slashes;
cmdLine = GetCommandLine();
/*
* Precompute an overly pessimistic guess at the number of arguments in
* the command line by counting non-space spans.
*/
size = 2;
for (p = cmdLine; *p != TEXT('\0'); p++) {
if ((*p == TEXT(' ')) || (*p == TEXT('\t'))) { /* INTL: ISO space. */
size++;
while ((*p == TEXT(' ')) || (*p == TEXT('\t'))) { /* INTL: ISO space. */
p++;
}
if (*p == TEXT('\0')) {
break;
}
}
}
argSpace = fossil_malloc(size * sizeof(char *)
+ (_tcslen(cmdLine) * sizeof(TCHAR)) + sizeof(TCHAR));
argv = (TCHAR **) argSpace;
argSpace += size * (sizeof(char *)/sizeof(TCHAR));
size--;
p = cmdLine;
for (argc = 0; argc < size; argc++) {
argv[argc] = arg = argSpace;
while ((*p == TEXT(' ')) || (*p == TEXT('\t'))) { /* INTL: ISO space. */
p++;
}
if (*p == TEXT('\0')) {
break;
}
inquote = 0;
slashes = 0;
while (1) {
copy = 1;
while (*p == TEXT('\\')) {
slashes++;
p++;
}
if (*p == TEXT('"')) {
if ((slashes & 1) == 0) {
copy = 0;
if ((inquote) && (p[1] == TEXT('"'))) {
p++;
copy = 1;
} else {
inquote = !inquote;
}
}
slashes >>= 1;
}
while (slashes) {
*arg = TEXT('\\');
arg++;
slashes--;
}
if ((*p == TEXT('\0')) || (!inquote &&
((*p == TEXT(' ')) || (*p == TEXT('\t'))))) { /* INTL: ISO space. */
break;
}
if (copy != 0) {
*arg = *p;
arg++;
}
p++;
}
*arg = '\0';
argSpace = arg + 1;
}
argv[argc] = NULL;
*argcPtr = argc;
*((TCHAR ***)argvPtr) = argv;
}
#endif /* MINGW_BROKEN_MAINARGS */
/*
** Convert all arguments from mbcs (or unicode) to UTF-8. Then
** search g.argv for arguments "--args FILENAME". If found, then
** (1) remove the two arguments from g.argv
** (2) Read the file FILENAME
** (3) Use the contents of FILE to replace the two removed arguments:
** (a) Ignore blank lines in the file
** (b) Each non-empty line of the file is an argument, except
** (c) If the line begins with "-" and contains a space, it is broken
** into two arguments at the space.
*/
static void expand_args_option(int argc, void *argv){
Blob file = empty_blob; /* Content of the file */
Blob line = empty_blob; /* One line of the file */
unsigned int nLine; /* Number of lines in the file*/
unsigned int i, j, k; /* Loop counters */
int n; /* Number of bytes in one line */
char *z; /* General use string pointer */
char **newArgv; /* New expanded g.argv under construction */
char const * zFileName; /* input file name */
FILE * zInFile; /* input FILE */
int foundBom = -1; /* -1= not searched yet, 0 = no; 1=yes */
#ifdef _WIN32
wchar_t buf[MAX_PATH];
#endif
g.argc = argc;
g.argv = argv;
#ifdef _WIN32
#ifdef MINGW_BROKEN_MAINARGS
setargv(&g.argc, &g.argv);
#endif
GetModuleFileNameW(NULL, buf, MAX_PATH);
g.argv[0] = fossil_unicode_to_utf8(buf);
#ifdef UNICODE
for(i=1; i<g.argc; i++) g.argv[i] = fossil_unicode_to_utf8(g.argv[i]);
#else
for(i=1; i<g.argc; i++) g.argv[i] = fossil_mbcs_to_utf8(g.argv[i]);
#endif
#endif
for(i=1; i<g.argc-1; i++){
z = g.argv[i];
if( z[0]!='-' ) continue;
z++;
if( z[0]=='-' ) z++;
if( z[0]==0 ) return; /* Stop searching at "--" */
|
| ︙ | ︙ | |||
428 429 430 431 432 433 434 | g.argc = j; g.argv = newArgv; } /* ** This procedure runs first. */ | > > > | > > | 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 |
g.argc = j;
g.argv = newArgv;
}
/*
** This procedure runs first.
*/
#if defined(_WIN32) && defined(UNICODE) && !defined(MINGW_BROKEN_MAINARGS)
int wmain(int argc, wchar_t **argv)
#else
int main(int argc, char **argv)
#endif
{
const char *zCmdName = "unknown";
int idx;
int rc;
sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0);
memset(&g, 0, sizeof(g));
g.now = time(0);
|
| ︙ | ︙ | |||
1740 1741 1742 1743 1744 1745 1746 |
** --th-trace trace TH1 execution (for debugging purposes)
**
** See also: cgi, http, winsrv
*/
void cmd_webserver(void){
int iPort, mxPort; /* Range of TCP ports allowed */
const char *zPort; /* Value of the --port option */
| | | 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 |
** --th-trace trace TH1 execution (for debugging purposes)
**
** See also: cgi, http, winsrv
*/
void cmd_webserver(void){
int iPort, mxPort; /* Range of TCP ports allowed */
const char *zPort; /* Value of the --port option */
const char *zBrowser; /* Name of web browser program */
char *zBrowserCmd = 0; /* Command to launch the web browser */
int isUiCmd; /* True if command is "ui", not "server' */
const char *zNotFound; /* The --notfound option or NULL */
int flags = 0; /* Server flags */
#if defined(_WIN32)
const char *zStopperFile; /* Name of file used to terminate server */
|
| ︙ | ︙ | |||
1777 1778 1779 1780 1781 1782 1783 |
}
#if !defined(_WIN32)
/* Unix implementation */
if( isUiCmd ){
#if !defined(__DARWIN__) && !defined(__APPLE__) && !defined(__HAIKU__)
zBrowser = db_get("web-browser", 0);
if( zBrowser==0 ){
| | | 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 |
}
#if !defined(_WIN32)
/* Unix implementation */
if( isUiCmd ){
#if !defined(__DARWIN__) && !defined(__APPLE__) && !defined(__HAIKU__)
zBrowser = db_get("web-browser", 0);
if( zBrowser==0 ){
static const char *const azBrowserProg[] = { "xdg-open", "gnome-open", "firefox" };
int i;
zBrowser = "echo";
for(i=0; i<sizeof(azBrowserProg)/sizeof(azBrowserProg[0]); i++){
if( binaryOnPath(azBrowserProg[i]) ){
zBrowser = azBrowserProg[i];
break;
}
|
| ︙ | ︙ |
Changes to src/makemake.tcl.
| ︙ | ︙ | |||
464 465 466 467 468 469 470 471 472 473 474 475 476 477 | endif # With JSON support ifdef FOSSIL_ENABLE_JSON TCC += -DFOSSIL_ENABLE_JSON=1 RCC += -DFOSSIL_ENABLE_JSON=1 endif #### We add the -static option here so that we can build a static # executable that will run in a chroot jail. # LIB = -static # OpenSSL: Add the necessary libraries required, if enabled. | > > > > > | 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 | endif # With JSON support ifdef FOSSIL_ENABLE_JSON TCC += -DFOSSIL_ENABLE_JSON=1 RCC += -DFOSSIL_ENABLE_JSON=1 endif # Fix buggy MinGW command line parsing ifdef MINGW_BROKEN_MAINARGS TCC += -DMINGW_BROKEN_MAINARGS endif #### We add the -static option here so that we can build a static # executable that will run in a chroot jail. # LIB = -static # OpenSSL: Add the necessary libraries required, if enabled. |
| ︙ | ︙ |
Changes to win/Makefile.mingw.
| ︙ | ︙ | |||
143 144 145 146 147 148 149 150 151 152 153 154 155 156 | endif # With JSON support ifdef FOSSIL_ENABLE_JSON TCC += -DFOSSIL_ENABLE_JSON=1 RCC += -DFOSSIL_ENABLE_JSON=1 endif #### We add the -static option here so that we can build a static # executable that will run in a chroot jail. # LIB = -static # OpenSSL: Add the necessary libraries required, if enabled. | > > > > > | 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | endif # With JSON support ifdef FOSSIL_ENABLE_JSON TCC += -DFOSSIL_ENABLE_JSON=1 RCC += -DFOSSIL_ENABLE_JSON=1 endif # Fix buggy MinGW command line parsing ifdef MINGW_BROKEN_MAINARGS TCC += -DMINGW_BROKEN_MAINARGS endif #### We add the -static option here so that we can build a static # executable that will run in a chroot jail. # LIB = -static # OpenSSL: Add the necessary libraries required, if enabled. |
| ︙ | ︙ |