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.10 by schorsch, Sat Jun 7 12:50:21 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 + #include <string.h>
15 + #include <stdio.h>
16 + #include <sys/types.h>
17 + #include <sys/stat.h>
18 + #include <fcntl.h>
19  
20 < #define NULL            0
20 > #ifdef _WIN32
21 > #include <io.h>
22 > #endif
23  
24 + #include "standard.h"
25 +
26 +
27   #define MAXFLEN         8192            /* file must be smaller than this */
28  
29   extern char     *bmalloc();
# Line 27 | Line 38 | char   *fname;
38          char    buf[MAXFLEN];
39          register int    n;
40                                          /* load file into buffer */
41 +        if (fname == NULL)
42 +                return(-1);                     /* no filename */
43          if ((fd = open(fname, 0)) < 0)
44                  return(-1);                     /* open error */
45          n = read(fd, buf, MAXFLEN);
# Line 55 | Line 68 | char   *str;
68          if (cp == NULL)                 /* ENOMEM */
69                  return(-1);
70          strcpy(cp, str);
71 <        for (ap = avl; *cp; *cp++ = '\0') {
72 <                while (isspace(*cp))    /* skip leading space */
73 <                        cp++;
74 <                if (*cp) {              /* add argument to list */
75 <                        *ap++ = cp;
76 <                        while (*cp && !isspace(*cp))
77 <                                cp++;
78 <                }
71 >        ap = avl;               /* parse into words */
72 >        for ( ; ; ) {
73 >                while (isspace(*cp))    /* nullify spaces */
74 >                        *cp++ = '\0';
75 >                if (!*cp)               /* all done? */
76 >                        break;
77 >                *ap++ = cp;             /* add argument to list */
78 >                while (*++cp && !isspace(*cp))
79 >                        ;
80          }
81          *ap = NULL;
82          return(ap - avl);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines