diff -cr ram:patch-2.0.12g8/backupfile.c dh2:patch-2.0.12g8/backupfile.c *** ram:patch-2.0.12g8/backupfile.c Fri Jan 08 20:36:12 1993 --- dh2:patch-2.0.12g8/backupfile.c Sun Nov 22 00:12:06 1992 *************** *** 42,52 **** --- 42,57 ---- #else /* !DIRENT */ #define NLENGTH(direct) ((direct)->d_namlen) #ifdef USG + #ifdef AMIGA + #include + #define direct dirent + #else /* !AMIGA */ #ifdef SYSNDIR #include #else /* !SYSNDIR */ #include #endif /* !SYSNDIR */ + #endif /* !AMIGA */ #else /* !USG */ #ifdef SYSDIR #include *************** *** 72,83 **** --- 77,96 ---- #define REAL_DIR_ENTRY(dp) ((dp)->d_ino != 0) #endif + #ifdef AMIGA + #define max(a,b) (((a)>(b))?(a):(b)) + #endif /* AMIGA */ + /* Which type of backup file names are generated. */ enum backup_type backup_type = none; /* The extension added to file names to produce a simple (as opposed to numbered) backup file name. */ + #ifndef AMIGA char *simple_backup_suffix = "~"; + #else /* AMIGA */ + char *simple_backup_suffix = "!"; + #endif /* AMIGA */ char *basename (); char *dirname (); *************** *** 103,109 **** --- 116,126 ---- if (backup_type == simple) return concat (file, simple_backup_suffix); + #ifndef AMIGA base_versions = concat (basename (file), ".~"); + #else /* AMIGA */ + base_versions = concat (basename (file), ".!"); + #endif /* AMIGA */ if (base_versions == 0) return 0; dir = dirname (file); *************** *** 168,174 **** --- 185,195 ---- backup_name = malloc (strlen (file) + 16); if (backup_name == 0) return 0; + #ifndef AMIGA sprintf (backup_name, "%s.~%d~", file, version); + #else /* AMIGA */ + sprintf (backup_name, "%s.!%d!", file, version); + #endif /* AMIGA */ return backup_name; } *************** *** 190,196 **** --- 211,221 ---- { for (p = &backup[base_length]; ISDIGIT (*p); ++p) version = version * 10 + *p - '0'; + #ifndef AMIGA if (p[0] != '~' || p[1]) + #else /* AMIGA */ + if (p[0] != '!' || p[1]) + #endif /* AMIGA */ version = 0; } return version; *************** *** 220,229 **** --- 245,263 ---- basename (name) char *name; { + #ifndef AMIGA char *base; base = rindex (name, '/'); return base ? base + 1 : name; + #else /* AMIGA */ + char *base1, *base2, *base; + + base1 = rindex (name, '/'); + base2 = rindex (name, ':'); + base = max (base1, base2); + return base ? base + 1 : name; + #endif /* AMIGA */ } /* Return the leading directories part of PATH, *************** *** 235,240 **** --- 269,275 ---- dirname (path) char *path; { + #ifndef AMIGA char *newpath; char *slash; int length; /* Length of result, not including NUL. */ *************** *** 260,265 **** --- 295,329 ---- strncpy (newpath, path, length); newpath[length] = 0; return newpath; + #else /* AMIGA */ + char *newpath; + char *slash, *colon, *dirsep; + int length; /* Length of result, not including NUL. */ + + slash = rindex (path, '/'); + colon = rindex (path, ':'); + dirsep = max (slash, colon); + if (dirsep == 0) + { + /* File is in the current directory. */ + path = ""; + length = 0; + } + else + { + /* Remove one trailing slash from result, if exists. */ + if (dirsep > path && *dirsep == '/') + --dirsep; + + length = dirsep - path + 1; + } + newpath = malloc (length + 1); + if (newpath == 0) + return 0; + strncpy (newpath, path, length); + newpath[length] = 0; + return newpath; + #endif /* AMIGA */ } /* If ARG is an unambiguous match for an element of the diff -cr ram:patch-2.0.12g8/inp.c dh2:patch-2.0.12g8/inp.c *** ram:patch-2.0.12g8/inp.c Fri Jan 08 20:36:13 1993 --- dh2:patch-2.0.12g8/inp.c Fri Jan 08 20:38:08 1993 *************** *** 79,85 **** --- 79,87 ---- int ifd, statfailed; Reg1 char *s; Reg2 LINENUM iline; + #ifndef AMIGA char lbuf[MAXLINELEN]; + #endif /* !AMIGA */ statfailed = stat(filename, &filestat); if (statfailed && ok_to_create_file) { *************** *** 89,94 **** --- 91,97 ---- close(creat(filename, 0666)); statfailed = stat(filename, &filestat); } + #ifndef AMIGA /* For nonexistent or read-only files, look for RCS or SCCS versions. */ if (statfailed /* No one can write to it. */ *************** *** 146,151 **** --- 149,159 ---- } } filemode = filestat.st_mode; + #else /* AMIGA */ + if (statfailed) + fatal2("can't find %s\n", filename); + filemode = filestat.st_mode; + #endif /* AMIGA */ if (!S_ISREG(filemode)) fatal2("%s is not a normal file--can't patch\n", filename); i_size = filestat.st_size; diff -cr ram:patch-2.0.12g8/patch.c dh2:patch-2.0.12g8/patch.c *** ram:patch-2.0.12g8/patch.c Fri Jan 08 20:36:14 1993 --- dh2:patch-2.0.12g8/patch.c Tue Nov 24 11:11:46 1992 *************** *** 90,95 **** --- 90,99 ---- * */ + #ifdef AMIGA + #include + #include + #endif /* AMIGA */ #include "INTERN.h" #include "common.h" #include "EXTERN.h" *************** *** 116,121 **** --- 120,129 ---- bool similar(); void re_input(); void my_exit(); + #ifdef AMIGA + void amiga_exit(); + static char curpath[256]; + #endif /* AMIGA */ /* TRUE if -E was specified on command line. */ static int remove_empty_files = FALSE; *************** *** 139,148 **** int failtotal = 0; int i; setbuf(stderr, serrbuf); for (i = 0; i= 0) ; /* while is for Eunice. */ + #else /* AMIGA */ + Unlink(realout); + #endif /* AMIGA */ } } Fclose(rejfp); *************** *** 950,953 **** --- 993,1010 ---- } Unlink(TMPPATNAME); exit(status); + } + + void + amiga_exit() + { + unlink(TMPINNAME); + if (!toutkeep) { + Unlink(TMPOUTNAME); + } + if (!trejkeep) { + Unlink(TMPREJNAME); + } + Unlink(TMPPATNAME); + chdir(curpath); } diff -cr ram:patch-2.0.12g8/pch.c dh2:patch-2.0.12g8/pch.c *** ram:patch-2.0.12g8/pch.c Fri Jan 08 20:36:14 1993 --- dh2:patch-2.0.12g8/pch.c Sun Nov 22 11:58:10 1992 *************** *** 1246,1251 **** --- 1246,1252 ---- void do_ed_script() { + #ifndef AMIGA Reg1 char *t; Reg2 long beginning_of_this_line; Reg3 bool this_line_is_command = FALSE; *************** *** 1302,1305 **** --- 1303,1310 ---- else chmod(outname, filemode); set_signals(1); + #else /* AMIGA */ + fprintf (stderr, "Ed scripts are not supported in the Amiga version of patch!\n"); + my_exit (20); + #endif /* AMIGA */ } diff -cr ram:patch-2.0.12g8/util.c dh2:patch-2.0.12g8/util.c *** ram:patch-2.0.12g8/util.c Fri Jan 08 20:36:16 1993 --- dh2:patch-2.0.12g8/util.c Tue Nov 24 09:59:24 1992 *************** *** 66,71 **** --- 66,72 ---- } if (stat(to, &filestat) == 0) { /* output file exists */ + #ifndef AMIGA dev_t to_device = filestat.st_dev; ino_t to_inode = filestat.st_ino; char *simplename = bakname; *************** *** 74,79 **** --- 75,90 ---- if (*s == '/') simplename = s+1; } + #else /* AMIGA */ + char *simplename = bakname; + + for (s=bakname; *s; s++) { + if (*s == '/' || *s == ':') + simplename = s+1; + } + #endif /* AMIGA */ + + #ifndef AMIGA /* Find a backup name that is not the same file. Change the first lowercase char into uppercase; if that isn't sufficient, chop off the first char and try again. */ *************** *** 87,92 **** --- 98,108 ---- Strcpy(simplename, simplename+1); } while (unlink(bakname) >= 0) ; /* while() is for benefit of Eunice */ + #else /* AMIGA */ + /* The stuff above is not very meaningful on the Amiga */ + Unlink(bakname); + #endif /* AMIGA */ + #ifdef DEBUGGING if (debug & 4) say3("Moving %s to %s.\n", to, bakname); *************** *** 96,108 **** --- 112,132 ---- strerror(errno)); return -1; } + #ifndef AMIGA while (unlink(to) >= 0) ; + #else /* AMIGA */ + Unlink(to); + #endif /* AMIGA */ } #ifdef DEBUGGING if (debug & 4) say3("Moving %s to %s.\n", from, to); #endif + #ifndef AMIGA if (rename(from, to) < 0) { /* different file system? */ + #else /* AMIGA */ + if (rename(from, to) != 0) { /* different file system? */ + #endif /* AMIGA */ Reg4 int tofd; tofd = creat(to, 0666); *************** *** 225,230 **** --- 249,255 ---- my_exit(1); } + #ifndef AMIGA /* Get a response from the user, somehow or other. */ void *************** *** 269,274 **** --- 294,334 ---- if (!tty2) say1(buf); } + #else /* AMIGA */ + /* The closest thing to "/dev/tty" on the Amiga is called "*". + Open it in any case, because stdin may be redirected, and the + user can't tell the difference if it's not redirected :-). + I think this will work with the ARP shell under Kick 1.3 too, + but I have no way to tell... */ + + void + ask(pat,arg1,arg2,arg3) + char *pat; + long arg1,arg2,arg3; + { + int console; + long r; + + + Sprintf (buf, pat, arg1, arg2, arg3); + console = open ("*", O_RDWR | O_CREAT); + if (console >= NULL) + { + write (console, buf, strlen (buf)); + r = read (console, buf, sizeof (buf)); + Close (console); + } + else + { /* no terminal at all--default it */ + buf[0] = '\n'; + r = 1; + } + if (r <= 0) + buf[0]=0; + else + buf[r]=0; + } + #endif /* AMIGA */ #endif /* lint */ /* How to handle certain events when not in a critical region. */ *************** *** 278,294 **** --- 338,362 ---- int reset; { #ifndef lint + #ifndef AMIGA static RETSIGTYPE (*hupval)(),(*intval)(); + #else /* AMIGA */ + static RETSIGTYPE (*intval)(); + #endif /* AMIGA */ if (!reset) { + #ifndef AMIGA hupval = signal(SIGHUP, SIG_IGN); if (hupval != SIG_IGN) hupval = (RETSIGTYPE(*)())my_exit; + #endif /* !AMIGA */ intval = signal(SIGINT, SIG_IGN); if (intval != SIG_IGN) intval = (RETSIGTYPE(*)())my_exit; } + #ifndef AMIGA Signal(SIGHUP, hupval); + #endif /* !AMIGA */ Signal(SIGINT, intval); #endif } *************** *** 299,305 **** --- 367,375 ---- ignore_signals() { #ifndef lint + #ifndef AMIGA Signal(SIGHUP, SIG_IGN); + #endif /* !AMIGA */ Signal(SIGINT, SIG_IGN); #endif } *************** *** 337,343 **** --- 407,417 ---- if (dirvp < 0) return; + #ifndef AMIGA strcpy(buf, "mkdir"); + #else /* AMIGA */ + strcpy(buf, "makedir"); + #endif /* AMIGA */ s = buf; for (i=0; i<=dirvp; i++) { struct stat sbuf; *************** *** 364,370 **** --- 438,446 ---- char *fullname; char *name; Reg1 char *t; + #ifndef AMIGA char tmpbuf[200]; + #endif /* !AMIGA */ int sleading = strip_leading; if (!at) *************** *** 375,389 **** --- 451,484 ---- if (debug & 128) say4("fetchname %s %d %d\n",at,strip_leading,assume_exists); #endif + #ifndef AMIGA if (strnEQ(at, "/dev/null", 9)) /* so files can be created by diffing */ return Nullch; /* against /dev/null. */ + #else /* AMIGA */ + /* This probably doesn't make much sense since you can't diff + against NIL: on the Amiga... */ + if (strnEQ(at, "NIL:", 9)) /* so files can be created by diffing */ + return Nullch; /* against NIL:. */ + #endif /* AMIGA */ + name = fullname = t = savestr(at); + #ifndef AMIGA /* Strip off up to `sleading' leading slashes and null terminate. */ for (; *t && !isspace(*t); t++) if (*t == '/') if (--sleading >= 0) name = t+1; + #else /* AMIGA */ + /* Strip off up to `sleading' leading slashes or colons and null terminate. */ + /* Please note that filenames with spaces are not handled correctly due + to the output format of diff and the assumptions that patch has to + make because of this output format. */ + for (; *t && !isspace(*t); t++) + if (*t == '/' || *t == ':') + if (--sleading >= 0) + name = t+1; + #endif /* AMIGA */ *t = '\0'; /* If no -p option was given (957 is the default value!), *************** *** 390,395 **** --- 485,491 ---- we were given a relative pathname, and the leading directories that we just stripped off all exist, put them back on. */ + #ifndef AMIGA if (strip_leading == 957 && name != fullname && *fullname != '/') { name[-1] = '\0'; if (stat(fullname, &filestat) == 0 && S_ISDIR (filestat.st_mode)) { *************** *** 397,406 **** --- 493,512 ---- name=fullname; } } + #else /* AMIGA */ + if (strip_leading == 957 && name != fullname && strchr(fullname,':') == NULL) { + name[-1] = '\0'; + if (stat(fullname, &filestat) == 0 && S_ISDIR (filestat.st_mode)) { + name[-1] = '/'; + name=fullname; + } + } + #endif /* AMIGA */ name = savestr(name); free(fullname); + #ifndef AMIGA if (stat(name, &filestat) && !assume_exists) { char *filebase = basename(name); int pathlen = filebase - name; *************** *** 418,423 **** --- 524,533 ---- free(name); name = Nullch; } + #else /* AMIGA */ + if (stat(name, &filestat) && !assume_exists) + name = Nullch; + #endif /* AMIGA */ return name; }