ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/fgetline.c
Revision: 1.1
Committed: Wed Oct 4 15:48:15 1989 UTC (34 years, 7 months ago) by greg
Content type: text/plain
Branch: MAIN
Log Message:
Initial revision

File Contents

# Content
1 /* Copyright (c) 1989 Regents of the University of California */
2
3 #ifndef lint
4 static char SCCSid[] = "$SunId$ LBL";
5 #endif
6
7 /*
8 * fgetline.c - read line with escaped newlines
9 *
10 * 10/4/89
11 */
12
13 #include <stdio.h>
14
15
16 char *
17 fgetline(s, n, fp) /* read in line with escapes, elide final newline */
18 char *s;
19 register int n;
20 FILE *fp;
21 {
22 register char *cp;
23 register int c;
24
25 cp = s;
26 while (--n > 0 && (c = getc(fp)) != EOF && c != '\n') {
27 if (c == '\\') {
28 if ((c = getc(fp)) == EOF)
29 break;
30 }
31 *cp++ = c;
32 }
33 if (cp == s)
34 return(NULL);
35 *cp++ = '\0';
36 return(s);
37 }