comparison src/oct-stream.cc @ 5338:c4b55d47122e

[project @ 2005-05-05 17:28:51 by jwe]
author jwe
date Thu, 05 May 2005 17:28:51 +0000
parents 4f5faf0fd322
children df230b7df93c
comparison
equal deleted inserted replaced
5337:7ffada2604ea 5338:c4b55d47122e
1467 std::string tmp = tbuf; \ 1467 std::string tmp = tbuf; \
1468 \ 1468 \
1469 delete [] tbuf 1469 delete [] tbuf
1470 1470
1471 // For a `%s' format, skip initial whitespace and then read until the 1471 // For a `%s' format, skip initial whitespace and then read until the
1472 // next whitespace character. 1472 // next whitespace character or until WIDTH characters have been read.
1473 #define BEGIN_S_CONVERSION() \ 1473 #define BEGIN_S_CONVERSION() \
1474 int width = elt->width; \ 1474 int width = elt->width; \
1475 \ 1475 \
1476 std::string tmp; \ 1476 std::string tmp; \
1477 \ 1477 \
1478 do \ 1478 do \
1479 { \ 1479 { \
1480 if (width) \ 1480 if (width) \
1481 { \ 1481 { \
1482 char *tbuf = new char [width+1]; \ 1482 char *tbuf = new char [width+1]; \
1483 \ 1483 \
1484 OCTAVE_SCAN (is, *elt, tbuf); \ 1484 int c = EOF; \
1485 \ 1485 \
1486 tbuf[width] = '\0'; \ 1486 int n = 0; \
1487 \
1488 while (is && (c = is.get ()) != EOF) \
1489 { \
1490 if (! isspace (c)) \
1491 { \
1492 tbuf[n++] = static_cast<char> (c); \
1493 break; \
1494 } \
1495 } \
1496 \
1497 while (is && n < width && (c = is.get ()) != EOF) \
1498 { \
1499 if (isspace (c)) \
1500 { \
1501 is.putback (c); \
1502 break; \
1503 } \
1504 else \
1505 tbuf[n++] = static_cast<char> (c); \
1506 } \
1507 \
1508 tbuf[n] = '\0'; \
1509 \
1510 if (n > 0 && c == EOF) \
1511 is.clear (); \
1512 \
1487 tmp = tbuf; \ 1513 tmp = tbuf; \
1514 \
1488 delete [] tbuf; \ 1515 delete [] tbuf; \
1489 } \ 1516 } \
1490 else \ 1517 else \
1491 { \ 1518 { \
1492 is >> std::ws >> tmp; \ 1519 is >> std::ws >> tmp; \
1493 } \ 1520 } \
1494 } \ 1521 } \
1495 while (0) 1522 while (0)
1496 1523
1497 // This format must match a nonempty sequence of characters. 1524 // This format must match a nonempty sequence of characters.
1498 #define BEGIN_CHAR_CLASS_CONVERSION() \ 1525 #define BEGIN_CHAR_CLASS_CONVERSION() \