Date: Mon, 20 Oct 2014 08:59:30 +0000 (UTC) From: Dag-Erling Smørgrav <des@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r273326 - stable/10/contrib/openpam/lib/libpam Message-ID: <201410200859.s9K8xUvP015377@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: des Date: Mon Oct 20 08:59:30 2014 New Revision: 273326 URL: https://svnweb.freebsd.org/changeset/base/273326 Log: MFH (r273273): Merge upstream r825: fix line continuation in whitespace Modified: stable/10/contrib/openpam/lib/libpam/openpam_readword.c Directory Properties: stable/10/ (props changed) Modified: stable/10/contrib/openpam/lib/libpam/openpam_readword.c ============================================================================== --- stable/10/contrib/openpam/lib/libpam/openpam_readword.c Mon Oct 20 08:09:36 2014 (r273325) +++ stable/10/contrib/openpam/lib/libpam/openpam_readword.c Mon Oct 20 08:59:30 2014 (r273326) @@ -55,18 +55,35 @@ openpam_readword(FILE *f, int *lineno, s { char *word; size_t size, len; - int ch, comment, escape, quote; + int ch, escape, quote; int serrno; errno = 0; /* skip initial whitespace */ - comment = 0; - while ((ch = getc(f)) != EOF && ch != '\n') { - if (ch == '#') - comment = 1; - if (!is_lws(ch) && !comment) + escape = quote = 0; + while ((ch = getc(f)) != EOF) { + if (ch == '\n') { + /* either EOL or line continuation */ + if (!escape) + break; + if (lineno != NULL) + ++*lineno; + escape = 0; + } else if (escape) { + /* escaped something else */ + break; + } else if (ch == '#') { + /* comment: until EOL, no continuation */ + while ((ch = getc(f)) != EOF) + if (ch == '\n') + break; break; + } else if (ch == '\\') { + escape = 1; + } else if (!is_ws(ch)) { + break; + } } if (ch == EOF) return (NULL); @@ -76,7 +93,6 @@ openpam_readword(FILE *f, int *lineno, s word = NULL; size = len = 0; - escape = quote = 0; while ((ch = fgetc(f)) != EOF && (!is_ws(ch) || quote || escape)) { if (ch == '\\' && !escape && quote != '\'') { /* escape next character */ @@ -90,7 +106,7 @@ openpam_readword(FILE *f, int *lineno, s } else if (ch == quote && !escape) { /* end quote */ quote = 0; - } else if (ch == '\n' && escape && quote != '\'') { + } else if (ch == '\n' && escape) { /* line continuation */ escape = 0; } else {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201410200859.s9K8xUvP015377>