[GRASS-SVN] r51945 - grass/trunk/db/db.select

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Jun 3 04:08:07 PDT 2012


Author: martinl
Date: 2012-06-03 04:08:06 -0700 (Sun, 03 Jun 2012)
New Revision: 51945

Modified:
   grass/trunk/db/db.select/main.c
Log:
db.select: truncate ';' where reading SQL statements from the file


Modified: grass/trunk/db/db.select/main.c
===================================================================
--- grass/trunk/db/db.select/main.c	2012-06-03 09:58:40 UTC (rev 51944)
+++ grass/trunk/db/db.select/main.c	2012-06-03 11:08:06 UTC (rev 51945)
@@ -304,12 +304,21 @@
 
 int get_stmt(FILE * fd, dbString * stmt)
 {
-    char buf[DB_SQL_MAX];
+    char buf[DB_SQL_MAX], buf2[DB_SQL_MAX];
+    size_t len;
     
     db_zero_string(stmt);
     
     if (G_getl2(buf, sizeof(buf), fd) == 0)
         return 0;
+        
+    strcpy(buf2, buf);
+    G_chop(buf2);
+    len = strlen(buf2);
+        
+    if (buf2[len - 1] == ';') { /* end of statement */
+        buf2[len - 1] = 0;      /* truncate ';' */
+    }
     
     db_set_string(stmt, buf);
     



More information about the grass-commit mailing list