delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1996/09/13/03:42:34

Date: Fri, 13 Sep 1996 10:32:48 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: djgpp-workers AT delorie DOT com
Cc: Robert Hoehne <robert DOT hoehne AT mathematik DOT tu-chemnitz DOT de>
Subject: Make-3.74 diffs
Message-Id: <Pine.SUN.3.91.960913102242.17978A-100000@is>
Mime-Version: 1.0

Everybody who's interested: please use the diffs below instead of the 
junk that I've sent a couple of days ago.  Sorry about the snafu...

diff -r -c -P -x*.o -x*.exe -x*~ -x*~[0-9] make-3.74-orig/commands.c make-3.74/commands.c
*** make-3.74-orig/commands.c	Thu Sep 29 08:23:24 1994
--- make-3.74/commands.c	Sat Aug 31 14:15:00 1996
***************
*** 360,367 ****
       int sig;
  {
  #ifdef	__MSDOS__
    remove_intermediates (1);
!   exit (1);
  #else	/* Not MSDOS.  */
    handling_fatal_signal = 1;
  
--- 360,374 ----
       int sig;
  {
  #ifdef	__MSDOS__
+   extern int dos_status, dos_command_running;
+ 
+   if (dos_command_running)
+     {
+       dos_status |= (sig << 8);
+       return;
+     }
    remove_intermediates (1);
!   exit (2);
  #else	/* Not MSDOS.  */
    handling_fatal_signal = 1;
  
diff -r -c -P -x*.o -x*.exe -x*~ -x*~[0-9] make-3.74-orig/configh.dos make-3.74/configh.dos
*** make-3.74-orig/configh.dos	Thu Mar  9 01:11:28 1995
--- make-3.74/configh.dos	Fri Sep  6 19:44:28 1996
***************
*** 21,33 ****
  #endif
  
  /* Define if `sys_siglist' is declared by <signal.h>.  */
! #define SYS_SIGLIST_DECLARED
! 
! /* Define if you have getdtablesize.  */
! #define HAVE_GETDTABLESIZE
! 
! /* Define if you have dup2.  */
! #define HAVE_DUP2
  
  /* Define if you have sys_siglist.  */
  #undef HAVE_SYS_SIGLIST
--- 21,27 ----
  #endif
  
  /* Define if `sys_siglist' is declared by <signal.h>.  */
! #undef SYS_SIGLIST_DECLARED
  
  /* Define if you have sys_siglist.  */
  #undef HAVE_SYS_SIGLIST
***************
*** 38,43 ****
--- 32,49 ----
  /* Define if you have psignal.  */
  #define HAVE_PSIGNAL
  
+ /* Define if you have strsignal.  */
+ #undef HAVE_STRSIGNAL
+ 
+ /* Define NSIG.  */
+ #define NSIG SIGMAX
+ 
+ /* Define if you have getdtablesize.  */
+ #define HAVE_GETDTABLESIZE
+ 
+ /* Define if you have dup2.  */
+ #define HAVE_DUP2
+ 
  /* Define if you have getcwd.  */
  #define HAVE_GETCWD
  
***************
*** 64,68 ****
--- 70,77 ----
  
  /* Define if you have the `strerror' function.  */
  #define HAVE_STRERROR
+ 
+ /* Define if you have the <sys/wait.h> header file.  */
+ #define HAVE_SYS_WAIT_H
  
  #define SCCS_GET "get"
diff -r -c -P -x*.o -x*.exe -x*~ -x*~[0-9] make-3.74-orig/configur.bat make-3.74/configur.bat
*** make-3.74-orig/configur.bat	Fri Mar 17 20:56:52 1995
--- make-3.74/configur.bat	Sat Aug 31 11:34:14 1996
***************
*** 1,10 ****
  @echo off
! echo Configuring MAKE for go32
  rem This batch file assumes a unix-type "sed" program
  
  update configh.dos config.h
  
! echo # Makefile generated by "configure.bat"> Makefile
  
  if exist config.sed del config.sed
  
--- 1,10 ----
  @echo off
! echo Configuring MAKE for DJGPP
  rem This batch file assumes a unix-type "sed" program
  
  update configh.dos config.h
  
! echo # Makefile generated for DJGPP by "configure.bat"> Makefile
  
  if exist config.sed del config.sed
  
***************
*** 18,24 ****
--- 18,32 ----
  echo "s/@srcdir@/./					">> config.sed
  echo "s/@CC@/gcc/					">> config.sed
  echo "s/@CFLAGS@/-O2 -g/				">> config.sed
+ if "%1"=="no-float" goto nofloat
+ if "%1"=="NO-FLOAT" goto nofloat
+ if "%1"=="NO_FLOAT" goto nofloat
+ if "%1"=="no_float" goto nofloat
  echo "s/@CPPFLAGS@/-DHAVE_CONFIG_H/			">> config.sed
+ goto floatdone
+ :nofloat
+ echo "s/@CPPFLAGS@/-DHAVE_CONFIG_H -DNO_FLOAT/		">> config.sed
+ :floatdone
  echo "s/@LDFLAGS@//					">> config.sed
  echo "s/@RANLIB@/ranlib/				">> config.sed
  echo "s/@DEFS@//					">> config.sed
diff -r -c -P -x*.o -x*.exe -x*~ -x*~[0-9] make-3.74-orig/dir.c make-3.74/dir.c
*** make-3.74-orig/dir.c	Tue Nov  8 00:14:50 1994
--- make-3.74/dir.c	Fri Aug 30 14:47:46 1996
***************
*** 49,54 ****
--- 49,55 ----
  
  #ifdef __MSDOS__
  #include <ctype.h>
+ #include <fcntl.h>
  
  static char *
  dosify (filename)
***************
*** 58,66 ****
    char *df;
    int i;
  
!   if (filename == 0)
!     return 0;
  
    if (strpbrk (filename, "\"*+,;<=>?[\\]|") != 0)
      return filename;
  
--- 59,68 ----
    char *df;
    int i;
  
!   if (filename == 0 || _USE_LFN)
!     return filename;
  
+   /* FIXME: what about filenames that violate 8+3 constraints?  */
    if (strpbrk (filename, "\"*+,;<=>?[\\]|") != 0)
      return filename;
  
diff -r -c -P -x*.o -x*.exe -x*~ -x*~[0-9] make-3.74-orig/function.c make-3.74/function.c
*** make-3.74-orig/function.c	Wed Apr 19 18:08:48 1995
--- make-3.74/function.c	Sat Sep  7 19:06:54 1996
***************
*** 22,32 ****
  #include "commands.h"
  #include "job.h"
  
- #ifdef __MSDOS__
- #include <process.h>
- #include <fcntl.h>
- #endif
- 
  static char *string_glob ();
  
  /* Store into VARIABLE_BUFFER at O the result of scanning TEXT and replacing
--- 22,27 ----
***************
*** 344,349 ****
--- 339,349 ----
  	char *error_prefix;
  	int pipedes[2];
  	int pid;
+ #ifdef __MSDOS__
+ 	int e;
+ 	FILE *fpipe;
+ 	int save_sys_flags = 0;
+ #endif
  
  	/* Expand the command line.  */
  	text = expand_argument (text, end);
***************
*** 376,389 ****
  	else
  	  error_prefix = "";
  
! #ifndef	  __MSDOS__
  	if (pipe (pipedes) < 0)
  	  {
  	    perror_with_name (error_prefix, "pipe");
  	    break;
  	  }
  
  	pid = vfork ();
  	if (pid < 0)
  	  perror_with_name (error_prefix, "fork");
  	else if (pid == 0)
--- 376,461 ----
  	else
  	  error_prefix = "";
  
! #ifdef	__MSDOS__
! 	{
! 	  struct variable *sh = lookup_variable ("SHELL", 5);
! 	  char *shbase;
! 
! 	  if (sh)
! 	    {
! 	      char buf[PATH_MAX + 7];
! #ifndef _POSIX_SOURCE
! 	      for (shbase = sh->value + strlen (sh->value) - 1;
! 		   shbase > sh->value;
! 		   shbase--)
! 		{
! 		  if (*shbase == '/' || *shbase == '\\' || *shbase == ':')
! 		    {
! 		      shbase++;
! 		      break;
! 		    }
! 		}
! 
! 	      /* If $SHELL doesn't match any of the known MSDOS shells,
! 		 we assume it is a real (Unix-like) shell, and thus
! 		 doesn't need any assistance from our `system'.  */
! 	      if (stricmp (shbase, "command.com")
! 		  && stricmp (shbase, "4dos.com")
! 		  && stricmp (shbase, "ndos.com"))
! 		{
! 		  save_sys_flags = __system_flags;
! 		  __system_flags |= __system_call_cmdproc;
! 		}
! #endif
! 	      /* This makes sure $SHELL value is used by $(shell), even
! 		 though the target environment is not passed to it.  */
! 	      sprintf (buf, "SHELL=%s", sh->value);
! 	      putenv (buf);
! 	    }
! 	}
! 	e = errno;
! 	errno = 0;
! 	{
! 	  extern int dos_command_running, dos_status;
! 
! 	  dos_command_running = 1;
! 	  dos_status = 0;
! 	  fpipe = popen (text, "rt");
! 	  dos_command_running = 0;
! #ifndef _POSIX_SOURCE
! 	  if (save_sys_flags)
! 	    __system_flags = save_sys_flags;
! #endif
! 	  if (!fpipe || dos_status)
! 	    {
! 	      pipedes[0] = -1;
! 	      pid = -1;
! 	      if (dos_status)
! 		errno = EINTR;
! 	      else if (errno == 0)
! 		errno = ENOMEM;
! 	      shell_function_completed = -1;
! 	    }
! 	  else
! 	    {
! 	      pipedes[0] = fileno (fpipe);
! 	      pid = 42;
! 	      errno = e;
! 	      shell_function_completed = 1;
! 	    }
! 	}
! 	if (pipedes[0] < 0)
! #else
  	if (pipe (pipedes) < 0)
+ #endif
  	  {
  	    perror_with_name (error_prefix, "pipe");
  	    break;
  	  }
  
+ #ifndef	__MSDOS__
  	pid = vfork ();
+ #endif
  	if (pid < 0)
  	  perror_with_name (error_prefix, "fork");
  	else if (pid == 0)
***************
*** 407,423 ****
  
  	    /* Record the PID for reap_children.  */
  	    shell_function_pid = pid;
  	    shell_function_completed = 0;
  
  
  	    /* Set up and read from the pipe.  */
  
  	    maxlen = 200;
  	    buffer = (char *) xmalloc (maxlen + 1);
  
- 	    /* Close the write side of the pipe.  */
- 	    (void) close (pipedes[1]);
- 
  	    /* Read from the pipe until it gets EOF.  */
  	    i = 0;
  	    do
--- 479,496 ----
  
  	    /* Record the PID for reap_children.  */
  	    shell_function_pid = pid;
+ #ifndef  __MSDOS__
  	    shell_function_completed = 0;
  
+ 	    /* Close the write side of the pipe.  */
+ 	    (void) close (pipedes[1]);
+ #endif
  
  	    /* Set up and read from the pipe.  */
  
  	    maxlen = 200;
  	    buffer = (char *) xmalloc (maxlen + 1);
  
  	    /* Read from the pipe until it gets EOF.  */
  	    i = 0;
  	    do
***************
*** 440,446 ****
--- 513,524 ----
  #endif
  
  	    /* Close the read side of the pipe.  */
+ #ifdef  __MSDOS__
+ 	    if (fpipe)
+ 	      (void) pclose (fpipe);
+ #else
  	    (void) close (pipedes[0]);
+ #endif
  
  	    /* Loop until child_handler sets shell_function_completed
  	       to the status of our child shell.  */
***************
*** 481,549 ****
  
  	    free (buffer);
  	  }
- #else	/* MSDOS.  */
-          {
- 	   /* MS-DOS can't do fork, but it can do spawn.  However, this
- 	      means that we don't have an opportunity to reopen stdout to
- 	      trap it.  Thus, we save our own stdout onto a new descriptor
- 	      and dup a temp file's descriptor onto our stdout temporarily.
- 	      After we spawn the shell program, we dup our own stdout back
- 	      to the stdout descriptor.  The buffer reading is the same as
- 	      above, except that we're now reading from a file.  */
- 
- 	   int save_stdout;
- 	   int child_stdout;
- 	   char tmp_output[FILENAME_MAX];
- 	   FILE *child_stream;
- 	   unsigned int maxlen = 200;
- 	   int cc;
- 	   char *buffer;
-  
- 	   strcpy (tmp_output, "shXXXXXX");
- 	   mktemp (tmp_output);
- 	   child_stdout = open (tmp_output,
- 				O_WRONLY|O_CREAT|O_TRUNC|O_TEXT, 0644);
- 	   save_stdout = dup (1);
- 	   dup2 (child_stdout, 1);
- 	   spawnvp (P_WAIT, argv[0], argv);
- 	   dup2 (save_stdout, 1);
- 	   close (child_stdout);
- 	   close (save_stdout);
-  
- 	   child_stdout = open (tmp_output, O_RDONLY|O_TEXT, 0644);
-  
- 	   buffer = xmalloc (maxlen);
- 	   i = 0;
- 	   do
- 	     {
- 	       if (i == maxlen)
- 		 {
- 		   maxlen += 512;
- 		   buffer = (char *) xrealloc (buffer, maxlen + 1);
- 		 }
-  
- 	       cc = read (child_stdout, &buffer[i], maxlen - i);
- 	       if (cc > 0)
- 		 i += cc;
- 	     } while (cc > 0);
-  
- 	   close (child_stdout);
- 	   unlink (tmp_output);
-  
- 	   if (i > 0)
- 	     {
- 	       if (buffer[i - 1] == '\n')
- 		 buffer[--i] = '\0';
- 	       else
- 		 buffer[i] = '\0';
- 	       p = buffer;
- 	       while ((p = index (p, '\n')) != 0)
- 		 *p++ = ' ';
- 	       o = variable_buffer_output (o, buffer, i);
- 	     }
- 	   free (buffer);
- 	 }
- #endif	/* Not MSDOS.  */
  
  	free (text);
  	break;
--- 559,564 ----
diff -r -c -P -x*.o -x*.exe -x*~ -x*~[0-9] make-3.74-orig/glob/configur.bat make-3.74/glob/configur.bat
*** make-3.74-orig/glob/configur.bat	Thu Mar  9 01:17:56 1995
--- make-3.74/glob/configur.bat	Sat Aug 24 17:18:14 1996
***************
*** 1,5 ****
  @echo off
! echo Configuring glob for GO32
  rem This batch file assumes a unix-type "sed" program
  
  echo # Makefile generated by "configure.bat"> Makefile
--- 1,5 ----
  @echo off
! echo Configuring glob for DJGPP
  rem This batch file assumes a unix-type "sed" program
  
  echo # Makefile generated by "configure.bat"> Makefile
diff -r -c -P -x*.o -x*.exe -x*~ -x*~[0-9] make-3.74-orig/job.c make-3.74/job.c
*** make-3.74-orig/job.c	Wed Apr 26 21:13:56 1995
--- make-3.74/job.c	Sat Sep  7 19:08:24 1996
***************
*** 23,40 ****
  #include "variable.h"
  #include <assert.h>
  
- /* Default shell to use.  */
- char default_shell[] = "/bin/sh";
  
  #ifdef __MSDOS__
  #include <process.h>
  static int dos_pid = 123;
! static int dos_status;
  static char *dos_bname;
  static char *dos_bename;
  static int dos_batch_file;
! #endif /* MSDOS.  */
! 
  
  /* If NGROUPS_MAX == 0 then try other methods for finding a real value.  */
  #if defined (NGROUPS_MAX) && NGROUPS_MAX == 0
--- 23,44 ----
  #include "variable.h"
  #include <assert.h>
  
  
  #ifdef __MSDOS__
  #include <process.h>
  static int dos_pid = 123;
! int dos_status;
! int dos_command_running;
  static char *dos_bname;
  static char *dos_bename;
  static int dos_batch_file;
! static int execute_by_shell;
! /* Default shell to use.  */
! char default_shell[] = "c:/command.com";
! #else /* not MSDOS  */
! /* Default shell to use.  */
! char default_shell[] = "/bin/sh";
! #endif
  
  /* If NGROUPS_MAX == 0 then try other methods for finding a real value.  */
  #if defined (NGROUPS_MAX) && NGROUPS_MAX == 0
***************
*** 158,163 ****
--- 162,172 ----
  /* Chain of children waiting to run until the load average goes down.  */
  
  static struct child *waiting_jobs = 0;
+ 
+ /* Non-zero if we use a *real* shell (always so on Unix).  */
+ 
+ static int real_shell = 1;
+ 
  
  /* Write an error message describing the exit status given in
     EXIT_CODE, EXIT_SIG, and COREDUMP, for the target TARGET_NAME.
***************
*** 320,327 ****
  	  /* Life is very different on MSDOS.  */
  	  pid = dos_pid - 1;
  	  status = dos_status;
! 	  exit_code = dos_status;
! 	  exit_sig = 0;
  	  coredump = 0;
  #endif	/* Not MSDOS.  */
  	}
--- 329,338 ----
  	  /* Life is very different on MSDOS.  */
  	  pid = dos_pid - 1;
  	  status = dos_status;
! 	  exit_code = WEXITSTATUS (status);
! 	  if (exit_code == 0xff)
! 	    exit_code = -1;
! 	  exit_sig = WIFSIGNALED (status) ? WTERMSIG (status) : 0;
  	  coredump = 0;
  #endif	/* Not MSDOS.  */
  	}
***************
*** 497,509 ****
  }
  
  #ifdef	POSIX
- #ifdef	__MSDOS__
- void
- unblock_sigs ()
- {
-   return;
- }
- #else
  extern sigset_t fatal_signal_set;
  
  void
--- 508,513 ----
***************
*** 514,520 ****
    sigprocmask (SIG_SETMASK, &empty, (sigset_t *) 0);
  }
  #endif
- #endif
  
  /* Start a job to run the commands specified in CHILD.
     CHILD is updated to reflect the commands and ID of the child process.  */
--- 518,523 ----
***************
*** 714,732 ****
      }
  
  #else	/* MSDOS.  */
!   dos_status = spawnvpe (P_WAIT, argv[0], argv, child->environment);
!   ++dead_children;
!   child->pid = dos_pid++;
!   if (dos_batch_file)
!    {
!      dos_batch_file = 0;
!      remove (dos_bname);	/* Ignore errors.  */
!      if (access (dos_bename, 0))
!        dos_status = 1;
!      else
!        dos_status = 0;
!      remove (dos_bename);
!    }
  #endif	/* Not MSDOS.  */
  
    /* We are the parent side.  Set the state to
--- 717,784 ----
      }
  
  #else	/* MSDOS.  */
!   {
!     int proc_return;
! #ifdef	 POSIX
!     (void) sigprocmask (SIG_BLOCK, &fatal_signal_set, (sigset_t *) 0);
! #endif
! 
!     /* We call `system' to do the job of the SHELL, since stock DOS
!        shell is too dumb.  Our `system' knows how to handle long
!        command lines even if pipes/redirection is needed; it will only
!        call COMMAND.COM when its internal commands are used.  */
!     if (execute_by_shell)
!       {
! 	int save_sys_flags = 0;
! 	char *cmdline = argv[0];
! 	/* We don't have a way to pass environment to `system',
! 	   so we need to save and restore ours, sigh...  */
! 	char **parent_environ = environ;
! 
! 	if (real_shell)
! 
! 	environ = child->environment;
! 	dos_status = 0;
! 
! 	/* If we have a *real* shell, tell `system' to call
! 	   it to do everything for us.  */
! 	if (real_shell)
! 	  {
! #ifndef _POSIX_SOURCE
! 	    save_sys_flags = __system_flags;
! 	    __system_flags |= __system_call_cmdproc;
! #endif
! 	    /* A *real* shell on MSDOS may not support long
! 	       command lines the DJGPP way, so we must use `system'.  */
! 	    cmdline = argv[2];	/* get past "shell -c" */
! 	  }
! 	  
! 	dos_command_running = 1;
! 	proc_return = system (cmdline);
! 	dos_command_running = 0;
! 	environ = parent_environ;
! 	execute_by_shell = 0;	/* for the next time */
! 
! #ifndef _POSIX_SOURCE
! 	if (real_shell && save_sys_flags)
! 	  __system_flags = save_sys_flags;
! #endif
! 	  
!       }
!     else
!       {
! 	dos_command_running = 1;
! 	proc_return = spawnvpe (P_WAIT, argv[0], argv, child->environment);
! 	dos_command_running = 0;
!       }
! 
!     if (proc_return == -1)
!       dos_status |= 0xff;
!     else
!       dos_status |= (proc_return & 0xff);
!     ++dead_children;
!     child->pid = dos_pid++;
!   }
  #endif	/* Not MSDOS.  */
  
    /* We are the parent side.  Set the state to
***************
*** 849,855 ****
        /* IN points to where in the line we are scanning.
  	 OUT points to where in the line we are writing.
  	 When we collapse a backslash-newline combination,
! 	 IN gets ahead out OUT.  */
  
        in = out = cmds->command_lines[i];
        while ((ref = index (in, '$')) != 0)
