This patch contains minor DJGPP specific adjustments.
It must be applied second.



2017-06-28  Juan Manuel Guerrero  <juan.guerrero@gmx.de>

	* pc/config.sed (HAVE_INTMAX_T, HAVE_INTTYPES_H, HAVE_ISASCII, HAVE_LOCALE_H,
	HAVE_MEMMOVE, HAVE_MEMORY_H, HAVE_SETLOCALE, HAVE_SNPRINTF, HAVE_STDBOOL_H,
	HAVE_STDINT_H, HAVE_STDLIB_H, HAVE_STRCASECMP, HAVE_STRCOLL, HAVE_STRINGS_H,
	HAVE_STRTOUL, HAVE_STRUCT_STAT_ST_BLKSIZE, HAVE_SYS_IOCTL_H, HAVE_SYS_PARAM_H
	HAVE_SYS_STAT_H, HAVE_TMPFILE, HAVE__BOOL and PRINTF_HAS_F_FORMAT): Define
	to 1 for DJGPP.
	(uintmax_t, intmax_t, restrict, uint32_t, int32_t, INT32_MAX, INT32_MIN):
	Defines and typdefs removed for DJGPP.

	* README_d/README.pc: Explain that only config.h and Makefile need
	to be copied to srcdir.

	* pc/Makefile: Change dependecy popen.h and socket.h to pc/popen.h and
	pc/socket.h.

	* pc/Makefile.tst (manyfiles): Set DATE to /dev/env/DJDIR/date.
	Remove DJGPP specific warnings about test failure for certain checks.

	* test/beginfile1.ok: Added "(ENOENT)" and "(EISDIR)" to error message.

	* test/getlndir.ok: Added "(EISDIR)" to error message.

	* test/space.ok: Added "(ENOENT)" to error message.






diff -aprNU5 gawk-4.1.4.orig/pc/config.h gawk-4.1.4/pc/config.h
--- gawk-4.1.4.orig/pc/config.h	2016-08-25 05:40:54 +0000
+++ gawk-4.1.4/pc/config.h	2017-06-24 11:32:10 +0000
@@ -75,21 +75,21 @@
 
 /* Define if you have the iconv() function and it works. */
 #undef HAVE_ICONV
 
 /* Define to 1 if the system has the type `intmax_t'. */
-#ifdef __MINGW32__
+#if defined(__MINGW32__) || defined(__DJGPP__)
 #define HAVE_INTMAX_T 1
 #endif
 
 /* Define to 1 if you have the <inttypes.h> header file. */
-#ifdef __MINGW32__
+#if defined(__MINGW32__) || defined(__DJGPP__)
 #define HAVE_INTTYPES_H 1
 #endif
 
 /* Define to 1 if you have the `isascii' function. */
-#ifdef __MINGW32__
+#if defined(__MINGW32__) || defined(__DJGPP__)
 #define HAVE_ISASCII 1
 #endif
 
 /* Define to 1 if you have the `iswctype' function. */
 #ifdef __MINGW32__
@@ -123,11 +123,11 @@
 
 /* Define to 1 if you have the <limits.h> header file. */
 #define HAVE_LIMITS_H 1
 
 /* Define to 1 if you have the <locale.h> header file. */
-#ifdef __MINGW32__
+#if defined(__MINGW32__) || defined(__DJGPP__)
 #define HAVE_LOCALE_H 1
 #endif
 
 /* Define to 1 if the system has the type 'long long int'. */
 #undef HAVE_LONG_LONG_INT
@@ -153,16 +153,18 @@
 
 /* Define to 1 if you have the `memcpy_ulong' function. */
 #undef HAVE_MEMCPY_ULONG
 
 /* Define to 1 if you have the `memmove' function. */
-#ifdef __MINGW32__
+#if defined(__MINGW32__) || defined(__DJGPP__)
 #define HAVE_MEMMOVE 1
 #endif
 
 /* Define to 1 if you have the <memory.h> header file. */
-#undef HAVE_MEMORY_H
+#ifdef __DJGPP__
+#define HAVE_MEMORY_H 1
+#endif
 
 /* Define to 1 if you have the `memset' function. */
 #define HAVE_MEMSET 1
 
 /* Define to 1 if you have the `memset_ulong' function. */
@@ -192,19 +194,19 @@
 #if defined(__MINGW32__) || defined(__DJGPP__)
 #define HAVE_SETENV 1
 #endif
 
 /* Define to 1 if you have the `setlocale' function. */
-#ifdef __MINGW32__
+#if defined(__MINGW32__) || defined(__DJGPP__)
 #define HAVE_SETLOCALE 1
 #endif
 
 /* Define to 1 if you have the `setsid' function. */
 #undef HAVE_SETSID
 
 /* Define to 1 if you have the `snprintf' function. */
-#ifdef __MINGW32__
+#if defined(__MINGW32__) || defined(__DJGPP__)
 #define HAVE_SNPRINTF 1
 #endif
 
 /* newer systems define this type here */
 #ifdef __MINGW32__
@@ -218,35 +220,41 @@
 
 /* Define to 1 if you have the <stdarg.h> header file. */
 #define HAVE_STDARG_H 1
 
 /* Define to 1 if stdbool.h conforms to C99. */
-#undef HAVE_STDBOOL_H
+#ifdef __DJGPP__
+#define HAVE_STDBOOL_H 1
+#endif
 
 /* Define to 1 if you have the <stddef.h> header file. */
 #ifdef __GNUC__
 #define HAVE_STDDEF_H 1
 #endif
 
 /* Define to 1 if you have the <stdint.h> header file. */
-#ifdef __MINGW32__
+#if defined(__MINGW32__) || defined(__DJGPP__)
 #define HAVE_STDINT_H 1
 #endif
 
 /* Define to 1 if you have the <stdlib.h> header file. */
-#ifdef __MINGW32__
+#if defined(__MINGW32__) || defined(__DJGPP__)
 #define HAVE_STDLIB_H 1
 #endif
 
 /* Define to 1 if you have the `strcasecmp' function. */
-#undef HAVE_STRCASECMP
+#ifdef __DJGPP__
+#define HAVE_STRCASECMP 1
+#endif
 
 /* Define to 1 if you have the `strchr' function. */
 #define HAVE_STRCHR 1
 
 /* Define to 1 if you have the `strcoll' function. */
-#undef HAVE_STRCOLL
+#ifdef __DJGPP__
+#define HAVE_STRCOLL 1
+#endif
 
 /* Define to 1 if you have the `strerror' function. */
 #define HAVE_STRERROR 1
 
 /* Define to 1 if you have the `strftime' function. */
@@ -259,11 +267,13 @@
 
 /* Define to 1 if cpp supports the ANSI # stringizing operator. */
 #define HAVE_STRINGIZE 1
 
 /* Define to 1 if you have the <strings.h> header file. */
-#undef HAVE_STRINGS_H
+#ifdef __DJGPP__
+#define HAVE_STRINGS_H 1
+#endif
 
 /* Define to 1 if you have the <string.h> header file. */
 #define HAVE_STRING_H 1
 
 /* Define to 1 if you have the `strncasecmp' function. */
@@ -277,45 +287,49 @@
 
 /* Define to 1 if you have the `strtod' function. */
 #define HAVE_STRTOD 1
 
 /* Define to 1 if you have the `strtoul' function. */
-#ifdef __MINGW32__
+#if defined(__MINGW32__) || defined(__DJGPP__)
 #define HAVE_STRTOUL 1
 #endif
 
 /* Define to 1 if `gr_passwd' is a member of `struct group'. */
 #undef HAVE_STRUCT_GROUP_GR_PASSWD
 
 /* Define to 1 if `pw_passwd' is a member of `struct passwd'. */
 #undef HAVE_STRUCT_PASSWD_PW_PASSWD
 
 /* Define to 1 if `st_blksize' is a member of `struct stat'. */
-#undef HAVE_STRUCT_STAT_ST_BLKSIZE
+#if defined(__MINGW32__) || defined(__DJGPP__)
+#define HAVE_STRUCT_STAT_ST_BLKSIZE 1
+#endif
 
 /* Define to 1 if `tm_zone' is a member of `struct tm'. */
 #undef HAVE_STRUCT_TM_TM_ZONE
 
 /* Define to 1 if you have the `system' function. */
 #define HAVE_SYSTEM 1
 
 /* Define to 1 if you have the <sys/ioctl.h> header file. */
-#undef HAVE_SYS_IOCTL_H
+#if defined(__MINGW32__) || defined(__DJGPP__)
+#define HAVE_SYS_IOCTL_H 1
+#endif
 
 /* Define to 1 if you have the <sys/param.h> header file. */
-#ifndef __MINGW32__
+#if defined(__MINGW32__) || defined(__DJGPP__)
 #define HAVE_SYS_PARAM_H 1
 #endif
 
 /* Define to 1 if you have the <sys/select.h> header file. */
 #undef HAVE_SYS_SELECT_H
 
 /* Define to 1 if you have the <sys/socket.h> header file. */
 #undef HAVE_SYS_SOCKET_H
 
 /* Define to 1 if you have the <sys/stat.h> header file. */
-#ifdef __MINGW32__
+#if defined(__MINGW32__) || defined(__DJGPP__)
 #define HAVE_SYS_STAT_H 1
 #endif
 
 /* Define to 1 if you have the <sys/time.h> header file. */
 #if defined(__DJGPP__) || defined(__MINGW32__)
@@ -332,11 +346,13 @@
 
 /* Define to 1 if you have the <termios.h> header file. */
 #undef HAVE_TERMIOS_H
 
 /* Define to 1 if you have the `tmpfile' function. */
-#undef HAVE_TMPFILE
+#ifdef __DJGPP__
+#define HAVE_TMPFILE 1
+#endif
 
 /* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use
    `HAVE_STRUCT_TM_TM_ZONE' instead. */
 #undef HAVE_TM_ZONE
 
@@ -358,13 +374,10 @@
 #define HAVE_TZSET 1
 
 /* Define to 1 if the system has the type `uintmax_t'. */
 #if defined(__DJGPP__) || defined(__MINGW32__)
 #define HAVE_UINTMAX_T 1
-#ifdef __DJGPP__
-#define uintmax_t unsigned long long
-#endif
 #endif
 
 /* Define to 1 if you have the <unistd.h> header file. */
 #if defined(__DJGPP__) || defined(__MINGW32__)
 #define HAVE_UNISTD_H 1
@@ -412,11 +425,13 @@
 #ifdef __MINGW32__
 #define HAVE_WINT_T 1
 #endif
 
 /* Define to 1 if the system has the type `_Bool'. */
-#undef HAVE__BOOL
+#ifdef __DJGPP__
+#define HAVE__BOOL 1
+#endif
 
 /* Define to 1 if you have the `__etoa_l' function. */
 #undef HAVE___ETOA_L
 
 /* enable severe portability problems */
@@ -448,11 +463,13 @@
 
 /* Define to the version of this package. */
 #define PACKAGE_VERSION "4.1.4"
 
 /* Define to 1 if *printf supports %F format */
-#undef PRINTF_HAS_F_FORMAT
+#ifdef __DJGPP__
+#define PRINTF_HAS_F_FORMAT 1
+#endif
 
 /* Define as the return type of signal handlers (`int' or `void'). */
 #define RETSIGTYPE void
 
 #if defined(__DJGPP__) || defined(__MINGW32__)
