Improve strtol(3) example
cover Improve strtol(3) example
Hi Michael,
Here are a few improvements for the strtol(3) example.
Cheers,
Alex
Alejandro Colomar (3):
strtol.3: EXAMPLES: Delimit output string using "" strtol.3: EXAMPLES: As the default base, use special value 0 strtol.3: EXAMPLES: Simplify errno checking (no expected change in
behavior)
man3/strtol.3 | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
Signature · 1 line
2.28.0
PATCH 1/3 strtol.3: EXAMPLES: Delimit output string using ""
--- man3/strtol.3 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
man3/strtol.3 +2 -2
@@ -236,7 +236,7 @@ strtol() returned 123 strtol() returned 123 .RB "$" " ./a.out 123abc" strtol() returned 123 -Further characters after number: abc +Further characters after number: "abc" .RB "$" " ./a.out 123abc 55" strtol: Invalid argument .RB "$" " ./a.out \(aq\(aq"
@@ -289,7 +289,7 @@ main(int argc, char *argv[]) printf("strtol() returned %ld\en", val); if (*endptr != \(aq\e0\(aq) /* Not necessarily an error... */ - printf("Further characters after number: %s\en", endptr); + printf("Further characters after number: \e"%s\e"\en", endptr); exit(EXIT_SUCCESS); }
Signature · 1 line
2.28.0
PATCH 2/3 strtol.3: EXAMPLES: As the default base, use special value 0
In reply to Alejandro Colomar--- man3/strtol.3 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
man3/strtol.3 +1 -1
@@ -266,7 +266,7 @@ main(int argc, char *argv[]) } str = argv[1]; - base = (argc > 2) ? atoi(argv[2]) : 10; + base = (argc > 2) ? atoi(argv[2]) : 0; errno = 0; /* To distinguish success/failure after call */ val = strtol(str, &endptr, base);
Signature · 1 line
2.28.0
Quoted 3 lines · Alejandro Colomar
Hi Michael,
Here are a few improvements for the strtol(3) example.
Thanks, Alex. I've applied all of these.
Cheers,
Michael
Quoted 13 lines
Cheers,
Alex
Alejandro Colomar (3):
strtol.3: EXAMPLES: Delimit output string using "" strtol.3: EXAMPLES: As the default base, use special value 0 strtol.3: EXAMPLES: Simplify errno checking (no expected change in
behavior)man3/strtol.3 | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
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 strtol.3: EXAMPLES: Simplify errno checking (no expected change in behavior)
In reply to Alejandro Colomar--- man3/strtol.3 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
man3/strtol.3 +1 -2
@@ -273,8 +273,7 @@ main(int argc, char *argv[]) /* Check for various possible errors */ - if ((errno == ERANGE && (val == LONG_MAX || val == LONG_MIN)) - || (errno != 0 && val == 0)) { + if (errno != 0) { perror("strtol"); exit(EXIT_FAILURE); }
Signature · 1 line
2.28.0