--- 901,907 ----
        /* IN points to where in the line we are scanning.
  	 OUT points to where in the line we are writing.
  	 When we collapse a backslash-newline combination,
! 	 IN gets ahead of OUT.  */
  
        in = out = cmds->command_lines[i];
        while ((ref = index (in, '$')) != 0)
***************
*** 1048,1053 ****
--- 1100,1108 ----
       int stdin_fd, stdout_fd;
       char **argv, **envp;
  {
+ #ifdef  __MSDOS__
+   abort ();
+ #else
    if (stdin_fd != 0)
      (void) dup2 (stdin_fd, 0);
    if (stdout_fd != 1)
***************
*** 1063,1068 ****
--- 1118,1124 ----
  
    /* Run the command.  */
    exec_command (argv, envp);
+ #endif
  }
  
  /* Replace the current process with one running the command in ARGV,
***************
*** 1072,1077 ****
--- 1128,1136 ----
  exec_command (argv, envp)
       char **argv, **envp;
  {
+ #ifdef  __MSDOS__
+   abort ();
+ #else
    /* Be the user, permanently.  */
    child_access ();
  
***************
*** 1123,1128 ****
--- 1182,1188 ----
      }
  
    _exit (127);
+ #endif
  }
  
  /* Figure out the argument list necessary to run LINE as a command.  Try to
***************
*** 1143,1164 ****
       char *line, **restp;
       char *shell, *ifs;
  {
! #ifdef __MSDOS__
!   static char sh_chars[] = "\"|<>";
!   static char *sh_cmds[] = { "break", "call", "cd", "chcp", "chdir", "cls",
! 			     "copy", "ctty", "date", "del", "dir", "echo",
! 			     "erase", "exit", "for", "goto", "if", "if", "md",
! 			     "mkdir", "path", "pause", "prompt", "rem", "ren",
! 			     "rename", "set", "shift", "time", "type",
! 			     "ver", "verify", "vol", ":", 0 };
  #else
!   static char sh_chars[] = "#;\"*?[]&|<>(){}$`^";
!   static char *sh_cmds[] = { "cd", "eval", "exec", "exit", "login",
! 			     "logout", "set", "umask", "wait", "while", "for",
! 			     "case", "if", ":", ".", "break", "continue",
! 			     "export", "read", "readonly", "shift", "times",
! 			     "trap", "switch", 0 };
  #endif
    register int i;
    register char *p;
    register char *ap;
--- 1203,1251 ----
       char *line, **restp;
       char *shell, *ifs;
  {
! #ifdef  __MSDOS__
!   char *theshell;
!   /* Since we call `system' for anything that requires ``slow'' processing,
!      certain characters and commands below are actually not specific to
!      COMMAND.COM, but to the DJGPP implementation of `system'.
!      In particular:
! 
!        The shell wildcard characters are in DOS_CHARS because they will
!        not be expanded if we call the child via `spawnXX'.
! 
!        The `;' is in DOS_CHARS, because our `system' knows how to run
!        multiple commands on a single line.
! 
!        DOS_CHARS also include characters special to 4DOS/NDOS, so we
!        won't have to tell one from another and have one more set of
!        commands and special characters.  */
!   static char dos_chars[]    = "*?[];|<>%^&()";
!   static char *dos_cmds[]    = { "break", "call", "cd", "chcp", "chdir", "cls",
! 				 "copy", "ctty", "date", "del", "dir", "echo",
! 				 "erase", "exit", "for", "goto", "if", "md",
! 				 "mkdir", "path", "pause", "prompt", "rd",
! 				 "rmdir", "rem", "ren", "rename", "set",
! 				 "shift", "time", "type", "ver", "verify",
! 				 "vol", ":", 0 };
!   static char shell_chars[]  = "#;\"*?[]&|<>(){}$`^";
!   static char *shell_cmds[]  = { "cd", "eval", "exec", "exit", "login",
! 				 "logout", "set", "umask", "wait", "while",
! 				 "for", "case", "if", ":", ".", "break",
! 				 "continue", "export", "read", "readonly",
! 				 "shift", "times", "trap", "switch", 0 };
! 
!   /* Default:  */
!   char *sh_chars = dos_chars;
!   char **sh_cmds = dos_cmds;
  #else
