home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-03-24 | 28.0 KB | 1,076 lines |
- diff -cN orig/common.h src/common.h
- *** orig/common.h Sat Mar 24 19:42:28 1990
- --- src/common.h Wed Dec 27 14:03:26 1989
- ***************
- *** 28,34 ****
- --- 28,36 ----
- #define Fclose (void)fclose
- #define Fflush (void)fflush
- #define Sprintf (void)sprintf
- + #ifndef MSDOS
- #define Mktemp (void)mktemp
- + #endif
- #define Strcpy (void)strcpy
- #define Strcat (void)strcat
-
- ***************
- *** 38,43 ****
- --- 40,47 ----
- #include <sys/stat.h>
- #include <ctype.h>
- #include <signal.h>
- + #include <io.h>
- + #include <fcntl.h>
-
- /* constants */
-
- ***************
- *** 54,61 ****
- --- 58,70 ----
- #define CHECKOUT "co -l %s"
-
- #ifdef FLEXFILENAMES
- + #ifdef MSDOS
- + #define ORIGEXT ".org"
- + #define REJEXT ".rej"
- + #else
- #define ORIGEXT ".orig"
- #define REJEXT ".rej"
- + #endif
- #else
- #define ORIGEXT "~"
- #define REJEXT "#"
- ***************
- *** 110,119 ****
- --- 119,136 ----
- EXT char *origext INIT(Nullch);
- EXT char *origprae INIT(Nullch);
-
- + #ifdef MSDOS
- + EXT char TMPOUTNAME[80] INIT("poXXXXXX");
- + EXT char TMPINNAME[80] INIT("piXXXXXX"); /* might want /usr/tmp here */
- + EXT char TMPREJNAME[80] INIT("prXXXXXX");
- + EXT char TMPPATNAME[80] INIT("ppXXXXXX");
- + #else
- EXT char TMPOUTNAME[] INIT("/tmp/patchoXXXXXX");
- EXT char TMPINNAME[] INIT("/tmp/patchiXXXXXX"); /* might want /usr/tmp here */
- EXT char TMPREJNAME[] INIT("/tmp/patchrXXXXXX");
- EXT char TMPPATNAME[] INIT("/tmp/patchpXXXXXX");
- + #endif
- +
- EXT bool toutkeep INIT(FALSE);
- EXT bool trejkeep INIT(FALSE);
-
- ***************
- *** 144,156 ****
-
- EXT char *revision INIT(Nullch); /* prerequisite revision, if any */
-
- ! char *malloc();
- ! char *realloc();
- char *strcpy();
- char *strcat();
- long atol();
- long lseek();
- char *mktemp();
- #ifdef CHARSPRINTF
- char *sprintf();
- #else
- --- 161,178 ----
-
- EXT char *revision INIT(Nullch); /* prerequisite revision, if any */
-
- ! void *malloc();
- ! void *realloc();
- char *strcpy();
- char *strcat();
- long atol();
- long lseek();
- char *mktemp();
- +
- + #ifdef MSDOS
- + #undef stderr
- + FILE *stderr;
- + #endif
- #ifdef CHARSPRINTF
- char *sprintf();
- #else
- diff -cN orig/config.h src/config.h
- *** orig/config.h
- --- src/config.h Wed Dec 27 14:03:26 1989
- ***************
- *** 0 ****
- --- 1,123 ----
- + /* config.h
- + * This file was produced by running the config.h.SH script, which
- + * gets its values from config.sh, which is generally produced by
- + * running Configure.
- + *
- + * Feel free to modify any of this as the need arises. Note, however,
- + * that running config.h.SH again will wipe out any changes you've made.
- + * For a more permanent change edit config.sh and rerun config.h.SH.
- + */
- +
- +
- + /* EUNICE:
- + * This symbol, if defined, indicates that the program is being compiled
- + * under the EUNICE package under VMS. The program will need to handle
- + * things like files that don't go away the first time you unlink them,
- + * due to version numbering. It will also need to compensate for lack
- + * of a respectable link() command.
- + */
- + /* VMS:
- + * This symbol, if defined, indicates that the program is running under
- + * VMS. It is currently only set in conjunction with the EUNICE symbol.
- + */
- + #/*undef EUNICE /**/
- + #/*undef VMS /**/
- +
- + /* CPPSTDIN:
- + * This symbol contains the first part of the string which will invoke
- + * the C preprocessor on the standard input and produce to standard
- + * output. Typical value of "cc -E" or "/lib/cpp".
- + */
- + /* CPPMINUS:
- + * This symbol contains the second part of the string which will invoke
- + * the C preprocessor on the standard input and produce to standard
- + * output. This symbol will have the value "-" if CPPSTDIN needs a minus
- + * to specify standard input, otherwise the value is "".
- + */
- + #define CPPSTDIN "/usr/lib/cpp"
- + #define CPPMINUS ""
- +
- + /* CHARSPRINTF:
- + * This symbol is defined if this system declares "char *sprintf()" in
- + * stdio.h. The trend seems to be to declare it as "int sprintf()". It
- + * is up to the package author to declare sprintf correctly based on the
- + * symbol.
- + */
- + /*#define CHARSPRINTF /**/
- +
- + /* FLEXFILENAMES:
- + * This symbol, if defined, indicates that the system supports filenames
- + * longer than 14 characters.
- + */
- + #define FLEXFILENAMES /**/
- +
- + /* index:
- + * This preprocessor symbol is defined, along with rindex, if the system
- + * uses the strchr and strrchr routines instead.
- + */
- + /* rindex:
- + * This preprocessor symbol is defined, along with index, if the system
- + * uses the strchr and strrchr routines instead.
- + */
- + #define index strchr /* cultural */
- + #define rindex strrchr /* differences? */
- +
- + /* VOIDSIG:
- + * This symbol is defined if this system declares "void (*signal())()" in
- + * signal.h. The old way was to declare it as "int (*signal())()". It
- + * is up to the package author to declare things correctly based on the
- + * symbol.
- + */
- + #define VOIDSIG /**/
- +
- + /* Reg1:
- + * This symbol, along with Reg2, Reg3, etc. is either the word "register"
- + * or null, depending on whether the C compiler pays attention to this
- + * many register declarations. The intent is that you don't have to
- + * order your register declarations in the order of importance, so you
- + * can freely declare register variables in sub-blocks of code and as
- + * function parameters. Do not use Reg<n> more than once per routine.
- + */
- +
- + #define Reg1 register /**/
- + #define Reg2 register /**/
- + #define Reg3 /* register /**/
- + #define Reg4 /* register /**/
- + #define Reg5 /* register /**/
- + #define Reg6 /* register /**/
- + #define Reg7 /**/
- + #define Reg8 /**/
- + #define Reg9 /**/
- + #define Reg10 /**/
- + #define Reg11 /**/
- + #define Reg12 /**/
- + #define Reg13 /**/
- + #define Reg14 /**/
- + #define Reg15 /**/
- + #define Reg16 /**/
- +
- + /* VOIDFLAGS:
- + * This symbol indicates how much support of the void type is given by this
- + * compiler. What various bits mean:
- + *
- + * 1 = supports declaration of void
- + * 2 = supports arrays of pointers to functions returning void
- + * 4 = supports comparisons between pointers to void functions and
- + * addresses of void functions
- + *
- + * The package designer should define VOIDUSED to indicate the requirements
- + * of the package. This can be done either by #defining VOIDUSED before
- + * including config.h, or by defining defvoidused in Myinit.U. If the
- + * level of void support necessary is not present, defines void to int.
- + */
- +
- + #ifndef VOIDUSED
- + #define VOIDUSED 7
- + #endif
- +
- + #define VOIDFLAGS 7
- +
- + #if (VOIDFLAGS & VOIDUSED) != VOIDUSED
- + #define void int /* is void to be avoided? */
- + #define M_VOID /* Xenix strikes again */
- + #endif
- diff -cN orig/inp.c src/inp.c
- *** orig/inp.c Sat Mar 24 19:42:30 1990
- --- src/inp.c Sat Mar 10 20:19:38 1990
- ***************
- *** 79,84 ****
- --- 79,87 ----
- int ifd;
- Reg1 char *s;
- Reg2 LINENUM iline;
- + #ifdef MSDOS
- + int i_res;
- + #endif
-
- if (ok_to_create_file && stat(filename, &filestat) < 0) {
- if (verbose)
- ***************
- *** 115,120 ****
- --- 118,127 ----
- if ((filemode & S_IFMT) & ~S_IFREG)
- fatal2("%s is not a normal file--can't patch.\n", filename);
- i_size = filestat.st_size;
- + #ifdef MSDOS
- + if ( i_size > 65500L )
- + return FALSE;
- + #endif
- if (out_of_mem) {
- set_hunkmax(); /* make sure dynamic arrays are allocated */
- out_of_mem = FALSE;
- ***************
- *** 131,136 ****
- --- 138,153 ----
- if ((ifd = open(filename, 0)) < 0)
- fatal2("Can't open file %s\n", filename);
- #ifndef lint
- + #ifdef MSDOS
- + if ((i_res = read(ifd, i_womp, (int)i_size)) == -1) {
- + Close(ifd); /* probably means i_size > 15 or 16 bits worth */
- + free(i_womp); /* at this point it doesn't matter if i_womp was */
- + return FALSE; /* undersized. */
- + }
- + else
- + /* cr/lf-translations would bomb here (i_res is != file size)! */
- + i_size = i_res;
- + #else
- if (read(ifd, i_womp, (int)i_size) != i_size) {
- Close(ifd); /* probably means i_size > 15 or 16 bits worth */
- free(i_womp); /* at this point it doesn't matter if i_womp was */
- ***************
- *** 137,142 ****
- --- 154,160 ----
- return FALSE; /* undersized. */
- }
- #endif
- + #endif
- Close(ifd);
- if (i_size && i_womp[i_size-1] != '\n')
- i_womp[i_size++] = '\n';
- ***************
- *** 208,214 ****
- 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))
- --- 226,233 ----
- using_plan_a = FALSE;
- if ((ifp = fopen(filename, "r")) == 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));
- --- 255,261 ----
- 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);
- }
- }
- --- 277,284 ----
- }
- Fclose(ifp);
- Close(tifd);
- !
- ! if ((tifd = open(TMPINNAME, O_RDONLY|O_BINARY)) < 0) {
- fatal2("Can't reopen file %s\n", TMPINNAME);
- }
- }
- diff -cN orig/patch.c src/patch.c
- *** orig/patch.c Sat Mar 24 19:42:32 1990
- --- src/patch.c Wed Dec 27 14:03:26 1989
- ***************
- *** 111,117 ****
- --- 111,120 ----
- bool similar();
- void re_input();
- void my_exit();
- + char *strchr();
-
- + static char *myname;
- +
- /* Apply a set of diffs as appropriate. */
-
- main(argc,argv)
- ***************
- *** 126,133 ****
- --- 129,141 ----
- int failed = 0;
- int failtotal = 0;
- int i;
- + char *s;
-
- + #ifdef MSDOS
- + stderr = fopen("con", "w");
- + #endif
- setbuf(stderr, serrbuf);
- +
- for (i = 0; i<MAXFILEC; i++)
- filearg[i] = Nullch;
- Mktemp(TMPOUTNAME);
- ***************
- *** 138,143 ****
- --- 146,152 ----
- /* parse switches */
- Argc = argc;
- Argv = argv;
- + myname = argv[0];
- get_some_switches();
-
- /* make sure we clean up /tmp in case of disaster */
- ***************
- *** 300,307 ****
- if (s[12] == '.') /* try to preserve difference */
- s[12] = s[13]; /* between .h, .c, .y, etc. */
- s[13] = '\0';
- ! }
- #endif
- Strcat(rejname, REJEXT);
- }
- if (skip_rest_of_patch) {
- --- 309,321 ----
- if (s[12] == '.') /* try to preserve difference */
- s[12] = s[13]; /* between .h, .c, .y, etc. */
- s[13] = '\0';
- ! }
- ! #else
- ! #ifdef MSDOS
- ! if ((s=strchr(rejname,'.'))!=NULL)
- ! *s=0;
- #endif
- + #endif
- Strcat(rejname, REJEXT);
- }
- if (skip_rest_of_patch) {
- ***************
- *** 460,465 ****
- --- 474,483 ----
- case 'v':
- version();
- break;
- + case 'h':
- + Usage();
- + exit(0);
- + break;
- #ifdef DEBUGGING
- case 'x':
- debug = atoi(s+1);
- ***************
- *** 468,473 ****
- --- 486,492 ----
- default:
- /*fatal2("Unrecognized switch: %s\n", Argv[0]);*/
- printf("\nUnrecognized switch: %s.\n", Argv[0]);
- + Usage();
- exit(1);
- break;
- }
- ***************
- *** 475,480 ****
- --- 494,524 ----
- }
- }
-
- +
- + Usage()
- + {
- + 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("-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
- ***************
- *** 822,827 ****
- if (!trejkeep) {
- Unlink(TMPREJNAME);
- }
- ! Unlink(TMPPATNAME);
- exit(status);
- }
- --- 866,877 ----
- if (!trejkeep) {
- Unlink(TMPREJNAME);
- }
- !
- ! if ( pfp != NULL )
- ! {
- ! Fclose(pfp);
- ! Unlink(TMPPATNAME);
- ! }
- !
- exit(status);
- }
- diff -cN orig/patch.cs src/patch.cs
- *** orig/patch.cs
- --- src/patch.cs Sat Mar 10 20:04:48 1990
- ***************
- *** 0 ****
- --- 1,5 ----
- + (-W1 -Oxn -DCANVARARG PATCH.C PCH.C INP.C VERSION.C)
- + (-W1 -Od -DCANVARARG UTIL.C)
- + PATCH.DEF
- + PATCH.EXE
- + -AC -LB -S0x4000
- diff -cN orig/patch.def src/patch.def
- *** orig/patch.def
- --- src/patch.def Wed Dec 27 14:03:26 1989
- ***************
- *** 0 ****
- --- 1,2 ----
- + NAME PATCH WINDOWCOMPAT
- + DESCRIPTION 'Patches original files with diffs - for MS-DOS and OS/2'
- diff -cN orig/pch.c src/pch.c
- *** orig/pch.c Sat Mar 24 19:42:36 1990
- --- src/pch.c Wed Dec 27 14:03:26 1989
- ***************
- *** 81,87 ****
- {
- if (filename == Nullch || !*filename || strEQ(filename, "-"))
- {
- ! pfp = fopen(TMPPATNAME, "w");
- if (pfp == Nullfp)
- fatal2("patch: can't create %s.\n", TMPPATNAME);
- while (fgets(buf, sizeof buf, stdin) != Nullch)
- --- 81,93 ----
- {
- if (filename == Nullch || !*filename || strEQ(filename, "-"))
- {
- ! if ( isatty(fileno(stdin)) )
- ! {
- ! Usage();
- ! exit(1);
- ! }
- !
- ! pfp = fopen(TMPPATNAME, "wb");
- if (pfp == Nullfp)
- fatal2("patch: can't create %s.\n", TMPPATNAME);
- while (fgets(buf, sizeof buf, stdin) != Nullch)
- ***************
- *** 793,799 ****
- 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;
- --- 799,805 ----
- 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;
- ***************
- *** 1073,1082 ****
- --- 1079,1095 ----
- if (!skip_rest_of_patch) {
- Unlink(TMPOUTNAME);
- copy_file(filearg[0], TMPOUTNAME);
- + #ifdef MSDOS
- + if (verbose)
- + Sprintf(buf, "ed %s", TMPOUTNAME);
- + else
- + Sprintf(buf, "ed - %s", TMPOUTNAME);
- + #else
- if (verbose)
- Sprintf(buf, "/bin/ed %s", TMPOUTNAME);
- else
- Sprintf(buf, "/bin/ed - %s", TMPOUTNAME);
- + #endif
- pipefp = popen(buf, "w");
- }
- for (;;) {
- diff -cN orig/util.c src/util.c
- *** orig/util.c Sat Mar 24 19:42:38 1990
- --- src/util.c Sat Mar 24 20:02:38 1990
- ***************
- *** 5,10 ****
- --- 5,12 ----
-
- /* Rename a file, copying it if necessary. */
-
- + char *strchr();
- +
- 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)
- --- 23,29 ----
- 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)
- ***************
- *** 31,50 ****
- return 0;
- }
-
- ! if (origprae) {
- ! Strcpy (bakname, origprae);
- ! Strcat(bakname, to);
- ! } else {
- ! Strcpy(bakname, to);
- ! Strcat(bakname, origext?origext:ORIGEXT);
- ! }
- if (stat(to, &filestat) >= 0) { /* output file exists */
- dev_t to_device = filestat.st_dev;
- ino_t to_inode = filestat.st_ino;
- char *simplename = bakname;
-
- ! for (s=bakname; *s; s++) {
- ! if (*s == '/')
- simplename = s+1;
- }
- /* find a backup name that is not the same file */
- --- 33,61 ----
- return 0;
- }
-
- ! if (origprae) {
- ! Strcpy (bakname, origprae);
- ! Strcat(bakname, to);
- ! } else {
- ! Strcpy(bakname, to);
- ! #ifdef MSDOS
- ! if ((s=strchr(bakname,'.'))!=NULL)
- ! *s=0;
- ! #endif
- ! Strcat(bakname, origext?origext:ORIGEXT);
- ! }
- !
- if (stat(to, &filestat) >= 0) { /* output file exists */
- dev_t to_device = filestat.st_dev;
- ino_t to_inode = filestat.st_ino;
- char *simplename = bakname;
-
- ! for (s=bakname; *s; s++) {
- ! #ifdef MSDOS
- ! if (*s == '/' || *s == '\\')
- ! #else
- ! if (*s == '/')
- ! #endif
- simplename = s+1;
- }
- /* find a backup name that is not the same file */
- ***************
- *** 56,87 ****
- else
- Strcpy(simplename, simplename+1);
- }
- while (unlink(bakname) >= 0) ; /* while() is for benefit of Eunice */
- #ifdef DEBUGGING
- if (debug & 4)
- say3("Moving %s to %s.\n", to, bakname);
- #endif
- if (link(to, bakname) < 0) {
- say3("patch: can't backup %s, output is in %s\n",
- to, from);
- return -1;
- }
- while (unlink(to) >= 0) ;
- }
- #ifdef DEBUGGING
- 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)
- --- 67,115 ----
- else
- Strcpy(simplename, simplename+1);
- }
- +
- while (unlink(bakname) >= 0) ; /* while() is for benefit of Eunice */
- +
- #ifdef DEBUGGING
- if (debug & 4)
- say3("Moving %s to %s.\n", to, bakname);
- #endif
- +
- + #ifdef MSDOS
- + 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 MSDOS
- while (unlink(to) >= 0) ;
- + #endif
- }
- +
- #ifdef DEBUGGING
- if (debug & 4)
- say3("Moving %s to %s.\n", from, to);
- #endif
- +
- + #ifdef MSDOS
- + 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 ****
- --- 117,129 ----
- fatal1("patch: write failed\n");
- Close(fromfd);
- Close(tofd);
- + #ifdef MSDOS
- + 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)
- --- 137,146 ----
- 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 ****
- --- 190,221 ----
-
- /* Vanilla terminal output (buffered). */
-
- + #ifdef MSDOS
- + #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 ****
- --- 237,258 ----
- say(pat, arg1, arg2, arg3);
- my_exit(1);
- }
- + #endif
-
- /* Get a response from the user, somehow or other. */
-
- + #ifdef MSDOS
- + 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 ****
- --- 263,269 ----
- 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);
- --- 274,284 ----
- write(1, buf, strlen(buf));
- r = read(1, buf, sizeof buf);
- }
- ! #ifdef MSDOS
- ! 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 ****
- --- 317,323 ----
- #endif
-
- if (!reset) {
- + #ifndef MSDOS
- hupval = signal(SIGHUP, SIG_IGN);
- if (hupval != SIG_IGN)
- #ifdef VOIDSIG
- ***************
- *** 247,252 ****
- --- 325,331 ----
- #else
- hupval = (int(*)())my_exit;
- #endif
- + #endif
- intval = signal(SIGINT, SIG_IGN);
- if (intval != SIG_IGN)
- #ifdef VOIDSIG
- ***************
- *** 255,261 ****
- --- 334,342 ----
- intval = (int(*)())my_exit;
- #endif
- }
- + #ifndef MSDOS
- Signal(SIGHUP, hupval);
- + #endif
- Signal(SIGINT, intval);
- #endif
- }
- ***************
- *** 266,272 ****
- --- 347,355 ----
- ignore_signals()
- {
- #ifndef lint
- + #ifndef MSDOS
- Signal(SIGHUP, SIG_IGN);
- + #endif
- Signal(SIGINT, SIG_IGN);
- #endif
- }
- ***************
- *** 285,291 ****
- Reg4 int dirvp = 0;
-
- while (*filename) {
- ! if (*filename == '/') {
- filename++;
- dirv[dirvp++] = s;
- *s++ = '\0';
- --- 368,378 ----
- Reg4 int dirvp = 0;
-
- while (*filename) {
- ! #ifdef MSDOS
- ! if (*filename == '/' || *filename == '\\') {
- ! #else
- ! if (*filename == '/') {
- ! #endif
- filename++;
- dirv[dirvp++] = s;
- *s++ = '\0';
- ***************
- *** 336,346 ****
- if (strnEQ(name, "/dev/null", 9)) /* so files can be created by diffing */
- return Nullch; /* against /dev/null. */
- for (; *t && !isspace(*t); t++)
- ! if (*t == '/')
- if (--strip_leading >= 0)
- name = t+1;
- *t = '\0';
- if (name != s && *s != '/') {
- name[-1] = '\0';
- if (stat(s, &filestat) && filestat.st_mode & S_IFDIR) {
- name[-1] = '/';
- --- 423,441 ----
- if (strnEQ(name, "/dev/null", 9)) /* so files can be created by diffing */
- return Nullch; /* against /dev/null. */
- for (; *t && !isspace(*t); t++)
- ! #ifdef MSDOS
- ! if (*t == '/' || *t == '\\')
- ! #else
- ! if (*t == '/')
- ! #endif
- if (--strip_leading >= 0)
- name = t+1;
- *t = '\0';
- + #ifdef MSDOS
- + 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 ****
- --- 457,536 ----
- }
- return name;
- }
- +
- +
- + #ifdef MSDOS
- +
- + char *getenv();
- +
- + 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);
- + }
- +
- + /* only one pipe can be open at a time */
- +
- + 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
- diff -cN orig/version.c src/version.c
- *** orig/version.c Sat Mar 24 19:42:40 1990
- --- src/version.c Wed Dec 27 14:03:26 1989
- ***************
- *** 10,16 ****
- #include "common.h"
- #include "util.h"
- #include "INTERN.h"
- ! #include "patchlevel.h"
- #include "version.h"
-
- /* Print out the version number and die. */
- --- 10,16 ----
- #include "common.h"
- #include "util.h"
- #include "INTERN.h"
- ! #include "patchlev.h"
- #include "version.h"
-
- /* Print out the version number and die. */
- ***************
- *** 23,28 ****
- #ifdef lint
- rcsid[0] = rcsid[0];
- #else
- ! fatal3("\n%s\nPatch level: %d\n", rcsid, PATCHLEVEL);
- #endif
- }
- --- 23,28 ----
- #ifdef lint
- rcsid[0] = rcsid[0];
- #else
- ! fatal3("\n%s\nPatch level: %d (DOS & OS/2)\n", rcsid, PATCHLEVEL);
- #endif
- }
-