file reorg, pathnames.h, paths.h
[unix-history] / usr / src / usr.bin / error / touch.c
index 65a2364..86122b5 100644 (file)
@@ -1,10 +1,31 @@
-static char *sccsid = "@(#)touch.c     1.6 (Berkeley) %G%";
-#include <stdio.h>
-#include <ctype.h>
+/*
+ * 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 <sys/types.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <signal.h>
+#include <sys/signal.h>
+#include <stdio.h>
+#include <ctype.h>
 #include "error.h"
 #include "error.h"
+#include "pathnames.h"
 
 /*
  *     Iterate through errors
 
 /*
  *     Iterate through errors
@@ -241,9 +262,13 @@ hackfile(name, files, ix, nerrors)
        boolean previewed;
        int     errordest;      /* where errors go*/
 
        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;
 
        if (errordest != TOSTDOUT)
                touchedfiles[ix] = TRUE;
@@ -270,18 +295,16 @@ boolean preview(name, nerrors, files, ix)
        int     back;
        reg     Eptr    *erpp;
 
        int     back;
        reg     Eptr    *erpp;
 
-       if (!oktotouch(name))
-               return(false);
        if (nerrors <= 0)
        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:
        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);
                        }
                        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];
 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;
 int    o_lineno;
 int    n_lineno;
 boolean        tempfileopen = FALSE;
@@ -587,7 +610,7 @@ writetouched(overwrite)
                        fclose(tmpfile);
        }
        if (oktorm == 0){
                        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);
        }
                        processname, o_name, n_name);
                exit(1);
        }