- Deduplicate the trailing-whitespace code.
- Don't treat "\\\n" as whitespace. It's not what most people would expect, and the documentation doesn't mention it. - Improve the documentation a bit now that gendoc.pl supports bullet lists. git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@473 185d5e19-27fe-0310-9dcf-9bff6b9f3609
This commit is contained in:
parent
c20b753856
commit
ebccc4d687
|
@ -87,33 +87,23 @@ openpam_readline(FILE *f, int *lineno, size_t *lenp)
|
|||
}
|
||||
/* eof */
|
||||
if (ch == EOF) {
|
||||
/* remove trailing whitespace */
|
||||
while (len > 0 && isspace((unsigned char)line[len - 1]))
|
||||
--len;
|
||||
line[len] = '\0';
|
||||
if (len == 0)
|
||||
goto fail;
|
||||
/* done */
|
||||
break;
|
||||
}
|
||||
/* eol */
|
||||
if (ch == '\n') {
|
||||
if (lineno != NULL)
|
||||
++*lineno;
|
||||
|
||||
/* remove trailing whitespace */
|
||||
while (len > 0 && isspace((unsigned char)line[len - 1]))
|
||||
--len;
|
||||
line[len] = '\0';
|
||||
/* skip blank lines */
|
||||
if (len == 0)
|
||||
continue;
|
||||
/* continuation */
|
||||
if (line[len - 1] == '\\') {
|
||||
line[--len] = '\0';
|
||||
/* fall through to whitespace case */
|
||||
} else {
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
/* done */
|
||||
break;
|
||||
}
|
||||
/* whitespace */
|
||||
if (isspace(ch)) {
|
||||
|
@ -127,6 +117,12 @@ openpam_readline(FILE *f, int *lineno, size_t *lenp)
|
|||
line_putch(ch);
|
||||
}
|
||||
|
||||
/* remove trailing whitespace */
|
||||
while (len > 0 && isspace((unsigned char)line[len - 1]))
|
||||
--len;
|
||||
line[len] = '\0';
|
||||
if (len == 0)
|
||||
goto fail;
|
||||
if (lenp != NULL)
|
||||
*lenp = len;
|
||||
return (line);
|
||||
|
@ -140,13 +136,14 @@ fail:
|
|||
* in a NUL-terminated buffer allocated with =malloc.
|
||||
*
|
||||
* The =openpam_readline function performs a certain amount of processing
|
||||
* on the data it reads.
|
||||
* Comments (introduced by a hash sign) are stripped, as is leading and
|
||||
* trailing whitespace.
|
||||
* Any amount of linear whitespace is collapsed to a single space.
|
||||
* Blank lines are ignored.
|
||||
* If a line ends in a backslash, the backslash is stripped and the next
|
||||
* line is appended.
|
||||
* on the data it reads:
|
||||
*
|
||||
* - Comments (introduced by a hash sign) are stripped, as is leading and
|
||||
* trailing whitespace.
|
||||
* - Any amount of linear whitespace is collapsed to a single space.
|
||||
* - Blank lines are ignored.
|
||||
* - If a line ends in a backslash, the backslash is stripped and the
|
||||
* next line is appended.
|
||||
*
|
||||
* If =lineno is not =NULL, the integer variable it points to is
|
||||
* incremented every time a newline character is read.
|
||||
|
|
Loading…
Reference in New Issue