From 9b394f152f4f0cebea9575547ec232285e66566f Mon Sep 17 00:00:00 2001 From: Paul Ramsey Date: Fri, 18 Mar 2011 19:13:26 +0000 Subject: [PATCH] Jeff Adams: Added regression test for LATIN1 encoding, fixed failure to convert to UTF8. (#808) git-svn-id: http://svn.osgeo.org/postgis/trunk@6932 b70326c6-7e19-0410-871a-916f4a2858ee --- loader/shp2pgsql-core.c | 1 + regress/Makefile.in | 1 + regress/loader/Latin1.dbf | Bin 0 -> 99 bytes regress/loader/Latin1.opts | 2 ++ regress/loader/Latin1.select.expected | 1 + regress/loader/Latin1.select.sql | 1 + regress/loader/README | 9 ++++++--- regress/run_test | 6 ++++-- 8 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 regress/loader/Latin1.dbf create mode 100644 regress/loader/Latin1.opts create mode 100644 regress/loader/Latin1.select.expected create mode 100644 regress/loader/Latin1.select.sql diff --git a/loader/shp2pgsql-core.c b/loader/shp2pgsql-core.c index 84c4e48cf..7a22d9f63 100644 --- a/loader/shp2pgsql-core.c +++ b/loader/shp2pgsql-core.c @@ -1557,6 +1557,7 @@ ShpLoaderGenerateSQLRowStatement(SHPLOADERSTATE *state, int item, char **strreco return SHPLOADERERR; } + strncpy(val, utf8str, MAXVALUELEN); } /* Escape attribute correctly according to dump format */ diff --git a/regress/Makefile.in b/regress/Makefile.in index eea28f994..37be67516 100644 --- a/regress/Makefile.in +++ b/regress/Makefile.in @@ -46,6 +46,7 @@ TESTS = \ loader/MultiToSinglePoint \ loader/ReprojectPts \ loader/ReprojectPtsGeog \ + loader/Latin1 \ regress \ regress_index \ regress_index_nulls \ diff --git a/regress/loader/Latin1.dbf b/regress/loader/Latin1.dbf new file mode 100644 index 0000000000000000000000000000000000000000..bdee7f78190bf86a2f3041a5ce61ab7ccc43f655 GIT binary patch literal 99 zcmZSPW|U-PU|?`$Py~{gz|qAe$Tc_^B;gDq6hH(L;8h5DT9lWXRH=}erx5luC$&hy UQz1A%=SPu3c7ASdX.dbf + +Most tests will use a shapefile, so these files as well: .shp .shx -.dbf -The loader will be run against the shapefile with no command-line flags, +The loader will be run against the dbf/shapefile with no command-line flags, then the output will be run via psql to insert the table into PostGIS. If there is no .opts file, the loader is then run with the -D flag, diff --git a/regress/run_test b/regress/run_test index f0ea44385..db1e084dc 100755 --- a/regress/run_test +++ b/regress/run_test @@ -570,9 +570,11 @@ while [ -n "$1" ]; do fi fi - # Check .shp *before* .sql as loader test could + # Check .dbf *before* .sql as loader test could # create the .sql - if [ -r "${TEST}.shp" ]; then + # Check for .dbf not just .shp since the loader can load + # .dbf files without a .shp. + if [ -r "${TEST}.dbf" ]; then if run_loader_test; then echo " ok" fi -- 2.50.1