added error handling for the "file" command
authorMark Linton <linton@ucbvax.Berkeley.EDU>
Thu, 20 May 1982 11:35:44 +0000 (03:35 -0800)
committerMark Linton <linton@ucbvax.Berkeley.EDU>
Thu, 20 May 1982 11:35:44 +0000 (03:35 -0800)
SCCS-vsn: usr.bin/pascal/pdx/tree/eval.c 1.8

usr/src/usr.bin/pascal/pdx/tree/eval.c

index fe41721..feec3bf 100644 (file)
@@ -1,6 +1,6 @@
 /* Copyright (c) 1982 Regents of the University of California */
 
 /* Copyright (c) 1982 Regents of the University of California */
 
-static char sccsid[] = "@(#)eval.c 1.7 %G%";
+static char sccsid[] = "@(#)eval.c 1.8 %G%";
 
 /*
  * Parse tree evaluation.
 
 /*
  * Parse tree evaluation.
@@ -32,6 +32,7 @@ register NODE *p;
 {
     long r0, r1;
     double fr0, fr1;
 {
     long r0, r1;
     double fr0, fr1;
+    FILE *fp;
 
     if (p == NULL) {
        return;
 
     if (p == NULL) {
        return;
@@ -264,7 +265,13 @@ register NODE *p;
            if (p->sconval == NIL) {
                printf("%s\n", cursource);
            } else {
            if (p->sconval == NIL) {
                printf("%s\n", cursource);
            } else {
-               skimsource(p->sconval);
+               fp = fopen(p->sconval, "r");
+               if (fp == NIL) {
+                   error("can't read \"%s\"", p->sconval);
+               } else {
+                   fclose(fp);
+                   skimsource(p->sconval);
+               }
            }
            break;
 
            }
            break;