From: marcusd AT cathcart DOT sysc DOT pdx DOT edu (Marcus G. Daniels) Subject: open vs stat and install behavior 2 Aug 1997 11:49:25 -0700 Approved: cygnus DOT gnu-win32 AT cygnus DOT com Distribution: cygnus Message-ID: Original-To: gnu-win32 AT cygnus DOT com X-Mailer: Gnus v5.5/Emacs 20.0 Original-Sender: owner-gnu-win32 AT cygnus DOT com I think `install' should be able to deal with executable filenames without an .exe suffix. The b18 behavior is that `stat' will succeed finding an executable named "t", but `open' will fail. For example, the following program correctly prints the file size of itself, but fails on the open. If there is an important reason for the different open and stat behavior, I propose the patch that follows to install.c. #include #include #include #include main() { struct stat statbuf; const char *file = "t"; if (stat (file, &statbuf) == 1) { fprintf (stderr, "stat failed to find `%s'\n",file); exit (1); } printf ("%d\n", statbuf.st_size); if (open (file, O_BINARY | O_RDONLY) == -1) { fprintf (stderr, "open failed to find `%s'\n", file); exit (1); } } /* Local Variables: compile-command: "gcc t.c -o t" End: */ *** install.c Tue Apr 15 00:57:17 1997 --- install.c.new Sat Aug 2 10:00:52 1997 *************** *** 309,321 **** Return 0 if successful, 1 if an error occurs. */ static int ! install_file_in_file (char *from, char *to) { int to_created; int no_need_to_chown; ! if (copy_file (from, to, &to_created)) ! return 1; if (strip_files) strip (to); no_need_to_chown = (to_created --- 309,346 ---- Return 0 if successful, 1 if an error occurs. */ static int ! install_file_in_file (char *from_, char *to_) { int to_created; int no_need_to_chown; ! char *from, *to; ! int fromfd = open (from, O_RDONLY | O_BINARY, 0); ! if (fromfd == -1) ! { ! from = alloca (strlen (from_) + 5); ! to = alloca (strlen (to_) + 5); ! strcpy (from, from_); ! strcat (from, ".exe"); ! strcpy (to, to_); ! strcat (to, ".exe"); ! fromfd = open (from, O_RDONLY | O_BINARY, 0); ! if (fromfd == -1) ! { ! from = from_; ! to = to_; ! } ! else ! close (fromfd); ! } ! else ! { ! close (fromfd); ! from = from_; ! to = to_; ! } ! if (copy_file (from, to, &to_created)) ! return 1; if (strip_files) strip (to); no_need_to_chown = (to_created - For help on using this list (especially unsubscribing), send a message to "gnu-win32-request AT cygnus DOT com" with one line of text: "help".