delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-developers/1998/10/16/05:59:19

From: cgf AT cygnus DOT com (Christopher Faylor)
Subject: Re: build_argv fix.
16 Oct 1998 05:59:19 -0700 :
Message-ID: <19981016085010.C12868.cygnus.cygwin32.developers@cygnus.com>
References: <01BDF8FC DOT 88D57720 AT sos>
Mime-Version: 1.0
To: Sergey Okhapkin <sos AT prospect DOT com DOT ru>,
"'cygwin32-developers AT cygnus DOT com'" <cygwin32-developers AT cygnus DOT com>

On Fri, Oct 16, 1998 at 11:59:47AM +0300, Sergey Okhapkin wrote:
>dcrt0.cc (build_argv): only space and tab are command line separators,
>but not all characters returned by isspace().
>
>With this fix sed problems while configuring cdk are gone, but if
>CONFIG_SHELL is bash, ash still reports:
>
>$ nice /usr/src/cygnus/src/configure --host=i586-cygwin32 --prefix=/usr --exec-prefix=/usr/H-i386-cygwin32 -v
>/usr/src/cygnus/src/configure: 679: Syntax error: EOF in backquote substitution
>$ 

This is scary.  DJ noticed this problem yesterday, and I made a change
to dcrt0.cc by making a macro called -- issep to handle it, just like
you did.  The only difference is that I also accounted for \r and \n
since the command line may have come from the (sigh) @file stuff.
I also check for this in spawn_guts just to be safe.

I wonder if allowing \r and \n is what is causing the problems with sed,
though.  Although, catching this in spawn might help.

Do you want to give this patch a try?

cgf

Index: dcrt0.cc
===================================================================
RCS file: /cvs/cvsfiles/devo/winsup/dcrt0.cc,v
retrieving revision 1.115
diff -u -p -r1.115 dcrt0.cc
--- dcrt0.cc	1998/10/13 03:14:52	1.115
+++ dcrt0.cc	1998/10/16 12:47:19
@@ -387,7 +384,7 @@ build_argv (char *cmd, char **&argv, int
   while (*cmd)
     {
       /* Ignore spaces */
-      if (isspace (*cmd))
+      if (issep (*cmd))
 	{
 	  cmd++;
 	  continue;
@@ -406,7 +403,7 @@ build_argv (char *cmd, char **&argv, int
 	      sawquote = cmd;
 	      cmd = quoted (word, cmd, winshell);
 	    }
-	  if (isspace (*cmd))	// End of argument if space
+	  if (issep (*cmd))	// End of argument if space
 	    break;
 	}
       if (*cmd)
Index: spawn.cc
===================================================================
RCS file: /cvs/cvsfiles/devo/winsup/spawn.cc,v
retrieving revision 1.84
diff -u -p -r1.84 spawn.cc
--- spawn.cc	1998/10/15 16:02:28	1.84
+++ spawn.cc	1998/10/16 12:47:19
@@ -214,7 +214,7 @@ spawn_guts (HANDLE hToken, const char * 
 	  {
 	    if (*str == '"')
 	      clen++;
-	    if (*str == ' ' || *str == '\t' || *str == '"')
+	    if (issep (*str) || *str == '"')
 	      needquote = 1;
 	    clen++;
 	  }
@@ -245,7 +245,7 @@ spawn_guts (HANDLE hToken, const char * 
 	  needquote = 1;
 
 	for (str = argv[i]; *str; str++)
-	  if (*str == ' ' || *str == '\t' || *str == '"')
+	  if (issep (*str) || *str == '"')
 	    needquote = 1;
 
 	if (needquote)
Index: winsup.h
===================================================================
RCS file: /cvs/cvsfiles/devo/winsup/winsup.h,v
retrieving revision 1.120
diff -u -p -r1.120 winsup.h
--- winsup.h	1998/10/09 02:56:24	1.120
+++ winsup.h	1998/10/16 12:49:32
@@ -677,3 +677,6 @@ class save_errno
     void reset () {saved = get_errno ();}
     ~save_errno () {set_errno (saved);}
   };
+
+#undef issep
+#define issep(ch) (strchr (" \t\n\r", (ch)) != NULL)

- Raw text -


  webmaster     delorie software   privacy  
  Copyright 2019   by DJ Delorie     Updated Jul 2019