This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

improved patch to fix a POSIX compliance bug in gcc.c



hello, world\n

an off-by-one error crept in the patch I submitted yesterday. We don't
want strlen("-l") but strlen of the next arg. I am ashamed.

Regards,

	Jens
-- 
Jens Schweikhardt http://www.schweikhardt.net/
SIGSIG -- signature too long (core dumped)

--- gcc.c.orig	Fri Feb  9 22:22:06 2001
+++ gcc.c	Sat Feb 10 09:50:47 2001
@@ -3290,6 +3290,14 @@
 	  n_infiles++;
 	  i++;
 	}
+      else if (strcmp (argv[i], "-l") == 0)
+	{
+	  if (i + 1 == argc)
+	    fatal ("argument to `-l' is missing");
+
+	  n_infiles++;
+	  i++;
+	}
       else if (strncmp (argv[i], "-l", 2) == 0)
 	n_infiles++;
       else if (strcmp (argv[i], "-save-temps") == 0)
@@ -3730,6 +3738,14 @@
 	{
 	  infiles[n_infiles].language = "*";
 	  infiles[n_infiles++].name = argv[++i];
+	}
+      else if (strcmp (argv[i], "-l") == 0)
+	{ /* POSIX allows separation of -l and the lib arg;
+	     canonicalize by concatenating -l with its arg */
+	  register char *libarg = xmalloc (3 + strlen (argv[++i]));
+	  sprintf (libarg, "-l%s", argv[i]);
+	  infiles[n_infiles].language = "*";
+	  infiles[n_infiles++].name = libarg;
 	}
       else if (strncmp (argv[i], "-l", 2) == 0)
 	{


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]