Changeset 38984
- Timestamp:
- Oct 27, 2015, 4:27:02 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20150625/Ohana/src/opihi/cmd.data/read_vectors.c
r38980 r38984 190 190 ALLOCATE (buffer, char, 0x10001); 191 191 bzero (buffer, 0x10001); 192 193 /* 192 194 for (i = 0; i < Nskip; i++) { 193 195 if (scan_line_maxlen (f, buffer, 0x10000) == EOF) { … … 197 199 } 198 200 } 201 */ 202 203 int Nline_read = 0; // track number of lines read so far (use to skip lines as well) 199 204 200 205 // we have a working buffer read from the file. we parse the lines in the working buffer 201 206 // until we reach the last chunk without an EOL char. at that point, we shift the start 202 207 // of the last (partial) line to the start of the buffer and re-fill. 208 209 // we treat \n\r pair as a single EOL char to handle mac files: 203 210 204 211 Nstart = 0; // location of the last valid byte in the buffer (start filling here) … … 218 225 c0 = buffer; // c0 always marks the start of a line 219 226 while (bufferStatus) { 220 c1 = strchr (c0, '\n'); // find the end of this current line 227 c1 = strchr (c0, '\n'); // find the end of this current line (also valid for a Mac: \r\n) 221 228 if (!c1) { 222 c1 = strchr (c0, '\r'); // try \r for non-UNIX files (what do we do about a Mac? \n\r?)229 c1 = strchr (c0, '\r'); // try \r for non-UNIX files 223 230 } 224 231 if (c1 == (char *) NULL) { … … 229 236 } 230 237 *c1 = 0; // mark the end of the line 238 Nline_read ++; 239 240 if (Nline_read <= Nskip) { c0 = c1 + 1; continue; } 231 241 232 242 if (*c0 == '#') { c0 = c1 + 1; continue; }
Note:
See TracChangeset
for help on using the changeset viewer.
