|
|
1.1 root 1: .TH GETFLDS 3S
2: .SH NAME
3: getflds \(mi read a line from a file and break it into fields
4: .SH SYNOPSIS
5: .nf
6: .B #include <stdio.h>
7: .PP
8: .B char **getflds(stream)
9: .B FILE *stream;
10: .fi
11: .SH DESCRIPTION
12: .I Getflds
13: reads a line from the
14: .I stream
15: given as argument, breaks it into fields,
16: and returns a pointer to a null-terminated array of
17: character pointers, each of which points
18: to a null-terminated string representing one field.
19: These strings, and the array that points to them,
20: persist until the next call to
21: .IR getflds .
22: On end of file, a null pointer is returned.
23: .PP
24: If the first character of a line is a
25: .LR # ,
26: that line is considered to be a comment and ignored.
27: .PP
28: Fields are separated by white space (spaces or tabs).
29: Leading and trailing white space on a line is ignored.
30: White space may appear inside a field in one of three
31: ways: each space or tab may be preceded by a backslash,
32: the white space may be enclosed in single or
33: double quotes, or characters may described
34: in octal, as detailed below.
35: .PP
36: A field, or any parts of a field, may be enclosed in single
37: or double quotes.
38: Within quotes, white space and
39: quotes of the other sort are treated as
40: ordinary characters, but a closing quote
41: is silently inserted before a newline.
42: .PP
43: Inside or outside quotes, a backslash
44: and the character(s) after it are changed as follows:
45: .nf
46: .ta 10n
47: \fL\eb\fR backspace
48: \fL\ef\fR form feed
49: \fL\en\fR newline
50: \fL\er\fR return
51: \fL\et\fR horizontal tab
52: \fL\ev\fR vertical tab
53: \fL\e\e\fR \e
54: \fL\e\'\fR \'
55: \fL\e"\fR "
56: \fL\e#\fR #
57: \fL\e\fIspace\fR space
58: \fL\e\fItab\fR tab
59: \fL\e\fInewline\fR completely ignored; this allows a logical line to span any number of physical lines.
60: \fL\e\fIdigits\fR the one, two, or three octal digits are the value of the character to be used.
61: .fi
62: .PP
63: If any other character follows the
64: .LR \e ,
65: both
66: characters lose their special interpretation.
67: .SH DIAGNOSTICS
68: If
69: .I getflds
70: detects an error, it returns
71: .LR 0 ,
72: just as it does at end of file.
73: However, the error will have changed
74: .I errno
75: (see
76: .IR intro (2)).
77: To distinguish between error and
78: end of file set
79: .I errno
80: to zero before calling
81: .I getflds
82: and test it afterwards.
83: .SH BUGS
84: .I Getflds
85: provides no way to distinguish a null character
86: within a field from the end of the field.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.