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]
Other format: [Raw text]

libiberty: fix running extension-less binaries on windows


On windows, libiberty fails to run binary that's specified like:

	./whatever

even if whatever.exe is present in the current directory. The problem is this 
code in find_executable:

	int has_extension = !!strchr (program, '.');

which decides that all of the passed thing is actually an extensions, and 
disable automatic trying of .exe. This patch fixes the problem. I've checked 
that ./whatever now works. 

OK?

- Volodya

	* pex-win32.c (no_suffixes): Remove.
	(std_suffixes): Add "" as first element.
	(find_executable): Remove detection of already-present
	extension. Try all suffixes in std_suffixes.
? Makefile
? config.cache
? config.h
? config.log
? config.status
? needed-list
? pex.diff
? required-list
? stamp-h
? stamp-picdir
? xhost-mkfrag
? testsuite/Makefile
Index: pex-win32.c
===================================================================
RCS file: /cvs/src/src/libiberty/pex-win32.c,v
retrieving revision 1.14
diff -u -r1.14 pex-win32.c
--- pex-win32.c	26 Oct 2006 04:18:42 -0000	1.14
+++ pex-win32.c	3 Nov 2006 15:44:06 -0000
@@ -382,19 +382,17 @@
   return cmdline;
 }
 
+/* We'll try the passed filename without any extension,
+   and then will all known standard extensions.  */
 static const char *const
 std_suffixes[] = {
+  "",
   ".com",
   ".exe",
   ".bat",
   ".cmd",
   0
 };
-static const char *const
-no_suffixes[] = {
-  "",
-  0
-};
 
 /* Returns the full path to PROGRAM.  If SEARCH is true, look for
    PROGRAM in each directory in PATH.  */
@@ -409,7 +407,6 @@
   const char *const *ext;
   const char *p, *q;
   size_t proglen = strlen (program);
-  int has_extension = !!strchr (program, '.');
   int has_slash = (strchr (program, '/') || strchr (program, '\\'));
   HANDLE h;
 
@@ -432,7 +429,7 @@
       if (*q == ';')
 	q++;
     }
-  fe_len = fe_len + 1 + proglen + (has_extension ? 1 : 5);
+  fe_len = fe_len + 1 + proglen + 5 /* space for extension */;
   full_executable = XNEWVEC (char, fe_len);
 
   p = path;
@@ -458,7 +455,7 @@
 
       /* At this point, e points to the terminating NUL character for
          full_executable.  */
-      for (ext = has_extension ? no_suffixes : std_suffixes; *ext; ext++)
+      for (ext = std_suffixes; *ext; ext++)
 	{
 	  /* Remove any current extension.  */
 	  *e = '\0';

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