@@ -567,23 +584,19 @@
 #endif
 #endif
 
 /* Define to the widest signed integer type if <stdint.h> and <inttypes.h> do
    not define. */
-#ifdef __DJGPP__
-#define intmax_t long long
-#endif
+#undef intmax_t
 
 /* Define to `int' if <sys/types.h> does not define. */
 #undef pid_t
 
 /* Define to the equivalent of the C99 'restrict' keyword, or to
    nothing if this is not supported.  Do not define if restrict is
    supported directly.  */
-#ifdef __DJGPP__
-#define restrict
-#endif
+#undef restrict
 /* Work around a bug in Sun C++: it does not support _Restrict or
    __restrict__, even though the corresponding Sun C compiler ends up with
    "#define restrict _Restrict" or "#define restrict __restrict__" in the
    previous line.  Perhaps some future version of Sun C++ will work with
    restrict; if so, hopefully it defines __RESTRICT like Sun C does.  */
@@ -604,32 +617,28 @@
 /* Define to `int' if <sys/types.h> doesn't define. */
 #undef uid_t
 
 /* Define to the widest unsigned integer type if <stdint.h> and <inttypes.h>
    do not define. */
-#ifdef __DJGPP__
-#define uintmax_t unsigned long long
-#endif
+#undef uintmax_t
 
 #include "custom.h"
+#ifdef __DJGPP__
+/* gcc no longer includes this by default */
+# include <sys/version.h>
+
 /* Library search path */
-#if defined(__DJGPP__) && (__DJGPP__ > 2 || __DJGPP_MINOR__ >= 3)
-# define DEFPATH  ".;/dev/env/DJDIR/share/awk"
-#else
-# define DEFPATH  ".;c:/lib/awk;c:/gnu/lib/awk"
+# if (__DJGPP__ > 2 || __DJGPP_MINOR__ >= 3)
+#  define DEFPATH  ".;/dev/env/DJDIR/share/awk"
+# else
+#  define DEFPATH  ".;c:/lib/awk;c:/gnu/lib/awk"
+# endif
 #endif
 
 #ifndef __DJGPP__
 #define HAVE_POPEN_H 1
 #endif
 
-#if defined(__DJGPP__)
-typedef unsigned int uint32_t;
-typedef int int32_t;
-#define INT32_MAX INT_MAX
-#define INT32_MIN INT_MIN
-#endif
-
 #if defined(__EMX__)
 #define strcasecmp stricmp
 #define strncasecmp strnicmp
 #endif
diff -aprNU5 gawk-4.1.4.orig/pc/Makefile gawk-4.1.4/pc/Makefile
--- gawk-4.1.4.orig/pc/Makefile	2017-06-24 11:16:50 +0000
+++ gawk-4.1.4/pc/Makefile	2017-06-25 02:11:34 +0000
@@ -237,44 +237,60 @@ all : gawk.exe
 gawk.exe:: $(GAWKOBJS) $(RSP)
 	$(DO_LNK)
 	$(DO_BIND)
 
 $(RSPFILE) : $(GAWKOBJS)
-	echo $(AWKOBJS1)$P > $@
-	echo $(AWKOBJS2)$P >> $@
-	echo $(AWKOBJS3)$P >> $@
-	echo $(AWKOBJS4)$P >> $@
-	echo awkgram$O getid$O $(OBJ) $(LIBOBJS)$P >> $@
+	echo $(AWKOBJS1) > $@
+	echo $(AWKOBJS2) >> $@
+	echo $(AWKOBJS3) >> $@
+	echo $(AWKOBJS4) >> $@
+	echo awkgram$O getid$O $(OBJ) $(LIBOBJS) >> $@
 
 # Notes to dependencies:
 # 1. The dependency on getopt.h is because unistd.h includes it,
 #    and we have -I. on the compiler command line.  unistd.h is
 #    included by awk.h.
 # 2. custom.h is not mentioned because pc ports don't use it.
 $(ALLOBJS) $(LIBOBJS): \
   awk.h regex.h config.h gettext.h mbsupport.h protos.h dfa.h getopt.h nonposix.h
 
