| 31 | // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // |
| 32 | |
| 33 | char Foam::ISstream::nextValid() |
| 34 | { |
| 35 | char c = 0; |
| 36 | |
| 37 | while (true) |
| 38 | { |
| 39 | // Get next non-whitespace character |
| 40 | while (get(c) && isspace(c)) |
| 41 | {} |
| 42 | |
| 43 | // Return if stream is bad - ie, previous get() failed |
| 44 | if (bad() || isspace(c)) |
| 45 | { |
| 46 | break; |
| 47 | } |
| 48 | |
| 49 | // Is this the start of a C/C++ comment? |
| 50 | if (c == '/') |
| 51 | { |
| 52 | if (!get(c)) |
| 53 | { |
| 54 | // cannot get another character - return this one |
| 55 | return '/'; |
| 56 | } |
| 57 | |
| 58 | if (c == '/') |
| 59 | { |
| 60 | // C++ style single-line comment - skip through past end-of-line |
| 61 | while (get(c) && c != '\n') |
| 62 | {} |
| 63 | } |
| 64 | else if (c == '*') |
| 65 | { |
| 66 | // within a C-style comment |
| 67 | while (true) |
| 68 | { |
| 69 | // search for end of C-style comment - '*/' |
| 70 | if (get(c) && c == '*') |
| 71 | { |
| 72 | if (get(c)) |
| 73 | { |
| 74 | if (c == '/') |
| 75 | { |
| 76 | // matched '*/' |
| 77 | break; |
| 78 | } |
| 79 | else if (c == '*') |
| 80 | { |
| 81 | // check again |
| 82 | putback(c); |
| 83 | } |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | if (!good()) |
| 88 | { |
| 89 | return 0; |
| 90 | } |