*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/libpq/hba.c,v 1.116.2.5 2010/03/03 20:31:50 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/libpq/hba.c,v 1.116.2.6 2010/03/06 00:46:27 tgl Exp $
*
*-------------------------------------------------------------------------
*/
* next line or EOF, whichever comes first. Allow spaces in quoted
* strings. Terminate on unquoted commas. Handle comments.
*/
-void
-next_token(FILE *fp, char *buf, const int bufsz)
+static void
+next_token(FILE *fp, char *buf, int bufsz, bool *initial_quote)
{
int c;
char *start_buf = buf;
bool in_quote = false;
bool was_quote = false;
+ *initial_quote = false;
+
/* Move over initial whitespace and commas */
while ((c = getc(fp)) != EOF && (pg_isblank(c) || c == ','))
;
was_quote = false;
if (c == '"')
+ {
in_quote = !in_quote;
+ if (buf == start_buf)
+ *initial_quote = true;
+ }
c = getc(fp);
}
char buf[MAX_TOKEN];
char *comma_str = pstrdup("");
bool trailing_comma;
+ bool initial_quote;
char *incbuf;
int needed;
do
{
- next_token(file, buf, sizeof(buf));
+ next_token(file, buf, sizeof(buf), &initial_quote);
if (!*buf)
break;
trailing_comma = false;
/* Is this referencing a file? */
- if (buf[0] == '@')
+ if (!initial_quote && buf[0] == '@' && buf[1] != '\0')
incbuf = tokenize_inc_file(buf + 1);
else
incbuf = pstrdup(buf);
* Interface to hba.c
*
*
- * $Id: hba.h,v 1.33 2003/04/17 22:26:01 tgl Exp $
+ * $Id: hba.h,v 1.33.4.1 2010/03/06 00:46:27 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#define MAX_TOKEN 256
-extern void next_token(FILE *fp, char *buf, const int bufsz);
extern List **get_user_line(const char *user);
extern void load_hba(void);
extern void load_ident(void);