home *** CD-ROM | disk | FTP | other *** search
- Only in new: patch.cs
- Only in new: patch.def
- Only in new: patches.os2
- Only in new: isvalid.c
- diff -cbBw orig/common.h new/common.h
- *** orig/common.h Tue Dec 24 18:13:12 1991
- --- new/common.h Tue Dec 24 18:17:02 1991
- ***************
- *** 39,44 ****
- --- 39,46 ----
- #include <sys/stat.h>
- #include <ctype.h>
- #include <signal.h>
- + #include <io.h>
- + #include <fcntl.h>
-
- /* constants */
-
- ***************
- *** 146,153 ****
-
- EXT char *revision INIT(Nullch); /* prerequisite revision, if any */
-
- ! char *malloc();
- ! char *realloc();
- char *strcpy();
- char *strcat();
- long atol();
- --- 148,155 ----
-
- EXT char *revision INIT(Nullch); /* prerequisite revision, if any */
-
- ! void *malloc();
- ! void *realloc();
- char *strcpy();
- char *strcat();
- long atol();
- diff -cbBw orig/inp.c new/inp.c
- *** orig/inp.c Tue Dec 24 18:10:30 1991
- --- new/inp.c Tue Dec 24 18:25:40 1991
- ***************
- *** 115,120 ****
- --- 115,124 ----
- if ((filemode & S_IFMT) & ~S_IFREG)
- fatal2("%s is not a normal file--can't patch.\n", filename);
- i_size = filestat.st_size;
- + #ifdef OS2
- + if ( i_size > 65500L )
- + return FALSE;
- + #endif
- if (out_of_mem) {
- set_hunkmax(); /* make sure dynamic arrays are allocated */
- out_of_mem = FALSE;
- ***************
- *** 128,134 ****
- #endif
- if (i_womp == Nullch)
- return FALSE;
- ! if ((ifd = open(filename, 0)) < 0)
- fatal2("Can't open file %s\n", filename);
- #ifndef lint
- if (read(ifd, i_womp, (int)i_size) != i_size) {
- --- 132,138 ----
- #endif
- if (i_womp == Nullch)
- return FALSE;
- ! if ((ifd = open(filename, O_BINARY)) < 0)
- fatal2("Can't open file %s\n", filename);
- #ifndef lint
- if (read(ifd, i_womp, (int)i_size) != i_size) {
- ***************
- *** 206,214 ****
- Reg4 bool found_revision = (revision == Nullch);
-
- using_plan_a = FALSE;
- ! if ((ifp = fopen(filename, "r")) == Nullfp)
- fatal2("Can't open file %s\n", filename);
- ! if ((tifd = creat(TMPINNAME, 0666)) < 0)
- fatal2("Can't open file %s\n", TMPINNAME);
- while (fgets(buf, sizeof buf, ifp) != Nullch) {
- if (revision != Nullch && !found_revision && rev_in_string(buf))
- --- 210,219 ----
- Reg4 bool found_revision = (revision == Nullch);
-
- using_plan_a = FALSE;
- ! if ((ifp = fopen(filename, "rb")) == Nullfp)
- fatal2("Can't open file %s\n", filename);
- ! if ((tifd = open(TMPINNAME, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY,
- ! S_IWRITE|S_IREAD)) < 0)
- fatal2("Can't open file %s\n", TMPINNAME);
- while (fgets(buf, sizeof buf, ifp) != Nullch) {
- if (revision != Nullch && !found_revision && rev_in_string(buf))
- ***************
- *** 236,242 ****
- say2("Good. This file appears to be the %s version.\n",
- revision);
- }
- ! Fseek(ifp, 0L, 0); /* rewind file */
- lines_per_buf = BUFFERSIZE / maxlen;
- tireclen = maxlen;
- tibuf[0] = malloc((MEM)(BUFFERSIZE + 1));
- --- 241,247 ----
- say2("Good. This file appears to be the %s version.\n",
- revision);
- }
- ! rewind(ifp); /* rewind file */
- lines_per_buf = BUFFERSIZE / maxlen;
- tireclen = maxlen;
- tibuf[0] = malloc((MEM)(BUFFERSIZE + 1));
- ***************
- *** 258,264 ****
- }
- Fclose(ifp);
- Close(tifd);
- ! if ((tifd = open(TMPINNAME, 0)) < 0) {
- fatal2("Can't reopen file %s\n", TMPINNAME);
- }
- }
- --- 263,270 ----
- }
- Fclose(ifp);
- Close(tifd);
- !
- ! if ((tifd = open(TMPINNAME, O_RDONLY|O_BINARY)) < 0) {
- fatal2("Can't reopen file %s\n", TMPINNAME);
- }
- }
- diff -cbBw orig/patch.c new/patch.c
- *** orig/patch.c Tue Dec 24 18:10:32 1991
- --- new/patch.c Tue Dec 24 18:25:40 1991
- ***************
- *** 97,102 ****
- --- 97,103 ----
- #include "util.h"
- #include "pch.h"
- #include "inp.h"
- + #include "patchlevel.h"
-
- /* procedures */
-
- ***************
- *** 114,120 ****
- --- 115,126 ----
- bool similar();
- void re_input();
- void my_exit();
- + char *strchr();
- + char *strrchr();
-
- + /* Program name */
- + static char *myname;
- +
- /* Nonzero if -R was specified on command line. */
- static int reverse_flag_specified = FALSE;
-
- ***************
- *** 132,137 ****
- --- 138,144 ----
- int failed = 0;
- int failtotal = 0;
- int i;
- + char *s;
-
- setbuf(stderr, serrbuf);
- for (i = 0; i<MAXFILEC; i++)
- ***************
- *** 143,172 ****
- char *tmpdir;
- int tmpname_len;
-
- tmpdir = getenv ("TMPDIR");
- if (tmpdir == NULL) {
- tmpdir = "/tmp";
- }
- tmpname_len = strlen (tmpdir) + 20;
-
- TMPOUTNAME = (char *) malloc (tmpname_len);
- strcpy (TMPOUTNAME, tmpdir);
- ! strcat (TMPOUTNAME, "/patchoXXXXXX");
- Mktemp(TMPOUTNAME);
-
- TMPINNAME = (char *) malloc (tmpname_len);
- strcpy (TMPINNAME, tmpdir);
- ! strcat (TMPINNAME, "/patchiXXXXXX");
- Mktemp(TMPINNAME);
-
- TMPREJNAME = (char *) malloc (tmpname_len);
- strcpy (TMPREJNAME, tmpdir);
- ! strcat (TMPREJNAME, "/patchrXXXXXX");
- Mktemp(TMPREJNAME);
-
- TMPPATNAME = (char *) malloc (tmpname_len);
- strcpy (TMPPATNAME, tmpdir);
- ! strcat (TMPPATNAME, "/patchpXXXXXX");
- Mktemp(TMPPATNAME);
- }
-
- --- 150,185 ----
- char *tmpdir;
- int tmpname_len;
-
- + #ifdef OS2
- + tmpdir = getenv ("TMP");
- + if (tmpdir == NULL) {
- + tmpdir = "";
- + #else
- tmpdir = getenv ("TMPDIR");
- if (tmpdir == NULL) {
- tmpdir = "/tmp";
- + #endif
- }
- tmpname_len = strlen (tmpdir) + 20;
-
- TMPOUTNAME = (char *) malloc (tmpname_len);
- strcpy (TMPOUTNAME, tmpdir);
- ! strcat (TMPOUTNAME, "/poXXXXXX");
- Mktemp(TMPOUTNAME);
-
- TMPINNAME = (char *) malloc (tmpname_len);
- strcpy (TMPINNAME, tmpdir);
- ! strcat (TMPINNAME, "/piXXXXXX");
- Mktemp(TMPINNAME);
-
- TMPREJNAME = (char *) malloc (tmpname_len);
- strcpy (TMPREJNAME, tmpdir);
- ! strcat (TMPREJNAME, "/prXXXXXX");
- Mktemp(TMPREJNAME);
-
- TMPPATNAME = (char *) malloc (tmpname_len);
- strcpy (TMPPATNAME, tmpdir);
- ! strcat (TMPPATNAME, "/ppXXXXXX");
- Mktemp(TMPPATNAME);
- }
-
- ***************
- *** 173,178 ****
- --- 186,192 ----
- /* parse switches */
- Argc = argc;
- Argv = argv;
- + myname = argv[0];
- get_some_switches();
-
- /* make sure we clean up /tmp in case of disaster */
- ***************
- *** 337,343 ****
- --- 351,371 ----
- s[13] = '\0';
- }
- #endif
- + #ifdef OS2
- + s = strchr(rejname, 0);
- + #endif
- Strcat(rejname, REJEXT);
- + #ifdef OS2
- + if ( !IsFileNameValid(rejname) )
- + {
- + *s=0;
- +
- + if ((s=strrchr(rejname,'.'))!=NULL)
- + *s=0;
- +
- + strcat(rejname, ".rej");
- + }
- + #endif
- }
- if (skip_rest_of_patch) {
- say4("%d out of %d hunks ignored--saving rejects to %s\n",
- ***************
- *** 499,504 ****
- --- 527,536 ----
- case 'v':
- version();
- break;
- + case 'h':
- + Usage();
- + exit(0);
- + break;
- #ifdef DEBUGGING
- case 'x':
- debug = atoi(s+1);
- ***************
- *** 506,516 ****
- --- 538,552 ----
- #endif
- default:
- fprintf(stderr, "patch: unrecognized option `%s'\n", Argv[0]);
- + #ifdef OS2
- + Usage();
- + #else
- fprintf(stderr, "\
- Usage: patch [-ceflnNRsSuv] [-b backup-ext] [-B backup-prefix] [-d directory]\n\
- [-D symbol] [-Fmax-fuzz] [-o out-file] [-p[strip-count]]\n\
- [-r rej-name] [origfile] [patchfile] [[+] [options] [origfile]...]\n\
- ");
- + #endif
- my_exit(1);
- }
- }
- ***************
- *** 517,522 ****
- --- 553,586 ----
- }
- }
-
- +
- + Usage()
- + {
- + printf("\npatch 2.0, patchlevel %s\n", PATCHLEVEL);
- +
- + printf("\nUsage: %s [options] orig patchfile [+ [options] orig]\n\n", myname);
- + printf(" -b next argument is the extension to be used in place of '.orig'\n");
- + printf(" -c forces patch to interpret the patch file as a context diff\n");
- + printf(" -d next argument is a directory, cd to it before doing anything else\n");
- + printf(" -D next argument is the symbol for '#ifdef...#endif' to mark changes\n");
- + printf(" -e forces patch to interpret the patch file as an ed script\n");
- + printf(" -f do not ask any questions\n");
- + printf(" -l more loosely whitespace matching\n");
- + printf(" -n forces patch to interpret the patch file as a normal diff\n");
- + printf(" -N ignore patches that are reversed or already applied, see -R\n");
- + printf(" -o next argument is the output file name\n");
- + printf(" -r next argument is the reject file name\n");
- + printf(" -R patch was created with the old and new files swapped\n");
- + printf(" -s makes patch do its work silently, unless an error occurs\n");
- + printf(" -S ignore this patch from the patch file\n");
- + printf(" -u forces patch to interpret the patch file as a unified context diff\n");
- + printf(" -v print out revision header and patch level\n\n");
- + printf(" -F<number> maximum fuzz factor for context diffs (default 2)\n");
- + printf(" -p<number> sets the pathname strip count\n");
- + printf(" -x<number> set internal debugging flags\n");
- + }
- +
- +
- /* Attempt to find the right place to apply this hunk of patch. */
-
- LINENUM
- ***************
- *** 611,616 ****
- --- 675,703 ----
-
- /* We found where to apply it (we hope), so do it. */
-
- + #ifdef OS2
- + static int fputs(const char *buffer, FILE *file)
- + {
- + const char *ptr;
- +
- + for ( ptr = buffer; *ptr; ptr++ )
- + if ( *ptr == '\r' )
- + {
- + putc(*ptr, file);
- +
- + if ( *(ptr + 1) == '\n' )
- + putc(*++ptr, file);
- + }
- + else if ( *ptr == '\n' )
- + {
- + putc('\r', file);
- + putc(*ptr, file);
- + }
- + else
- + putc(*ptr, file);
- + }
- + #endif
- +
- void
- apply_hunk(where)
- LINENUM where;
- ***************
- *** 735,741 ****
- init_output(name)
- char *name;
- {
- ! ofp = fopen(name, "w");
- if (ofp == Nullfp)
- fatal2("patch: can't create %s.\n", name);
- }
- --- 822,828 ----
- init_output(name)
- char *name;
- {
- ! ofp = fopen(name, "wb");
- if (ofp == Nullfp)
- fatal2("patch: can't create %s.\n", name);
- }
- ***************
- *** 814,823 ****
- --- 901,929 ----
- pch_line_len(pline) ))
- return FALSE;
- }
- + #ifdef OS2
- + else
- + {
- + char *s1, *s2;
- + int len;
- +
- + s1 = ifetch(iline, (offset >= 0));
- + s2 = pfetch(pline);
- + len = pch_line_len(pline);
- +
- + /* special CR/LF case */
- + if ( s1[len - 1] == '\r' && s1[len] == '\n' && s2[len - 1] == '\n' )
- + len--;
- +
- + if (strnNE(s1, s2, len))
- + return FALSE;
- + }
- + #else
- else if (strnNE(ifetch(iline, (offset >= 0)),
- pfetch(pline),
- pch_line_len(pline) ))
- return FALSE;
- + #endif
- }
- return TRUE;
- }
- ***************
- *** 863,868 ****
- --- 969,978 ----
- if (!trejkeep) {
- Unlink(TMPREJNAME);
- }
- + if ( pfp != NULL )
- + {
- + Fclose(pfp);
- Unlink(TMPPATNAME);
- + }
- exit(status);
- }
- diff -cbBw orig/pch.c new/pch.c
- *** orig/pch.c Tue Dec 24 18:11:18 1991
- --- new/pch.c Tue Dec 24 18:25:40 1991
- ***************
- *** 37,43 ****
- --- 37,50 ----
- #include "util.h"
- #include "INTERN.h"
- #include "pch.h"
- + #include "version.h"
-
- + #ifdef OS2
- + #define EDPATH "ed"
- + #else
- + #define EDPATH "/bin/ed"
- + #endif
- +
- /* Patch (diff listing) abstract type. */
-
- static long p_filesize; /* size of the patch file */
- ***************
- *** 83,88 ****
- --- 90,101 ----
- char *filename;
- {
- if (filename == Nullch || !*filename || strEQ(filename, "-")) {
- + if ( isatty(fileno(stdin)) )
- + {
- + Usage();
- + exit(1);
- + }
- +
- pfp = fopen(TMPPATNAME, "w");
- if (pfp == Nullfp)
- fatal2("patch: can't create %s.\n", TMPPATNAME);
- ***************
- *** 978,984 ****
- if (*buf != '-')
- fatal2("--- expected at line %ld of patch.\n", p_input_line);
- }
- ! Sprintf(buf, "--- %ld,%ld\n", min, max);
- p_line[i] = savestr(buf);
- if (out_of_mem) {
- p_end = i-1;
- --- 991,997 ----
- if (*buf != '-')
- fatal2("--- expected at line %ld of patch.\n", p_input_line);
- }
- ! Sprintf(buf, "--- %ld,%ld\n", (long) min, (long) max);
- p_line[i] = savestr(buf);
- if (out_of_mem) {
- p_end = i-1;
- ***************
- *** 1254,1262 ****
- Unlink(TMPOUTNAME);
- copy_file(filearg[0], TMPOUTNAME);
- if (verbose)
- ! Sprintf(buf, "/bin/ed %s", TMPOUTNAME);
- else
- ! Sprintf(buf, "/bin/ed - %s", TMPOUTNAME);
- pipefp = popen(buf, "w");
- }
- for (;;) {
- --- 1267,1275 ----
- Unlink(TMPOUTNAME);
- copy_file(filearg[0], TMPOUTNAME);
- if (verbose)
- ! Sprintf(buf, "%s %s", EDPATH, TMPOUTNAME);
- else
- ! Sprintf(buf, "%s - %s", EDPATH, TMPOUTNAME);
- pipefp = popen(buf, "w");
- }
- for (;;) {
- diff -cbBw orig/util.c new/util.c
- *** orig/util.c Tue Dec 24 18:10:38 1991
- --- new/util.c Tue Dec 24 18:25:40 1991
- ***************
- *** 5,10 ****
- --- 5,13 ----
-
- /* Rename a file, copying it if necessary. */
-
- + char *strchr();
- + char *strrchr();
- +
- int
- move_file(from,to)
- char *from, *to;
- ***************
- *** 21,27 ****
- if (debug & 4)
- say2("Moving %s to stdout.\n", from);
- #endif
- ! fromfd = open(from, 0);
- if (fromfd < 0)
- fatal2("patch: internal error, can't reopen %s\n", from);
- while ((i=read(fromfd, buf, sizeof buf)) > 0)
- --- 24,30 ----
- if (debug & 4)
- say2("Moving %s to stdout.\n", from);
- #endif
- ! fromfd = open(from, O_RDONLY|O_BINARY);
- if (fromfd < 0)
- fatal2("patch: internal error, can't reopen %s\n", from);
- while ((i=read(fromfd, buf, sizeof buf)) > 0)
- ***************
- *** 36,43 ****
- --- 39,61 ----
- Strcat(bakname, to);
- } else {
- Strcpy(bakname, to);
- + #ifdef OS2
- + s = strchr(bakname, 0);
- + #endif
- Strcat(bakname, origext?origext:ORIGEXT);
- + #ifdef OS2
- + if ( !IsFileNameValid(bakname) )
- + {
- + *s=0;
- +
- + if ((s=strrchr(bakname,'.'))!=NULL)
- + *s=0;
- +
- + strcat(bakname, ".org");
- + }
- + #endif
- }
- +
- if (stat(to, &filestat) >= 0) { /* output file exists */
- dev_t to_device = filestat.st_dev;
- ino_t to_inode = filestat.st_ino;
- ***************
- *** 44,50 ****
- --- 62,72 ----
- char *simplename = bakname;
-
- for (s=bakname; *s; s++) {
- + #ifdef OS2
- + if (*s == '/' || *s == '\\')
- + #else
- if (*s == '/')
- + #endif
- simplename = s+1;
- }
- /* find a backup name that is not the same file */
- ***************
- *** 61,73 ****
- --- 83,104 ----
- if (debug & 4)
- say3("Moving %s to %s.\n", to, bakname);
- #endif
- +
- + #ifdef OS2
- + if (rename(to, bakname) < 0) {
- + #else
- if (link(to, bakname) < 0) {
- + #endif
- say3("patch: can't backup %s, output is in %s\n",
- to, from);
- return -1;
- }
- +
- + #ifndef OS2
- while (unlink(to) >= 0) ;
- + #endif
- }
- +
- #ifdef DEBUGGING
- if (debug & 4)
- say3("Moving %s to %s.\n", from, to);
- ***************
- *** 72,87 ****
- if (debug & 4)
- say3("Moving %s to %s.\n", from, to);
- #endif
- if (link(from, to) < 0) { /* different file system? */
- Reg4 int tofd;
-
- ! tofd = creat(to, 0666);
- if (tofd < 0) {
- say3("patch: can't create %s, output is in %s.\n",
- to, from);
- return -1;
- }
- ! fromfd = open(from, 0);
- if (fromfd < 0)
- fatal2("patch: internal error, can't reopen %s\n", from);
- while ((i=read(fromfd, buf, sizeof buf)) > 0)
- --- 103,124 ----
- if (debug & 4)
- say3("Moving %s to %s.\n", from, to);
- #endif
- +
- + #ifdef OS2
- + if (rename(from, to) < 0) { /* different file system? */
- + #else
- if (link(from, to) < 0) { /* different file system? */
- + #endif
- Reg4 int tofd;
-
- ! tofd = open(to, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY,S_IWRITE|S_IREAD);
- if (tofd < 0) {
- say3("patch: can't create %s, output is in %s.\n",
- to, from);
- return -1;
- }
- !
- ! fromfd = open(from, O_RDONLY|O_BINARY);
- if (fromfd < 0)
- fatal2("patch: internal error, can't reopen %s\n", from);
- while ((i=read(fromfd, buf, sizeof buf)) > 0)
- ***************
- *** 89,96 ****
- --- 126,138 ----
- fatal1("patch: write failed\n");
- Close(fromfd);
- Close(tofd);
- + #ifdef OS2
- + Unlink(from);
- }
- + #else
- + }
- Unlink(from);
- + #endif
- return 0;
- }
-
- ***************
- *** 104,113 ****
- Reg2 int fromfd;
- Reg1 int i;
-
- ! tofd = creat(to, 0666);
- if (tofd < 0)
- fatal2("patch: can't create %s.\n", to);
- ! fromfd = open(from, 0);
- if (fromfd < 0)
- fatal2("patch: internal error, can't reopen %s\n", from);
- while ((i=read(fromfd, buf, sizeof buf)) > 0)
- --- 146,155 ----
- Reg2 int fromfd;
- Reg1 int i;
-
- ! tofd = open(to, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY,S_IWRITE|S_IREAD);
- if (tofd < 0)
- fatal2("patch: can't create %s.\n", to);
- ! fromfd = open(from, O_RDONLY|O_BINARY);
- if (fromfd < 0)
- fatal2("patch: internal error, can't reopen %s\n", from);
- while ((i=read(fromfd, buf, sizeof buf)) > 0)
- ***************
- *** 157,162 ****
- --- 199,230 ----
-
- /* Vanilla terminal output (buffered). */
-
- + #ifdef OS2
- + #include <stdarg.h>
- +
- + void say(char *pat,...)
- + {
- + va_list argptr;
- +
- + va_start(argptr, pat);
- + vfprintf(stderr, pat, argptr);
- + va_end(argptr);
- + Fflush(stderr);
- + }
- +
- + void fatal(char *pat,...)
- + {
- + void my_exit();
- + va_list argptr;
- +
- + va_start(argptr, pat);
- + vfprintf(stderr, pat, argptr);
- + va_end(argptr);
- + Fflush(stderr);
- + my_exit(1);
- + }
- +
- + #else
- void
- say(pat,arg1,arg2,arg3)
- char *pat;
- ***************
- *** 178,186 ****
- --- 246,267 ----
- say(pat, arg1, arg2, arg3);
- my_exit(1);
- }
- + #endif
-
- /* Get a response from the user, somehow or other. */
-
- + #ifdef OS2
- + void ask(char *pat,...)
- + {
- + int ttyfd;
- + int r;
- + bool tty2 = isatty(2);
- + va_list argptr;
- +
- + va_start(argptr, pat);
- + vsprintf(buf, pat, argptr);
- + va_end(argptr);
- + #else
- void
- ask(pat,arg1,arg2,arg3)
- char *pat;
- ***************
- *** 191,196 ****
- --- 272,278 ----
- bool tty2 = isatty(2);
-
- Sprintf(buf, pat, arg1, arg2, arg3);
- + #endif
- Fflush(stderr);
- write(2, buf, strlen(buf));
- if (tty2) { /* might be redirected to a file */
- ***************
- *** 201,207 ****
- write(1, buf, strlen(buf));
- r = read(1, buf, sizeof buf);
- }
- ! else if ((ttyfd = open("/dev/tty", 2)) >= 0 && isatty(ttyfd)) {
- /* might be deleted or unwriteable */
- write(ttyfd, buf, strlen(buf));
- r = read(ttyfd, buf, sizeof buf);
- --- 283,293 ----
- write(1, buf, strlen(buf));
- r = read(1, buf, sizeof buf);
- }
- ! #ifdef OS2
- ! else if ((ttyfd = open("con", O_RDWR)) >= 0 && isatty(ttyfd)) {
- ! #else
- ! else if ((ttyfd = open("/dev/tty", O_RDWR)) >= 0 && isatty(ttyfd)) {
- ! #endif
- /* might be deleted or unwriteable */
- write(ttyfd, buf, strlen(buf));
- r = read(ttyfd, buf, sizeof buf);
- ***************
- *** 240,245 ****
- --- 326,332 ----
- #endif
-
- if (!reset) {
- + #ifndef OS2
- hupval = signal(SIGHUP, SIG_IGN);
- if (hupval != SIG_IGN)
- #ifdef VOIDSIG
- ***************
- *** 247,252 ****
- --- 334,340 ----
- #else
- hupval = (int(*)())my_exit;
- #endif
- + #endif
- intval = signal(SIGINT, SIG_IGN);
- if (intval != SIG_IGN)
- #ifdef VOIDSIG
- ***************
- *** 255,261 ****
- --- 343,351 ----
- intval = (int(*)())my_exit;
- #endif
- }
- + #ifndef OS2
- Signal(SIGHUP, hupval);
- + #endif
- Signal(SIGINT, intval);
- #endif
- }
- ***************
- *** 266,272 ****
- --- 356,364 ----
- ignore_signals()
- {
- #ifndef lint
- + #ifndef OS2
- Signal(SIGHUP, SIG_IGN);
- + #endif
- Signal(SIGINT, SIG_IGN);
- #endif
- }
- ***************
- *** 285,291 ****
- --- 377,387 ----
- Reg4 int dirvp = 0;
-
- while (*filename) {
- + #ifdef OS2
- + if (*filename == '/' || *filename == '\\') {
- + #else
- if (*filename == '/') {
- + #endif
- filename++;
- dirv[dirvp++] = s;
- *s++ = '\0';
- ***************
- *** 336,346 ****
- --- 432,450 ----
- if (strnEQ(name, "/dev/null", 9)) /* so files can be created by diffing */
- return Nullch; /* against /dev/null. */
- for (; *t && !isspace(*t); t++)
- + #ifdef OS2
- + if (*t == '/' || *t == '\\')
- + #else
- if (*t == '/')
- + #endif
- if (--strip_leading >= 0)
- name = t+1;
- *t = '\0';
- + #ifdef OS2
- + if (name != s && *s != '/' && *s != '\\') {
- + #else
- if (name != s && *s != '/') {
- + #endif
- name[-1] = '\0';
- if (stat(s, &filestat) && filestat.st_mode & S_IFDIR) {
- name[-1] = '/';
- ***************
- *** 362,364 ****
- --- 466,527 ----
- }
- return name;
- }
- +
- +
- + #ifdef OS2
- +
- + /* only one pipe can be open at a time */
- +
- + /* In fact, this is a pipe simulation for the dumb MS-DOS */
- + /* but it works good enough for the situation where it is */
- + /* needed in patch, even if OS/2 has real pipes. */
- +
- + static char pipename[128], command[128];
- + static int wrpipe;
- +
- + FILE *popen(char *cmd, char *flags)
- + {
- + wrpipe = (strchr(flags, 'w') != NULL);
- +
- + if ( wrpipe )
- + {
- + strcpy(command, cmd);
- + strcpy(pipename, "~WXXXXXX");
- + Mktemp(pipename);
- + return fopen(pipename, flags); /* ordinary file */
- + }
- + else
- + {
- + strcpy(pipename, "~RXXXXXX");
- + Mktemp(pipename);
- + strcpy(command, cmd);
- + strcat(command, ">");
- + strcat(command, pipename);
- + system(command);
- + return fopen(pipename, flags); /* ordinary file */
- + }
- + }
- +
- + int pclose(FILE *pipe)
- + {
- + int rc;
- +
- + if ( fclose(pipe) == EOF )
- + return EOF;
- +
- + if ( wrpipe )
- + {
- + strcat(command, "<");
- + strcat(command, pipename);
- + rc = system(command);
- + unlink(pipename);
- + return rc;
- + }
- + else
- + {
- + unlink(pipename);
- + return 0;
- + }
- + }
- +
- + #endif
-