!   static char sh_chars[]  = "#;\"*?[]&|<>(){}$`^";
!   static char *sh_cmds[]  = { "cd", "eval", "exec", "exit", "login",
! 			      "logout", "set", "umask", "wait", "while", "for",
! 			      "case", "if", ":", ".", "break", "continue",
! 			      "export", "read", "readonly", "shift", "times",
! 			      "trap", "switch", 0 };
  #endif
+ 
    register int i;
    register char *p;
    register char *ap;
***************
*** 1176,1183 ****
--- 1263,1303 ----
      return 0;
  
    /* See if it is safe to parse commands internally.  */
+ #ifdef  __MSDOS__
+   if (shell == 0)
+     {
+       /* We always need to know what the shell is.  */
+       shell = lookup_variable ("SHELL", 5)->value;
+       if (!shell)
+ 	shell = default_shell;
+     }
+ 
+   /* We can't assume anything about the directory where the shell
+      should reside, so we need to find its basename and look at that.  */
+   real_shell = 0;
+   theshell = p = shell;
+   while (*p)
+     {
+       if ((*p == '/' || *p == '\\' || *p == ':') && p[1])
+ 	theshell = p + 1;
+       p++;
+     }
+   if (!stricmp (theshell, "sh") || !stricmp (theshell, "sh.exe")
+       || !stricmp (theshell, "sh32") || !stricmp (theshell, "sh32.exe")
+       || !stricmp (theshell, "bash") || !stricmp (theshell, "bash.exe"))
+     {
+       sh_chars = shell_chars;
+       sh_cmds  = shell_cmds;
+       real_shell = 1;
+     }
+   else if (!stricmp (theshell, "command.com")
+ 	   || !stricmp (theshell, "4dos.com")
+ 	   || !stricmp (theshell, "ndos.com"))
+     ;
+ #else  /* not MSDOS */
    if (shell == 0)
      shell = default_shell;
+ #endif /* MSDOS */
    else if (strcmp (shell, default_shell))
      goto slow;
  
***************
*** 1219,1226 ****
  	      goto end_of_line;
  	    }
  	  /* Backslash, $, and ` are special inside double quotes.
! 	     If we see any of those, punt.  */
! 	  else if (instring == '"' && index ("\\$`", *p) != 0)
  	    goto slow;
  	  else
  	    *ap++ = *p;
--- 1339,1348 ----
  	      goto end_of_line;
  	    }
  	  /* Backslash, $, and ` are special inside double quotes.
! 	     If we see any of those, punt.
! 	     But when we use COMMAND.COM, double and single
! 	     quotes have the same effect.  */
! 	  else if (instring == '"' && index ("\\$`", *p) != 0 && real_shell)
  	    goto slow;
  	  else
  	    *ap++ = *p;
***************
*** 1228,1233 ****
--- 1350,1360 ----
        else if (index (sh_chars, *p) != 0)
  	/* Not inside a string, but it's a special char.  */
  	goto slow;
+ #ifdef  __MSDOS__
+       else if (*p == '.' && p[1] == '.' && p[2] == '.')
+ 	/* `...' is a wildcard in DJGPP.  */
+ 	goto slow;
+ #endif
        else
  	/* Not a special char.  */
  	switch (*p)
***************
*** 1237,1243 ****
  	       first word with no equals sign in it.  This is not the case
  	       with sh -k, but we never get here when using nonstandard
  	       shell flags.  */
! 	    if (! seen_nonequals)
  	      goto slow;
  	    word_has_equals = 1;
  	    *ap++ = '=';
--- 1364,1370 ----
  	       first word with no equals sign in it.  This is not the case
  	       with sh -k, but we never get here when using nonstandard
  	       shell flags.  */
! 	    if (! seen_nonequals && real_shell)
  	      goto slow;
  	    word_has_equals = 1;
  	    *ap++ = '=';
***************
*** 1371,1404 ****
        free (new_argv);
      }
  
