IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 30, 2012, 10:26:52 AM (14 years ago)
Author:
eugene
Message:

handle \r as well as \n for EOL in read vectors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20120905/Ohana/src/opihi/cmd.data/read_vectors.c

    r34468 r34751  
    3030  int i, j, Nskip, Narg, Nvec, *col, IsCSV, VERBOSE;
    3131  int Nbytes, Nstart, NELEM, Nelem, nread, *coltype;
    32   char *colstr, *c0, *c1, *buffer, *extname;
     32  char *colstr, *c0, *c1, *extname;
    3333  Vector **vec;
     34
     35  char *buffer = NULL;
    3436
    3537  /* auto-sense table type */
     
    155157  bzero (buffer, 0x10001);
    156158  for (i = 0; i < Nskip; i++) {
    157     scan_line (f, buffer);
     159    if (scan_line_maxlen (f, buffer, 0x10000) == EOF) {
     160      gprint (GP_ERR, "problem reading file %s\n", filename);
     161      free (vec);
     162      free (col);
     163      return FALSE;
     164    }
    158165  }
    159166
     
    179186    while (bufferStatus) {
    180187      c1 = strchr (c0, '\n'); // find the end of this current line
     188      if (!c1) {
     189        c1 = strchr (c0, '\r'); // try \r for non-UNIX files (what do we do about a Mac? \n\r?)
     190      }
    181191      if (c1 == (char *) NULL) {
    182192        Nstart = strlen (c0);
     
    260270  free (vec);
    261271  free (col);
    262   free (buffer);
     272  if (buffer) free (buffer);
    263273  return (TRUE);
    264274
Note: See TracChangeset for help on using the changeset viewer.