IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 13, 2017, 5:37:44 AM (9 years ago)
Author:
eugene
Message:

handle invalid characters in column numbers

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/cmd.data/read_vectors.c

    r39634 r40012  
    115115  }
    116116  fseeko (f, 0LL, SEEK_SET);
     117
     118  buffer = NULL;
    117119
    118120  Nvec = (argc - 1) / 2;
     
    160162
    161163    colstr = argv[2*i+2];
     164
     165    // numerical columns, e.g., 15, must be base 10 and not have other characters (15x)
     166    if (isdigit(colstr[0])) {
     167      char *endptr;
     168      long colnum_tmp = strtol(colstr, &endptr, 10);
     169      if (endptr[0]) {
     170        gprint (GP_ERR, "unexpected characters in column number: %s\n", endptr);
     171        goto bad_colname;
     172      }
     173      col[i] = colnum_tmp;
     174      continue;
     175    }
     176
     177    // allow 'excel' columns names of the form A-Z, AA-AZ, BA-BZ, .. ZA-ZZ
    162178    for (j = 0; j < strlen (colstr); j++) {
    163       if (isdigit(colstr[j])) {
    164         col[i] = atof (colstr);
    165         continue;
    166       }
    167       // allow 'excel' columns names of the form A-Z, AA-AZ, BA-BZ, .. ZA-ZZ
    168179      if (strlen(colstr) >= 3) goto bad_colname;
    169180      if (colstr[0] < 'A') goto bad_colname;
Note: See TracChangeset for help on using the changeset viewer.