2015-07-25  Juan Manuel Guerrero  <juan.guerrero@gmx.de>

	* dfa.c [__GLIBC__, !HAVE_BTOWC]: Provide btowc prototype.


2015-07-18  Juan Manuel Guerrero  <juan.guerrero@gmx.de>

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

	* pc/Makefile: Change dependecy popen.h to pc/popen.h.
	Add popen.o to the list of gawk objects.
	Add definitions for pkgextensiondir, DEFLIBPATH and LOCALEDIR.  For all
	use $(prefix) to define their path.
	Use /dev/env/DJDIR as $(prefix) value.
	Add definition for SHLIBEXT.  Use dxe.
	Do not copy gawk.exe as awk.exe during install.

	* pc/Makefile.tst (manyfiles): Limit the number of simultaneously
	opened files to 250.
	Set DATE to /dev/env/DJDIR/date.
	Remove DJGPP specific warnings about test failure for certain checks.

	* pc/gawkmisc.pc [__DJGPP__, __DJGPP_MINOR__]: Use unsetenv only if
	compiling with DJGPP 2.03 or less.
	[__DJGPP__]: Include io.h for setmode declaration.

	* 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.1.orig/dfa.c gawk-4.1.1/dfa.c
--- gawk-4.1.1.orig/dfa.c	2014-03-30 18:27:30 -0502
+++ gawk-4.1.1/dfa.c	2015-07-25 12:00:50 -0502
@@ -747,10 +747,13 @@ static charclass newline;
    BSD-based systems, many values in the 128..255 range are classified as
    alphabetic, while on glibc-based systems, they are not.  */
 #ifdef __GLIBC__
 # define is_valid_unibyte_character(c) 1
 #else
+#ifndef HAVE_BTOWC
+wint_t btowc (int c);
+#endif
 # define is_valid_unibyte_character(c) (! (MBS_SUPPORT && btowc (c) == WEOF))
 #endif
 
 /* Return non-zero if C is a "word-constituent" byte; zero otherwise.  */
 #define IS_WORD_CONSTITUENT(C) \
diff -aprNU5 gawk-4.1.1.orig/pc/gawkmisc.pc gawk-4.1.1/pc/gawkmisc.pc
--- gawk-4.1.1.orig/pc/gawkmisc.pc	2014-01-20 19:53:00 -0502
+++ gawk-4.1.1/pc/gawkmisc.pc	2015-07-25 12:00:04 -0502
@@ -297,10 +297,11 @@ os_is_setuid()
 }
 
 /* os_setbinmode --- set binary mode on file */
 
 #ifdef __DJGPP__
+#include <io.h>
 #include <sys/exceptn.h>
 #endif
 static int orig_tty_mode = -1;
 
 int
@@ -867,18 +868,20 @@ init_sockets(void)
 
 #endif	/* __DJGPP__ || __MINGW32__ */
 
 #ifdef __DJGPP__
 
+# if __DJGPP__ == 2 && __DJGPP_MINOR__ < 4 
 int
 unsetenv (const char *name)
 {
   if (!name || !*name || strchr (name, '=') != NULL)
     return -1;
 
   return putenv (name);
 }
+#endif
 
 /* This is needed to defeat too-clever GCC warnings in dfa.c about
    comparison being always false due to limited range of data type.  */
 wint_t
 btowc (int c)
diff -aprNU5 gawk-4.1.1.orig/pc/Makefile gawk-4.1.1/pc/Makefile
--- gawk-4.1.1.orig/pc/Makefile	2014-03-31 19:17:46 -0502
+++ gawk-4.1.1/pc/Makefile	2015-07-25 12:00:04 -0502
@@ -79,11 +79,14 @@ MAK = $(MAKE) $(MAKEFILE)
 #prefix =
 prefix = c:/gnu
 pkgdatadir = $(prefix)/lib/awk
 pkgextensiondir = $(prefix)/lib/gawk
 DEFLIBPATH = "\"$(pkgextensiondir)\""
+LOCALEDIR="\"$(prefix)/share/locale\""
 SHLIBEXT = "\"dll\""
+infodir = $(prefix)/info
+mandir = $(prefix)/share/man
 #
 # Define the install method. Method 1 is Unix-like (and requires cat
 # and cp); method 2 uses gawk and batch files.
 install = 1
 #------------------------------------------------------------------------
@@ -98,12 +101,18 @@ DO_BIND= $($(BIND))
 #========================================================================
 #========================== DJGPP =======================================
 #========================================================================
 
 ifneq ($(DJGPP),)
-prefix = $(DJDIR)
+prefix = /dev/env/DJDIR
 pkgdatadir = $(prefix)/share/awk
+pkgextensiondir = $(prefix)/lib/gawk
+DEFLIBPATH = "\"$(pkgextensiondir)\""
+LOCALEDIR="\"$(prefix)/share/locale\""
+SHLIBEXT = "\"dxe\""
+infodir = $(prefix)/share/info
+mandir = $(prefix)/share/man
 endif
 LDJG = $(CC) $(LF) -o gawk.exe $(LDRSP) $(LF2)
 BDJG = stubify -g awk.exe | stubedit awk.exe runfile=gawk
 
 djgpp:
