2007-11-23 Juan Manuel Guerrero  <juan.guerrero@gmx.de>

	This is patch 2 of 3 and must be applied as second.


        * Makefile.DOS: Added MAKEINFOFLAGS.
	(.texi.info, .texi, .texi.dvi): Do not split the info docs.
	(.SUFFIX): .html and .pdf added.

	* make.h [HAVE_DOS_PATHS, VMS]: New macro HAVE_DRIVE.  Define macro
	IS_PATHSEP.  All OS specific macros to handle path peculiarities
	are defined here.

	* function.c [HAVE_DOS_PATHS, VMS]: Remove IS_PATHSEP definition.
	(func_notdir_suffix, func_basename_dir, abspath): Use HAVE_DRIVE.
	(abspath) [HAVE_DOS_PATHS]: Include colon as separator char in the
	IS_PATHSEP definition and use it to check for root char.

	* dir.c (file_exists_p) [HAVE_DOS_PATHS]: Use HAVE_DRIVE.
	(file_impossible) [HAVE_DOS_PATHS]: Use HAVE_DRIVE.
	(file_impossible_p) [HAVE_DOS_PATHS]: Use HAVE_DRIVE.

	* implicit.c (pattern_search) [HAVE_DOS_PATHS]: Use HAVE_DRIVE.


2007-11-22  Juan Manuel Guerrero  <juan.guerrero@gmx.de>

	* function.c (abspath): Fix bug in striping trailing pathsepartor code.
	Add logic for the case that backslash are path separators.

	* tests/scripts/functions/abspath: Added new MSDOS specific tests.

	* tests/scripts/variables/SHELL: Do not run this test at all.



diff -aprNU5 make-3.81.orig/Makefile.DOS make-3.81/Makefile.DOS
--- make-3.81.orig/Makefile.DOS	2007-11-19 17:11:42 +0000
+++ make-3.81/Makefile.DOS	2007-11-23 13:32:40 +0000
@@ -65,10 +65,11 @@ AR = ar
 AWK = gawk
 CC = gcc
 CPP = gcc -E
 LIBOBJS =
 MAKEINFO = ${exec_prefix}/bin/makeinfo
+MAKEINFOFLAGS = --no-split
 PACKAGE = make
 PERL = perl
 RANLIB = ranlib
 REMOTE = stub
 VERSION = 3.81
@@ -133,11 +134,11 @@ OBJECTS = $(make_OBJECTS)
 HEADERS = $(wildcard $(srcdir)/*.h)
 
 default: all
 
 .SUFFIXES:
-.SUFFIXES: .c .dvi .info .o .obj .ps .texi .tex
+.SUFFIXES: .c .dvi .html .info .o .obj .pdf .ps .texi .tex
 
 mostlyclean-hdr:
 
 clean-hdr:
 
@@ -184,26 +185,26 @@ make$(EXEEXT): $(make_OBJECTS) $(make_DE
 	@command.com /c if exist make del make
 	@command.com /c if exist make.exe del make.exe
 	$(LINK) $(make_LDFLAGS) $(make_OBJECTS) $(make_LDADD) $(LIBS)
 
 doc/make.info: ${TEXINFOS}
-doc/make.dvi: ${TEXINFOS)
+doc/make.dvi: ${TEXINFOS}
 
 DVIPS = dvips
 
 .texi.info:
 	@command.com /c if exist doc\make.info* del doc\make.info*
 	@command.com /c if exist doc\make.i* del doc\make.i*
-	$(MAKEINFO) -I$(srcdir)/doc $< -o ./$@
+	$(MAKEINFO) $(MAKEINFOFLAGS) -I$(srcdir)/doc $< -o ./$@
 
 .texi:
 	@command.com /c if exist doc\make.info* del doc\make.info*
 	@command.com /c if exist doc\make.i* del doc\make.i*
-	$(MAKEINFO) -I$(srcdir)/doc $< -o ./$@
+	$(MAKEINFO) $(MAKEINFOFLAGS) -I$(srcdir)/doc $< -o ./$@
 
 .texi.dvi:
-	TEXINPUTS="$(srcdir);$$TEXINPUTS"    MAKEINFO='$(MAKEINFO) -I $(srcdir)' $(TEXI2DVI) $<
+	TEXINPUTS="$(srcdir);$$TEXINPUTS"    MAKEINFO='$(MAKEINFO) $(MAKEINFOFLAGS) -I $(srcdir)' $(TEXI2DVI) $<
 
 
 .dvi.ps:
 	$(DVIPS) $< -o $@
 
diff -aprNU5 make-3.81.orig/function.c make-3.81/function.c
--- make-3.81.orig/function.c	2007-11-19 17:11:42 +0000
+++ make-3.81/function.c	2007-11-22 23:41:02 +0000
@@ -1895,11 +1895,12 @@ abspath (const char *name, char *apath)
       strncpy (apath, name, 2);
       dest = apath + 2;
       name += 2;
       if (IS_PATHSEP (*name))
        {
-         *dest++ = *name++;
+         name++;
+         *dest++ = '/';
        }
       *dest = '\0';
     }
   else
 #endif
@@ -1968,11 +1969,11 @@ abspath (const char *name, char *apath)
     }
 
   /* Unless it is root strip trailing separator.  */
   if (dest > apath + 1 && IS_PATHSEP (dest[-1])
 #ifdef HAVE_DOS_PATHS
-      && (dest < apath + 3 || dest[-2] == ':')
+      && (dest > apath + 3 || dest[-3] == ':')
 #endif
       )
     --dest;
 
   *dest = '\0';
diff -aprNU5 make-3.81.orig/tests/scripts/functions/abspath make-3.81/tests/scripts/functions/abspath
--- make-3.81.orig/tests/scripts/functions/abspath	2005-08-29 14:11:00 +0000
+++ make-3.81/tests/scripts/functions/abspath	2007-11-22 23:47:12 +0000
@@ -75,7 +75,115 @@ all: ; @:
 ',
 '',
 '');
 
 
+if ($port_type eq "DOS") {
+
+  #
+  #  Some DOS specific tests.
+  #
+  #  abspath translate backslash to slash.
+  #  Mixed backslash and slash as directory
+  #  separators are allowed.
+  #
+
+$description = "Test the abspath functions with DOS path syntax.";
+
+$details = "";
+
+run_make_test('
+ifneq ($(realpath $(abspath .\)),$(CURDIR))
+  $(warning .\: abs="$(abspath .\)" real="$(realpath $(abspath .\))" curdir="$(CURDIR)")
+endif
+
+ifneq ($(realpath $(abspath .\\\)),$(CURDIR))
+  $(warning .\\\: abs="$(abspath .\\\)" real="$(realpath $(abspath .\\\))" curdir="$(CURDIR)")
+endif
+
+ifneq ($(abspath \),/)
+  $(warning \: abspath="$(abspath \)")
+endif
+
+ifneq ($(abspath \\\\\\),/)
+  $(warning \\\\\\: abspath="$(abspath \\\\\\)")
+endif
+
+ifneq ($(abspath \\.),/)
+  $(warning \\.: abspath="$(abspath \\.)")
+endif
+
+ifneq ($(abspath ///.),/)
+  $(warning ///.: abspath="$(abspath ///.)")
+endif
+
+ifneq ($(abspath \\./),/)
+  $(warning \\./: abspath="$(abspath \\./)")
+endif
+
+ifneq ($(abspath \\.///),/)
+  $(warning \\.///: abspath="$(abspath \\.///)")
+endif
+
+ifneq ($(abspath \\..),/)
+  $(warning \\..: abspath="$(abspath \\..)")
+endif
+
+ifneq ($(abspath //\\..),/)
+  $(warning //\\..: abspath="$(abspath //\\..)")
+endif
+
+ifneq ($(abspath \\../),/)
+  $(warning \\../: abspath="$(abspath \\../)")
+endif
+
+ifneq ($(abspath \\..///),/)
+  $(warning \\..///: abspath="$(abspath \\..///)")
+endif
+
+
+ifneq ($(abspath \\foo\\bar\\..),/foo)
+  $(warning \\foo\\bar\\..: abspath="$(abspath \\foo\\bar\\..)")
+endif
+
+ifneq ($(abspath a:\\foo\\bar\\..),a:/foo)
+  $(warning a:\\foo\\bar\\..: abspath="$(abspath a:\\foo\\bar\\..)")
+endif
+
+ifneq ($(abspath a:foo\\bar\\..),a:foo)
+  $(warning a:foo\\bar\\..: abspath="$(abspath a:foo\\bar\\..)")
+endif
+
+ifneq ($(abspath \\foo\\bar\\..\\..\\..\\baz),/baz)
+  $(warning \\foo\\bar\\..\\..\\..\\baz: abspath="$(abspath \\foo\\bar\\..\\..\\..\\baz)")
+endif
+
+ifneq ($(abspath a:\\foo\\bar\\..\\..\\..\\baz),a:/baz)
+  $(warning a:\\foo\\bar\\..\\..\\..\\baz: abspath="$(abspath a:\\foo\\bar\\..\\..\\..\\baz)")
+endif
+
+ifneq ($(abspath a:foo\\bar\\..\\..\\..\\baz),a:baz)
+  $(warning a:foo\\bar\\..\\..\\..\\baz: abspath="$(abspath a:foo\\bar\\..\\..\\..\\baz)")
+endif
+
+ifneq ($(abspath \\foo\\bar\\..\\ \\..),/foo /)
+  $(warning \\foo\\bar\\..\\ \\..: abspath="$(abspath \\foo\\bar\\..\\ \\..)")
+endif
+
+ifneq ($(abspath a:\\foo\\bar\\..\\ a:\\..),a:/foo a:/)
+  $(warning a:\\foo\\bar\\..\\ a:\\..: abspath="$(abspath a:\\foo\\bar\\..\\ a:\\..)")
+endif
+
+ifneq ($(abspath a:foo\\bar\\..\\ a:..),a:foo a:)
+  $(warning a:foo\\bar\\..\\ a:..: abspath="$(abspath a:foo\\bar\\..\\ a:..)")
+endif
+
+.PHONY: all
+all: ; @:
+',
+'',
+'');
+
+}
+
 # This tells the test driver that the perl test script executed properly.
 1;
diff -aprNU5 make-3.81.orig/tests/scripts/variables/SHELL make-3.81/tests/scripts/variables/SHELL
--- make-3.81.orig/tests/scripts/variables/SHELL	2005-08-25 04:40:10 +0000
+++ make-3.81/tests/scripts/variables/SHELL	2007-11-222 23:56:08 +0000
@@ -1,9 +1,13 @@
 #                                                                    -*-perl-*-
 
 $description = "Test proper handling of SHELL.";
 
+if ($port_type eq "DOS") {
+  return -1;
+}
+
 # Find the default value when SHELL is not set.  On UNIX it will be /bin/sh,
 # but on other platforms who knows?
 resetENV();
 delete $ENV{SHELL};
 $mshell = `echo 'all:;\@echo \$(SHELL)' | $make_path -f-`;
diff -aprNU5 make-3.81.orig/dir.c make-3.81/dir.c
--- make-3.81.orig/dir.c	2006-02-11 22:16:04 +0000
+++ make-3.81/dir.c	2007-11-23 16:31:20 +0000
@@ -764,11 +764,11 @@ file_exists_p (char *name)
   {
     char *bslash = strrchr(name, '\\');
     if (!dirend || bslash > dirend)
       dirend = bslash;
     /* The case of "d:file".  */
-    if (!dirend && name[0] && name[1] == ':')
+    if (!dirend && HAVE_DRIVE (name))
       dirend = name + 1;
   }
 #endif /* HAVE_DOS_PATHS */
   if (dirend == 0)
 #ifndef _AMIGA
@@ -822,11 +822,11 @@ file_impossible (char *filename)
   {
     char *bslash = strrchr(p, '\\');
     if (!dirend || bslash > dirend)
       dirend = bslash;
     /* The case of "d:file".  */
-    if (!dirend && p[0] && p[1] == ':')
+    if (!dirend && HAVE_DRIVE (p))
       dirend = p + 1;
   }
 # endif /* HAVE_DOS_PATHS */
   if (dirend == 0)
 # ifdef _AMIGA
@@ -903,11 +903,11 @@ file_impossible_p (char *filename)
   {
     char *bslash = strrchr(filename, '\\');
     if (!dirend || bslash > dirend)
       dirend = bslash;
     /* The case of "d:file".  */
-    if (!dirend && filename[0] && filename[1] == ':')
+    if (!dirend && HAVE_DRIVE (filename))
       dirend = filename + 1;
   }
 #endif /* HAVE_DOS_PATHS */
   if (dirend == 0)
 #ifdef _AMIGA
diff -aprNU5 make-3.81.orig/function.c make-3.81/function.c
--- make-3.81.orig/function.c	2007-11-22 23:41:02 +0000
+++ make-3.81/function.c	2007-11-23 18:50:24 +0000
@@ -502,20 +502,10 @@ func_flavor (char *o, char **argv, const
       o = variable_buffer_output (o, "simple", 6);
 
   return o;
 }
 
-#ifdef VMS
-# define IS_PATHSEP(c) ((c) == ']')
-#else
-# ifdef HAVE_DOS_PATHS
-#  define IS_PATHSEP(c) ((c) == '/' || (c) == '\\')
-# else
-#  define IS_PATHSEP(c) ((c) == '/')
-# endif
-#endif
-
 
 static char *
 func_notdir_suffix (char *o, char **argv, const char *funcname)
 {
   /* Expand the argument.  */
@@ -546,11 +536,11 @@ func_notdir_suffix (char *o, char **argv
 	    continue;
 	  o = variable_buffer_output (o, p, len - (p - p2));
 	}
 #ifdef HAVE_DOS_PATHS
       /* Handle the case of "d:foo/bar".  */
-      else if (streq (funcname, "notdir") && p2[0] && p2[1] == ':')
+      else if (streq (funcname, "notdir") && HAVE_DRIVE (p2))
 	{
 	  p = p2 + 2;
 	  o = variable_buffer_output (o, p, len - (p - p2));
 	}
 #endif
@@ -599,11 +589,11 @@ func_basename_dir (char *o, char **argv,
 	    o = variable_buffer_output (o, p2, ++p - p2);
 	  else if (p >= p2 && (*p == '.'))
 	    o = variable_buffer_output (o, p2, p - p2);
 #ifdef HAVE_DOS_PATHS
 	/* Handle the "d:foobar" case */
-	  else if (p2[0] && p2[1] == ':' && is_dir)
+	  else if (HAVE_DRIVE (p2) && is_dir)
 	    o = variable_buffer_output (o, p2, 2);
 #endif
 	  else if (is_dir)
 #ifdef VMS
 	    o = variable_buffer_output (o, "[]", 2);
@@ -1879,20 +1869,25 @@ func_not (char *o, char **argv, char *fu
    `..' components nor any repeated path separators ('/').   */
 
 static char *
 abspath (const char *name, char *apath)
 {
+#ifdef HAVE_DOS_PATHS
+# undef  IS_PATHSEP
+# define IS_PATHSEP(c) ((c) == '/' || (c) == '\\' || (c) == ':')
+#endif
+
   char *dest;
   const char *start, *end, *apath_limit;
 
   if (name[0] == '\0' || apath == NULL)
     return NULL;
 
   apath_limit = apath + GET_PATH_MAX;
 
 #ifdef HAVE_DOS_PATHS
-  if (name[1] == ':')  /* DOS-style drive letter? */
+  if (HAVE_DRIVE (name))  /* DOS-style drive letter? */
     {
       strncpy (apath, name, 2);
       dest = apath + 2;
       name += 2;
       if (IS_PATHSEP (*name))
@@ -1939,26 +1934,20 @@ abspath (const char *name, char *apath)
       else if (len == 1 && start[0] == '.')
 	/* nothing */;
       else if (len == 2 && start[0] == '.' && start[1] == '.')
 	{
 	  /* Back up to previous component, ignore if at root already.  */
-#ifdef HAVE_DOS_PATHS
 	  if (dest > apath + 1
-	      && (apath[1] != ':' || dest > apath + 2 + IS_PATHSEP (apath[2])))
-	    while (--dest, (!IS_PATHSEP (dest[-1]) && dest[-1] != ':'));
-#else
-	  if (dest > apath + 1)
-	    while (--dest, (!IS_PATHSEP (dest[-1])));
+#ifdef HAVE_DOS_PATHS
+	      && (apath[1] != ':' || dest > apath + 2 + IS_PATHSEP (apath[2]))
 #endif
+	      )
+	    while (--dest, (!IS_PATHSEP (dest[-1])));
 	}
       else
 	{
-	  if (!IS_PATHSEP (dest[-1])
-#ifdef HAVE_DOS_PATHS
-	      && (dest[-1] != ':')
-#endif
-	     )
+	  if (!IS_PATHSEP (dest[-1]))
             *dest++ = '/';
 
 	  if (dest + len >= apath_limit)
             return NULL;
 
@@ -1977,10 +1966,15 @@ abspath (const char *name, char *apath)
     --dest;
 
   *dest = '\0';
 
   return apath;
+
+#ifdef HAVE_DOS_PATHS
+# undef  IS_PATHSEP
+# define IS_PATHSEP(c) ((c) == '/' || (c) == '\\')
+#endif
 }
 
 
 static char *
 func_realpath (char *o, char **argv, const char *funcname UNUSED)
diff -aprNU5 make-3.81.orig/implicit.c make-3.81/implicit.c
--- make-3.81.orig/implicit.c	2006-04-01 06:36:40 +0000
+++ make-3.81/implicit.c	2007-11-23 16:35:32 +0000
@@ -290,11 +290,11 @@ pattern_search (struct file *file, int a
 	 and the case of "d:file".  */
       {
 	char *bslash = strrchr (filename, '\\');
 	if (lastslash == 0 || bslash > lastslash)
 	  lastslash = bslash;
-	if (lastslash == 0 && filename[0] && filename[1] == ':')
+	if (lastslash == 0 && HAVE_DRIVE (filename))
 	  lastslash = filename + 1;
       }
 #endif
 #endif
       if (lastslash != 0 && lastslash[1] == '\0')
@@ -355,11 +355,11 @@ pattern_search (struct file *file, int a
 #ifdef HAVE_DOS_PATHS
               /* Didn't find it yet: check for DOS-type directories.  */
               if (check_lastslash)
                 {
                   char *b = strchr (target, '\\');
-                  check_lastslash = !(b || (target[0] && target[1] == ':'));
+                  check_lastslash = !(b || HAVE_DRIVE (target));
                 }
 #endif
 #endif
             }
 	  if (check_lastslash)
diff -aprNU5 make-3.81.orig/make.h make-3.81/make.h
--- make-3.81.orig/make.h	2006-02-15 23:54:42 +0000
+++ make-3.81/make.h	2007-11-23 18:44:08 +0000
@@ -347,14 +347,18 @@ extern int strcmpi (const char *,const c
 #define S_(msg1,msg2,num)   ngettext (msg1,msg2,num)
 
 /* Handle other OSs.  */
 #if defined(HAVE_DOS_PATHS)
 # define PATH_SEPARATOR_CHAR ';'
+# define IS_PATHSEP(c)       ((c) == '/' || (c) == '\\')
+# define HAVE_DRIVE(n)       ((n)[0] && (n)[1] == ':')
 #elif defined(VMS)
 # define PATH_SEPARATOR_CHAR ','
+# define IS_PATHSEP(c)       ((c) == ']')
 #else
 # define PATH_SEPARATOR_CHAR ':'
+# define IS_PATHSEP(c)       ((c) == '/')
 #endif
 
 /* This is needed for getcwd() and chdir().  */
 #if defined(_MSC_VER) || defined(__BORLANDC__)
 # include <direct.h>
