| | @@ -268,10 +268,21 @@ |
| 268 | 268 | ** The following variable becomes true while processing a fatal error |
| 269 | 269 | ** or a panic. If additional "recursive-fatal" errors occur while |
| 270 | 270 | ** shutting down, the recursive errors are silently ignored. |
| 271 | 271 | */ |
| 272 | 272 | static int mainInFatalError = 0; |
| 273 | + |
| 274 | +/* |
| 275 | +** Return the name of the current executable. |
| 276 | +*/ |
| 277 | +const char *fossil_nameofexe(void){ |
| 278 | +#ifdef _WIN32 |
| 279 | + return _pgmptr; |
| 280 | +#else |
| 281 | + return g.argv[0]; |
| 282 | +#endif |
| 283 | +} |
| 273 | 284 | |
| 274 | 285 | /* |
| 275 | 286 | ** Exit. Take care to close the database first. |
| 276 | 287 | */ |
| 277 | 288 | void fossil_exit(int rc){ |
| | @@ -294,11 +305,11 @@ |
| 294 | 305 | if( g.cgiOutput && once ){ |
| 295 | 306 | once = 0; |
| 296 | 307 | cgi_printf("<p class=\"generalError\">%h</p>", z); |
| 297 | 308 | cgi_reply(); |
| 298 | 309 | }else{ |
| 299 | | - fprintf(stderr, "%s: %s\n", g.argv[0], z); |
| 310 | + fprintf(stderr, "%s: %s\n", fossil_nameofexe(), z); |
| 300 | 311 | } |
| 301 | 312 | db_force_rollback(); |
| 302 | 313 | fossil_exit(1); |
| 303 | 314 | } |
| 304 | 315 | void fossil_fatal(const char *zFormat, ...){ |
| | @@ -311,11 +322,11 @@ |
| 311 | 322 | if( g.cgiOutput ){ |
| 312 | 323 | g.cgiOutput = 0; |
| 313 | 324 | cgi_printf("<p class=\"generalError\">%h</p>", z); |
| 314 | 325 | cgi_reply(); |
| 315 | 326 | }else{ |
| 316 | | - fprintf(stderr, "%s: %s\n", g.argv[0], z); |
| 327 | + fprintf(stderr, "%s: %s\n", fossil_nameofexe(), z); |
| 317 | 328 | } |
| 318 | 329 | db_force_rollback(); |
| 319 | 330 | fossil_exit(1); |
| 320 | 331 | } |
| 321 | 332 | |
| | @@ -339,11 +350,11 @@ |
| 339 | 350 | if( g.cgiOutput ){ |
| 340 | 351 | g.cgiOutput = 0; |
| 341 | 352 | cgi_printf("<p class=\"generalError\">%h</p>", z); |
| 342 | 353 | cgi_reply(); |
| 343 | 354 | }else{ |
| 344 | | - fprintf(stderr, "%s: %s\n", g.argv[0], z); |
| 355 | + fprintf(stderr, "%s: %s\n", fossil_nameofexe(), z); |
| 345 | 356 | } |
| 346 | 357 | db_force_rollback(); |
| 347 | 358 | fossil_exit(1); |
| 348 | 359 | } |
| 349 | 360 | |
| | @@ -356,11 +367,11 @@ |
| 356 | 367 | z = vmprintf(zFormat, ap); |
| 357 | 368 | va_end(ap); |
| 358 | 369 | if( g.cgiOutput ){ |
| 359 | 370 | cgi_printf("<p class=\"generalError\">%h</p>", z); |
| 360 | 371 | }else{ |
| 361 | | - fprintf(stderr, "%s: %s\n", g.argv[0], z); |
| 372 | + fprintf(stderr, "%s: %s\n", fossil_nameofexe(), z); |
| 362 | 373 | } |
| 363 | 374 | } |
| 364 | 375 | |
| 365 | 376 | /* |
| 366 | 377 | ** Malloc and free routines that cannot fail |
| | @@ -443,11 +454,11 @@ |
| 443 | 454 | |
| 444 | 455 | /* |
| 445 | 456 | ** Print a usage comment and quit |
| 446 | 457 | */ |
| 447 | 458 | void usage(const char *zFormat){ |
| 448 | | - fprintf(stderr, "Usage: %s %s %s\n", g.argv[0], g.argv[1], zFormat); |
| 459 | + fprintf(stderr, "Usage: %s %s %s\n", fossil_nameofexe(), g.argv[1], zFormat); |
| 449 | 460 | fossil_exit(1); |
| 450 | 461 | } |
| 451 | 462 | |
| 452 | 463 | /* |
| 453 | 464 | ** Remove n elements from g.argv beginning with the i-th element. |
| | @@ -603,11 +614,12 @@ |
| 603 | 614 | */ |
| 604 | 615 | void help_cmd(void){ |
| 605 | 616 | int rc, idx; |
| 606 | 617 | const char *z; |
| 607 | 618 | if( g.argc!=3 ){ |
| 608 | | - printf("Usage: %s help COMMAND.\nAvailable COMMANDs:\n", g.argv[0]); |
| 619 | + printf("Usage: %s help COMMAND.\nAvailable COMMANDs:\n", |
| 620 | + fossil_nameofexe()); |
| 609 | 621 | cmd_cmd_list(); |
| 610 | 622 | version_cmd(); |
| 611 | 623 | return; |
| 612 | 624 | } |
| 613 | 625 | rc = name_search(g.argv[2], aCommand, count(aCommand), &idx); |
| | @@ -621,11 +633,11 @@ |
| 621 | 633 | fossil_fatal("no help available for the %s command", |
| 622 | 634 | aCommand[idx].zName); |
| 623 | 635 | } |
| 624 | 636 | while( *z ){ |
| 625 | 637 | if( *z=='%' && strncmp(z, "%fossil", 7)==0 ){ |
| 626 | | - printf("%s", g.argv[0]); |
| 638 | + printf("%s", fossil_nameofexe()); |
| 627 | 639 | z += 7; |
| 628 | 640 | }else{ |
| 629 | 641 | putchar(*z); |
| 630 | 642 | z++; |
| 631 | 643 | } |
| 632 | 644 | |