getline.3: !*lineptr is sufficient
PATCH 1/3 getline.3: !*lineptr is sufficient
From: наб <[email protected]>
No implementation or spec requires *n to be 0 to allocate a new buffer:
* musl checks for !*lineptr
(and sets *n=0 for later allocations)
* glibc checks for !*lineptr || !*n
(but only because it allocates early)
* NetBSD checks for !*lineptr
(and sets *n=0 for later allocations)
(but specifies *n => mlen(*lineptr) >= *n as a precondition,
to which this appears to be an exception)
* FreeBSD checks for !*lineptr and sets *n=0
(and specifies !*lineptr as sufficient)
* Lastly, POSIX.1-2017 specifies:
Quoted 3 lines
If *n is non-zero, the application shall ensure that *lineptr either points to an object of size at least *n bytes, or is a null pointer.
The new wording matches POSIX, even if it arrives at the point slightly differently
--- man3/getline.3 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
man3/getline.3 +1 -3
@@ -59,9 +59,7 @@ one was found. .PP If .I "*lineptr" -is set to NULL and -.I *n -is set 0 before the call, then +is set to NULL before the call, then .BR getline () will allocate a buffer for storing the line. This buffer should be freed by the user program
Signature · 1 line
2.32.0
PATCH 2/3 ferror.3: tfix
From: thomasavoss <[email protected]>
--- man3/ferror.3 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
man3/ferror.3 +1 -1
@@ -85,7 +85,7 @@ function returns nonzero if the end-of-file indicator is set for otherwise, it returns zero. .PP The -.BR feof () +.BR ferror () function returns nonzero if the error indicator is set for .IR stream ; otherwise, it returns zero.
Signature · 1 line
2.32.0
Re: [PATCH 2/3] ferror.3: tfix
Hello Alex and Thomas,
Quoted 3 lines · Alejandro Colomar
From: thomasavoss <[email protected]>
Signed-off-by Alejandro Colomar <[email protected]>
Thanks. Patch applied.
Cheers,
Michael
Quoted 18 lines
--- man3/ferror.3 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)man3/ferror.3 +1
-1@@ -85,7 +85,7 @@ function returns nonzero if the end-of-file indicator is set for otherwise, it returns zero. .PP The -.BR feof () +.BR ferror () function returns nonzero if the error indicator is set for .IR stream ; otherwise, it returns zero.
Signature · 3 lines
Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/
PATCH 3/3 strcmp.3: tfix
In reply to Alejandro ColomarWith a simple backslash, '\0' ended up as ' ' in the man output.
--- man3/strcmp.3 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
man3/strcmp.3 +1 -1
@@ -143,7 +143,7 @@ First, some examples using .EX $ \fB./string_comp ABC ABC\fP <str1> and <str2> are equal -$ \fB./string_comp ABC AB\fP # \(aqC\(aq is ASCII 67; \(aqC\(aq \- \(aq\0\(aq = 67 +$ \fB./string_comp ABC AB\fP # \(aqC\(aq is ASCII 67; \(aqC\(aq \- \(aq\e0\(aq = 67 <str1> is greater than <str2> (67) $ \fB./string_comp ABA ABZ\fP # \(aqA\(aq is ASCII 65; \(aqZ\(aq is ASCII 90 <str1> is less than <str2> (\-25)
Signature · 1 line
2.32.0
Re: [PATCH 3/3] strcmp.3: tfix
Hello Štěpán and Alex,
Quoted 4 lines · Alejandro Colomar
With a simple backslash, '\0' ended up as ' ' in the man output.
Reported-by Štěpán Němec <[email protected]>Signed-off-by Alejandro Colomar <[email protected]>
Thanks. Patch applied.
Cheers,
Michael
Quoted 18 lines
--- man3/strcmp.3 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)man3/strcmp.3 +1
-1@@ -143,7 +143,7 @@ First, some examples using .EX $ \fB./string_comp ABC ABC\fP <str1> and <str2> are equal -$ \fB./string_comp ABC AB\fP # \(aqC\(aq is ASCII 67; \(aqC\(aq \- \(aq\0\(aq = 67 +$ \fB./string_comp ABC AB\fP # \(aqC\(aq is ASCII 67; \(aqC\(aq \- \(aq\e0\(aq = 67 <str1> is greater than <str2> (67) $ \fB./string_comp ABA ABZ\fP # \(aqA\(aq is ASCII 65; \(aqZ\(aq is ASCII 90 <str1> is less than <str2> (\-25)
Signature · 3 lines
Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/
Hello Alex and Ahelenia,
Quoted 14 lines · Alejandro Colomar
From: наб <[email protected]>
No implementation or spec requires *n to be 0 to allocate a new buffer:
* musl checks for !*lineptr
(and sets *n=0 for later allocations)
* glibc checks for !*lineptr || !*n
(but only because it allocates early)
* NetBSD checks for !*lineptr
(and sets *n=0 for later allocations)
(but specifies *n =>mlen(*lineptr)>= *n as a precondition,
to which this appears to be an exception)
* FreeBSD checks for !*lineptr and sets *n=0
(and specifies !*lineptr as sufficient)
* Lastly, POSIX.1-2017 specifies:
Quoted 8 lines
Quoted 3 lines
If *n is non-zero, the application shall ensure that *lineptr either points to an object of size at least *n bytes, or is a null pointer.
The new wording matches POSIX, even if it arrives at the point slightly differently
Thanks. Patch applied.
Cheers,
Michael
Quoted 20 lines
--- man3/getline.3 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)man3/getline.3 +1
-3@@ -59,9 +59,7 @@ one was found. .PP If .I "*lineptr" -is set to NULL and -.I *n -is set 0 before the call, then +is set to NULL before the call, then .BR getline () will allocate a buffer for storing the line. This buffer should be freed by the user program
Signature · 3 lines
Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/