Ver código fonte

db.select: truncate ';' where reading SQL statements from the file

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@51945 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 13 anos atrás
pai
commit
22046db2f9
1 arquivos alterados com 10 adições e 1 exclusões
  1. 10 1
      db/db.select/main.c

+ 10 - 1
db/db.select/main.c

@@ -304,12 +304,21 @@ void parse_command_line(int argc, char **argv)
 
 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);