! #ifdef __MSDOS__
!    {
!      FILE *batch;
!      dos_batch_file = 1;
!      if (dos_bname == 0)
!        {
! 	 dos_bname = tempnam (".", "mk");
! 	 for (i = 0; dos_bname[i] != '\0'; ++i)
! 	   if (dos_bname[i] == '/')
! 	     dos_bname[i] = '\\';
! 	 dos_bename = (char *) xmalloc (strlen (dos_bname) + 5);
! 	 strcpy (dos_bename, dos_bname);
! 	 strcat (dos_bname, ".bat");
! 	 strcat (dos_bename, ".err");
!        }
!      batch = fopen (dos_bename, "w"); /* Create a file.  */
!      if (batch != NULL)
!        fclose (batch);
!      batch = fopen (dos_bname, "w");
!      fputs ("@echo off\n", batch);
!      fputs (line, batch);
!      fprintf (batch, "\nif errorlevel 1 del %s\n", dos_bename);
!      fclose (batch);
!      new_argv = (char **) xmalloc(2 * sizeof(char *));
!      new_argv[0] = strdup (dos_bname);
!      new_argv[1] = 0;
!    }
! #else	/* Not MSDOS.  */
    {
      /* SHELL may be a multi-word command.  Construct a command line
         "SHELL -c LINE", with all special chars in LINE escaped.
--- 1498,1507 ----
        free (new_argv);
      }
  
! #ifdef  __MSDOS__
!   execute_by_shell = 1;
! #endif
! 
    {
      /* SHELL may be a multi-word command.  Construct a command line
         "SHELL -c LINE", with all special chars in LINE escaped.
***************
*** 1411,1417 ****
      
      char *new_line = (char *) alloca (shell_len + (sizeof (minus_c) - 1)
  				      + (line_len * 2) + 1);
!     
      ap = new_line;
      bcopy (shell, ap, shell_len);
      ap += shell_len;
--- 1514,1520 ----
      
      char *new_line = (char *) alloca (shell_len + (sizeof (minus_c) - 1)
  				      + (line_len * 2) + 1);
! 
      ap = new_line;
      bcopy (shell, ap, shell_len);
      ap += shell_len;
***************
*** 1440,1462 ****
  
  	    p = next_token (p);
  	    --p;
! 	    *ap++ = '\\';
  	    *ap++ = ' ';
  	    continue;
  	  }
  
! 	if (*p == '\\' || *p == '\'' || *p == '"'
! 	    || isspace (*p)
! 	    || index (sh_chars, *p) != 0)
  	  *ap++ = '\\';
  	*ap++ = *p;
        }
      *ap = '\0';
      
!     new_argv = construct_command_argv_internal (new_line, (char **) NULL,
! 						(char *) 0, (char *) 0);
    }
- #endif	/* MSDOS.  */
  
    return new_argv;
  }
--- 1543,1583 ----
  
  	    p = next_token (p);
  	    --p;
! 	    if (real_shell)
! 	      *ap++ = '\\';
  	    *ap++ = ' ';
  	    continue;
  	  }
  
! 	/* DOS shells don't know about backslash-escaping.  */
! 	if (real_shell &&
! 	    (*p == '\\' || *p == '\'' || *p == '"'
! 	     || isspace (*p)
! 	     || index (sh_chars, *p) != 0))
  	  *ap++ = '\\';
+ 
  	*ap++ = *p;
        }
      *ap = '\0';
      
!     if (real_shell)
!       new_argv = construct_command_argv_internal (new_line, (char **) NULL,
! 						  (char *) 0, (char *) 0);
!     else
!       {
! #ifdef  __MSDOS__
! 	/* With MSDOS shells, we must construct the command line here
! 	   instead of recursively calling ourselves, because we
! 	   cannot backslash-escape the special characters (see above).  */
! 	new_argv = (char **) xmalloc (sizeof (char *));
! 	line_len = strlen (new_line) - shell_len - sizeof (minus_c) + 1;
! 	new_argv[0] = xmalloc (line_len + 1);
! 	strncpy (new_argv[0],
! 		 new_line + shell_len + sizeof (minus_c) - 1, line_len);
! 	new_argv[0][line_len] = '\0';
! #endif
!       }
    }
  
    return new_argv;
  }
diff -r -c -P -x*.o -x*.exe -x*~ -x*~[0-9] make-3.74-orig/main.c make-3.74/main.c
*** make-3.74-orig/main.c	Tue Mar 28 18:59:06 1995
--- make-3.74/main.c	Sat Sep  7 18:38:02 1996
***************
*** 61,67 ****
--- 61,69 ----
  	flag_off,		/* Turn int flag off.  */
  	string,			/* One string per switch.  */
  	positive_int,		/* A positive integer.  */
+ #if !defined(__MSDOS__) || !defined(NO_FLOAT)
  	floating,		/* A floating-point number (double).  */
+ #endif
  	ignore			/* Ignored.  */
        } type;
  
***************
*** 171,178 ****
--- 173,182 ----
     zero load (which could be useful to start infinite jobs remotely
     but one at a time locally).  */
  
+ #if !defined(__MSDOS__) || !defined(NO_FLOAT)
  double max_load_average = -1.0;
  double default_load_average = -1.0;
+ #endif
  
  /* List of directories given with -C switches.  */
  
***************
*** 235,244 ****
--- 239,250 ----
  	0, (char *) &default_keep_going_flag,
  	"keep-going", 0,
  	"Keep going when some targets can't be made" },
+ #if !defined(__MSDOS__) || !defined(NO_FLOAT)
      { 'l', floating, (char *) &max_load_average, 1, 1, 0,
  	(char *) &default_load_average, (char *) &default_load_average,
  	"load-average", "N",
  	"Don't start multiple jobs unless load is below N" },
+ #endif
      { 'm', ignore, 0, 0, 0, 0, 0, 0,
  	0, 0,
  	"-b" },
***************
*** 352,357 ****
--- 358,376 ----
     This turns on pedantic compliance with POSIX.2.  */
  
  int posix_pedantic;
+ 
+ #ifdef  __MSDOS__
+ /* The initial directory, where it all started.  */
+ 
+ static char *initial_directory;
+ 
+ static void
+ msdos_return_to_initial_directory ()
+ {
+   if (initial_directory)
+     chdir (initial_directory);
+ }
+ #endif
  
  /* Mask of signals that are being caught with fatal_error_signal.  */
  
***************
*** 424,429 ****
--- 443,460 ----
    default_goal_file = 0;
    reading_filename = 0;
    reading_lineno_ptr = 0;
+ 
+ #if defined (__MSDOS__) && !defined (_POSIX_SOURCE)
+   /* Request the most powerful version of `system', to
+      make up for the dumb default shell.  */
+   __system_flags = (__system_redirect
+ 		    | __system_use_shell
+ 		    | __system_allow_multiple_cmds
+ 		    | __system_allow_long_cmds
+ 		    | __system_handle_null_commands
+ 		    | __system_emulate_chdir);
+ 
+ #endif
    
  #if !defined (HAVE_STRSIGNAL) && !defined (HAVE_SYS_SIGLIST)
    signame_init ();
