aboutsummaryrefslogtreecommitdiffstats
path: root/pc
diff options
context:
space:
mode:
Diffstat (limited to 'pc')
-rw-r--r--pc/ChangeLog55
-rw-r--r--pc/Makefile37
-rw-r--r--pc/Makefile.tst99
-rw-r--r--pc/awklib/igawk.awk8
-rw-r--r--pc/config.h2
-rw-r--r--pc/gawkmisc.pc235
-rw-r--r--pc/install.awk1
7 files changed, 381 insertions, 56 deletions
diff --git a/pc/ChangeLog b/pc/ChangeLog
index c572b1bb..37a02436 100644
--- a/pc/ChangeLog
+++ b/pc/ChangeLog
@@ -1,3 +1,58 @@
+Wed May 1 16:41:32 2002 Arnold D. Robbins <arnold@skeeve.com>
+
+ * Release 3.1.1: Release tar file made.
+
+Thu Apr 18 17:29:16 2002 Scott Deifik <scottd@amgen.com>
+
+ * Makefile.tst (strftime): Remove comment on call to $(CMP).
+
+Sun Mar 10 17:05:35 2002 Scott Deifik <scottd@amgen.com>
+
+ * Makefile.tst: More clean up and sync with ../test/Makefile.
+
+Thu Jan 3 15:20:17 2002 Scott Deifik <scottd@amgen.com>
+
+ * Makefile.tst: Minor clean up and sync with ../test/Makefile.
+
+Wed Dec 19 16:01:58 2001 Peter J. Farley III <pjfarley@dorsai.org>
+
+ * gawkmisc.pc: Just use single quote for `quote' for all cases.
+
+Wed Dec 19 15:59:52 2001 Eli Zaretskii <eliz@is.elta.co.il>
+
+ * install.awk: Install gawkinet.info as well.
+ * awklib/igawk.awk: Bring in sync with awklib/eg/prog/igawk.sh.
+ * makefile (PRSPFILE, PRSP, PLDRSP, DO_PLNK, DO_PBIND, PLDJG): New
+ variables.
+ (djgpp, djgpp-debug): Set PLNK and PBIND.
+ (PBIND): Define to EMPTY as default.
+ (PAWKOBJS1, PAWKOBJS2, PGAWKOBJS): New variables.
+ (all): Add pgawk.exe.
+ (pgawk.exe, $(PRSPFILE)): New rules.
+ ($(ALLOBJS)): Add eval_p.o and profile_p.o to the list of files
+ that are dependent on awk.h, dfa.h, regex.h, and config.h.
+ (eval_p$O, profile_p$O): New dependencies.
+ (clean): Add pgawk and $(PRSPFILE) to files that are to be cleaned
+ up.
+
+Tue Dec 4 16:44:07 2001 Andreas Buening <andreas.buening@nexgo.de>
+
+ Updated OS/2 support.
+
+ * gawkmisc.pc (quote): Use single quote for __EMX__.
+ (os_arg_fixup): new OS/2 code.
+ (os_devopen): for OS/2 return -1.
+ (ispath): check for leading drive letter for __EMX__.
+ (os_close_on_exec): Add check for defined __EMX__.
+ (os_is_setuid): Add real code for __EMX__.
+ (_os2_is_abs_path): new function.
+ (_os2_unixroot): new function.
+ (_os2_unixroot_path): new function.
+
+Tue Sep 25 15:19:53 2001 Arnold D. Robbins <arnold@skeeve.com>
+
+ * gawkmisc.pc (os_close_on_exec): If fd <= 2, return.
+
Sun Jun 3 13:04:44 2001 Arnold D. Robbins <arnold@skeeve.com>
* Release 3.1.0: Release tar file made. And there was
diff --git a/pc/Makefile b/pc/Makefile
index 9dd8f350..57b1e0fa 100644
--- a/pc/Makefile
+++ b/pc/Makefile
@@ -37,6 +37,7 @@ default:
#======================= Configuration ==================================
RSPFILE = gawk.rsp
+PRSPFILE = pgawk.rsp
#
# Choose method for passing arguments to the linker.
#
@@ -54,7 +55,9 @@ RSPFILE = gawk.rsp
#
# else use brain-dead approach (emxbnd will need 'tr').
RSP = $(RSPFILE)
+PRSP = $(PRSPFILE)
LDRSP = @$(RSP)
+PLDRSP = @$(PRSP)
LNKRSP = $(LDRSP)
#------------------------------------------------------------------------
# Some makes do not define MAKE (and ndmake does not allow a define).
@@ -84,6 +87,8 @@ install = 1
# and then comment the following:
DO_LNK = $($(LNK))
DO_BIND= $($(BIND))
+DO_PLNK = $($(PLNK))
+DO_PBIND= $($(PBIND))
#========================================================================
# End of general configuration. Some platform-specific configuration
# notes appear below.
@@ -93,19 +98,20 @@ DO_BIND= $($(BIND))
#========================================================================
LDJG = $(CC) $(LF) -o gawk.exe $(LDRSP) $(LF2)
+PLDJG = $(CC) $(LF) -o pgawk.exe $(PLDRSP) $(LF2)
BDJG = stubify -g awk.exe | stubedit awk.exe runfile=gawk
djgpp:
$(MAK) all \
CC=gcc O=.o CF=-O2 \
- LNK=LDJG LF=-s LF2=-lm \
- BIND=BDJG
+ LNK=LDJG PLNK=PLDJG LF=-s LF2=-lm \
+ BIND=BDJG PBIND=''
djgpp-debug:
$(MAK) all \
CC=gcc O=.o CF='-O2 -g' \
- LNK=LDJG LF2=-lm \
- BIND=BDJG
+ LNK=LDJG PLNK=PLDJG LF2=-lm \
+ BIND=BDJG PBIND=''
LDJGv1 = $(CC) $(LF) -o gawk $(LDRSP) $(LF2)
#BDJGv1 = coff2exe -s /djgpp/bin/go32.exe gawk
@@ -281,6 +287,7 @@ vcWin32:
# Define BIND for BINDless compiles, otherwise $($(BIND)) may break.
BIND = EMPTY
+PBIND = EMPTY
EMPTY=
# bitwise operations (-DBITOPS) and non-decimal input data (-DNONDECDATA) are
@@ -290,6 +297,8 @@ CFLAGS = $(CF) -DGAWK -I. -DHAVE_CONFIG_H
# object files
AWKOBJS1 = array$O builtin$O eval$O field$O gawkmisc$O io$O main$O
AWKOBJS2 = ext$O msg$O node$O profile$O re$O version$O
+PAWKOBJS1 = array$O builtin$O eval_p$O field$O gawkmisc$O io$O main$O
+PAWKOBJS2 = ext$O msg$O node$O profile_p$O re$O version$O
AWKOBJS = $(AWKOBJS1) $(AWKOBJS2)
ALLOBJS = $(AWKOBJS) awkgram$O getid$O $(OBJ)
@@ -299,6 +308,7 @@ ALLOBJS = $(AWKOBJS) awkgram$O getid$O $(OBJ)
LIBOBJS= getopt$O getopt1$O regex$O dfa$O random$O
GAWKOBJS = $(ALLOBJS) $(LIBOBJS)
+PGAWKOBJS = $(PAWKOBJS1) $(PAWKOBJS2) awkgram$O getid$O $(OBJ)
# clear out suffixes list
# .SUFFIXES:
@@ -308,18 +318,27 @@ GAWKOBJS = $(ALLOBJS) $(LIBOBJS)
$(CC) -c $(CFLAGS) $<
# rules to build gawk
-all : gawk.exe
+all : gawk.exe pgawk.exe
gawk.exe:: $(GAWKOBJS) $(RSP)
$(DO_LNK)
$(DO_BIND)
+pgawk.exe:: $(PGAWKOBJS) $(PRSP)
+ $(DO_PLNK)
+ $(DO_PBIND)
+
$(RSPFILE) : $(GAWKOBJS)
echo $(AWKOBJS1)$P > $@
echo $(AWKOBJS2)$P >> $@
echo awkgram$O getid$O $(OBJ) $(LIBOBJS)$P >> $@
-$(ALLOBJS): awk.h dfa.h regex.h config.h
+$(PRSPFILE) : $(PGAWKOBJS)
+ echo $(PAWKOBJS1)$P > $@
+ echo $(PAWKOBJS2)$P >> $@
+ echo awkgram$O getid$O $(OBJ) $(LIBOBJS)$P >> $@
+
+$(ALLOBJS) eval_p$O profile_p$O: awk.h dfa.h regex.h config.h
gawkmisc$O: pc/gawkmisc.pc
@@ -329,6 +348,10 @@ getopt1$O: getopt.h
main$O: patchlev.h
+eval_p$O: eval.c
+
+profile_p$O: profile.c
+
# A bug in ndmake requires the following rule
awkgram$O: awk.h awkgram.c
$(CC) -c $(CFLAGS) awkgram.c
@@ -358,7 +381,7 @@ install2:
gawk -v prefix=$(prefix) -f install.awk
clean:
- rm -rf gawk gawk.exe gawk.map *.o *.obj core a.out $(RSPFILE)
+ rm -rf gawk pgawk *.exe gawk.map *.o *.obj core a.out $(RSPFILE) $(PRSPFILE)
# cd doc && $(MAKE) clean
# cd test && $(MAKE) clean
# cd awklib && $(MAKE) clean
diff --git a/pc/Makefile.tst b/pc/Makefile.tst
index af62e8b8..22928552 100644
--- a/pc/Makefile.tst
+++ b/pc/Makefile.tst
@@ -1,6 +1,6 @@
# Makefile for GNU Awk test suite.
#
-# Copyright (C) 1988-2001 the Free Software Foundation, Inc.
+# Copyright (C) 1988-2002 the Free Software Foundation, Inc.
#
# This file is part of GAWK, the GNU implementation of the
# AWK Programming Language.
@@ -67,6 +67,8 @@ AWK2 = '..\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).
+# This is also an issue for the "mmap8k" test. If it fails, make sure that
+# mmap8k.in has CR/LFs or that you've used diff.
#
# 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).
@@ -79,8 +81,8 @@ AWK2 = '..\gawk.exe'
# 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 = env LFN=n diff
+CMP = diff
#CMP = diff -c
#CMP = gcmp
@@ -105,8 +107,6 @@ DATE = gdate
srcdir = .
-bigtest: basic unix-tests gawk-extensions
-
# message stuff is to make it a little easier to follow
check: msg \
basic-msg-start basic basic-msg-end \
@@ -115,19 +115,20 @@ check: msg \
# try to keep these sorted
basic: addcomma anchgsub argarray arrayparm arrayref arynasty arynocls \
- arysubnm asgext awkpath back89 backgsub childin clobber clsflnam \
- compare convfmt datanonl defref delarprm dynlj eofsplit fldchg \
- fldchgnf fnamedat fnarray fnarydel fnaryscl fnasgnm fnparydl \
- fsbs fsrs fstabplus funsmnam funstack getline getlnbuf getnr2tb \
- getnr2tm gsubasgn gsubtest hsprint intest intprec leaddig litoct \
- longwrds math messages mmap8k nasty nasty2 negexp nfldstr nfset \
- nlfldsep nlinstr nlstrina noeffect nofmtch nonl noparms nors \
- numindex numsubstr octsub ofmt ofmtbig ofmts opasnidx opasnslf \
- paramdup paramtyp parseme pcntplus prdupval printf1 prmarscl \
- prmreuse prt1eval prtoeval psx96sub rand rebt8b1 rebt8b2 redfilnm \
- regeq reindops reparse resplit rs rsnul1nl rswhite sclforin \
- sclifin splitargv splitdef splitvar splitwht sprintfc strtod \
- subslash substr swaplns tradanch tweakfld zeroflag
+ arysubnm arrymem1 asgext awkpath back89 backgsub childin clobber \
+ clsflnam compare compare2 concat1 convfmt datanonl defref delarprm dynlj eofsplit \
+ fldchg fldchgnf fnamedat fnarray fnarydel fnaryscl fnasgnm \
+ fnparydl forsimp fsbs fsrs fstabplus funsemnl funsmnam funstack getline \
+ getlnbuf getnr2tb getnr2tm gsubasgn gsubtest hsprint intest \
+ intprec leaddig leadnl litoct longsub longwrds math membug1 messages minusstr \
+ mmap8k nasty nasty2 negexp nfldstr nfset nlfldsep nlinstr nlstrina \
+ noeffect nofmtch nonl noparms nors numindex numsubstr octsub \
+ ofmt ofmtbig ofmtfidl ofmts onlynl opasnidx opasnslf paramdup paramtyp \
+ parseme pcntplus prdupval printf1 prmarscl prmreuse prt1eval \
+ prtoeval psx96sub rand rebt8b1 rebt8b2 redfilnm regeq reindops \
+ reparse resplit rs rsnul1nl rswhite sclforin sclifin splitargv \
+ splitdef splitvar splitwht sprintfc strtod subslash substr \
+ swaplns tradanch tweakfld zeroflag
unix-tests: fflush getlnhd pid pipeio1 pipeio2 poundba strftlng
@@ -186,8 +187,6 @@ poundba::
@rm -f /tmp/gawk.exe
swaplns::
- @echo 'If swaplns fails make sure that all of the .ok files have CR/LFs.'
- @echo 'Or, set CMP to use diff.'
@$(AWK) -f $(srcdir)/swaplns.awk $(srcdir)/swaplns.in >_$@
-$(CMP) $(srcdir)/swaplns.ok _$@ && rm -f _$@
@@ -231,8 +230,8 @@ 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
- AWK=`pwd`/$(AWK) CMP="$(CMP)" $(srcdir)/regtest
+# AWK=`pwd`/$(AWK) $(srcdir)/regtest.sh
+ AWK=`pwd`/$(AWK) CMP="$(CMP)" $(srcdir)/regtest.sh
posix::
@echo 'posix test may fail due to 1.500000e+000 not being equal to'
@@ -249,7 +248,6 @@ manyfiles::
@echo 'If manyfiles says "junk/*: No such file or directory",'
@echo 'use the line on test/Makefile which invokes wc'
@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
@@ -359,11 +357,12 @@ nofmtch::
strftime::
: this test could fail on slow machines or on a second boundary,
: so if it does, double check the actual results
- @echo 'It will also fail using DJGPP because DJGPP does not'
- @echo 'have a default timezone.'
+# We set TZ to make sure that we properly set the timezone.
# @LC_ALL=C; export LC_ALL; LANG=C; export LANG; \
+# TZ=GMT0; export TZ; \
# date | $(AWK) -v OUTPUT=_$@ -f $(srcdir)/strftime.awk
@LC_ALL=C; export LC_ALL; LANG=C; export LANG; \
+ TZ=GMT0; export TZ; \
$(DATE) | $(AWK) -v OUTPUT=_$@ -f $(srcdir)/strftime.awk
-$(CMP) strftime.ok _$@ && rm -f _$@ strftime.ok || exit 0
@@ -468,7 +467,6 @@ clsflnam::
-$(CMP) $(srcdir)/clsflnam.ok _$@ && rm -f _$@
mmap8k::
- @echo 'If mmap8k fails make sure that mmap8k.in has CR/LFs.'
@$(AWK) '{ print }' $(srcdir)/mmap8k.in >_$@
-$(CMP) $(srcdir)/mmap8k.in _$@ && rm -f _$@
@@ -551,8 +549,7 @@ nfldstr::
-$(CMP) $(srcdir)/nfldstr.ok _$@ && rm -f _$@
nors::
-# @echo A B C D E | tr -d '\12' | $(AWK) '{ print $$NF }' - $(srcdir)/nors.in > _$@
- @echo A B C D E | tr -d '\15\12' | $(AWK) '{ print $$NF }' - $(srcdir)/nors.in > _$@
+ @echo A B C D E | tr -d '\12\15' | $(AWK) '{ print $$NF }' - $(srcdir)/nors.in > _$@
-$(CMP) $(srcdir)/nors.ok _$@ && rm -f _$@
fnarydel::
@@ -832,7 +829,7 @@ psx96sub::
addcomma::
@echo 'If addcomma 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 'comment in this makefile about setting CMP for information'
@echo 'about what may be happenning.'
@$(AWK) -f $(srcdir)/addcomma.awk $(srcdir)/addcomma.in >_$@
-$(CMP) $(srcdir)/addcomma.ok _$@ && rm -f _$@
@@ -849,6 +846,50 @@ rebt8b2::
@$(AWK) -f $(srcdir)/rebt8b2.awk >_$@
-$(CMP) $(srcdir)/rebt8b2.ok _$@ && rm -f _$@
+leadnl::
+ @$(AWK) -f $(srcdir)/leadnl.awk $(srcdir)/leadnl.in >_$@
+ -$(CMP) $(srcdir)/leadnl.ok _$@ && rm -f _$@
+
+funsemnl::
+ @$(AWK) -f $(srcdir)/funsemnl.awk >_$@
+ -$(CMP) $(srcdir)/funsemnl.ok _$@ && rm -f _$@
+
+ofmtfidl::
+ @$(AWK) -f $(srcdir)/ofmtfidl.awk $(srcdir)/ofmtfidl.in >_$@
+ -$(CMP) $(srcdir)/ofmtfidl.ok _$@ && rm -f _$@
+
+onlynl::
+ @$(AWK) -f $(srcdir)/onlynl.awk $(srcdir)/onlynl.in >_$@
+ -$(CMP) $(srcdir)/onlynl.ok _$@ && rm -f _$@
+
+arrymem1::
+ @$(AWK) -f $(srcdir)/arrymem1.awk >_$@
+ -$(CMP) $(srcdir)/arrymem1.ok _$@ && rm -f _$@
+
+compare2::
+ @$(AWK) -f $(srcdir)/compare2.awk >_$@
+ -$(CMP) $(srcdir)/compare2.ok _$@ && rm -f _$@
+
+minusstr::
+ @$(AWK) -f $(srcdir)/minusstr.awk >_$@
+ -$(CMP) $(srcdir)/minusstr.ok _$@ && rm -f _$@
+
+membug1::
+ @$(AWK) -f $(srcdir)/membug1.awk $(srcdir)/membug1.in >_$@
+ -$(CMP) $(srcdir)/membug1.ok _$@ && rm -f _$@
+
+forsimp::
+ @$(AWK) -f $(srcdir)/forsimp.awk >_$@
+ -$(CMP) $(srcdir)/forsimp.ok _$@ && rm -f _$@
+
+concat1::
+ @$(AWK) -f $(srcdir)/concat1.awk $(srcdir)/concat1.in >_$@
+ -$(CMP) $(srcdir)/concat1.ok _$@ && rm -f _$@
+
+longsub::
+ @$(AWK) -f $(srcdir)/longsub.awk $(srcdir)/longsub.in >_$@
+ -$(CMP) $(srcdir)/longsub.ok _$@ && rm -f _$@
+
clean:
rm -fr _* core junk out1 out2 out3 strftime.ok test1 test2 seq *~
diff --git a/pc/awklib/igawk.awk b/pc/awklib/igawk.awk
index dc0ba405..c660b8dc 100644
--- a/pc/awklib/igawk.awk
+++ b/pc/awklib/igawk.awk
@@ -34,16 +34,16 @@ BEGIN {
}
fpath = pathto($2)
if (fpath == "") {
- printf("igawk:%s:%d: cannot find %s\n", \
+ printf("igawk:%s:%d: cannot find %s\n",
input[stackptr], FNR, $2) > "/dev/stderr"
continue
}
if (! (fpath in processed)) {
processed[fpath] = input[stackptr]
- input[++stackptr] = fpath
+ input[++stackptr] = fpath # push onto stack
} else
- print $2, "included in", input[stackptr], \
- "already included in", \
+ print $2, "included in", input[stackptr],
+ "already included in",
processed[fpath] > "/dev/stderr"
}
close(input[stackptr])
diff --git a/pc/config.h b/pc/config.h
index 626027cf..6544abb8 100644
--- a/pc/config.h
+++ b/pc/config.h
@@ -5,7 +5,7 @@
*/
/*
- * Copyright (C) 1995-2001 the Free Software Foundation, Inc.
+ * Copyright (C) 1995-2002 the Free Software Foundation, Inc.
*
* This file is part of GAWK, the GNU implementation of the
* AWK Programming Language.
diff --git a/pc/gawkmisc.pc b/pc/gawkmisc.pc
index 860e6b71..10e4b140 100644
--- a/pc/gawkmisc.pc
+++ b/pc/gawkmisc.pc
@@ -1,9 +1,9 @@
/*
- * gawkmisc.c --- miscellanious gawk routines that are OS specific.
+ * gawkmisc.c --- miscellaneous gawk routines that are OS specific.
*/
/*
- * Copyright (C) 1986, 1988, 1989, 1991 - 2001 the Free Software Foundation, Inc.
+ * Copyright (C) 1986, 1988, 1989, 1991 - 2002 the Free Software Foundation, Inc.
*
* This file is part of GAWK, the GNU implementation of the
* AWK Progamming Language.
@@ -23,12 +23,19 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
-char quote = '"';
-char envsep = ';';
-#ifdef DEFPATH
+char quote = '\'';
+char envsep = ';';
+
+# ifdef DEFPATH
char *defpath = DEFPATH;
-#else
+# else
char *defpath = ".;c:\\lib\\awk;c:\\gnu\\lib\\awk";
+# endif
+
+#ifdef __EMX__
+static int _os2_is_abs_path(const char *dirname);
+static char* _os2_unixroot(const char *path);
+static const char* _os2_unixroot_path(const char *path);
#endif
/* gawk_name --- pull out the "gawk" part from how the OS called us */
@@ -60,10 +67,16 @@ int *argcp;
char ***argvp;
{
#ifdef __EMX__
- _response(argcp, argvp);
+# ifdef initialize_main
+ initialize_main(argcp, argvp);
+# else
_wildcard(argcp, argvp);
+ _response(argcp, argvp);
+# endif
+
setvbuf(stdout, NULL, _IOLBF, BUFSIZ);
-#endif
+ defpath = (char*) _os2_unixroot_path(defpath);
+#endif /* __EMX__ */
return;
}
@@ -74,6 +87,10 @@ os_devopen(name, flag)
const char *name;
int flag;
{
+#ifdef __EMX__
+ /* do not use open(name, flag) here !!! */
+ return -1;
+#else
if (strcmp(name, "/dev/null") == 0)
return open("NUL", flag);
/* FIXME: */
@@ -81,6 +98,7 @@ int flag;
* return open("???", flag);
*/
return -1;
+#endif
}
/* optimal_bufsize --- determine optimal buffer size */
@@ -101,13 +119,10 @@ struct stat *stb;
*/
#define DEFBLKSIZE BUFSIZ
- if (isatty(fd))
- return BUFSIZ;
if (fstat(fd, stb) == -1)
fatal("can't stat fd %d (%s)", fd, strerror(errno));
- if (lseek(fd, (off_t)0, 0) == -1) /* not a regular file */
- return DEFBLKSIZE;
- if (stb->st_size > 0 && stb->st_size < DEFBLKSIZE) /* small file */
+ if (S_ISREG(stb->st_mode)
+ && 0 < stb->st_size && stb->st_size < DEFBLKSIZE) /* small file */
return stb->st_size;
return DEFBLKSIZE;
}
@@ -118,6 +133,10 @@ int
ispath(file)
const char *file;
{
+#ifdef __EMX__
+ return (strpbrk(file, "/\\") != NULL ||
+ (toupper(file[0]) >= 'A' && toupper(file[0]) <= 'Z' && file[1] == ':'));
+#else
for (; *file; file++) {
switch (*file) {
case '/':
@@ -127,6 +146,7 @@ const char *file;
}
}
return 0;
+#endif
}
/* isdirpunct --- return true if char is a directory separator */
@@ -146,11 +166,14 @@ int fd;
const char *name, *what, *dir;
{
#if ! defined(_MSC_VER) && ! defined(__MINGW32__)
-#if defined(__DJGPP__) && (__DJGPP__ > 2 || __DJGPP_MINOR__ >= 4)
+# if (defined(__DJGPP__) && (__DJGPP__ > 2 || __DJGPP_MINOR__ >= 4)) || defined __EMX__
+ if (fd <= 2) /* sanity */
+ return;
+
if (fcntl(fd, F_SETFD, 1) < 0)
warning("%s %s `%s': could not set close-on-exec: %s",
what, dir, name, strerror(errno));
-#endif
+# endif
#endif
}
@@ -174,7 +197,16 @@ int fd;
int
os_is_setuid()
{
+#ifdef __EMX__
+ long uid, euid;
+
+ uid = getuid();
+ euid = geteuid();
+
+ return (euid == 0 && euid != uid);
+#else
return 0;
+#endif
}
/* os_setbinmode --- set binary mode on file */
@@ -210,3 +242,176 @@ int fd;
setmode(fd, orig_tty_mode);
}
}
+
+
+#ifdef __EMX__
+# ifndef PATH_SEPARATOR
+# define PATH_SEPARATOR ';'
+# endif
+
+/* result is 0 if dirname is no absolute path, 1 otherwise */
+
+static int
+_os2_is_abs_path(const char *dirname)
+{
+ int result = 0;
+ if (dirname != NULL && dirname[0] != '\0') {
+ /* if dirname contains a valid drive letter like "c:" */
+ if (((dirname[0] >= 'A' && dirname[0] <= 'Z') || (dirname[0] >= 'a' && dirname[0] <= 'z'))
+ && dirname[1] == ':') dirname += 2; /* remove the drive letter */
+
+ if (dirname[0] == '/' || dirname[0] == '\\') result = 1; /* asbolute path */
+ }
+
+ return result;
+}
+
+
+/* path is assumed to be a list of directories separated by PATH_SEPARATOR.
+ This function determines if the first directory of path is on the
+ drive specified by the environment variable UNIXROOT.
+ If it is the case, NULL is returned, otherwise a new directory name
+ is allocated using the drive letter from UNIXROOT and returned as result.
+ If the first directory is a relative path NULL is returned, too.
+ The new directory name is allocated by malloc().
+ Example (UNIXROOT is set to "e:"):
+ "c:/usr/share" -> "e:/usr/share"
+ "e:/usr/share" -> NULL (already on the $UNIXROOT drive)
+ "/usr/share" -> "e:/usr/share"
+ "." -> NULL (not an absolute path)
+ "usr/share" -> NULL (not an absolute path)
+ "c:usr/share" -> NULL (not an absolute path)
+ "c:/usr/share;d:/etc" -> "e:/usr/share" (only the first directory in path is used) */
+
+static char*
+_os2_unixroot(const char *path)
+{
+ static const char *unixroot = NULL;
+ static int unixroot_init = 0;
+ char *result = NULL;
+
+ if (unixroot_init == 0) {
+ /* get $UNIXROOT only one time */
+ unixroot = getenv("UNIXROOT");
+
+ /* check whether unixroot is valid (must be "x:") */
+ if (unixroot != NULL) {
+ int drive = toupper(unixroot[0]);
+ if (drive < 'A' || drive > 'Z' || unixroot[1] != ':' || unixroot[2] != '\0')
+ unixroot = NULL; /* unixroot not valid */
+ }
+
+ unixroot_init = 1; /* initialized */
+ }
+
+ /* note: if unixroot != NULL then it contains a valid drive letter */
+ if (unixroot != NULL && _os2_is_abs_path(path)) {
+ /* dirname is an absolute path and unixroot is a drive letter, "c:" for example */
+ size_t old_path_len = strlen(path);
+
+ /* end points to the first ';' in path or to NULL */
+ const char *end = strchr(path, PATH_SEPARATOR);
+
+ /* dir_len is the length of the first directory in path */
+ size_t dir_len = (end) ? end - path : old_path_len;
+
+ if (toupper(unixroot[0]) != toupper(path[0]) || path[1] != ':') {
+ /* the first directory of path does not start with the string $UNIXROOT */
+ if (path[1] == ':') {
+ /* if there is a drive letter remove it */
+ dir_len -= 2;
+ path += 2;
+ }
+
+ result = malloc(dir_len + 3);
+ if (result) { /* do nothing if we are out of memory */
+ result[0] = unixroot[0];
+ result[1] = unixroot[1];
+ memcpy(result + 2, path, dir_len);
+ result[dir_len + 2] = '\0';
+ }
+ }
+ }
+ return result;
+}
+
+/* path is assumed to be a list of directories separated by PATH_SEPARATOR.
+ Every directory is processed. _os2_unixroot() is used to find out whether
+ these directories are on the drive specified by the environment variable
+ UNIXROOT. If this is not the case the same directory on the UNIXROOT drive
+ is added to the end of path. If path is a valid path this function returns a valid path, too.
+ Example ($UNIXROOT is set to "e:"):
+ ".;c:/usr/local;d:/usr/local;d:/etc;e:/etc"
+ -> ".;c:/usr/local;d:/usr/local;d:/etc;e:/etc;e:/usr/local;e:/usr/local;e:/etc" */
+
+static const char*
+_os2_unixroot_path(const char *path)
+{
+ char *result = NULL;
+ const char *p = path;
+ unsigned dir_count = 1;
+
+ if (path == NULL || path[0] == '\0') return NULL; /* empty path */
+
+ /* save number of path components in dir_count */
+ while(*p) {
+ if (*p++ == PATH_SEPARATOR && *p != '\0' && *p != PATH_SEPARATOR)
+ dir_count += 1;
+ }
+
+ {
+ const char *list[dir_count]; /* list of char pointers */
+ size_t dir_len[dir_count]; /* the according directory length */
+ size_t old_path_len = strlen(path); /* the old path length */
+ size_t total_len;
+ unsigned i = 0;
+
+ if (path[old_path_len - 1] == PATH_SEPARATOR) /* last character is ';' */
+ old_path_len--;
+
+ list[0] = p = path; /* first directory */
+
+ while(*p) {
+ if (*p++ == PATH_SEPARATOR && *p != '\0' && *p != PATH_SEPARATOR)
+ list[++i] = p;
+ }
+ /* now list[i] contains the ith directory of path (no 0-terminated strings!!!) */
+
+ /* determine the total length for the new path */
+ total_len = old_path_len;
+
+ for(i = 0; i < dir_count; i++) {
+ list[i] = _os2_unixroot(list[i]);
+ if (list[i] != NULL) {
+ dir_len[i] = strlen(list[i]);
+ total_len += dir_len[i] + 1; /* one character for ';' or '\0' */
+ }
+ else dir_len[i] = 0;
+ }
+ /* now list[] contains the according directories on the UNIXROOT drive or NULL
+ total_len contains the total length for the new path */
+ result = malloc(total_len + 1);
+
+ if (result) {
+ /* copy the old path and the new directories into the new path */
+ char *q = result;
+ memcpy(q, path, old_path_len);
+ q += old_path_len;
+
+ for(i = 0; i < dir_count; i++) {
+ if (dir_len[i] != 0) {
+ *q++ = PATH_SEPARATOR;
+ memcpy(q, list[i], dir_len[i]);
+ q += dir_len[i];
+ }
+ }
+
+ *q = '\0'; /* terminating '\0' */
+ }
+
+ for(i = 0; i++; i < dir_count) free((void*) list[i]);
+ }
+
+ return (result) ? (const char*) result : path;
+}
+#endif /* __EMX__ */
diff --git a/pc/install.awk b/pc/install.awk
index 67113898..367e8b98 100644
--- a/pc/install.awk
+++ b/pc/install.awk
@@ -58,4 +58,5 @@ mkinstalldirs(prefix "/lib/awk " prefix "/man/man1 " prefix "/info")
cp("awklib/eg/lib/* pc/awklib/igawk.awk " prefix "/lib/awk");
cp("doc/*.1 " prefix "/man/man1");
cp("doc/gawk.info " prefix "/info");
+cp("doc/gawkinet.info " prefix "/info");
}