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

Comparing ray/src/common/wordfile.c (file contents):
Revision 2.3 by greg, Sat Oct 17 08:08:02 1992 UTC vs.
Revision 2.9 by greg, Tue Feb 25 02:47:22 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1992 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char       RCSid[] = "$Id$";
3   #endif
6
4   /*
5   * Load whitespace separated words from a file into an array.
6   * Assume the passed pointer array is big enough to hold them all.
7 + *
8 + * External symbols declared in standard.h
9   */
10  
11 + #include "copyright.h"
12 +
13   #include <ctype.h>
14  
15   #define NULL            0
# Line 27 | Line 28 | char   *fname;
28          char    buf[MAXFLEN];
29          register int    n;
30                                          /* load file into buffer */
31 +        if (fname == NULL)
32 +                return(-1);                     /* no filename */
33          if ((fd = open(fname, 0)) < 0)
34                  return(-1);                     /* open error */
35          n = read(fd, buf, MAXFLEN);
# Line 55 | Line 58 | char   *str;
58          if (cp == NULL)                 /* ENOMEM */
59                  return(-1);
60          strcpy(cp, str);
61 <        for (ap = avl; *cp; *cp++ = '\0') {
62 <                while (isspace(*cp))    /* skip leading space */
63 <                        cp++;
64 <                if (*cp) {              /* add argument to list */
65 <                        *ap++ = cp;
66 <                        while (*cp && !isspace(*cp))
67 <                                cp++;
68 <                }
61 >        ap = avl;               /* parse into words */
62 >        for ( ; ; ) {
63 >                while (isspace(*cp))    /* nullify spaces */
64 >                        *cp++ = '\0';
65 >                if (!*cp)               /* all done? */
66 >                        break;
67 >                *ap++ = cp;             /* add argument to list */
68 >                while (*++cp && !isspace(*cp))
69 >                        ;
70          }
71          *ap = NULL;
72          return(ap - avl);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines