X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/7799334e368626f1065bcc66a2c355cf2007b062..dc0e9d5051968b633dbad1c43b90e583b0784799:/usr/src/usr.bin/error/touch.c diff --git a/usr/src/usr.bin/error/touch.c b/usr/src/usr.bin/error/touch.c index 65a236437c..86122b55a9 100644 --- a/usr/src/usr.bin/error/touch.c +++ b/usr/src/usr.bin/error/touch.c @@ -1,10 +1,31 @@ -static char *sccsid = "@(#)touch.c 1.6 (Berkeley) %G%"; -#include -#include +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that the above copyright notice and this paragraph are + * duplicated in all such forms and that any documentation, + * advertising materials, and other materials related to such + * distribution and use acknowledge that the software was developed + * by the University of California, Berkeley. The name of the + * University may not be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +#ifndef lint +static char sccsid[] = "@(#)touch.c 5.5 (Berkeley) %G%"; +#endif /* not lint */ + #include #include -#include +#include +#include +#include #include "error.h" +#include "pathnames.h" /* * Iterate through errors @@ -241,9 +262,13 @@ hackfile(name, files, ix, nerrors) boolean previewed; int errordest; /* where errors go*/ - previewed = preview(name, nerrors, files, ix); - - errordest = settotouch(name); + if (!oktotouch(name)) { + previewed = FALSE; + errordest = TOSTDOUT; + } else { + previewed = preview(name, nerrors, files, ix); + errordest = settotouch(name); + } if (errordest != TOSTDOUT) touchedfiles[ix] = TRUE; @@ -270,18 +295,16 @@ boolean preview(name, nerrors, files, ix) int back; reg Eptr *erpp; - if (!oktotouch(name)) - return(false); if (nerrors <= 0) - return(false); - back = false; + return(FALSE); + back = FALSE; if(query){ switch(inquire(terse ? "Preview? " : "Do you want to preview the errors first? ")){ case Q_YES: case Q_yes: - back = true; + back = TRUE; EITERATE(erpp, files, ix){ errorprint(stdout, *erpp, TRUE); } @@ -473,7 +496,7 @@ FILE *o_touchedfile; /* the old file */ FILE *n_touchedfile; /* the new file */ char *o_name; char n_name[64]; -char *canon_name = "/tmp/ErrorXXXXXX"; +char *canon_name = _PATH_TMP; int o_lineno; int n_lineno; boolean tempfileopen = FALSE; @@ -587,7 +610,7 @@ writetouched(overwrite) fclose(tmpfile); } if (oktorm == 0){ - fprintf(stderr, "%s: Catastrophe: A copy of \"%s\: was saved in \"%s\"\n", + fprintf(stderr, "%s: Catastrophe: A copy of \"%s\": was saved in \"%s\"\n", processname, o_name, n_name); exit(1); }