Mercurial > emacs
comparison src/w32proc.c @ 37290:6e6e46d239df
(sys_spawnve): Quote more chars for Cygwin.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Tue, 10 Apr 2001 12:14:49 +0000 |
parents | 3f0eabdbb9aa |
children | d0b43907dca5 |
comparison
equal
deleted
inserted
replaced
37289:a1af2574e64b | 37290:6e6e46d239df |
---|---|
1 /* Process support for GNU Emacs on the Microsoft W32 API. | 1 /* Process support for GNU Emacs on the Microsoft W32 API. |
2 Copyright (C) 1992, 1995, 1999 Free Software Foundation, Inc. | 2 Copyright (C) 1992, 1995, 1999, 2000, 2001 Free Software Foundation, Inc. |
3 | 3 |
4 This file is part of GNU Emacs. | 4 This file is part of GNU Emacs. |
5 | 5 |
6 GNU Emacs is free software; you can redistribute it and/or modify | 6 GNU Emacs is free software; you can redistribute it and/or modify |
7 it under the terms of the GNU General Public License as published by | 7 it under the terms of the GNU General Public License as published by |
718 char escape_char; | 718 char escape_char; |
719 /* We pass our process ID to our children by setting up an environment | 719 /* We pass our process ID to our children by setting up an environment |
720 variable in their environment. */ | 720 variable in their environment. */ |
721 char ppid_env_var_buffer[64]; | 721 char ppid_env_var_buffer[64]; |
722 char *extra_env[] = {ppid_env_var_buffer, NULL}; | 722 char *extra_env[] = {ppid_env_var_buffer, NULL}; |
723 char *sepchars = " \t"; | |
723 | 724 |
724 /* We don't care about the other modes */ | 725 /* We don't care about the other modes */ |
725 if (mode != _P_NOWAIT) | 726 if (mode != _P_NOWAIT) |
726 { | 727 { |
727 errno = EINVAL; | 728 errno = EINVAL; |
813 escape_char = XINT (Vw32_quote_process_args); | 814 escape_char = XINT (Vw32_quote_process_args); |
814 else | 815 else |
815 escape_char = is_cygnus_app ? '"' : '\\'; | 816 escape_char = is_cygnus_app ? '"' : '\\'; |
816 } | 817 } |
817 | 818 |
819 /* Cygwin apps needs quoting a bit more often */ | |
820 if (escape_char == '"') | |
821 sepchars = "\r\n\t\f '"; | |
822 | |
818 /* do argv... */ | 823 /* do argv... */ |
819 arglen = 0; | 824 arglen = 0; |
820 targ = argv; | 825 targ = argv; |
821 while (*targ) | 826 while (*targ) |
822 { | 827 { |
826 | 831 |
827 if (*p == 0) | 832 if (*p == 0) |
828 need_quotes = 1; | 833 need_quotes = 1; |
829 for ( ; *p; p++) | 834 for ( ; *p; p++) |
830 { | 835 { |
831 if (*p == '"') | 836 if (escape_char == '"' && *p == '\\') |
837 /* If it's a Cygwin app, \ needs to be escaped. */ | |
838 arglen++; | |
839 else if (*p == '"') | |
832 { | 840 { |
833 /* allow for embedded quotes to be escaped */ | 841 /* allow for embedded quotes to be escaped */ |
834 arglen++; | 842 arglen++; |
835 need_quotes = 1; | 843 need_quotes = 1; |
836 /* handle the case where the embedded quote is already escaped */ | 844 /* handle the case where the embedded quote is already escaped */ |
840 preceding escape characters (plus adding one to | 848 preceding escape characters (plus adding one to |
841 escape the quote character itself). */ | 849 escape the quote character itself). */ |
842 arglen += escape_char_run; | 850 arglen += escape_char_run; |
843 } | 851 } |
844 } | 852 } |
845 else if (*p == ' ' || *p == '\t') | 853 else if (strchr (sepchars, *p) != NULL) |
846 { | 854 { |
847 need_quotes = 1; | 855 need_quotes = 1; |
848 } | 856 } |
849 | 857 |
850 if (*p == escape_char && escape_char != '"') | 858 if (*p == escape_char && escape_char != '"') |
874 need_quotes = 1; | 882 need_quotes = 1; |
875 | 883 |
876 if (do_quoting) | 884 if (do_quoting) |
877 { | 885 { |
878 for ( ; *p; p++) | 886 for ( ; *p; p++) |
879 if (*p == ' ' || *p == '\t' || *p == '"') | 887 if ((strchr (sepchars, *p) != NULL) || *p == '"') |
880 need_quotes = 1; | 888 need_quotes = 1; |
881 } | 889 } |
882 if (need_quotes) | 890 if (need_quotes) |
883 { | 891 { |
884 int escape_char_run = 0; | 892 int escape_char_run = 0; |
914 escape_char_run--; | 922 escape_char_run--; |
915 } | 923 } |
916 /* escape all quote chars, even at beginning or end */ | 924 /* escape all quote chars, even at beginning or end */ |
917 *parg++ = escape_char; | 925 *parg++ = escape_char; |
918 } | 926 } |
927 else if (escape_char == '"' && *p == '\\') | |
928 *parg++ = '\\'; | |
919 *parg++ = *p; | 929 *parg++ = *p; |
920 | 930 |
921 if (*p == escape_char && escape_char != '"') | 931 if (*p == escape_char && escape_char != '"') |
922 escape_char_run++; | 932 escape_char_run++; |
923 else | 933 else |