summaryrefslogtreecommitdiff
path: root/os2
diff options
context:
space:
mode:
authorLarry Wall <lwall@jpl-devvax.jpl.nasa.gov>1990-10-16 02:28:17 +0000
committerLarry Wall <lwall@jpl-devvax.jpl.nasa.gov>1990-10-16 02:28:17 +0000
commitd9d8d8de9462d72f6b4520fc11dd84dbe2c8bf1d (patch)
tree42dd9d991eecc159ab1e232be5f9941456228df0 /os2
parentc2ab57d4ffc80c0e2a9e968e66e52c289ac9ed45 (diff)
downloadperl-d9d8d8de9462d72f6b4520fc11dd84dbe2c8bf1d.tar.gz
perl 3.0 patch #32 patch #29, continued
See patch #29.
Diffstat (limited to 'os2')
-rw-r--r--os2/makefile125
-rw-r--r--os2/mktemp.c28
-rw-r--r--os2/os2.c273
-rw-r--r--os2/perl.bad6
-rw-r--r--os2/perl.cs13
-rw-r--r--os2/perl.def2
6 files changed, 447 insertions, 0 deletions
diff --git a/os2/makefile b/os2/makefile
new file mode 100644
index 0000000000..9d5fac42b0
--- /dev/null
+++ b/os2/makefile
@@ -0,0 +1,125 @@
+#
+# Makefile for compiling Perl under OS/2
+#
+# Needs a Unix compatible make.
+# This makefile works for an initial compilation. It does not
+# include all dependencies and thus is unsuitable for serious
+# development work. Hey, I'm just inheriting what Diomidis gave me.
+#
+# Originally by Diomidis Spinellis, March 1990
+# Adjusted for OS/2 port by Raymond Chen, June 1990
+#
+
+# Source files
+SRC = array.c cmd.c cons.c consarg.c doarg.c doio.c dolist.c dump.c \
+eval.c form.c hash.c perl.y perly.c regcomp.c regexec.c \
+stab.c str.c toke.c util.c os2.c popen.c director.c suffix.c mktemp.c
+
+# Object files
+OBJ = perl.obj array.obj cmd.obj cons.obj consarg.obj doarg.obj doio.obj \
+dolist.obj dump.obj eval.obj form.obj hash.obj perly.obj regcomp.obj \
+regexec.obj stab.obj str.obj toke.obj util.obj os2.obj popen.obj \
+director.obj suffix.obj mktemp.obj
+
+# Files in the OS/2 distribution
+DOSFILES=config.h director.c dir.h makefile os2.c popen.c suffix.c \
+mktemp.c readme.os2
+
+# Yacc flags
+YFLAGS=-d
+
+# Manual pages
+MAN=perlman.1 perlman.2 perlman.3 perlman.4
+
+CC=cl
+# CBASE = flags everybody gets
+# CPLAIN = flags for modules that give the compiler indigestion
+# CFLAGS = flags for milder modules
+# PERL = which version of perl to build
+#
+# For preliminary building: No optimization, DEBUGGING set, symbols included.
+#CBASE=-AL -Zi -G2 -Gs -DDEBUGGING
+#CPLAIN=$(CBASE) -Od
+#CFLAGS=$(CBASE) -Od
+#PERL=perlsym.exe
+
+# For the final build: Optimization on, symbols stripped.
+CBASE=-AL -Zi -G2 -Gs -DDEBUGGING
+CPLAIN=$(CBASE) -Olt
+CFLAGS=$(CBASE) -Oeglt
+PERL=perl.exe
+
+# Destination directory for executables
+DESTDIR=\usr\bin
+
+# Deliverables
+#
+all: $(PERL) glob.exe
+
+perl.exe: $(OBJ) perl.arp
+ link @perl.arp,perl,nul,/stack:32767 /NOE;
+ exehdr /nologo /newfiles /pmtype:windowcompat perl.exe >nul
+
+perlsym.exe: $(OBJ) perl.arp
+ link @perl.arp,perlsym,nul,/stack:32767 /NOE /CODE;
+ exehdr /nologo /newfiles /pmtype:windowcompat perlsym.exe >nul
+
+perl.arp:
+ echo array+cmd+cons+consarg+doarg+doio+dolist+dump+ >perl.arp
+ echo eval+form+hash+perl+perly+regcomp+regexec+stab+suffix+ >>perl.arp
+ echo str+toke+util+os2+popen+director+\c600\lib\setargv >>perl.arp
+
+glob.exe: glob.c
+ $(CC) glob.c setargv.obj -link /NOE
+ exehdr /nologo /newfiles /pmtype:windowcompat glob.exe >nul
+
+array.obj: array.c
+ $(CC) $(CPLAIN) -c array.c
+cmd.obj: cmd.c
+cons.obj: cons.c perly.h
+consarg.obj: consarg.c
+# $(CC) $(CPLAIN) -c consarg.c
+doarg.obj: doarg.c
+doio.obj: doio.c
+dolist.obj: dolist.c
+dump.obj: dump.c
+eval.obj: eval.c evalargs.xc
+ $(CC) /B2c2l /B3c3l $(CFLAGS) -c eval.c
+form.obj: form.c
+hash.obj: hash.c
+perl.obj: perl.y
+perly.obj: perly.c
+regcomp.obj: regcomp.c
+regexec.obj: regexec.c
+stab.obj: stab.c
+ $(CC) $(CPLAIN) -c stab.c
+str.obj: str.c
+suffix.obj: suffix.c
+toke.obj: toke.c
+ $(CC) /B3c3l $(CFLAGS) -c toke.c
+util.obj: util.c
+# $(CC) $(CPLAIN) -c util.c
+perly.h: ytab.h
+ cp ytab.h perly.h
+director.obj: director.c
+popen.obj: popen.c
+os2.obj: os2.c
+
+perl.1: $(MAN)
+ nroff -man $(MAN) >perl.1
+
+install: all
+ exepack perl.exe $(DESTDIR)\perl.exe
+ exepack glob.exe $(DESTDIR)\glob.exe
+
+clean:
+ rm -f *.obj *.exe perl.1 perly.h perl.arp
+
+tags:
+ ctags *.c *.h *.xc
+
+dosperl:
+ mv $(DOSFILES) ../perl30.new
+
+doskit:
+ mv $(DOSFILES) ../os2
diff --git a/os2/mktemp.c b/os2/mktemp.c
new file mode 100644
index 0000000000..e70507aaee
--- /dev/null
+++ b/os2/mktemp.c
@@ -0,0 +1,28 @@
+/* MKTEMP.C using TMP environment variable */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <io.h>
+
+void Mktemp(char *file)
+{
+ char fname[32], *tmp;
+
+ tmp = getenv("TMP");
+
+ if ( tmp != NULL )
+ {
+ strcpy(fname, file);
+ strcpy(file, tmp);
+
+ if ( file[strlen(file) - 1] != '\\' )
+ strcat(file, "\\");
+
+ strcat(file, fname);
+ }
+
+ mktemp(file);
+}
+
+/* End of MKTEMP.C */
diff --git a/os2/os2.c b/os2/os2.c
new file mode 100644
index 0000000000..279a88f88b
--- /dev/null
+++ b/os2/os2.c
@@ -0,0 +1,273 @@
+/* $Header: os2.c,v 3.0.1.1 90/10/15 17:49:55 lwall Locked $
+ *
+ * (C) Copyright 1989, 1990 Diomidis Spinellis.
+ *
+ * You may distribute under the terms of the GNU General Public License
+ * as specified in the README file that comes with the perl 3.0 kit.
+ *
+ * $Log: os2.c,v $
+ * Revision 3.0.1.1 90/10/15 17:49:55 lwall
+ * patch29: Initial revision
+ *
+ * Revision 3.0.1.1 90/03/27 16:10:41 lwall
+ * patch16: MSDOS support
+ *
+ * Revision 1.1 90/03/18 20:32:01 dds
+ * Initial revision
+ *
+ */
+
+#define INCL_DOS
+#define INCL_NOPM
+#include <os2.h>
+
+/*
+ * Various Unix compatibility functions for OS/2
+ */
+
+#include <stdio.h>
+#include <errno.h>
+#include <process.h>
+
+#include "EXTERN.h"
+#include "perl.h"
+
+
+/* dummies */
+
+int ioctl(int handle, unsigned int function, char *data)
+{ return -1; }
+
+int userinit()
+{ return -1; }
+
+int syscall()
+{ return -1; }
+
+
+/* extendd chdir() */
+
+int chdir(char *path)
+{
+ if ( path[0] != 0 && path[1] == ':' )
+ DosSelectDisk(tolower(path[0]) - '@');
+
+ DosChDir(path, 0L);
+}
+
+
+/* priorities */
+
+int setpriority(int class, int pid, int val)
+{
+ int flag = 0;
+
+ if ( pid < 0 )
+ {
+ flag++;
+ pid = -pid;
+ }
+
+ return DosSetPrty(flag ? PRTYS_PROCESSTREE : PRTYS_PROCESS, class, val, pid);
+}
+
+int getpriority(int which /* ignored */, int pid)
+{
+ USHORT val;
+
+ if ( DosGetPrty(PRTYS_PROCESS, &val, pid) )
+ return -1;
+ else
+ return val;
+}
+
+
+/* get parent process id */
+
+int getppid(void)
+{
+ PIDINFO pi;
+
+ DosGetPID(&pi);
+ return pi.pidParent;
+}
+
+
+/* kill */
+
+int kill(int pid, int sig)
+{
+ int flag = 0;
+
+ if ( pid < 0 )
+ {
+ flag++;
+ pid = -pid;
+ }
+
+ switch ( sig & 3 )
+ {
+
+ case 0:
+ DosKillProcess(flag ? DKP_PROCESSTREE : DKP_PROCESS, pid);
+ break;
+
+ case 1: /* FLAG A */
+ DosFlagProcess(pid, flag ? FLGP_SUBTREE : FLGP_PID, PFLG_A, 0);
+ break;
+
+ case 2: /* FLAG B */
+ DosFlagProcess(pid, flag ? FLGP_SUBTREE : FLGP_PID, PFLG_B, 0);
+ break;
+
+ case 3: /* FLAG C */
+ DosFlagProcess(pid, flag ? FLGP_SUBTREE : FLGP_PID, PFLG_C, 0);
+ break;
+
+ }
+}
+
+
+/* Sleep function. */
+void
+sleep(unsigned len)
+{
+ DosSleep(len * 1000L);
+}
+
+/* Just pretend that everyone is a superuser */
+
+int setuid()
+{ return 0; }
+
+int setgid()
+{ return 0; }
+
+int getuid(void)
+{ return 0; }
+
+int geteuid(void)
+{ return 0; }
+
+int getgid(void)
+{ return 0; }
+
+int getegid(void)
+{ return 0; }
+
+/*
+ * The following code is based on the do_exec and do_aexec functions
+ * in file doio.c
+ */
+int
+do_aspawn(really,arglast)
+STR *really;
+int *arglast;
+{
+ register STR **st = stack->ary_array;
+ register int sp = arglast[1];
+ register int items = arglast[2] - sp;
+ register char **a;
+ char **argv;
+ char *tmps;
+ int status;
+
+ if (items) {
+ New(1101,argv, items+1, char*);
+ a = argv;
+ for (st += ++sp; items > 0; items--,st++) {
+ if (*st)
+ *a++ = str_get(*st);
+ else
+ *a++ = "";
+ }
+ *a = Nullch;
+ if (really && *(tmps = str_get(really)))
+ status = spawnvp(P_WAIT,tmps,argv);
+ else
+ status = spawnvp(P_WAIT,argv[0],argv);
+ Safefree(argv);
+ }
+ return status;
+}
+
+char *getenv(char *name);
+
+int
+do_spawn(cmd)
+char *cmd;
+{
+ register char **a;
+ register char *s;
+ char **argv;
+ char flags[10];
+ int status;
+ char *shell, *cmd2;
+
+ /* save an extra exec if possible */
+ if ((shell = getenv("COMSPEC")) == 0)
+ shell = "C:\\OS2\\CMD.EXE";
+
+ /* see if there are shell metacharacters in it */
+ if (strchr(cmd, '>') || strchr(cmd, '<') || strchr(cmd, '|')
+ || strchr(cmd, '&') || strchr(cmd, '^'))
+ doshell:
+ return spawnl(P_WAIT,shell,shell,"/C",cmd,(char*)0);
+
+ New(1102,argv, strlen(cmd) / 2 + 2, char*);
+
+ New(1103,cmd2, strlen(cmd) + 1, char);
+ strcpy(cmd2, cmd);
+ a = argv;
+ for (s = cmd2; *s;) {
+ while (*s && isspace(*s)) s++;
+ if (*s)
+ *(a++) = s;
+ while (*s && !isspace(*s)) s++;
+ if (*s)
+ *s++ = '\0';
+ }
+ *a = Nullch;
+ if (argv[0])
+ if ((status = spawnvp(P_WAIT,argv[0],argv)) == -1) {
+ Safefree(argv);
+ Safefree(cmd2);
+ goto doshell;
+ }
+ Safefree(cmd2);
+ Safefree(argv);
+ return status;
+}
+
+usage(char *myname)
+{
+#ifdef MSDOS
+ printf("\nUsage: %s [-acdnpsSvw] [-Dnumber] [-i[extension]] [-Idirectory]"
+#else
+ printf("\nUsage: %s [-acdnpPsSuUvw] [-Dnumber] [-i[extension]] [-Idirectory]"
+#endif
+ "\n [-e \"command\"] [-x[directory]] [filename] [arguments]\n", myname);
+
+ printf("\n -a autosplit mode with -n or -p"
+ "\n -c syntaxcheck only"
+ "\n -d run scripts under debugger"
+ "\n -n assume 'while (<>) { ...script... }' loop arround your script"
+ "\n -p assume loop like -n but print line also like sed"
+#ifndef MSDOS
+ "\n -P run script through C preprocessor befor compilation"
+#endif
+ "\n -s enable some switch parsing for switches after script name"
+ "\n -S look for the script using PATH environment variable");
+#ifndef MSDOS
+ printf("\n -u dump core after compiling the script"
+ "\n -U allow unsafe operations");
+#endif
+ printf("\n -v print version number and patchlevel of perl"
+ "\n -w turn warnings on for compilation of your script\n"
+ "\n -Dnumber set debugging flags"
+ "\n -i[extension] edit <> files in place (make backup if extension supplied)"
+ "\n -Idirectory specify include directory in conjunction with -P"
+ "\n -e command one line of script, multiple -e options are allowed"
+ "\n [filename] can be ommitted, when -e is used"
+ "\n -x[directory] strip off text before #!perl line and perhaps cd to directory\n");
+}
diff --git a/os2/perl.bad b/os2/perl.bad
new file mode 100644
index 0000000000..bec21328fc
--- /dev/null
+++ b/os2/perl.bad
@@ -0,0 +1,6 @@
+DOSMAKEPIPE
+DOSCWAIT
+DOSKILLPROCESS
+DOSFLAGPROCESS
+DOSSETPRTY
+DOSGETPRTY
diff --git a/os2/perl.cs b/os2/perl.cs
new file mode 100644
index 0000000000..530f0930df
--- /dev/null
+++ b/os2/perl.cs
@@ -0,0 +1,13 @@
+(-W1 -Od -Olt -DDEBUGGING -Gt2048
+array.c cmd.c cons.c consarg.c doarg.c doio.c dolist.c dump.c form.c
+hash.c perl.c perly.c regcomp.c regexec.c stab.c str.c util.c
+)
+(-W1 -Od -Olt -B2C2L -B3C3L -DDEBUGGING eval.c{evalargs.xc} toke.c)
+(-W1 -Od -Olt os2.c popen.c mktemp.c director.c suffix.c)
+
+setargv.obj
+perl.def
+perl.bad
+perl.exe
+
+-AL -LB -S0x9000
diff --git a/os2/perl.def b/os2/perl.def
new file mode 100644
index 0000000000..2b49370937
--- /dev/null
+++ b/os2/perl.def
@@ -0,0 +1,2 @@
+NAME PERL WINDOWCOMPAT NEWFILES
+DESCRIPTION 'PERL 3.0, patchlevel 28 - for MS-DOS and OS/2'