This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch][windres] Handle embedded spaces in input filenames


windres currently is unable to handle path or filenames with embedded
spaces, even if they are enclosed in quotes, eg

windres --include-dir "/Programe Files/mingw/include" --input "Copy of
foo.rc"

A mingw.org bug report is at
https://sourceforge.net/tracker/?func=detail&atid=102435&aid=1640385&gro
up_id=2435

The problem is that these option args are passed to prepocessor without
the enclosing quotes. Fixed like so:

2007-02-04  Danny Smith  <dannysmaith@users.sourceforge.net>.

	* windres.c (main): Before passing to preprocessor, enclose
	each include dir in  quotes in case it contains spaces.   
	* resrc.c (look_for_default): Quote input filename when passing
	as arg to preprocessor.
	(read_rc_file): Allocate 2 extra bytes for quotes.
Index: windres.c
===================================================================
RCS file: /cvs/src/src/binutils/windres.c,v
retrieving revision 1.27
diff -c -3 -p -r1.27 windres.c
*** windres.c	3 Oct 2005 19:37:44 -0000	1.27
--- windres.c	4 Feb 2007 07:42:45 -0000
*************** main (int argc, char **argv)
*** 868,886 ****
  	      break;
  	    }
  
  	  if (preprocargs == NULL)
  	    {
  	      quotedarg = quot (optarg);
! 	      preprocargs = xmalloc (strlen (quotedarg) + 3);
! 	      sprintf (preprocargs, "-I%s", quotedarg);
  	    }
  	  else
  	    {
  	      char *n;
  
  	      quotedarg = quot (optarg);
! 	      n = xmalloc (strlen (preprocargs) + strlen (quotedarg) +
4);
! 	      sprintf (n, "%s -I%s", preprocargs, quotedarg);
  	      free (preprocargs);
  	      preprocargs = n;
  	    }
--- 868,888 ----
  	      break;
  	    }
  
+ 	  /* Before passing to preprocessor, enclose each include dir in
+              quotes in case it contains spaces.  */
  	  if (preprocargs == NULL)
  	    {
  	      quotedarg = quot (optarg);
! 	      preprocargs = xmalloc (strlen (quotedarg) + 3 + 2);
! 	      sprintf (preprocargs, "-I\"%s\"", quotedarg);
  	    }
  	  else
  	    {
  	      char *n;
  
  	      quotedarg = quot (optarg);
! 	      n = xmalloc (strlen (preprocargs) + strlen (quotedarg) + 4
+ 2);
! 	      sprintf (n, "%s -I\"%s\"", preprocargs, quotedarg);
  	      free (preprocargs);
  	      preprocargs = n;
  	    }
Index: resrc.c
===================================================================
RCS file: /cvs/src/src/binutils/resrc.c,v
retrieving revision 1.27
diff -c -3 -p -r1.27 resrc.c
*** resrc.c	8 May 2005 14:17:39 -0000	1.27
--- resrc.c	4 Feb 2007 07:53:30 -0000
*************** look_for_default (char *cmd, const char 
*** 365,372 ****
      }
  
    strcpy (cmd, prefix);
! 
!   sprintf (cmd + end_prefix, "%s %s %s",
  	   DEFAULT_PREPROCESSOR, preprocargs, filename);
  
    if (verbose)
--- 365,373 ----
      }
  
    strcpy (cmd, prefix);
!   /* Quote input filename when passing as arg to preprocessor.
!      It may contain spaces.  */
!   sprintf (cmd + end_prefix, "%s %s \"%s\"",
  	   DEFAULT_PREPROCESSOR, preprocargs, filename);
  
    if (verbose)
*************** read_rc_file (const char *filename, cons
*** 396,401 ****
--- 397,403 ----
        cmd = xmalloc (strlen (preprocessor)
  		     + strlen (preprocargs)
  		     + strlen (filename)
+ 		     + 2 /* for quotes around filename */	
  		     + 10);
        sprintf (cmd, "%s %s %s", preprocessor, preprocargs, filename);
  
*************** read_rc_file (const char *filename, cons
*** 414,419 ****
--- 416,422 ----
  #ifdef HAVE_EXECUTABLE_SUFFIX
  		     + strlen (EXECUTABLE_SUFFIX)
  #endif
+ 		     + 2 /* for quotes around filename */	
  		     + 10);
  
  


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