ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/calexpr.c
(Generate patch)

Comparing ray/src/common/calexpr.c (file contents):
Revision 1.5 by greg, Tue Jun 26 09:15:11 1990 UTC vs.
Revision 1.6 by greg, Thu Jul 19 12:56:50 1990 UTC

# Line 85 | Line 85 | double  (*eoper[])() = {               /* expression operations */
85          epow,
86   };
87  
88 static char  *infile;                   /* input file name */
88   static FILE  *infp;                     /* input file pointer */
89   static char  *linbuf;                   /* line buffer */
90 + static char  *infile;                   /* input file name */
91 + static int  lineno;                     /* input line number */
92   static int  linepos;                    /* position in buffer */
93  
94  
# Line 97 | Line 98 | char  *expr;
98   {
99      EPNODE  *ep;
100  
101 <    initstr(NULL, expr);
101 >    initstr(expr, NULL, 0);
102   #if  defined(VARIABLE) && defined(FUNCTION)
103      curfunc = NULL;
104   #endif
# Line 292 | Line 293 | register EPNODE  *ep;
293   }
294  
295  
296 < initfile(file, fp)              /* prepare input file */
296 < char  *file;
296 > initfile(fp, fn, ln)            /* prepare input file */
297   FILE  *fp;
298 + char  *fn;
299 + int  ln;
300   {
301      static char  inpbuf[MAXLINE];
302  
301    infile = file;
303      infp = fp;
304      linbuf = inpbuf;
305 +    infile = fn;
306 +    lineno = ln;
307      linepos = 0;
308      inpbuf[0] = '\0';
309      scan();
310   }
311  
312  
313 < initstr(file, s)                /* prepare input string */
311 < char  *file;
313 > initstr(s, fn, ln)              /* prepare input string */
314   char  *s;
315 + char  *fn;
316 + int  ln;
317   {
314    infile = file;
318      infp = NULL;
319 +    infile = fn;
320 +    lineno = ln;
321      linbuf = s;
322      linepos = 0;
323      scan();
# Line 327 | Line 332 | scan()                         /* scan next character */
332                  nextc = EOF;
333              else {
334                  nextc = linbuf[0];
335 +                lineno++;
336                  linepos = 1;
337              }
338          else
# Line 344 | Line 350 | scan()                         /* scan next character */
350   }
351  
352  
353 + char *
354 + ltoa(l)                         /* convert long to ascii */
355 + long  l;
356 + {
357 +    static char  buf[16];
358 +    register char  *cp;
359 +    int  neg = 0;
360 +
361 +    if (l == 0)
362 +        return("0");
363 +    if (l < 0) {
364 +        l = -l;
365 +        neg++;
366 +    }
367 +    cp = buf + sizeof(buf);
368 +    *--cp = '\0';
369 +    while (l) {
370 +        *--cp = l % 10 + '0';
371 +        l /= 10;
372 +    }
373 +    if (neg)
374 +        *--cp = '-';
375 +    return(cp);
376 + }
377 +
378 +
379   syntax(err)                     /* report syntax error and quit */
380   char  *err;
381   {
# Line 355 | Line 387 | char  *err;
387      for (i = 0; i < linepos-1; i++)
388          eputs(linbuf[i] == '\t' ? "\t" : " ");
389      eputs("^ ");
390 <    if (infile != NULL) {
391 <        eputs(infile);
390 >    if (infile != NULL || lineno != 0) {
391 >        eputs("\n");
392 >        if (infile != NULL) eputs(infile);
393 >        if (lineno != 0) {
394 >            eputs(infile != NULL ? ", line " : "line ");
395 >            eputs(ltoa((long)lineno));
396 >        }
397          eputs(": ");
398      }
399      eputs(err);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines