]> granicus.if.org Git - postgis/commitdiff
Jeff Adams: Added regression test for LATIN1 encoding, fixed failure to convert to...
authorPaul Ramsey <pramsey@cleverelephant.ca>
Fri, 18 Mar 2011 19:13:26 +0000 (19:13 +0000)
committerPaul Ramsey <pramsey@cleverelephant.ca>
Fri, 18 Mar 2011 19:13:26 +0000 (19:13 +0000)
git-svn-id: http://svn.osgeo.org/postgis/trunk@6932 b70326c6-7e19-0410-871a-916f4a2858ee

loader/shp2pgsql-core.c
regress/Makefile.in
regress/loader/Latin1.dbf [new file with mode: 0644]
regress/loader/Latin1.opts [new file with mode: 0644]
regress/loader/Latin1.select.expected [new file with mode: 0644]
regress/loader/Latin1.select.sql [new file with mode: 0644]
regress/loader/README
regress/run_test

index 84c4e48cf10c8a1505f52548dce3822e9629091b..7a22d9f63c90a33253791f146e8fefda61b7e38d 100644 (file)
@@ -1557,6 +1557,7 @@ ShpLoaderGenerateSQLRowStatement(SHPLOADERSTATE *state, int item, char **strreco
 
                                        return SHPLOADERERR;
                                }
+                               strncpy(val, utf8str, MAXVALUELEN);
                        }
 
                        /* Escape attribute correctly according to dump format */
index eea28f9940e0c02e52badcc467a578193e5e2064..37be6751676d514be9b275325cb9f21902c7bfb6 100644 (file)
@@ -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 (file)
index 0000000..bdee7f7
Binary files /dev/null and b/regress/loader/Latin1.dbf differ
diff --git a/regress/loader/Latin1.opts b/regress/loader/Latin1.opts
new file mode 100644 (file)
index 0000000..478a5b7
--- /dev/null
@@ -0,0 +1,2 @@
+# The DBF contains a string with Norweigan characters.
+-W LATIN1
diff --git a/regress/loader/Latin1.select.expected b/regress/loader/Latin1.select.expected
new file mode 100644 (file)
index 0000000..3f9b462
--- /dev/null
@@ -0,0 +1 @@
+1|Tårneby in Våler I Solør kommune
diff --git a/regress/loader/Latin1.select.sql b/regress/loader/Latin1.select.sql
new file mode 100644 (file)
index 0000000..663dc29
--- /dev/null
@@ -0,0 +1 @@
+SELECT * FROM loadedshp;
index 4b9ae6de06b71d4d727a8774ee4a05f2d4a2d763..f515b4f22d286482d795f2c3b59e3d738f7c1d95 100644 (file)
@@ -1,10 +1,13 @@
-A loader test requires, at a minimum, a shapefile:
+A loader test requires, at a minimum, a dbf file:
+
+<name>.dbf
+
+Most tests will use a shapefile, so these files as well:
 
 <name>.shp
 <name>.shx
-<name>.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 <name>.opts file, the loader is then run with the -D flag,
index f0ea443852db6053da50ca462d6e41eddab19987..db1e084dc8137570a5905d5420da97671a376c3c 100755 (executable)
@@ -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