+ifneq ($(DJGPP),)
+builtin$O:	floatmagic.h random.h pc/popen.h
+
+io$O:		pc/popen.h pc/socket.h pc/in.h
+
+gawkmisc$O:	pc/gawkmisc.pc pc/socket.h
+else
 builtin$O:	floatmagic.h random.h popen.h
 
+io$O:		popen.h socket.h in.h
+
+gawkmisc$O:	pc/gawkmisc.pc socket.h
+endif
+
 random$O:	random.h
 
 node$O:		floatmagic.h
 
 command$O debug$O:	cmd.h
 
 dfa$O:		xalloc.h
 
-gawkmisc$O:	pc/gawkmisc.pc socket.h
-
 getopt$O getopt1$O :	getopt_int.h
 
-io$O:		popen.h socket.h in.h
-
 regex$O:	regcomp.c regexec.c regex_internal.h
 
 eval$O:		interpret.h
 
+ifneq ($(DJGPP),)
+getid$O:	pc/getid.c
+	$(CC) -c $(CFLAGS) pc/getid.c
+
+popen$O:	pc/popen.c
+	$(CC) -c $(CFLAGS) pc/popen.c
+endif
+
 # A bug in ndmake requires the following rule
 awkgram$O: awk.h awkgram.c
 	$(CC) -c $(CFLAGS) awkgram.c
 
 awkgram.c:	awkgram.y
@@ -400,5 +416,19 @@ SEDME2 = sed "/%%Page: 10 10/,/0 Cg EP/d
 	cd doc
 	ps2pdf ./awkcard.ps ./awkcard.pdf
 	cd ..
 
 doc: $(INFOS) $(DVIS) $(HTMLS) $(PSS) $(PDFS) ./doc/awkcard.ps ./doc/awkcard.pdf
+	-mkdir "$(prefix)"
+	-mkdir "$(prefix)/gnudocs"
+	-mkdir "$(prefix)/gnudocs/gawk-4.1-4"
+	cp doc/gawk.dvi $(prefix)/gnudocs/gawk-4.1-4
+	cp doc/gawk.html $(prefix)/gnudocs/gawk-4.1-4
+	cp doc/gawk.pdf $(prefix)/gnudocs/gawk-4.1-4
+	cp doc/gawk.ps $(prefix)/gnudocs/gawk-4.1-4
+	cp doc/gawkinet.dvi $(prefix)/gnudocs/gawk-4.1-4
+	cp doc/gawkinet.html $(prefix)/gnudocs/gawk-4.1-4
+	cp doc/gawkinet.pdf $(prefix)/gnudocs/gawk-4.1-4
+	cp doc/gawkinet.ps $(prefix)/gnudocs/gawk-4.1-4
+	cp doc/awkcard.pdf $(prefix)/gnudocs/gawk-4.1-4
+	cp doc/awkcard.ps $(prefix)/gnudocs/gawk-4.1-4
+
diff -aprNU5 gawk-4.1.4.orig/pc/Makefile.tst gawk-4.1.4/pc/Makefile.tst
--- gawk-4.1.4.orig/pc/Makefile.tst	2016-08-14 18:12:40 +0000
+++ gawk-4.1.4/pc/Makefile.tst	2017-06-24 11:20:20 +0000
@@ -95,11 +95,11 @@ PGAWK = ../gawk.exe -p
 CMP = diff -u
 #CMP = gcmp
 
 # cmp replacement program for PC where the error messages aren't
 # exactly the same.  Should run even on old awk.
-TESTOUTCMP = $(AWK) -f ../testoutcmp.awk
+TESTOUTCMP = $(AWK) -f ../pc/testoutcmp.awk
 
 # Set your "cp," "mv," and "mkdir" commands here.  Note: DOS's copy must take
 # forward slashes.
 CP = cp
 #CP = : && command -c copy
@@ -113,11 +113,11 @@ MV = cmd.exe /c ren
 #MKDIR = : && command -c mkdir
 MKDIR  = command.com /c mkdir
 
 # Set your unix-style date function here
 #DATE = date
-DATE = gdate
+DATE = /dev/env/DJDIR/bin/date
 
 # MS-DOS and OS/2 use ; as a PATH delimiter
 PATH_SEPARATOR = ;
 
 # Non-default GREP_OPTIONS might fail the badargs test
diff -aprNU5 gawk-4.1.4.orig/README_d/README.pc gawk-4.1.4/README_d/README.pc
--- gawk-4.1.4.orig/README_d/README.pc	2015-04-05 08:13:46 +0000
+++ gawk-4.1.4/README_d/README.pc	2017-06-24 11:20:20 +0000
@@ -23,11 +23,11 @@ The `configure' step takes a long time,
 ************************************************************************
 
 Building gawk
 -------------
 
-Copy the files in the `pc' directory (EXCEPT for `ChangeLog') to the
+Copy the files config.h and Makefile in the `pc' directory to the
 directory with the rest of the gawk sources.  (The subdirectories of 
 `pc' need not be copied.)  The Makefile contains a configuration 
 section with comments, and may need to be edited in order to work
 with your make utility.  If you are building with MinGW, copy the
 file Makefile.ext to extension/Makefile.
diff -aprNU5 gawk-4.1.4.orig/test/beginfile1.ok gawk-4.1.4/test/beginfile1.ok
--- gawk-4.1.4.orig/test/beginfile1.ok	2014-01-20 19:52:56 +0000
+++ gawk-4.1.4/test/beginfile1.ok	2017-06-24 11:20:20 +0000
@@ -2,13 +2,13 @@ In BEGINFILE:
 	FILENAME = beginfile1.awk, FNR = 0, ERRNO = ""
 processing beginfile1.awk
 In ENDFILE:
 	FILENAME = beginfile1.awk, FNR = 2, ERRNO = ""
 In BEGINFILE:
-	FILENAME = ., FNR = 0, ERRNO = "Is a directory"
+	FILENAME = ., FNR = 0, ERRNO = "Is a directory (EISDIR)"
 In BEGINFILE:
-	FILENAME = file, FNR = 0, ERRNO = "No such file or directory"
+	FILENAME = file, FNR = 0, ERRNO = "No such file or directory (ENOENT)"
 In BEGINFILE:
-	FILENAME = Makefile, FNR = 0, ERRNO = ""
+	FILENAME = Makefile, FNR = 0, ERRNO = "No such file or directory (ENOENT)"
 processing Makefile
 In ENDFILE:
 	FILENAME = Makefile, FNR = 2, ERRNO = ""
diff -aprNU5 gawk-4.1.4.orig/test/getlndir.ok gawk-4.1.4/test/getlndir.ok
--- gawk-4.1.4.orig/test/getlndir.ok	2012-05-03 18:13:52 +0000
+++ gawk-4.1.4/test/getlndir.ok	2017-06-24 11:20:20 +0000
@@ -1 +1 @@
-4, -1, Is a directory
+4, -1, Is a directory (EISDIR)
diff -aprNU5 gawk-4.1.4.orig/test/space.ok gawk-4.1.4/test/space.ok
--- gawk-4.1.4.orig/test/space.ok	2012-05-03 18:13:52 +0000
+++ gawk-4.1.4/test/space.ok	2017-06-24 11:20:20 +0000
@@ -1,2 +1,2 @@
-gawk: fatal: can't open source file ` ' for reading (No such file or directory)
+gawk: fatal: can't open source file ` ' for reading (No such file or directory (ENOENT))
 EXIT CODE: 2