***************
*** 519,524 ****
--- 550,562 ----
    else
      directory_before_chdir = savestring (current_directory,
  					 strlen (current_directory));
+ #ifdef  __MSDOS__
+     /* MS-DOS doesn't have per-process cwd.  */
+   if (directory_before_chdir)
+     initial_directory = savestring (current_directory,
+ 				    strlen (current_directory));
+   atexit (msdos_return_to_initial_directory);
+ #endif
  
    /* Read in variables from the environment.  It is important that this be
       done before $(MAKE) is are figured out so its definitions will not be
***************
*** 1180,1186 ****
--- 1218,1226 ----
  
  	case string:
  	case positive_int:
+ #if !defined(__MSDOS__) || !defined(NO_FLOAT)
  	case floating:
+ #endif
  	  if (isalnum (switches[i].c))
  	    *p++ = ':';
  	  if (switches[i].noarg_value != 0)
***************
*** 1366,1371 ****
--- 1406,1412 ----
  		      = *(unsigned int *) cs->noarg_value;
  		  break;
  
+ #if !defined(__MSDOS__) || !defined(NO_FLOAT)
  		case floating:
  		  if (optarg == 0 && optind < argc
  		      && (isdigit (argv[optind][0]) || argv[optind][0] == '.'))
***************
*** 1377,1382 ****
--- 1418,1424 ----
  			 : *(double *) cs->noarg_value);
  
  		  break;
+ #endif
  		}
  	    
  	      /* We've found the switch.  Stop looking.  */
***************
*** 1692,1697 ****
--- 1734,1740 ----
  	    }
  	  break;
  
+ #if !defined(__MSDOS__) || !defined(NO_FLOAT)
  	case floating:
  	  if (all)
  	    {
***************
*** 1711,1716 ****
--- 1754,1760 ----
  		}
  	    }
  	  break;
+ #endif
  
  	case string:
  	  if (all)
diff -r -c -P -x*.o -x*.exe -x*~ -x*~[0-9] make-3.74-orig/make.h make-3.74/make.h
*** make-3.74-orig/make.h	Tue Feb  7 18:36:00 1995
--- make-3.74/make.h	Sat Aug 24 17:09:36 1996
***************
*** 333,339 ****
--- 333,341 ----
  extern int posix_pedantic;
  
  extern unsigned int job_slots;
+ #if !defined(__MSDOS__) || !defined(NO_FLOAT)
  extern double max_load_average;
+ #endif
  
  extern char *program;
  extern char *starting_directory;
diff -r -c -P -x*.o -x*.exe -x*~ -x*~[0-9] make-3.74-orig/read.c make-3.74/read.c
*** make-3.74-orig/read.c	Mon Mar 13 05:38:52 1995
--- make-3.74/read.c	Fri Aug 30 20:27:56 1996
***************
*** 712,717 ****
--- 712,735 ----
  
  	  /* Is this a static pattern rule: `target: %targ: %dep; ...'?  */
  	  p = index (p2, ':');
+ #ifdef	__MSDOS__
+ 	  /* On MS-DOS, search for a colon which is neither
+ 	     escaped by a backslash, nor a drive letter followed
+ 	     by a slash (like in "C:\..." or "c:/...").	 */
+ 	  while (p != 0
+ 		 && (p[-1] == '\\' || p[1] == '/' || p[1] == '\\'))
+ 	    {
+ 	      int dos_full_path	= (p[1] == '/' || p[1] == '\\');
+ 	      register char *q = &p[-1];
+ 	      register int backslash = 0;
+ 	      while (*q-- == '\\')
+ 		backslash = !backslash;
+ 	      if (backslash || dos_full_path)
+ 		p = index (p + 1, ':');
+ 	      else
+ 		break;
+ 	    }
+ #else	/* not __MSDOS__ */
  	  while (p != 0 && p[-1] == '\\')
  	    {
  	      register char *q = &p[-1];
***************
*** 723,733 ****
  	      else
  		break;
  	    }
! #ifdef __MSDOS__
! 	  /* For MS-DOS, skip a "C:\...".  */
! 	  if (p != 0 && p[1] == '\\' && isalpha (p[-1]))
! 	    p = 0;
! #endif
  	  if (p != 0)
  	    {
  	      struct nameseq *target;
--- 741,748 ----
  	      else
  		break;
  	    }
! #endif /* not __MSDOS__ */
! 
  	  if (p != 0)
  	    {
  	      struct nameseq *target;
***************
*** 1543,1551 ****
        q = p;
        p = find_char_unquote (q, stopchars, 1);
  #ifdef __MSDOS__
!       /* For MS-DOS, skip a "C:\...".  */
!       if (stopchar == ':' && p != 0 && p[1] == '\\' && isalpha (p[-1]))
! 	p = 0;
  #endif
        if (p == 0)
  	p = q + strlen (q);
--- 1558,1569 ----
        q = p;
        p = find_char_unquote (q, stopchars, 1);
  #ifdef __MSDOS__
!       /* For MS-DOS,a colon in "C:\..." or "c:/..." doesn't count.
! 	 We should search for the first colon which isn't followed by
! 	 a slash or a backslash.  */
!       if (stopchar == ':')
! 	while (p != 0 && (p[1] == '\\' || p[1] == '/'))
! 	  p = find_char_unquote (p + 1, stopchars, 1);
  #endif
        if (p == 0)
  	p = q + strlen (q);
***************
*** 1804,1809 ****
--- 1822,1830 ----
    register char **dirs = (char **) xmalloc ((5 + defsize) * sizeof (char *));
    register unsigned int idx = 0;
  
+ #ifdef  __MSDOS__
+   defsize++;
+ #endif
    /* First consider any dirs specified with -I switches.
       Ignore dirs that don't exist.  */
  
***************
*** 1834,1839 ****
--- 1855,1874 ----
        }
  
    /* Now add at the end the standard default dirs.  */
