Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite76ef8d

Browse files
committed
Remove some redundant tests and improve comments in next_token().
Cosmetic, but it might make this a bit less confusing to the next reader.
1 parent85dfe37 commite76ef8d

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

‎src/backend/libpq/hba.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* 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 $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -98,7 +98,7 @@ pg_isblank(const char c)
9898
* Grab one token out of fp. Tokens are strings of non-blank
9999
* characters bounded by blank characters, commas, beginning of line, and
100100
* 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).
102102
*
103103
* The token, if any, is returned at *buf (a buffer of size bufsz).
104104
*
@@ -110,7 +110,9 @@ pg_isblank(const char c)
110110
* beginning of the next line or EOF, whichever comes first.
111111
*
112112
* 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.
114116
*/
115117
staticbool
116118
next_token(FILE*fp,char*buf,intbufsz)
@@ -139,7 +141,7 @@ next_token(FILE *fp, char *buf, int bufsz)
139141
* or unquoted whitespace.
140142
*/
141143
while (c!=EOF&&c!='\n'&&
142-
(!pg_isblank(c)||in_quote== true))
144+
(!pg_isblank(c)||in_quote))
143145
{
144146
/* skip comments to EOL */
145147
if (c=='#'&& !in_quote)
@@ -165,11 +167,11 @@ next_token(FILE *fp, char *buf, int bufsz)
165167
break;
166168
}
167169

168-
if (c!='"'||(c=='"'&&was_quote))
170+
if (c!='"'||was_quote)
169171
*buf++=c;
170172

171173
/* 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)
173175
break;
174176

175177
/* Literal double-quote is two double-quotes */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp