diff options
Diffstat (limited to 'pc.d')
-rw-r--r-- | pc.d/makefile.pc | 169 | ||||
-rw-r--r-- | pc.d/names.lnk | 16 | ||||
-rw-r--r-- | pc.d/popen.c | 90 | ||||
-rw-r--r-- | pc.d/popen.h | 8 |
4 files changed, 283 insertions, 0 deletions
diff --git a/pc.d/makefile.pc b/pc.d/makefile.pc new file mode 100644 index 00000000..b812dad4 --- /dev/null +++ b/pc.d/makefile.pc @@ -0,0 +1,169 @@ +# Makefile for GNU Awk (for use with Microsoft C V5.1) +# +# Rewritten by Arnold Robbins, September 1988, March 1989. +# +# Copyright (C) 1986, 1988, 1989 the Free Software Foundation, Inc. +# +# This file is part of GAWK, the GNU implementation of the +# AWK Progamming Language. +# +# GAWK is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 1, or (at your option) +# any later version. +# +# GAWK is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GAWK; see the file COPYING. If not, write to +# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. + +# CFLAGS: options to the C compiler +# +# -Ox optimize +# -Zi include debugging info (include /CO in LINKFLAFS) +# -AL compile in large model +# -AS compile in small model +# +# -DNOVPRINTF - system has no vprintf and associated routines +# -DHASDOPRNT - system needs version of vprintf et al. defined in awk5.c +# and has a BSD compatable doprnt() +# -DNOMEMCMP - system lacks memcmp() +# -DUSG - system is generic-ish System V. +# +CC=cl +LINKFLAGS= /E /FAR /PAC /NOE /NOI /st:0x1800 +#LINKFLAGS= /CO /NOE /NOI /st:0x1800 +OPTIMIZE= -AL -Ox +DEBUG=#-DDEBUG #-DFUNC_TRACE -DMEMDEBUG +DEBUGGER= #-Zi +PROFILE=#-pg +SYSV= +BSD=#-DHASDOPRNT +MEMCMP=#-DNOMEMCMP +VPRINTF=#-DNOVPRINTF + +FLAGS= $(OPTIMIZE) $(SYSV) $(DEBUG) $(BSD) $(MEMCMP) $(VPRINTF) +CFLAGS= $(FLAGS) $(DEBUGGER) $(PROFILE) +LDFLAGS= #-Bstatic + +SRC = awk1.c awk2.c awk3.c awk4.c awk5.c \ + awk6.c awk7.c awk8.c awk9.c regex.c version.c do_free.c awka.c + +PCSTUFF= makefile.pc names.lnk random.c + +AWKOBJS = awk1.obj awk2.obj awk3.obj awk4.obj awk5.obj awk6.obj awk7.obj \ + awk8.obj awk9.obj version.obj awka.obj # do_free.obj # used for MEMDEBUG +ALLOBJS = $(AWKOBJS) awk_tab.obj + +# Parser to use on grammar -- if you don't have bison use the first one +PARSER = yacc +PARSOUT=ytab.c +#PARSER = bison -y +#PARSOUT=y_tab.c +#PARSFLAGS=-v + +# S5OBJS +# Set equal to alloca.o if your system is S5 and you don't have +# alloca. Uncomment the rule below to actually make alloca.o. +S5OBJS= + +# GETOPT +# Set equal to getopt.o if you have a generic BSD system. The +# generic BSD getopt is reported to not work with gawk. The +# gnu getopt is supplied in gnu.getopt.c. The Public Domain +# getopt from AT&T is in att.getopt.c. Choose one of these, +# and rename it getopt.c. +GETOPT=getopt.obj + +# LIBOBJS +# Stuff that awk uses as library routines, but not in /lib/libc.a. +LIBOBJS= regex.obj random.obj $(S5OBJS) $(GETOPT) + +UPDATES = Makefile awk.h awk.y \ + $(SRC) regex.c regex.h + +INFOFILES= gawk-info gawk-info-1 gawk-info-2 gawk-info-3 gawk-info-4 \ + gawk-info-5 gawk.aux gawk.cp gawk.cps gawk.dvi gawk.fn gawk.fns \ + gawk.ky gawk.kys gawk.pg gawk.pgs gawk.texinfo gawk.toc \ + gawk.tp gawk.tps gawk.vr gawk.vrs + +# DOCS +# Documentation for users +# +DOCS=gawk.1 $(INFOFILES) + +# We don't distribute shar files, but they're useful for mailing. +SHARS = $(DOCS) COPYING README PROBLEMS $(UPDATES) awk.tab.c \ + alloca.s alloca.c att_getopt.c gnu_getopt.c $(PCSTUFF) + +gawk: $(ALLOBJS) $(LIBOBJS) + link @names.lnk,gawk.exe $(LINKFLAGS); + +# this kludge necessary because MSC 5.1 compiler bombs with -Oa or -Ol (where +# -Ox == "-Oailt -Gs") +regex.obj: regex.c + $(CC) -c -Oit -AL regex.c + +$(AWKOBJS): awk.h + +awk_tab.obj: awk.h awk_tab.c + +awk_tab.c: awk.y + @-del awk_tab.c + $(PARSER) $(PARSFLAGS) awk.y + -rename $(PARSOUT) awk_tab.c + +# Alloca: uncomment this if your system (notably System V boxen) +# does not have alloca in /lib/libc.a +# +#alloca.o: alloca.s +# /lib/cpp < alloca.s | sed '/^#/d' > t.s +# as t.s -o alloca.o +# rm t.s + +# If your machine is not supported by the assembly version of alloca.s, +# use the C version instead. This uses the default rules to make alloca.o. +# +#alloca.o: alloca.c + +lint: $(SRC) + lint -hcbax $(FLAGS) $(SRC) awk_tab.c + +clean: + rm -f gawk *.obj core awk.output gmon.out make.out #awk_tab.c + +awk.shar: $(SHARS) + shar -f awk -c $(SHARS) + +awk.tar: $(SHARS) + tar cvf awk.tar $(SHARS) + +updates.tar: $(UPDATES) + tar cvf gawk.tar $(UPDATES) + +awk.tar.Z: awk.tar + compress < awk.tar > awk.tar.Z + +doc: $(DOCS) + nroff -man $(DOCS) | col > $(DOCS).out + +# This command probably won't be useful to the rest of the world, but makes +# life much easier for me. +dist: awk.tar awk.tar.Z + +diff: + for i in RCS/*; do rcsdiff -c -b $$i > `basename $$i ,v`.diff; done + +update: $(UPDATES) + sendup $? + touch update + +release: $(SHARS) + -rm -fr gawk-dist + mkdir gawk-dist + cp $(SHARS) gawk-dist + tar -cvf - gawk-dist | compress > dist.tar.Z diff --git a/pc.d/names.lnk b/pc.d/names.lnk new file mode 100644 index 00000000..28e1a0d5 --- /dev/null +++ b/pc.d/names.lnk @@ -0,0 +1,16 @@ +awk1.obj+ +awk2.obj+ +awk3.obj+ +awk4.obj+ +awk5.obj+ +awk6.obj+ +awk7.obj+ +awk8.obj+ +awk9.obj+ +awka.obj+ +version.obj+ +awk_tab.obj+ +regex.obj+ +random.obj+ +setargv.obj+ +getopt.obj diff --git a/pc.d/popen.c b/pc.d/popen.c new file mode 100644 index 00000000..48952c22 --- /dev/null +++ b/pc.d/popen.c @@ -0,0 +1,90 @@ +#include <stdio.h> +#include "popen.h" +#include <io.h> +#include <string.h> +#include <process.h> + +static char template[] = "piXXXXXX"; +typedef enum { unopened = 0, reading, writing } pipemode; +static +struct { + char *command; + char *name; + pipemode pmode; +} pipes[_NFILE]; + +FILE * +popen( char *command, char *mode ) { + FILE *current; + char *name; + int cur; + pipemode curmode; + /* + ** decide on mode. + */ + if(strcmp(mode,"r") == 0) + curmode = reading; + else if(strcmp(mode,"w") == 0) + curmode = writing; + else + return NULL; + /* + ** get a name to use. + */ + if((name = tempnam(".","pip"))==NULL) + return NULL; + /* + ** If we're reading, just call system to get a file filled with + ** output. + */ + if(curmode == reading) { + char cmd[256]; + sprintf(cmd,"%s > %s",command,name); + system(cmd); + if((current = fopen(name,"r")) == NULL) + return NULL; + } else { + if((current = fopen(name,"w")) == NULL) + return NULL; + } + cur = fileno(current); + pipes[cur].name = name; + pipes[cur].pmode = curmode; + pipes[cur].command = strdup(command); + return current; +} + +int +pclose( FILE * current) { + int cur = fileno(current),rval; + /* + ** check for an open file. + */ + if(pipes[cur].pmode == unopened) + return -1; + if(pipes[cur].pmode == reading) { + /* + ** input pipes are just files we're done with. + */ + rval = fclose(current); + unlink(pipes[cur].name); + } else { + /* + ** output pipes are temporary files we have + ** to cram down the throats of programs. + */ + char command[256]; + fclose(current); + sprintf(command,"%s < %s",pipes[cur].command,pipes[cur].name); + rval = system(command); + unlink(pipes[cur].name); + } + /* + ** clean up current pipe. + */ + pipes[cur].pmode = unopened; + free(pipes[cur].name); + free(pipes[cur].command); + return rval; +} + diff --git a/pc.d/popen.h b/pc.d/popen.h new file mode 100644 index 00000000..55501324 --- /dev/null +++ b/pc.d/popen.h @@ -0,0 +1,8 @@ +/* +** popen.h -- prototypes for pipe functions +*/ +#if !defined(FILE) +#include <stdio.h> +#endif +extern FILE *popen( char *, char * ); + |