+ 
+ #ifdef  __MSDOS__
+   {
+     struct variable *djdir = lookup_variable ("DJDIR", 5);
+ 
+     if (djdir)
+       {
+ 	char *defdir = (char *) xmalloc (strlen (djdir->value) + 8 + 1);
+ 
+ 	strcat (strcpy (defdir, djdir->value), "/include");
+ 	dirs[idx++] = defdir;
+       }
+   }
+ #endif
  
    for (i = 0; default_include_directories[i] != 0; ++i)
      if (safe_stat (default_include_directories[i], &stbuf) == 0
diff -r -c -P -x*.o -x*.exe -x*~ -x*~[0-9] make-3.74-orig/remake.c make-3.74/remake.c
*** make-3.74-orig/remake.c	Thu Apr 27 16:36:38 1995
--- make-3.74/remake.c	Fri Aug 30 21:26:30 1996
***************
*** 29,34 ****
--- 29,38 ----
  #include <sys/file.h>
  #endif
  
+ #ifdef  __MSDOS__
+ #include "variable.h"
+ #endif
+ 
  extern int try_implicit_rule ();
  
  
***************
*** 1061,1066 ****
--- 1065,1093 ----
      }
  
    /* Now try the standard set of directories.  */
+ 
+ #ifdef  __MSDOS__
+   {
+     struct variable *djdir = lookup_variable ("DJDIR", 5);
+ 
+     if (djdir)
+       {
+ 	size_t djdir_len = strlen (djdir->value);
+ 
+ 	if (djdir_len > sizeof(LIBDIR) + 8 + strlen(libname) + 4 + 2)
+ 	  buf = (char *) xrealloc (djdir_len + 1);
+ 	sprintf (buf, "%s/lib/lib%s.a", djdir->value, libname);
+ 	mtime = name_mtime (buf);
+ 	if (mtime != (time_t) -1)
+ 	  {
+ 	    *lib = buf;
+ 	    if (mtime_ptr != 0)
+ 	      *mtime_ptr = mtime;
+ 	    return 1;
+ 	  }
+       }
+   }
+ #endif
  
    for (dp = dirs; *dp != 0; ++dp)
      {
diff -r -c -P -x*.o -x*.exe -x*~ -x*~[0-9] make-3.74-orig/signame.c make-3.74/signame.c
*** make-3.74-orig/signame.c	Wed May 10 21:46:48 1995
--- make-3.74/signame.c	Sat Sep  7 19:17:58 1996
***************
*** 227,232 ****
--- 227,235 ----
  #if defined (SIGINFO)
    init_sig (SIGINFO, "INFO", "Information request");
  #endif
+ #if defined (SIGNOFP)
+   init_sig (SIGNOFP, "NOFP", "Floating point co-processor not available");
+ #endif
  }
  
  /* Return the abbreviation for signal NUMBER.  */
diff -r -c -P -x*.o -x*.exe -x*~ -x*~[0-9] make-3.74-orig/variable.c make-3.74/variable.c
*** make-3.74-orig/variable.c	Mon Oct 10 08:08:58 1994
--- make-3.74/variable.c	Sat Sep  7 19:20:22 1996
***************
*** 360,371 ****
--- 360,399 ----
  	   ? "" : remote_description);
    (void) define_variable ("MAKE_VERSION", 12, buf, o_default, 0);
  
+ #ifdef  __MSDOS__
+   /* Allow to specify a special shell just for Make,
+      and use $COMSPEC as the default $SHELL when appropriate.  */
+   {
+     static char shell_str[] = "SHELL";
+     const int shlen = sizeof (shell_str) - 1;
+     struct variable *mshp = lookup_variable ("MAKESHELL", 9);
+     struct variable *comp = lookup_variable ("COMSPEC", 7);
+ 
+     /* Make $MAKESHELL override $SHELL even if -e is in effect.  */
+     if (mshp)
+       (void) define_variable (shell_str, shlen,
+ 			      mshp->value, o_env_override, 0);
+     else if (comp)
+       {
+ 	/* $COMSPEC shouldn't override $SHELL, unless $SHELL is /bin/sh,
+ 	   which is just the default setting on many Makefiles.  */
+ 	struct variable *shp = lookup_variable (shell_str, shlen);
+ 
+ 	if (!shp || (!strcmp (shp->value, "/bin/sh") && shp->origin == o_file))
+ 	  (void) define_variable (shell_str, shlen, comp->value, o_env, 0);
+       }
+   }
+ #endif
    
    /* This won't override any definition, but it
       will provide one if there isn't one there.  */
    v = define_variable ("SHELL", 5, default_shell, o_default, 0);
    v->export = v_export;		/* Always export SHELL.  */
  
+   /* On MSDOS we do use SHELL from environment, since
+      it isn't a standard environment variable on MSDOS,
+      so whoever sets it, does that on purpose.  */
+ #ifndef __MSDOS__
    /* Don't let SHELL come from the environment.  */
    if (*v->value == '\0' || v->origin == o_env || v->origin == o_env_override)
      {
***************
*** 373,378 ****
--- 401,407 ----
        v->origin = o_file;
        v->value = savestring (default_shell, strlen (default_shell));
      }
+ #endif
  
    /* Make sure MAKEFILES gets exported if it is set.  */
    v = define_variable ("MAKEFILES", 9, "", o_default, 0);
***************
*** 678,683 ****
--- 707,725 ----
  	  bcopy (p, &value[oldlen + 1], newlen + 1);
  	}
      }
+ 
+ #ifdef  __MSDOS__
+   /* Don't let "SHELL=/bin/sh" from the Makefile override $SHELL
+      from the environment.  Most Unix Makefiles include such a line,
+      but $SHELL in the environment points to the real pathname.
+      Note that we don't use EXPANDED_NAME: if they use such trickery,
+      they might know what they are doing, so let them have what they want.  */
+   if (origin == o_file
+       && strncmp (name, "SHELL", 6) == 0
+       && strncmp (value, "/bin/sh", 8) == 0)
+     v = lookup_variable (name, 5);
+   else
+ #endif
  
    v = define_variable (expanded_name, strlen (expanded_name),
  		       value, origin, flavor == recursive);


- Raw text -


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