diff options
author | Peter Eisentraut <peter_e@gmx.net> | 2009-11-21 23:59:12 +0000 |
---|---|---|
committer | Peter Eisentraut <peter_e@gmx.net> | 2009-11-21 23:59:12 +0000 |
commit | 93d3bac5648bddfe195a9cecc45ef0a2da5e85a8 (patch) | |
tree | e0d9d8bc89367c7b838c76356bae897a8895520b | |
parent | e6c63bf6604f2fb3b17c15e0652686a92f8b8a77 (diff) | |
download | postgresql-93d3bac5648bddfe195a9cecc45ef0a2da5e85a8.tar.gz postgresql-93d3bac5648bddfe195a9cecc45ef0a2da5e85a8.zip |
Ignore UTF-8-encoded Unicode byte-order mark at the beginning of a file if
the client encoding is UTF-8.
a limited version of a patch proposed by Itagaki Takahiro
-rw-r--r-- | src/bin/psql/mainloop.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/bin/psql/mainloop.c b/src/bin/psql/mainloop.c index b39b2a44e50..b6f87670af0 100644 --- a/src/bin/psql/mainloop.c +++ b/src/bin/psql/mainloop.c @@ -3,7 +3,7 @@ * * Copyright (c) 2000-2009, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/bin/psql/mainloop.c,v 1.96 2009/11/10 23:12:13 tgl Exp $ + * $PostgreSQL: pgsql/src/bin/psql/mainloop.c,v 1.97 2009/11/21 23:59:12 petere Exp $ */ #include "postgres_fe.h" #include "mainloop.h" @@ -14,6 +14,8 @@ #include "input.h" #include "settings.h" +#include "mb/pg_wchar.h" + /* * Main processing loop for reading lines of input @@ -167,6 +169,10 @@ MainLoop(FILE *source) pset.lineno++; + /* ignore UTF-8 Unicode byte-order mark */ + if (pset.lineno == 1 && pset.encoding == PG_UTF8 && strncmp(line, "\xef\xbb\xbf", 3) == 0) + memmove(line, line + 3, strlen(line + 3) + 1); + /* nothing left on line? then ignore */ if (line[0] == '\0' && !psql_scan_in_quote(scan_state)) { |