@@ -196,11 +205,11 @@ mingw32-readline-mpfr:
 # Define BIND for BINDless compiles, otherwise $($(BIND)) may break.
 BIND = EMPTY
 PBIND = EMPTY
 EMPTY=
 
-CFLAGS = $(CF) -DGAWK -I. -DHAVE_CONFIG_H -DDEFLIBPATH=$(DEFLIBPATH) -DSHLIBEXT=$(SHLIBEXT)
+CFLAGS = $(CF) -DGAWK -I. -DHAVE_CONFIG_H -DDEFLIBPATH=$(DEFLIBPATH) -DSHLIBEXT=$(SHLIBEXT) -DLOCALEDIR=$(LOCALEDIR)
 
 # object files
 AWKOBJS1  = array$O builtin$O eval$O field$O floatcomp$O gawkmisc$O io$O main$O
 AWKOBJS2  = ext$O msg$O node$O profile$O re$O replace$O version$O symbol$O
 AWKOBJS3  = debug$O cint_array$O int_array$O mpfr$O str_array$O command$O
@@ -242,30 +251,46 @@ $(RSPFILE) : $(GAWKOBJS)
 #    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
 
+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
@@ -286,12 +311,12 @@ install1:
 	-mkdir "$(prefix)"
 	-mkdir "$(prefix)/bin"
 	-mkdir "$(prefix)/share"
 	-mkdir "$(prefix)/share/man"
 	-mkdir "$(pkgdatadir)" "$(prefix)/share/man/man1" "$(prefix)/share/info"
-	cp *awk.exe igawk.bat igawk.cmd pc/awklib/igawk $(prefix)/bin
 	cp gawk.exe $(prefix)/bin/awk.exe
+	cp *awk.exe igawk.bat igawk.cmd pc/awklib/igawk $(prefix)/bin
 	cp awklib/eg/lib/* pc/awklib/igawk.awk $(pkgdatadir)
 	cp doc/*.1 $(prefix)/share/man/man1
 	cp doc/*.info $(prefix)/share/info
 
 # install2 is equivalent to install1, but doesn't require cp, sed, etc.
diff -aprNU5 gawk-4.1.1.orig/pc/Makefile.tst gawk-4.1.1/pc/Makefile.tst
--- gawk-4.1.1.orig/pc/Makefile.tst	2014-03-31 19:17:46 -0502
+++ gawk-4.1.1/pc/Makefile.tst	2015-07-25 12:00:04 -0502
@@ -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
@@ -385,11 +385,11 @@ regtest::
 
 manyfiles::
 	@echo manyfiles
 	@rm -rf junk
 	@mkdir junk
-	@$(AWK) 'BEGIN { for (i = 1; i <= 1030; i++) print i, i}' >_$@
+	@$(AWK) 'BEGIN { for (i = 1; i <= 245; i++) print i, i}' >_$@
 	@$(AWK) -f "$(srcdir)"/manyfiles.awk _$@ _$@
 	@wc -l junk/* | $(AWK) '$$1 != 2' | wc -l | sed "s/  *//g" > _$@
 	@rm -rf junk
 	@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
 
@@ -2162,11 +2162,10 @@ gensub2:
 	@AWKPATH="$(srcdir)" $(AWK) -f $@.awk  >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
 	@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
 
 getlndir:
 	@echo $@
-	@echo Expect getlndir to fail with DJGPP.
 	@AWKPATH="$(srcdir)" $(AWK) -f $@.awk  >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@
 	@-$(CMP) "$(srcdir)"/$@.ok _$@ && rm -f _$@
 
 gnuops2:
 	@echo $@
diff -aprNU5 gawk-4.1.1.orig/README_d/README.pc gawk-4.1.1/README_d/README.pc
--- gawk-4.1.1.orig/README_d/README.pc	2014-04-08 16:11:58 -0502
+++ gawk-4.1.1/README_d/README.pc	2015-07-25 12:00:04 -0502
@@ -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.1.orig/test/beginfile1.ok gawk-4.1.1/test/beginfile1.ok
--- gawk-4.1.1.orig/test/beginfile1.ok	2014-01-20 19:53:00 -0502
+++ gawk-4.1.1/test/beginfile1.ok	2015-07-25 12:00:04 -0502
@@ -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.1.orig/test/getlndir.ok gawk-4.1.1/test/getlndir.ok
--- gawk-4.1.1.orig/test/getlndir.ok	2012-05-03 18:13:56 -0502
+++ gawk-4.1.1/test/getlndir.ok	2015-07-25 12:00:04 -0502
@@ -1 +1 @@
-4, -1, Is a directory
+4, -1, Is a directory (EISDIR)
diff -aprNU5 gawk-4.1.1.orig/test/space.ok gawk-4.1.1/test/space.ok
--- gawk-4.1.1.orig/test/space.ok	2012-05-03 18:13:56 -0502
+++ gawk-4.1.1/test/space.ok	2015-07-25 12:00:04 -0502
@@ -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
