summaryrefslogtreecommitdiff
path: root/pc
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2010-07-16 12:54:45 +0300
committerArnold D. Robbins <arnold@skeeve.com>2010-07-16 12:54:45 +0300
commitf20ab7c3039a4023f41372bfe4bde3b16d481df7 (patch)
tree4425de8c6177df655f165cb61d70d0acb5fdc968 /pc
parent6607eb3d5e40b98d2acc8f6b0d6a0b5a4b0f56bd (diff)
downloadgawk-f20ab7c3039a4023f41372bfe4bde3b16d481df7.tar.gz
Move to gawk-3.0.4.gawk-3.0.4
Diffstat (limited to 'pc')
-rw-r--r--pc/ChangeLog58
-rw-r--r--pc/Makefile46
-rw-r--r--pc/Makefile.tst114
-rw-r--r--pc/config.h23
-rw-r--r--pc/getid.c4
-rw-r--r--pc/include/process.h3
-rw-r--r--pc/popen.c143
-rw-r--r--pc/popen.h30
8 files changed, 360 insertions, 61 deletions
diff --git a/pc/ChangeLog b/pc/ChangeLog
index f1386886..7663bb06 100644
--- a/pc/ChangeLog
+++ b/pc/ChangeLog
@@ -1,3 +1,61 @@
+Wed Jun 30 16:14:36 1999 Arnold D. Robbins <arnold@gnu.org>
+
+ * Release 3.0.4: Release tar file made. This time for sure.
+
+Sun Jun 27 12:27:00 1999 Darrel Hankerson <hankedr@mail.auburn.edu>
+
+ * Makefile, Makefile.tst, ../README_d/README.pc: finalized.
+ * include/process.h: new file
+
+Fri May 21 00:00:00 1999 Darrel Hankerson <hankedr@mail.auburn.edu>
+
+ * popen.c: MSC (on DOS/Win32) and MINGW32 now honor SHELL.
+ * io.c: MINGW32 reports errno==0 after failure in redirect();
+ assume close_one() in this case.
+ * io.c: Add HAVE_POPEN_H and let pc/config.h deal with the mess.
+ (Can't move everything to config.h because of popen define.)
+
+Sun May 9 09:12:33 1999 Darrel Hankerson <hankedr@mail.auburn.edu>
+
+ * Add 1999-04-30 changes from Eli Zaretskii <eliz@is.elta.co.il>
+ 1. Makefile (TAGS, tags): New targets.
+ 2. Makefile.tst (regtes): Pass the value of $CMP to the
+ regtest script.
+
+Thu Nov 18 03:48:32 1998 Scott Deifik <scottd@amgen.com>
+
+ * Readme.pc: More LFN-based comments.
+
+Thu Nov 12 21:01:24 1998 Darrel Hankerson <hankedr@mail.auburn.edu>
+
+ * mingw32 target added with corresponding minor changes to getid.c,
+ io.c, and config.h.
+
+ * vcWin32 needed popen defines in config.h which were inadvertently
+ omitted from 3.0.3.
+
+ * README.pc updated to clarify the procedure for building
+ non-LFN versions on LFN systems, and to note that Win32 gawk
+ may require Win32 utilities.
+
+ * emxbnd target modified to accomodate older versions of emx.
+
+Thu Nov 08 09:11:44 1998 Scott Deifik <scottd@amgen.com>
+
+ * pc/Makefile: Stack reduced again for 16bit MSC versions.
+
+ * pc/Makefile.tst: Updated to keep in sync with new
+ test/Makefile.in. In addition, made to work in Windows 9x
+ with non-LFN tools.
+
+Wed Nov 4 11:32:24 1998 Arnold D. Robbins <arnold@gnu.org>
+
+ * BETA Release 3.0.41: Release tar file made.
+
+Thu Oct 8 19:36:57 1998 Arnold D. Robbins <arnold@gnu.org>
+
+ * BETA Release 3.0.40: Release tar file made.
+
Thu May 15 12:49:08 1997 Arnold D. Robbins <arnold@skeeve.atl.ga.us>
* Release 3.0.3: Release tar file made.
diff --git a/pc/Makefile b/pc/Makefile
index b7fe1e43..8aeede86 100644
--- a/pc/Makefile
+++ b/pc/Makefile
@@ -1,8 +1,9 @@
-# Makefile for gawk (GNU awk) 2 Jan 1997
+# Makefile for gawk (GNU awk) 31 Oct 1998
#
# - for GNU C (djgpp) [32bit executable for DOS]
# - for GNU C (emx) [32bit executable for OS/2 or DOS or Win32]
-# - for MS-Visual C/C++ 4.x [Win32 executable for Windows 95 & NT]
+# - for GNU C (mingw32) [Win32 executable for Windows 9x/NT]
+# - for MS-Visual C/C++ 4.x [Win32 executable for Windows 9x/NT]
# - for Microsoft C 7 [16bit ececutable for DOS]
# - for Microsoft C 6.00A [16bit executable for OS/2 or DOS]
@@ -19,6 +20,7 @@ default:
@echo " emx ..... OS/2 32-bit exe [emx/gcc; uses emxlibc.dll] "
@echo " emxnt ... NT exe [emx/gcc with RSXNT] "
@echo " emxbnd .. OS/2 and DOS 32-bit exe [emx/gcc] "
+ @echo " mingw32 . Win32 exe [Mingw32 GNU C] "
@echo " msc ..... DOS exe [Microsoft C 7 & 8 (AKA 1.52)] "
@echo " msc6 .... DOS exe [Microsoft C 6.00a] "
@echo " msc6os2 . OS/2 exe [Microsoft C 6.00a] "
@@ -86,7 +88,6 @@ DO_BIND= $($(BIND))
# End of general configuration. Some platform-specific configuration
# notes appear below.
-
#========================================================================
#========================== DJGPP =======================================
#========================================================================
@@ -125,8 +126,12 @@ LEMX = $(CC) $(LF) -o $@ $(GAWKOBJS) gawk.def -lbsd $(LF2)
# Link and bind for DOS and OS/2 versions.
# emx-09 needs '-p' emx option here or in EMXOPT environ var.
-LEMXBND = $(CC) $(LF) -o a.out $(LDRSP) gawk.def -lbsd $(LF2)
-BEMX = emxbind -bs -o $@ a.out -p
+# The following works with 0.9a or newer
+LEMXBND = $(CC) $(LF) -o gawk $(LDRSP) gawk.def -lbsd $(LF2)
+BEMX = emxbind -bs gawk -p
+# The following works with 0.9c or newer
+#LEMXBND = $(CC) $(LF) -o a.out $(LDRSP) gawk.def -lbsd $(LF2)
+#BEMX = emxbind -bs -o $@ a.out -p
#BEMX = emxbind -bs /emx/bin/emx.exe a.out $@ -p
BEMXD = emxbind -b -o $@ a.out -p
@@ -153,6 +158,19 @@ emxbnd-debug:
BIND=BEMXD "P=|tr \" \" \"\n\""
#========================================================================
+#========================== MINGW32 =====================================
+#========================================================================
+
+LMINGW32 = $(CC) $(LF) -o $@ $(GAWKOBJS) $(LF2)
+# The following might work around command-line length limitations:
+#LMINGW32 = $(CC) $(LF) -o $@ *.o $(LF2)
+
+mingw32:
+ $(MAK) all \
+ CC=gcc O=.o CF=-O OBJ=popen.o \
+ LNK=LMINGW32 LF=-s RSP=
+
+#========================================================================
#========================== MSC =========================================
#========================================================================
@@ -174,7 +192,7 @@ MSCLIB = llibce
MSCCL = -FPi
#MSCCL = -FPc
-LMSC = link $(LF) $(LNKRSP) $(STDARGV)/NOE,$@,,/NOD:llibce $(MSCLIB)$(LF2)/STACK:0x5420,nul
+LMSC = link $(LF) $(LNKRSP) $(STDARGV)/NOE,$@,,/NOD:llibce $(MSCLIB)$(LF2)/STACK:0x5270,nul
# CLMSC-linking works when building under OS/2
CLMSC = $(CC) -o $@ $(LF) $(GAWKOBJS) $(STDARGV) $(LF2) -link /NOE/NOI/STACK:0x6f00
@@ -235,12 +253,13 @@ Lmsc6bnd = $(LMSC) # for broken makes (nmake) which cannot expand $($X)
Bmsc6bnd = $(BMSC)
-# Windows '95 / NT
+# Windows '9x / NT
LvcWin32 = link -nologo -subsystem:console -release -out:$@ $(LNKRSP)
vcWin32:
$(MAK) all \
"CC=cl -nologo" O=.obj "CF=-o2 -DWIN32 -D__STDC__=0" \
+ OBJ=popen.obj \
LNK=LvcWin32
@@ -338,7 +357,7 @@ install2:
gawk -v prefix=$(prefix) -f install.awk
clean:
- rm -rf gawk gawk.exe *.o *.obj core a.out $(RSPFILE)
+ rm -rf gawk gawk.exe gawk.map *.o *.obj core a.out $(RSPFILE)
# cd doc && $(MAKE) clean
# cd test && $(MAKE) clean
# cd awklib && $(MAKE) clean
@@ -352,7 +371,14 @@ check:
@echo "recommendation is to copy pc/Makefile.tst to test/Makefile. Under"
@echo "DOS, it may be necessary to run make from the test directory."
# The `-k' option to make should be unnecessary if using pc/Makefile.tst.
-# sh -c "cd test && $(MAK) -k AWK=../gawk.exe"
- sh -c "cd test && $(MAK) AWK=../gawk.exe bigtest extra"
+ sh -c "cd test && $(MAK) -k AWK=../gawk.exe"
+# sh -c "cd test && $(MAK) AWK=../gawk.exe bigtest extra"
test: check
+
+# for those who have the necessary tools:
+TAGS:
+ etags awk.h *.y custom.h *.c *.h
+
+tags:
+ ctags awk.h *.y custom.h *.c *.h
diff --git a/pc/Makefile.tst b/pc/Makefile.tst
index f530a300..14166958 100644
--- a/pc/Makefile.tst
+++ b/pc/Makefile.tst
@@ -1,6 +1,6 @@
# Makefile for GNU Awk test suite.
#
-# Copyright (C) 1988-1997 the Free Software Foundation, Inc.
+# Copyright (C) 1988-1999 the Free Software Foundation, Inc.
#
# This file is part of GAWK, the GNU implementation of the
# AWK Programming Language.
@@ -70,7 +70,7 @@
# Using EMXSHELL=/bin/sh with emx versions can exhaust lower mem.
# Lower mem can also be exhausted on some of the tests even with MSC gawk.
# The .SWAP setting forces (DOS-only) dmake to swap itself out.
-.SWAP: childin fflush getlnhd tweakfld pipeio1
+.SWAP: childin fflush getlnhd tweakfld pipeio1 pipeio2
# This won't work unless you have "sh" and set SHELL equal to it (Make 3.74
# or later which comes with DJGPP will work with SHELL=/bin/sh if you have
@@ -83,15 +83,27 @@ AWK = ../gawk.exe
# Set your cmp command here (you can use most versions of diff instead of cmp
# if you don't want to convert the .ok files to the DOS CR/LF format).
+#
+# The following comment is for users of OSs which support long file names
+# (such as Windows 95) for all versions of gawk (both 16 & 32-bit).
+# If you use a shell which doesn't support long filenames, temporary files
+# created by this makefile will be truncated by your shell. "_argarra" is an
+# example of this. If $(CMP) is a DJGPP-compiled program, then it will fail
+# because it looks for the long filename (eg. _argarray). To fix this, you
+# need to set LFN=n in your shell's environment.
+# NOTE: Setting LFN in the makefile most probably won't help you because LFN
+# needs to be an environment variable.
#CMP = cmp
+# See the comment above for why you might want to set CMP to "env LFN=n diff"
+CMP = env LFN=n diff
CMP = diff
#CMP = diff -c
#CMP = gcmp
-# Set your "cp" and "mkdir" commands here. Note: cp must take forward
+# Set your "cp" and "mkdir" commands here. Note: cp must take forward
# slashes. Using "command -c" may work for MS-DOS with Stewartson's shell
# (but not bash) if "command=noexpand switch export" is set in extend.lst.
-# `true &&' is needed to force DJGPP Make to call the shell, or else the
+# `true &&' is needed to force DJGPP Make to call the shell, or else the
# conversion of `command -c' won't work.
CP = cp
#CP = true && command -c copy
@@ -120,21 +132,26 @@ basic: msg swaplns messages argarray longwrds \
sprintfc backgsub tweakfld clsflnam mmap8k fnarray \
dynlj substr eofsplit prt1eval gsubasgn prtoeval gsubtest splitwht \
back89 tradanch nlfldsep splitvar intest nfldstr nors fnarydel \
- noparms funstack clobber delarprm prdupval
+ noparms funstack delarprm prdupval nasty zeroflag \
+ getnr2tm getnr2tb
+
+# clobber removed
unix-tests: poundba fflush getlnhd pipeio1 pipeio2 strftlng pid
gawk.extensions: fieldwdth ignrcase posix manyfiles igncfs argtest \
- badargs strftime gensub gnureops reint nondec
+ badargs strftime gensub gnureops reint
+# add this back for 3.1
+# nondec
extra: regtes inftest
poundba::
# The need for "basename" has been removed for MS-DOS & OS/2 systems which
# lack it.
-# cp $(AWK) /tmp/gawk && $(srcdir)/poundbang $(srcdir)/poundbang >_`basename $@`
+# @cp $(AWK) /tmp/gawk && $(srcdir)/poundbang $(srcdir)/poundbang >_`basename $@`
$(CP) $(AWK) /tmp/gawk.exe && $(srcdir)/poundbang $(srcdir)/poundbang >_$@
-# rm -f /tmp/gawk
+# @rm -f /tmp/gawk
rm -f /tmp/gawk.exe
# $(CMP) $(srcdir)/poundbang.ok _`basename $@` && rm -f _`basename $@`
$(CMP) $(srcdir)/poundbang.ok _$@ && rm -f _$@
@@ -153,8 +170,12 @@ swaplns::
messages::
@echo 'If messages fails, set sh to swap to disk only (in sh.rc).'
@$(AWK) -f $(srcdir)/messages.awk >out2 2>out3
-# { $(CMP) $(srcdir)/out1.ok out1 && $(CMP) $(srcdir)/out2.ok out2 && $(CMP) $(srcdir)/out3.ok out3 && rm -f out1 out2 out3; } || { test -d /dev/fd && echo IT IS OK THAT THIS TEST FAILED; }
- { $(CMP) $(srcdir)/out1.ok out1 && $(CMP) $(srcdir)/out2.ok out2 && $(CMP) $(srcdir)/out3.ok out3; } || { test -d /dev/fd && echo OK TEST FAILED; }
+# { $(CMP) $(srcdir)/out1.ok out1 && $(CMP) $(srcdir)/out2.ok out2 && \
+# $(CMP) $(srcdir)/out3.ok out3 && rm -f out1 out2 out3; } || \
+# { { test -d /dev/fd || test -d /proc/self/fd; } && \
+# echo IT IS OK THAT THIS TEST FAILED; }
+ { $(CMP) $(srcdir)/out1.ok out1 && $(CMP) $(srcdir)/out2.ok out2 && \
+ $(CMP) $(srcdir)/out3.ok out3; } || test -d /dev/fd
rm -f out1 out2 out3
argarray::
@@ -163,6 +184,10 @@ argarray::
*) cp $(srcdir)/argarray.in . ;; \
esac
@TEST=test echo just a test | $(AWK) -f $(srcdir)/argarray.awk ./argarray.in - >_$@
+ @echo 'If argarray fails, set try setting LFN=n in your environment'
+ @echo "before running make. If that still doesn't work, read the"
+ @echo 'the comment in this makefile about setting CMP for information'
+ @echo 'about what may be happenning.'
$(CMP) $(srcdir)/argarray.ok _$@ && rm -f _$@
fstabplus::
@@ -193,7 +218,7 @@ regtes::
@echo 'Some of the output from regtest is very system specific, do not'
@echo 'be distressed if your output differs from that distributed.'
@echo 'Manual inspection is called for.'
- AWK=`pwd`/$(AWK) $(srcdir)/regtest
+ AWK=`pwd`/$(AWK) CMP="$(CMP)" $(srcdir)/regtest
posix::
@echo 'posix test may fail due to 1.500000e+000 not being equal to'
@@ -213,8 +238,8 @@ manyfiles::
@echo 'without quoting the "junk/*" argument.'
# @echo "This number better be 1 ->" | tr -d '\012'
@echo "This number better be 1 ->" | tr -d '\012\015'
-# @wc -l junk/* | $(AWK) '$$1 != 2' | wc -l
- @wc -l "junk/*" | $(AWK) '$$1 != 2' | wc -l
+ @wc -l junk/* | $(AWK) '$$1 != 2' | wc -l
+# @wc -l "junk/*" | $(AWK) '$$1 != 2' | wc -l
# The quotes above are for people with a "wc" that doesn't support sh's "@"
# argument passing.
@rm -rf junk _$@
@@ -322,10 +347,10 @@ nofmtch::
strftime::
: this test could fail on slow machines or on a second boundary,
: so if it does, double check the actual results
-# @LC_ALL=C; export LC_ALL; LANC=C; export LANG; \
+# @LC_ALL=C; export LC_ALL; LANG=C; export LANG; \
# date | $(AWK) '{ $$3 = sprintf("%02d", $$3 + 0) ; \
# This was changed for DOS to avoid the command-line length limit.
- @LC_ALL=C; export LC_ALL; LANC=C; export LANG; $(DATE) > strf
+ @LC_ALL=C; export LC_ALL; LANG=C; export LANG; $(DATE) > strf
@cat strf | $(AWK) '{ $$3 = sprintf("%02d", $$3 + 0) ; \
print > "strftime.ok" ; \
print strftime() > "'_$@'" }'
@@ -414,15 +439,15 @@ sprintfc::
$(CMP) $(srcdir)/sprintfc.ok _$@ && rm -f _$@
getlnhd::
-# We need to set COMSPEC to a UNIX-like shell for the here doc in getlnhd.awk
-# to work.
-# @$(AWK) -f $(srcdir)/getlnhd.awk >_$@
@echo 'Getlnhd is set to ignore errors. However, there should not be any.'
@echo 'If getlnhd fails, set sh to swap to disk only (in sh.rc).'
@echo 'If it still hangs with EMX gawk type ^C, then try the test when'
@echo 'not using DPMI and RSX (in particular, run outside MS-Windows).'
@echo 'If it fails with MSC, run make from the test directory.'
- COMSPEC=$(SHELL) $(AWK) -f $(srcdir)/getlnhd.awk >_$@
+# In 3.0.3, COMSPEC=$(SHELL) was used for MSC and MINGW32 which do
+# not honor SHELL.
+# COMSPEC=$(SHELL) $(AWK) -f $(srcdir)/getlnhd.awk >_$@
+ @$(AWK) -f $(srcdir)/getlnhd.awk >_$@
-$(CMP) $(srcdir)/getlnhd.ok _$@ && rm -f _$@
backgsub::
@@ -509,8 +534,11 @@ pid::
strftlng::
@echo 'Edit test/Makefile if you use MSC6, since strftlng will fail.'
@TZ=UTC; export TZ; $(AWK) -f $(srcdir)/strftlng.awk >_$@
+# @if $(CMP) -s $(srcdir)/strftlng.ok _$@ ; then : ; else \
+# TZ=UTC0; export TZ; $(AWK) -f $(srcdir)/strftlng.awk >_$@ ; \
+# fi
@if $(CMP) -s $(srcdir)/strftlng.ok _$@ ; then : ; else \
- TZ=UTC0; export TZ; $(AWK) -f $(srcdir)/strftlng.awk >_$@ ; \
+ env TZ=UTC0; $(AWK) -f $(srcdir)/strftlng.awk >_$@ ; \
fi
$(CMP) $(srcdir)/strftlng.ok _$@ && rm -f _$@
@@ -547,6 +575,8 @@ pipeio1::
pipeio2::
# This would fail were it not for the "cat" line due to DOS's ECHO command.
@echo 'pipeio may fail due to the way that your tr & echo work in DOS'
+ @echo 'You may also need to set tr=noexpand switch if you use'
+ @echo "Stewartson's sh."
@$(AWK) -v SRCDIR=$(srcdir) -f $(srcdir)/pipeio2.awk >_$@
@cat _$@ | $(AWK) '{ sub("ECHO is.*","",$$0); print $$0 } ' > _$@.2
# $(CMP) $(srcdir)/pipeio2.ok _$@ && rm -f _$@
@@ -554,12 +584,15 @@ pipeio2::
funstack::
@echo 'Expect funstack to fail with MSC DOS versions.'
- -@$(AWK) -f $(srcdir)/funstack.awk $(srcdir)/funstack.in >_$@ && $(CMP) $(srcdir)/funstack.ok _$@ && rm -f _$@
+# @$(AWK) -f $(srcdir)/funstack.awk $(srcdir)/funstack.in >_$@
+ @-$(AWK) -f $(srcdir)/funstack.awk $(srcdir)/funstack.in >_$@
+# $(CMP) $(srcdir)/funstack.ok _$@ && rm -f _$@
+ -$(CMP) $(srcdir)/funstack.ok _$@ && rm -f _$@
clobber::
- @$(AWK) -f $(srcdir)/clobber.awk >_$@
- $(CMP) $(srcdir)/clobber.ok seq && $(CMP) $(srcdir)/clobber.ok _$@ && rm -f _$@
- @rm -f seq
+# @$(AWK) -f $(srcdir)/clobber.awk >_$@
+# $(CMP) $(srcdir)/clobber.ok seq && $(CMP) $(srcdir)/clobber.ok _$@ && rm -f _$@
+# @rm -f seq
delarprm::
@$(AWK) -f $(srcdir)/delarprm.awk >_$@
@@ -570,16 +603,29 @@ prdupval::
$(CMP) $(srcdir)/prdupval.ok _$@ && rm -f _$@
nondec::
-# This was changed for DOS to avoid the command-line length limit.
-# @if grep BITOP ../config.h | grep define > /dev/null; \
-# then \
-# $(AWK) -f $(srcdir)/nondec.awk >_$@; \
-# else \
-# cp $(srcdir)/nondec.ok _$@; \
-# fi
- @echo "Don't worry if nondec fails"
- $(AWK) -f $(srcdir)/nondec.awk >_$@;
- -$(CMP) $(srcdir)/nondec.ok _$@ && rm -f _$@
+ @if grep BITOP ../config.h | grep define > /dev/null; \
+ then \
+ $(AWK) -f $(srcdir)/nondec.awk >_$@; \
+ else \
+ cp $(srcdir)/nondec.ok _$@; \
+ fi
+ $(CMP) $(srcdir)/nondec.ok _$@ && rm -f _$@
+
+nasty::
+ @$(AWK) -f $(srcdir)/nasty.awk >_$@
+ $(CMP) $(srcdir)/nasty.ok _$@ && rm -f _$@
+
+zeroflag::
+ @$(AWK) -f $(srcdir)/zeroflag.awk >_$@
+ $(CMP) $(srcdir)/zeroflag.ok _$@ && rm -f _$@
+
+getnr2tm::
+ @$(AWK) -f $(srcdir)/getnr2tm.awk $(srcdir)/getnr2tm.in >_$@
+ $(CMP) $(srcdir)/getnr2tm.ok _$@ && rm -f _$@
+
+getnr2tb::
+ @$(AWK) -f $(srcdir)/getnr2tb.awk $(srcdir)/getnr2tb.in >_$@
+ $(CMP) $(srcdir)/getnr2tb.ok _$@ && rm -f _$@
clean:
rm -fr _* core junk out1 out2 out3 strftime.ok test1 test2 seq *~
diff --git a/pc/config.h b/pc/config.h
index 7140ac80..fa0abf51 100644
--- a/pc/config.h
+++ b/pc/config.h
@@ -5,7 +5,7 @@
*/
/*
- * Copyright (C) 1995-1997 the Free Software Foundation, Inc.
+ * Copyright (C) 1995-1999 the Free Software Foundation, Inc.
*
* This file is part of GAWK, the GNU implementation of the
* AWK Progamming Language.
@@ -128,8 +128,8 @@
#define REGEX_MALLOC 1 /* use malloc instead of alloca in regex.c */
#define SPRINTF_RET int /* return type of sprintf */
-/* #define BITOPS 1 */ /* bitwise ops (undocumented feature) */
-/* #define NONDECDATA 1 */ /* non-decimal input data (undocumented feature) */
+/* #undef BITOPS */ /* bitwise ops (undocumented feature) */
+/* #undef NONDECDATA */ /* non-decimal input data (undocumented feature) */
/* Define if you have the fmod function. */
#define HAVE_FMOD 1
@@ -206,6 +206,12 @@ void * alloca(unsigned);
#endif
#endif
+# define HAVE_POPEN_H
+
+#if (defined(_MSC_VER) && defined(MSDOS)) || defined(__MINGW32__)
+# define system(s) os_system(s)
+#endif
+
#if defined (_MSC_VER) || defined(__EMX__)
#define strcasecmp stricmp
#define strncasecmp strnicmp
@@ -213,8 +219,19 @@ void * alloca(unsigned);
#if defined(DJGPP)
# define HAVE_LIMITS_H
+# undef HAVE_POPEN_H
#endif
#if defined(__WIN32__) && defined(__CRTRSXNT__)
#include <crtrsxnt.h>
#endif
+
+/* For vcWin32 */
+#if defined(WIN32) && defined(_MSC_VER)
+#define alloca _alloca
+#define system(s) os_system(s)
+#endif
+
+#if defined(__MINGW32__)
+#undef HAVE_SYS_PARAM_H
+#endif
diff --git a/pc/getid.c b/pc/getid.c
index 20cec884..82cfd6cb 100644
--- a/pc/getid.c
+++ b/pc/getid.c
@@ -1,4 +1,4 @@
-#ifdef _MSC_VER
+#if defined(_MSC_VER) || defined(__MINGW32__)
#ifdef OS2
# define INCL_DOSPROCESS
@@ -47,7 +47,7 @@ int getpgrp(void)
return (0);
}
-#if defined(_MSC_VER) || defined(__GO32__)
+#if defined(_MSC_VER) || defined(__GO32__) || defined(__MINGW32__)
int getppid(void)
{
#ifdef OS2
diff --git a/pc/include/process.h b/pc/include/process.h
new file mode 100644
index 00000000..f511d5f7
--- /dev/null
+++ b/pc/include/process.h
@@ -0,0 +1,3 @@
+#undef __STDC__
+#include <process.h>
+#define __STDC__ 1
diff --git a/pc/popen.c b/pc/popen.c
index c2eca24d..88de3e29 100644
--- a/pc/popen.c
+++ b/pc/popen.c
@@ -1,4 +1,4 @@
-#include "popen.h"
+#include <stdio.h>
#include <stdlib.h>
#include <io.h>
#include <string.h>
@@ -11,6 +11,11 @@
#endif
#endif
+#if defined(WIN32) && defined(_MSC_VER)
+#define popen _popen
+#define pclose _pclose
+#endif
+
#ifndef _NFILE
#define _NFILE 40
#endif
@@ -24,6 +29,121 @@ struct {
pipemode pmode;
} pipes[_NFILE];
+
+/*
+ * For systems where system() and popen() do not follow SHELL:
+ * 1. Write command to temp file. Temp filename must have slashes
+ * compatible with SHELL (if set) or COMSPEC.
+ * 2. Convert slashes in SHELL (if present) to be compatible with COMSPEC.
+ * Currently, only MSC (running under DOS) and MINGW versions are managed.
+ */
+
+#if defined(_MSC_VER) || defined(__MINGW32__)
+
+static int
+unixshell(p)
+char *p;
+{
+ static char *shell[] = {"sh", "bash", "csh", "tcsh", "sh32", "sh16", "ksh", NULL};
+ char **shellp = shell, *s, *q;
+
+ if (p == NULL) return (0);
+ s = p = strdup(p);
+ if ((q = strrchr(p, '\\')) != NULL)
+ p = q + 1;
+ if ((q = strrchr(p, '/')) != NULL)
+ p = q + 1;
+ if ((q = strchr(p, '.')) != NULL)
+ *q = '\0';
+ strlwr(p);
+ do {
+ if (strcmp(*shellp, p) == 0) break;
+ } while (*++shellp);
+ free(s);
+ return(*shellp ? 1 : 0);
+}
+
+static char *
+slashify(p, s)
+char *p, *s;
+{
+ if (unixshell(s))
+ while (s = strchr(p, '\\')) *s = '/';
+ else
+ while (s = strchr(p, '/')) *s = '\\';
+ return(p);
+}
+
+static char *
+scriptify(command)
+char *command;
+{
+ FILE *fp;
+ char *cmd, *name, *s, *p;
+ int i;
+
+ if((name = tempnam(".", "pip")) == NULL) return(NULL);
+ p = getenv("COMSPEC"); s = getenv("SHELL");
+ cmd = malloc(strlen(name) + (s ? strlen(s) : 0) + 9); *cmd = '\0';
+ if (s) {
+ slashify(strcpy(cmd, s), p);
+ p = s;
+ }
+ slashify(name, p);
+ if (! unixshell(p)) {
+ realloc(name, strlen(name) + 5);
+ strcat(name, ".bat");
+ }
+ if (s) sprintf(cmd + strlen(cmd), " %cc ", unixshell(s) ? '-' : '/');
+ strcpy(p = cmd + strlen(cmd), name); free(name);
+
+ i = strlen(command);
+ if ( ((fp = fopen(p, "wb")) == NULL) || (fwrite(command, 1, i, fp) < i)
+ || (fputc('\n', fp) == EOF)) {
+ cmd = NULL;
+ }
+ if (fp) fclose(fp);
+ return(cmd);
+}
+
+static void
+unlink_and_free(cmd)
+char *cmd;
+{
+ char *s;
+
+ if (s = strrchr(cmd, ' '))
+ s++;
+ else
+ s = cmd;
+ unlink(s); free(cmd);
+}
+
+int
+os_system(cmd)
+char *cmd;
+{
+ char *s;
+ int i;
+
+#if defined(OS2)
+ if (_osmode == OS2_MODE)
+ return(system(cmd));
+#endif
+
+ if ((cmd = scriptify(cmd)) == NULL) return(1);
+ if (s = getenv("SHELL"))
+ i = spawnlp(P_WAIT, s, s, cmd + strlen(s), NULL);
+ else
+ i = system(cmd);
+ unlink_and_free(cmd);
+ return(i);
+}
+#else
+#define os_system(cmd) system(cmd)
+#endif
+
+
FILE *
os_popen( char *command, char *mode ) {
FILE *current;
@@ -45,6 +165,15 @@ os_popen( char *command, char *mode ) {
curmode = writing;
else
return NULL;
+
+#if defined(__MINGW32__) || (defined(_MSC_VER) && defined(WIN32))
+ current = popen(command = scriptify(command), mode);
+ cur = fileno(current);
+ pipes[cur].pmode = curmode;
+ pipes[cur].command = command;
+ return(current);
+#endif
+
/*
** get a name to use.
*/
@@ -55,11 +184,12 @@ os_popen( char *command, char *mode ) {
** output.
*/
if(curmode == reading) {
+ FILE *fp;
if ((cur = dup(fileno(stdout))) == -1)
return NULL;
if ((current = freopen(name, "w", stdout)) == NULL)
return NULL;
- system(command);
+ os_system(command);
if (dup2(cur, fileno(stdout)) == -1)
return NULL;
close(cur);
@@ -85,6 +215,13 @@ os_pclose( FILE * current) {
return(pclose(current));
#endif
+#if defined(__MINGW32__) || (defined(_MSC_VER) && defined(WIN32))
+ rval = pclose(current);
+ pipes[cur].pmode = unopened;
+ unlink_and_free(pipes[cur].command);
+ return rval;
+#endif
+
/*
** check for an open file.
*/
@@ -106,7 +243,7 @@ os_pclose( FILE * current) {
rval = -1;
if ((fd = dup(fileno(stdin))) != -1) {
if (current = freopen(pipes[cur].name, "r", stdin)) {
- rval = system(pipes[cur].command);
+ rval = os_system(pipes[cur].command);
fclose(current);
if (dup2(fd, fileno(stdin)) == -1) rval = -1;
close(fd);
diff --git a/pc/popen.h b/pc/popen.h
index e8cd1b9b..3735f455 100644
--- a/pc/popen.h
+++ b/pc/popen.h
@@ -1,9 +1,21 @@
-/*
-** popen.h -- prototypes for pipe functions
-*/
-#if !defined(FILE)
-#include <stdio.h>
-#endif
-
-extern FILE *os_popen( char *, char * );
-extern int os_pclose( FILE * );
+/*
+** popen.h -- prototypes for pipe functions
+*/
+
+#if defined (OS2) && !defined(MSDOS) /* OS/2, but not family mode */
+# if defined (_MSC_VER)
+# define popen(c, m) _popen(c, m)
+# define pclose(f) _pclose(f)
+# endif
+#else
+# if !defined (__GO32__)
+# if defined (popen)
+# undef popen
+# undef pclose
+# endif
+# define popen(c, m) os_popen(c, m)
+# define pclose(f) os_pclose(f)
+ extern FILE *os_popen( char *, char * );
+ extern int os_pclose( FILE * );
+# endif
+#endif