[GRASS-SVN] r33164 - grass/branches/develbranch_6/raster/r.in.xyz
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Aug 30 02:26:39 EDT 2008
Author: hamish
Date: 2008-08-30 02:26:38 -0400 (Sat, 30 Aug 2008)
New Revision: 33164
Modified:
grass/branches/develbranch_6/raster/r.in.xyz/main.c
Log:
don't overflow messages for >= 2^31 points
Modified: grass/branches/develbranch_6/raster/r.in.xyz/main.c
===================================================================
--- grass/branches/develbranch_6/raster/r.in.xyz/main.c 2008-08-30 05:49:04 UTC (rev 33163)
+++ grass/branches/develbranch_6/raster/r.in.xyz/main.c 2008-08-30 06:26:38 UTC (rev 33164)
@@ -104,7 +104,8 @@
double zrange_min, zrange_max, d_tmp;
char *fs; /* field delim */
off_t filesize;
- int linesize, estimated_lines;
+ int linesize;
+ long estimated_lines;
int from_stdin;
int can_seek;
@@ -118,13 +119,15 @@
int rows, cols; /* scan box size */
int row, col; /* counters */
- int pass, npasses, line;
+ int pass, npasses;
+ unsigned long line;
char buff[BUFFSIZE];
double x, y, z;
char **tokens;
int ntokens; /* number of tokens */
double pass_north, pass_south;
- int arr_row, arr_col, count, count_total;
+ int arr_row, arr_col;
+ unsigned long count, count_total;
double min = 0.0 / 0.0; /* init as nan */
double max = 0.0 / 0.0; /* init as nan */
@@ -504,7 +507,7 @@
if (linesize < 6) /* min possible: "0,0,0\n" */
linesize = 6;
estimated_lines = filesize / linesize;
- G_debug(2, "estimated number of lines in file: %d", estimated_lines);
+ G_debug(2, "estimated number of lines in file: %ld", estimated_lines);
}
else
estimated_lines = -1;
@@ -592,7 +595,7 @@
if (skipline->answer) {
G_warning(_("Not enough data columns. "
"Incorrect delimiter or column number? "
- "Found the following character(s) in row %d:\n[%s]"),
+ "Found the following character(s) in row %lu:\n[%s]"),
line, buff);
G_warning(_("Line ignored as requested"));
continue; /* line is garbage */
@@ -600,7 +603,7 @@
else {
G_fatal_error(_("Not enough data columns. "
"Incorrect delimiter or column number? "
- "Found the following character(s) in row %d:\n[%s]"),
+ "Found the following character(s) in row %lu:\n[%s]"),
line, buff);
}
}
@@ -613,21 +616,21 @@
else {
*/
if (1 != sscanf(tokens[ycol - 1], "%lf", &y))
- G_fatal_error(_("Bad y-coordinate line %d column %d. <%s>"),
+ G_fatal_error(_("Bad y-coordinate line %lu column %d. <%s>"),
line, ycol, tokens[ycol - 1]);
if (y <= pass_south || y > pass_north) {
G_free_tokens(tokens);
continue;
}
if (1 != sscanf(tokens[xcol - 1], "%lf", &x))
- G_fatal_error(_("Bad x-coordinate line %d column %d. <%s>"),
+ G_fatal_error(_("Bad x-coordinate line %lu column %d. <%s>"),
line, xcol, tokens[xcol - 1]);
if (x < region.west || x > region.east) {
G_free_tokens(tokens);
continue;
}
if (1 != sscanf(tokens[zcol - 1], "%lf", &z))
- G_fatal_error(_("Bad z-coordinate line %d column %d. <%s>"),
+ G_fatal_error(_("Bad z-coordinate line %lu column %d. <%s>"),
line, zcol, tokens[zcol - 1]);
z = z * zscale;
@@ -704,7 +707,7 @@
} /* while !EOF */
G_percent(1, 1, 1); /* flush */
- G_debug(2, "pass %d finished, %d coordinates in box", pass, count);
+ G_debug(2, "pass %d finished, %lu coordinates in box", pass, count);
count_total += count;
@@ -1052,9 +1055,9 @@
G_write_history(outmap, &history);
- sprintf(buff, _("%d points found in region."), count_total);
+ sprintf(buff, _("%lu points found in region."), count_total);
G_done_msg(buff);
- G_debug(1, "Processed %d lines.", line);
+ G_debug(1, "Processed %lu lines.", line);
exit(EXIT_SUCCESS);
@@ -1065,7 +1068,8 @@
int scan_bounds(FILE * fp, int xcol, int ycol, int zcol, char *fs,
int shell_style, int skipline, double zscale)
{
- int line, first, max_col;
+ unsigned long line;
+ int first, max_col;
char buff[BUFFSIZE];
double min_x, max_x, min_y, max_y, min_z, max_z;
char **tokens;
@@ -1095,7 +1099,7 @@
if (skipline) {
G_warning(_("Not enough data columns. "
"Incorrect delimiter or column number? "
- "Found the following character(s) in row %d:\n[%s]"),
+ "Found the following character(s) in row %lu:\n[%s]"),
line, buff);
G_warning(_("Line ignored as requested"));
continue; /* line is garbage */
@@ -1103,7 +1107,7 @@
else {
G_fatal_error(_("Not enough data columns. "
"Incorrect delimiter or column number? "
- "Found the following character(s) in row %d:\n[%s]"),
+ "Found the following character(s) in row %lu:\n[%s]"),
line, buff);
}
}
@@ -1116,7 +1120,7 @@
else {
*/
if (1 != sscanf(tokens[xcol - 1], "%lf", &x))
- G_fatal_error(_("Bad x-coordinate line %d column %d. <%s>"), line,
+ G_fatal_error(_("Bad x-coordinate line %lu column %d. <%s>"), line,
xcol, tokens[xcol - 1]);
if (first) {
@@ -1131,7 +1135,7 @@
}
if (1 != sscanf(tokens[ycol - 1], "%lf", &y))
- G_fatal_error(_("Bad y-coordinate line %d column %d. <%s>"), line,
+ G_fatal_error(_("Bad y-coordinate line %lu column %d. <%s>"), line,
ycol, tokens[ycol - 1]);
if (first) {
@@ -1146,7 +1150,7 @@
}
if (1 != sscanf(tokens[zcol - 1], "%lf", &z))
- G_fatal_error(_("Bad z-coordinate line %d column %d. <%s>"), line,
+ G_fatal_error(_("Bad z-coordinate line %lu column %d. <%s>"), line,
zcol, tokens[zcol - 1]);
if (first) {
@@ -1175,7 +1179,7 @@
fprintf(stdout, "n=%f s=%f e=%f w=%f b=%f t=%f\n",
max_y, min_y, max_x, min_x, min_z * zscale, max_z * zscale);
- G_debug(1, "Processed %d lines.", line);
+ G_debug(1, "Processed %lu lines.", line);
G_debug(1, "region template: g.region n=%f s=%f e=%f w=%f",
max_y, min_y, max_x, min_x);
More information about the grass-commit
mailing list