Mercurial > hg > octave-nkf
comparison src/ls-mat-ascii.cc @ 5275:23b37da9fd5b
[project @ 2005-04-08 16:07:35 by jwe]
author | jwe |
---|---|
date | Fri, 08 Apr 2005 16:07:37 +0000 |
parents | c7f9ea142fda |
children | 4c8a2e4e0717 |
comparison
equal
deleted
inserted
replaced
5274:eae7b40388e9 | 5275:23b37da9fd5b |
---|---|
106 | 106 |
107 return retval; | 107 return retval; |
108 } | 108 } |
109 | 109 |
110 static void | 110 static void |
111 get_lines_and_columns (std::istream& is, const std::string& filename, int& nr, int& nc) | 111 get_lines_and_columns (std::istream& is, const std::string& filename, octave_idx_type& nr, octave_idx_type& nc) |
112 { | 112 { |
113 std::streampos pos = is.tellg (); | 113 std::streampos pos = is.tellg (); |
114 | 114 |
115 int file_line_number = 0; | 115 int file_line_number = 0; |
116 | 116 |
136 // We had a blank line ending with a CRLF. Handle it the | 136 // We had a blank line ending with a CRLF. Handle it the |
137 // same as an empty line. | 137 // same as an empty line. |
138 beg = NPOS; | 138 beg = NPOS; |
139 } | 139 } |
140 | 140 |
141 int tmp_nc = 0; | 141 octave_idx_type tmp_nc = 0; |
142 | 142 |
143 while (beg != NPOS) | 143 while (beg != NPOS) |
144 { | 144 { |
145 tmp_nc++; | 145 tmp_nc++; |
146 | 146 |
226 if (is_keyword (varname) || ! isalpha (varname[0])) | 226 if (is_keyword (varname) || ! isalpha (varname[0])) |
227 varname.insert (0, "X"); | 227 varname.insert (0, "X"); |
228 | 228 |
229 if (valid_identifier (varname)) | 229 if (valid_identifier (varname)) |
230 { | 230 { |
231 int nr = 0; | 231 octave_idx_type nr = 0; |
232 int nc = 0; | 232 octave_idx_type nc = 0; |
233 | 233 |
234 int total_count = 0; | 234 int total_count = 0; |
235 | 235 |
236 get_lines_and_columns (is, filename, nr, nc); | 236 get_lines_and_columns (is, filename, nr, nc); |
237 | 237 |
244 if (nr < 1 || nc < 1) | 244 if (nr < 1 || nc < 1) |
245 is.clear (std::ios::badbit); | 245 is.clear (std::ios::badbit); |
246 else | 246 else |
247 { | 247 { |
248 double d; | 248 double d; |
249 for (int i = 0; i < nr; i++) | 249 for (octave_idx_type i = 0; i < nr; i++) |
250 { | 250 { |
251 std::string buf = get_mat_data_input_line (is); | 251 std::string buf = get_mat_data_input_line (is); |
252 | 252 |
253 #ifdef HAVE_SSTREAM | 253 #ifdef HAVE_SSTREAM |
254 std::istringstream tmp_stream (buf); | 254 std::istringstream tmp_stream (buf); |
255 #else | 255 #else |
256 std::istrstream tmp_stream (buf.c_str ()); | 256 std::istrstream tmp_stream (buf.c_str ()); |
257 #endif | 257 #endif |
258 | 258 |
259 for (int j = 0; j < nc; j++) | 259 for (octave_idx_type j = 0; j < nc; j++) |
260 { | 260 { |
261 OCTAVE_QUIT; | 261 OCTAVE_QUIT; |
262 | 262 |
263 d = octave_read_double (tmp_stream); | 263 d = octave_read_double (tmp_stream); |
264 | 264 |
303 // XXX FIXME XXX -- not sure this is best, but it works. | 303 // XXX FIXME XXX -- not sure this is best, but it works. |
304 | 304 |
305 if (is.eof ()) | 305 if (is.eof ()) |
306 is.clear (); | 306 is.clear (); |
307 | 307 |
308 int expected = nr * nc; | 308 octave_idx_type expected = nr * nc; |
309 | 309 |
310 if (expected == total_count) | 310 if (expected == total_count) |
311 { | 311 { |
312 tc = tmp; | 312 tc = tmp; |
313 retval = varname; | 313 retval = varname; |