Mercurial > emacs
comparison nt/cmdproxy.c @ 21733:a373669e1196
(main): Only set environment size for real shell, and
provide extra directory argument, when running on Windows 95.
author | Geoff Voelker <voelker@cs.washington.edu> |
---|---|
date | Thu, 23 Apr 1998 23:38:28 +0000 |
parents | 235f717e6916 |
children | 0110032de8b3 |
comparison
equal
deleted
inserted
replaced
21732:2cd3f6e8089e | 21733:a373669e1196 |
---|---|
541 pass_through_args[num_pass_through_args++] = *argv++; | 541 pass_through_args[num_pass_through_args++] = *argv++; |
542 } | 542 } |
543 #else | 543 #else |
544 /* Probably a mistake for there to be extra args; not fatal. */ | 544 /* Probably a mistake for there to be extra args; not fatal. */ |
545 if (argc > 0) | 545 if (argc > 0) |
546 warn ("warning: extra args ignored after %s\n", argv[-1]); | 546 warn ("warning: extra args ignored after '%s'\n", argv[-1]); |
547 #endif | 547 #endif |
548 | 548 |
549 pass_through_args[num_pass_through_args] = NULL; | 549 pass_through_args[num_pass_through_args] = NULL; |
550 | 550 |
551 /* If -c option, determine if we must spawn a real shell, or if we can | 551 /* If -c option, determine if we must spawn a real shell, or if we can |
576 if (progname != NULL) | 576 if (progname != NULL) |
577 need_shell = FALSE; | 577 need_shell = FALSE; |
578 } | 578 } |
579 } | 579 } |
580 | 580 |
581 pass_to_shell: | 581 pass_to_shell: |
582 if (need_shell) | 582 if (need_shell) |
583 { | 583 { |
584 char * p; | 584 char * p; |
585 int extra_arg_space = 0; | 585 int extra_arg_space = 0; |
586 | 586 |
618 /* Include pass_through_args verbatim; these are just switches | 618 /* Include pass_through_args verbatim; these are just switches |
619 so should not need quoting. */ | 619 so should not need quoting. */ |
620 for (argv = pass_through_args; *argv != NULL; ++argv) | 620 for (argv = pass_through_args; *argv != NULL; ++argv) |
621 p += wsprintf (p, " %s", *argv); | 621 p += wsprintf (p, " %s", *argv); |
622 | 622 |
623 /* Always set environment size to something reasonable. */ | 623 if (GetVersion () & 0x80000000) |
624 wsprintf(p, " /e:%d /c %s", envsize, cmdline); | 624 /* Set environment size to something reasonable on Windows 95. */ |
625 wsprintf(p, " /e:%d /c %s", envsize, cmdline); | |
626 else | |
627 wsprintf(p, " /c %s", cmdline); | |
625 cmdline = buf; | 628 cmdline = buf; |
626 } | 629 } |
627 else | 630 else |
628 { | 631 { |
629 /* Provide dir arg expected by command.com when first started | 632 if (GetVersion () & 0x80000000) |
630 interactively (the "command search path"). cmd.exe does | 633 { |
631 not require it, but accepts it silently - presumably other | 634 /* Provide dir arg expected by command.com when first |
632 DOS compatible shells do the same. To avoid potential | 635 started interactively (the "command search path"). |
633 problems with spaces in command dir (which cannot be quoted | 636 cmd.exe does not require it, but accepts it silently - |
634 - command.com doesn't like it), we always use the 8.3 form. */ | 637 presumably other DOS compatible shells do the same. To |
635 GetShortPathName (progname, path, sizeof (path)); | 638 avoid potential problems with spaces in command dir |
636 p = strrchr (path, '\\'); | 639 (which cannot be quoted - command.com doesn't like it), |
637 /* Trailing slash is acceptable, so always leave it. */ | 640 we always use the 8.3 form. */ |
638 *(++p) = '\0'; | 641 GetShortPathName (progname, path, sizeof (path)); |
642 p = strrchr (path, '\\'); | |
643 /* Trailing slash is acceptable, so always leave it. */ | |
644 *(++p) = '\0'; | |
645 } | |
646 else | |
647 /* Dir arg not needed on NT. */ | |
648 path[0] = '\0'; | |
639 | 649 |
640 cmdline = p = alloca (strlen (progname) + extra_arg_space + | 650 cmdline = p = alloca (strlen (progname) + extra_arg_space + |
641 strlen (path) + 13); | 651 strlen (path) + 13); |
642 | 652 |
643 /* Quote progname in case it contains spaces. */ | 653 /* Quote progname in case it contains spaces. */ |
646 /* Include pass_through_args verbatim; these are just switches | 656 /* Include pass_through_args verbatim; these are just switches |
647 so should not need quoting. */ | 657 so should not need quoting. */ |
648 for (argv = pass_through_args; *argv != NULL; ++argv) | 658 for (argv = pass_through_args; *argv != NULL; ++argv) |
649 p += wsprintf (p, " %s", *argv); | 659 p += wsprintf (p, " %s", *argv); |
650 | 660 |
651 /* Always set environment size to something reasonable - again | 661 if (GetVersion () & 0x80000000) |
652 cmd.exe ignores this silently. */ | 662 /* Set environment size to something reasonable on Windows 95. */ |
653 wsprintf (p, " /e:%d", envsize); | 663 wsprintf (p, " /e:%d", envsize); |
654 } | 664 } |
655 } | 665 } |
656 | 666 |
657 if (!progname) | 667 if (!progname) |
658 fail ("Internal error: program name not defined\n"); | 668 fail ("Internal error: program name not defined\n"); |