Changeset 473 in openpam


Ignore:
Timestamp:
Nov 3, 2011, 10:48:25 AM (6 years ago)
Author:
Dag-Erling Smørgrav
Message:
  • 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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/openpam_readline.c

    r437 r473  
    8888                /* eof */
    8989                if (ch == EOF) {
    90                         /* remove trailing whitespace */
    91                         while (len > 0 && isspace((unsigned char)line[len - 1]))
    92                                 --len;
    93                         line[len] = '\0';
    94                         if (len == 0)
    95                                 goto fail;
     90                        /* done */
    9691                        break;
    9792                }
     
    10095                        if (lineno != NULL)
    10196                                ++*lineno;
    102 
    103                         /* remove trailing whitespace */
    104                         while (len > 0 && isspace((unsigned char)line[len - 1]))
    105                                 --len;
    106                         line[len] = '\0';
    10797                        /* skip blank lines */
    10898                        if (len == 0)
     
    111101                        if (line[len - 1] == '\\') {
    112102                                line[--len] = '\0';
    113                                 /* fall through to whitespace case */
    114                         } else {
    115                                 break;
     103                                continue;
    116104                        }
     105                        /* done */
     106                        break;
    117107                }
    118108                /* whitespace */
     
    128118        }
    129119
     120        /* remove trailing whitespace */
     121        while (len > 0 && isspace((unsigned char)line[len - 1]))
     122                --len;
     123        line[len] = '\0';
     124        if (len == 0)
     125                goto fail;
    130126        if (lenp != NULL)
    131127                *lenp = len;
     
    141137 *
    142138 * The =openpam_readline function performs a certain amount of processing
    143  * on the data it reads.
    144  * Comments (introduced by a hash sign) are stripped, as is leading and
    145  * trailing whitespace.
    146  * Any amount of linear whitespace is collapsed to a single space.
    147  * Blank lines are ignored.
    148  * If a line ends in a backslash, the backslash is stripped and the next
    149  * line is appended.
     139 * on the data it reads:
     140 *
     141 *  - Comments (introduced by a hash sign) are stripped, as is leading and
     142 *    trailing whitespace.
     143 *  - Any amount of linear whitespace is collapsed to a single space.
     144 *  - Blank lines are ignored.
     145 *  - If a line ends in a backslash, the backslash is stripped and the
     146 *    next line is appended.
    150147 *
    151148 * If =lineno is not =NULL, the integer variable it points to is
Note: See TracChangeset for help on using the changeset viewer.