10
10
*
11
11
*
12
12
* IDENTIFICATION
13
- * $PostgreSQL: pgsql/src/backend/libpq/hba.c,v 1.164 2008/01/01 19:45:49 momjian Exp $
13
+ * $PostgreSQL: pgsql/src/backend/libpq/hba.c,v 1.165 2008/07/24 17:43:45 tgl Exp $
14
14
*
15
15
*-------------------------------------------------------------------------
16
16
*/
@@ -98,7 +98,7 @@ pg_isblank(const char c)
98
98
* Grab one token out of fp. Tokens are strings of non-blank
99
99
* characters bounded by blank characters, commas, beginning of line, and
100
100
* end of line. Blank means space or tab. Tokens can be delimited by
101
- * double quotes (and usually are, in current usage ).
101
+ * double quotes (this allows the inclusion of blanks, but not newlines ).
102
102
*
103
103
* The token, if any, is returned at *buf (a buffer of size bufsz).
104
104
*
@@ -110,7 +110,9 @@ pg_isblank(const char c)
110
110
* beginning of the next line or EOF, whichever comes first.
111
111
*
112
112
* Handle comments. Treat unquoted keywords that might be role names or
113
- * database names specially, by appending a newline to them.
113
+ * database names specially, by appending a newline to them. Also, when
114
+ * a token is terminated by a comma, the comma is included in the returned
115
+ * token.
114
116
*/
115
117
static bool
116
118
next_token (FILE * fp , char * buf , int bufsz )
@@ -139,7 +141,7 @@ next_token(FILE *fp, char *buf, int bufsz)
139
141
* or unquoted whitespace.
140
142
*/
141
143
while (c != EOF && c != '\n' &&
142
- (!pg_isblank (c ) || in_quote == true ))
144
+ (!pg_isblank (c ) || in_quote ))
143
145
{
144
146
/* skip comments to EOL */
145
147
if (c == '#' && !in_quote )
@@ -165,11 +167,11 @@ next_token(FILE *fp, char *buf, int bufsz)
165
167
break ;
166
168
}
167
169
168
- if (c != '"' || ( c == '"' && was_quote ) )
170
+ if (c != '"' || was_quote )
169
171
* buf ++ = c ;
170
172
171
173
/* We pass back the comma so the caller knows there is more */
172
- if (( pg_isblank ( c ) || c == ',' ) && !in_quote )
174
+ if (c == ',' && !in_quote )
173
175
break ;
174
176
175
177
/* Literal double-quote is two double-quotes */
0 commit comments