Tue Dec 1 08:15:50 2009 UTC ()
Make HTML-ready, use standard section headers, fix Xr.


(wiz)
diff -r1.5 -r1.6 src/lib/libc/stdio/getdelim.3

cvs diff -r1.5 -r1.6 src/lib/libc/stdio/getdelim.3 (expand / switch to unified diff)

--- src/lib/libc/stdio/getdelim.3 2009/11/30 23:23:29 1.5
+++ src/lib/libc/stdio/getdelim.3 2009/12/01 08:15:50 1.6
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1.\" $NetBSD: getdelim.3,v 1.5 2009/11/30 23:23:29 roy Exp $ 1.\" $NetBSD: getdelim.3,v 1.6 2009/12/01 08:15:50 wiz Exp $
2.\" 2.\"
3.\" Copyright (c) 2009 The NetBSD Foundation, Inc. 3.\" Copyright (c) 2009 The NetBSD Foundation, Inc.
4.\" All rights reserved. 4.\" All rights reserved.
5.\" 5.\"
6.\" This code is derived from software contributed to The NetBSD Foundation 6.\" This code is derived from software contributed to The NetBSD Foundation
7.\" by Roy Marples. 7.\" by Roy Marples.
8.\" 8.\"
9.\" Redistribution and use in source and binary forms, with or without 9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions 10.\" modification, are permitted provided that the following conditions
11.\" are met: 11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright 12.\" 1. Redistributions of source code must retain the above copyright
13.\" notice, this list of conditions and the following disclaimer. 13.\" notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright 14.\" 2. Redistributions in binary form must reproduce the above copyright
@@ -63,59 +63,59 @@ must be pre-allocated to at least @@ -63,59 +63,59 @@ must be pre-allocated to at least
63.Fa *n 63.Fa *n
64bytes. 64bytes.
65.Fn getdelim 65.Fn getdelim
66ensures that 66ensures that
67.Fa *lineptr 67.Fa *lineptr
68is large enough to hold the input, updating 68is large enough to hold the input, updating
69.Fa *n 69.Fa *n
70to reflect the new size. 70to reflect the new size.
71.Pp 71.Pp
72.Fa delimiter 72.Fa delimiter
73must be representable as an unsigned char, and 73must be representable as an unsigned char, and
74.Fa *lineptr 74.Fa *lineptr
75must be a 75must be a
76.Xr free(3) Ns No able 76.Xr free 3 Ns No able
77buffer. 77buffer.
78.Pp 78.Pp
79.Fa getline 79.Fa getline
80is equivalent to 80is equivalent to
81.Fa getdelim 81.Fa getdelim
82with the delimiter set to the newline character. 82with the delimiter set to the newline character.
83.Sh RETURN VALUES 83.Sh RETURN VALUES
84The 84The
85.Fn getdelim 85.Fn getdelim
86and 86and
87.Fn getline 87.Fn getline
88functions return the number of characters read, including the delimiter. 88functions return the number of characters read, including the delimiter.
89If no characters were read and the stream is at end-of-file, the functions 89If no characters were read and the stream is at end-of-file, the functions
90return \-1. 90return \-1.
91If an error occurs, the functions return \-1 and the global variable 91If an error occurs, the functions return \-1 and the global variable
92.Va errno 92.Va errno
93is set to indicate the error. 93is set to indicate the error.
94.Pp 94.Pp
95The functions do not distinguish between end-of-file and error, 95The functions do not distinguish between end-of-file and error,
96and callers must use 96and callers must use
97.Xr feof 3 97.Xr feof 3
98and 98and
99.Xr ferror 3 99.Xr ferror 3
100to determine which occurred. 100to determine which occurred.
101.Sh EXAMPLE 101.Sh EXAMPLES
102The following code fragment reads lines from a file and writes them to 102The following code fragment reads lines from a file and writes them to
103standard output. 103standard output.
104.Bd -literal -offset indent 104.Bd -literal -offset indent
105char *line = NULL; 105char *line = NULL;
106size_t linesize = 0; 106size_t linesize = 0;
107ssize_t linelen; 107ssize_t linelen;
108while ((linelen = getline(&line, &linesize, fp)) != -1) 108while ((linelen = getline(\*[Am]line, \*[Am]linesize, fp)) != -1)
109 fwrite(line, linelen, 1, stdout); 109 fwrite(line, linelen, 1, stdout);
110 110
111if (ferror(fp)) 111if (ferror(fp))
112 perror("getline"); 112 perror("getline");
113.Sh ERRORS 113.Sh ERRORS
114.Bl -tag -width [EOVERFLOW] 114.Bl -tag -width [EOVERFLOW]
115.It Bq Er EINVAL 115.It Bq Er EINVAL
116.Fa *lineptr 116.Fa *lineptr
117or 117or
118.Fa *n 118.Fa *n
119is a 119is a
120.Dv NULL 120.Dv NULL
121pointer. 121pointer.