Changeset 30675


Ignore:
Timestamp:
Mar 21, 2008, 4:31:16 AM (16 years ago)
Author:
neteler
Message:

Ignore broken lines added

Location:
grass/trunk/raster/r.in.xyz
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • grass/trunk/raster/r.in.xyz/local_proto.h

    r25198 r30675  
    3939
    4040/* main.c */
    41 int scan_bounds(FILE*, int, int, int, char*, int);
     41int scan_bounds(FILE*, int, int, int, char*, int, int);
    4242
    4343/* support.c */
  • grass/trunk/raster/r.in.xyz/main.c

    r29905 r30675  
    143143    struct Option *method_opt, *xcol_opt, *ycol_opt, *zcol_opt, *zrange_opt;
    144144    struct Option *trim_opt, *pth_opt;
    145     struct Flag *scan_flag, *shell_style;
     145    struct Flag *scan_flag, *shell_style, *skipline;
    146146
    147147
     
    245245    shell_style->description = _("In scan mode, print using shell script style");
    246246
     247    skipline = G_define_flag();
     248    skipline->key = 'i';
     249    skipline->description = _("Ignore broken lines");
    247250
    248251    if (G_parser(argc,argv))
     
    451454            G_warning(_("zrange will not be taken into account during scan"));
    452455
    453         scan_bounds(in_fp, xcol, ycol, zcol, fs, shell_style->answer);
     456        scan_bounds(in_fp, xcol, ycol, zcol, fs, shell_style->answer, skipline->answer);
    454457
    455458        if(!from_stdin)
     
    560563            ntokens = G_number_of_tokens ( tokens );
    561564
    562             if((ntokens < 3) || (max_col > ntokens) )
    563                 G_fatal_error(_("Not enough data columns. "
    564                    "Incorrect delimiter or column number? "
    565                    "Found the following character(s) in row %d:\n[%s]"), line, buff);
     565            if((ntokens < 3) || (max_col > ntokens) ) {
     566                if (skipline->answer) {
     567                   G_warning(_("Not enough data columns. "
     568                     "Incorrect delimiter or column number? "
     569                     "Found the following character(s) in row %d:\n[%s]"), line, buff);
     570                   G_warning(_("Line ignored as requested"));
     571                   continue; /* line is garbage */
     572                } else {
     573                   G_fatal_error(_("Not enough data columns. "
     574                     "Incorrect delimiter or column number? "
     575                     "Found the following character(s) in row %d:\n[%s]"), line, buff);
     576                }
     577            }
    566578
    567579/* too slow?
     
    10001012
    10011013
    1002 int scan_bounds(FILE* fp, int xcol, int ycol, int zcol, char *fs, int shell_style)
     1014int scan_bounds(FILE* fp, int xcol, int ycol, int zcol, char *fs, int shell_style, int skipline)
    10031015{
    10041016    int    line, first, max_col;
     
    10281040        ntokens = G_number_of_tokens ( tokens );
    10291041
    1030         if((ntokens < 3) || (max_col > ntokens) )
    1031             G_fatal_error(_("Not enough data columns. "
    1032                "Incorrect delimiter or column number?\n[%s]"), buff);
     1042        if((ntokens < 3) || (max_col > ntokens) ) {
     1043            if (skipline) {
     1044                   G_warning(_("Not enough data columns. "
     1045                     "Incorrect delimiter or column number? "
     1046                     "Found the following character(s) in row %d:\n[%s]"), line, buff);
     1047                   G_warning(_("Line ignored as requested"));
     1048                   continue; /* line is garbage */
     1049            } else {
     1050                   G_fatal_error(_("Not enough data columns. "
     1051                     "Incorrect delimiter or column number? "
     1052                     "Found the following character(s) in row %d:\n[%s]"), line, buff);
     1053            }
     1054        }
    10331055
    10341056/* too slow?
Note: See TracChangeset for help on using the changeset viewer.