comparison src/oct-stream.cc @ 12936:b74cb659e757

accept but discard sign when reading NA and NaN values * lo-utils.cc (octave_read_value<double>, octave_read_value<float>): Accept but discard sign for NA and NaN values. * oct-stream.cc (octave_scan<double>): Simplify by calling octave_read_value<double>.
author John W. Eaton <jwe@octave.org>
date Mon, 08 Aug 2011 12:14:41 -0400
parents 12df7854fa7c
children 8372d50de75a
comparison
equal deleted inserted replaced
12935:9529392f020e 12936:b74cb659e757
1225 while (is && (c1 = is.get ()) != EOF && isspace (c1)) 1225 while (is && (c1 = is.get ()) != EOF && isspace (c1))
1226 /* skip whitespace */; 1226 /* skip whitespace */;
1227 1227
1228 if (c1 != EOF) 1228 if (c1 != EOF)
1229 { 1229 {
1230 if (c1 == 'N') 1230 is.putback (c1);
1231 { 1231
1232 int c2 = is.get (); 1232 ref = octave_read_value<double> (is);
1233
1234 if (c2 != EOF)
1235 {
1236 if (c2 == 'A')
1237 {
1238 int c3 = is.get ();
1239
1240 if (c3 != EOF)
1241 {
1242 is.putback (c3);
1243
1244 if (isspace (c3) || ispunct (c3))
1245 ref = octave_NA;
1246 else
1247 {
1248 is.putback (c2);
1249 is.putback (c1);
1250
1251 is >> ref;
1252 }
1253 }
1254 else
1255 {
1256 is.clear ();
1257
1258 ref = octave_NA;
1259 }
1260 }
1261 else if (c2 == 'a')
1262 {
1263 int c3 = is.get ();
1264
1265 if (c3 != EOF)
1266 {
1267 if (c3 == 'N')
1268 {
1269 int c4 = is.get ();
1270
1271 if (c4 != EOF)
1272 {
1273 is.putback (c4);
1274
1275 if (isspace (c4) || ispunct (c4))
1276 ref = octave_NaN;
1277 else
1278 {
1279 is.putback (c3);
1280 is.putback (c2);
1281 is.putback (c1);
1282
1283 is >> ref;
1284 }
1285 }
1286 else
1287 {
1288 is.clear ();
1289
1290 ref = octave_NaN;
1291 }
1292 }
1293 else
1294 {
1295 is.putback (c3);
1296 is.putback (c2);
1297 is.putback (c1);
1298
1299 is >> ref;
1300 }
1301 }
1302 }
1303 else
1304 {
1305 is.putback (c2);
1306 is.putback (c1);
1307
1308 is >> ref;
1309 }
1310 }
1311 }
1312 else if (c1 == 'I')
1313 {
1314 int c2 = is.get ();
1315
1316 if (c2 != EOF)
1317 {
1318 if (c2 == 'n')
1319 {
1320 int c3 = is.get ();
1321
1322 if (c3 != EOF)
1323 {
1324 if (c3 == 'f')
1325 {
1326 int c4 = is.get ();
1327
1328 if (c4 != EOF)
1329 {
1330 is.putback (c4);
1331
1332 if (isspace (c4) || ispunct (c4))
1333 ref = octave_Inf;
1334 else
1335 {
1336 is.putback (c3);
1337 is.putback (c2);
1338 is.putback (c1);
1339
1340 is >> ref;
1341 }
1342 }
1343 else
1344 {
1345 is.clear ();
1346
1347 ref = octave_Inf;
1348 }
1349 }
1350 else
1351 {
1352 is.putback (c3);
1353 is.putback (c2);
1354 is.putback (c1);
1355
1356 is >> ref;
1357 }
1358 }
1359 else
1360 {
1361 is.putback (c2);
1362 is.putback (c1);
1363
1364 is >> ref;
1365 }
1366 }
1367 }
1368 }
1369 else
1370 {
1371 is.putback (c1);
1372
1373 is >> ref;
1374 }
1375 } 1233 }
1376 } 1234 }
1377 break; 1235 break;
1378 1236
1379 default: 1237 default: