Changeset 25353
- Timestamp:
- Nov 25, 2007, 3:09:36 AM (17 years ago)
- File:
-
- 1 edited
-
grass/trunk/vector/v.in.ascii/points.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
grass/trunk/vector/v.in.ascii/points.c
r24032 r25353 9 9 #include "local_proto.h" 10 10 11 12 /* Determine if the string is integer, e.g. 123, +123, -123 11 /* Determine if the string is integer, e.g. 123, +123, -123, 13 12 * return 1 if integer, 0 otherwise */ 14 13 static int is_int(char *str) 15 14 { 16 int i = -1; 17 18 while (str[++i] != '\0') { 19 if (i == 0 && (str[i] == '+' || str[i] == '-')) 20 continue; 21 22 if (!isdigit(str[i])) 23 return 0; 15 char *tail; 16 17 if (strtol (str, &tail, 10), 18 tail == str || *tail != '\0') { 19 /* doesn't look like a number, 20 or has extra characters after what looks to be a number */ 21 return 0; 24 22 } 25 23 … … 28 26 29 27 30 /* Determine if the string is double, e.g. 123.456, +123.456, -123.456 28 /* Determine if the string is double, e.g. 123.456, +123.456, -123.456, 1.23456e2 31 29 * return 1 if double, 0 otherwise */ 32 30 static int is_double(char *str) 33 31 { 34 int i = -1, ndots = 0; 35 36 while (str[++i] != '\0') { 37 if (i == 0 && (str[i] == '+' || str[i] == '-')) 38 continue; 39 40 if (str[i] == '.') { 41 if (ndots > 0) 42 return 0; /* > 1 dot */ 43 44 ndots++; 45 continue; 46 } 47 48 if (!isdigit(str[i])) 49 return 0; 32 char *tail; 33 34 if (strtod (str, &tail), 35 tail == str || *tail != '\0') { 36 /* doesn't look like a number, 37 or has extra characters after what looks to be a number */ 38 return 0; 50 39 } 51 40 52 41 return 1; 53 42 } 43 54 44 55 45 … … 92 82 sav_buf = NULL; 93 83 94 G_message(_("Scanning input for column types ..."));84 G_message(_("Scanning input for column types...")); 95 85 /* fetch projection for LatLong test */ 96 86 G_get_window(&window); … … 218 208 row, i, tokens[i], is_int(tokens[i]), is_double(tokens[i])); 219 209 220 if (is_int(tokens[i])) 210 if (is_int(tokens[i])) { 221 211 continue; /* integer */ 212 } 222 213 if (is_double(tokens[i])) { /* double */ 223 214 if (coltype[i] == DB_C_TYPE_INT) { … … 255 246 256 247 if (region_flag) 257 G_message(_("Skipping [%d] of [%d]rows falling outside of current region"),248 G_message(_("Skipping %d of %d rows falling outside of current region"), 258 249 skipped, row-1); 259 250 … … 283 274 struct Cell_head window; 284 275 285 G_message(_("Importing points ..."));276 G_message(_("Importing points...")); 286 277 /* fetch projection for LatLong test */ 287 278 G_get_window(&window); … … 395 386 396 387 if (db_execute_immediate(driver, &sql) != DB_OK) { 397 G_fatal_error(_("Cannot insert values: %s"), db_get_string(&sql)); 388 G_fatal_error(_("Unable to insert new record: %s"), 389 db_get_string(&sql)); 398 390 } 399 391 }
Note:
See TracChangeset
for help on using the changeset viewer.
