=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/patch/util.c,v retrieving revision 1.26 retrieving revision 1.27 diff -c -r1.26 -r1.27 *** src/usr.bin/patch/util.c 2003/08/15 08:00:51 1.26 --- src/usr.bin/patch/util.c 2003/10/31 20:20:45 1.27 *************** *** 1,4 **** ! /* $OpenBSD: util.c,v 1.26 2003/08/15 08:00:51 otto Exp $ */ /* * patch - a program to apply diffs to original files --- 1,4 ---- ! /* $OpenBSD: util.c,v 1.27 2003/10/31 20:20:45 millert Exp $ */ /* * patch - a program to apply diffs to original files *************** *** 27,33 **** */ #ifndef lint ! static const char rcsid[] = "$OpenBSD: util.c,v 1.26 2003/08/15 08:00:51 otto Exp $"; #endif /* not lint */ #include --- 27,33 ---- */ #ifndef lint ! static const char rcsid[] = "$OpenBSD: util.c,v 1.27 2003/10/31 20:20:45 millert Exp $"; #endif /* not lint */ #include *************** *** 330,338 **** * Make filenames more reasonable. */ char * ! fetchname(const char *at, int strip_leading, int assume_exists) { ! char *fullname, *name, *t, tmpbuf[200]; int sleading; struct stat filestat; --- 330,338 ---- * Make filenames more reasonable. */ char * ! fetchname(const char *at, bool *exists, int strip_leading) { ! char *fullname, *name, *t; int sleading; struct stat filestat; *************** *** 342,348 **** at++; #ifdef DEBUGGING if (debug & 128) ! say("fetchname %s %d %d\n", at, strip_leading, assume_exists); #endif /* So files can be created by diffing against /dev/null. */ if (strnEQ(at, _PATH_DEVNULL, sizeof(_PATH_DEVNULL) - 1)) --- 342,348 ---- at++; #ifdef DEBUGGING if (debug & 128) ! say("fetchname %s %d\n", at, strip_leading); #endif /* So files can be created by diffing against /dev/null. */ if (strnEQ(at, _PATH_DEVNULL, sizeof(_PATH_DEVNULL) - 1)) *************** *** 372,394 **** name = savestr(name); free(fullname); ! if (stat(name, &filestat) && !assume_exists) { ! char *filebase = basename(name); ! char *filedir = dirname(name); #define try(f, a1, a2, a3) \ ! (snprintf(tmpbuf, sizeof tmpbuf, f, a1, a2, a3), stat(tmpbuf, &filestat) == 0) ! if (try("%s/RCS/%s%s", filedir, filebase, RCSSUFFIX) || ! try("%s/RCS/%s%s", filedir, filebase, "") || ! try("%s/%s%s", filedir, filebase, RCSSUFFIX) || ! try("%s/SCCS/%s%s", filedir, SCCSPREFIX, filebase) || ! try("%s/%s%s", filedir, SCCSPREFIX, filebase)) ! return name; ! free(name); ! name = NULL; ! } ! return name; } void --- 372,405 ---- name = savestr(name); free(fullname); ! *exists = stat(name, &filestat) == 0; ! return name; ! } + /* + * Takes the name returned by fetchname and looks in RCS/SCCS directories + * for a checked in version. + */ + char * + checked_in(char *file) + { + char *filebase, *filedir, tmpbuf[MAXPATHLEN]; + struct stat filestat; + + filebase = basename(file); + filedir = dirname(file); + #define try(f, a1, a2, a3) \ ! (snprintf(tmpbuf, sizeof tmpbuf, f, a1, a2, a3), stat(tmpbuf, &filestat) == 0) ! if (try("%s/RCS/%s%s", filedir, filebase, RCSSUFFIX) || ! try("%s/RCS/%s%s", filedir, filebase, "") || ! try("%s/%s%s", filedir, filebase, RCSSUFFIX) || ! try("%s/SCCS/%s%s", filedir, SCCSPREFIX, filebase) || ! try("%s/%s%s", filedir, SCCSPREFIX, filebase)) ! return file; ! ! return NULL; } void