| OLD | NEW |
| (Empty) |
| 1 #include <cstdlib> | |
| 2 #include <cstring> | |
| 3 #include <cstdio> | |
| 4 #include <ctype.h> | |
| 5 | |
| 6 #include "../hunspell/csutil.hxx" | |
| 7 #include "manparser.hxx" | |
| 8 | |
| 9 | |
| 10 #ifndef W32 | |
| 11 using namespace std; | |
| 12 #endif | |
| 13 | |
| 14 ManParser::ManParser() { | |
| 15 } | |
| 16 | |
| 17 ManParser::ManParser(const char * wordchars) | |
| 18 { | |
| 19 init(wordchars); | |
| 20 } | |
| 21 | |
| 22 ManParser::ManParser(unsigned short * wordchars, int len) | |
| 23 { | |
| 24 init(wordchars, len); | |
| 25 } | |
| 26 | |
| 27 ManParser::~ManParser() | |
| 28 { | |
| 29 } | |
| 30 | |
| 31 char * ManParser::next_token() | |
| 32 { | |
| 33 for (;;) { | |
| 34 switch (state) | |
| 35 { | |
| 36 case 1: // command arguments | |
| 37 if (line[actual][head] == ' ') state = 2; | |
| 38 break; | |
| 39 case 0: // dot in begin of line | |
| 40 if (line[actual][0] == '.') { | |
| 41 state = 1; | |
| 42 break; | |
| 43 } else { | |
| 44 state = 2; | |
| 45 } | |
| 46 // no break | |
| 47 case 2: // non word chars | |
| 48 if (is_wordchar(line[actual] + head)) { | |
| 49 state = 3; | |
| 50 token = head; | |
| 51 } else if ((line[actual][head] == '\\') && | |
| 52 (line[actual][head + 1] == 'f') && | |
| 53 (line[actual][head + 2] != '\0')) { | |
| 54 head += 2; | |
| 55 } | |
| 56 break; | |
| 57 case 3: // wordchar | |
| 58 if (! is_wordchar(line[actual] + head)) { | |
| 59 state = 2; | |
| 60 char * t = alloc_token(token, &head); | |
| 61 if (t) return t; | |
| 62 } | |
| 63 break; | |
| 64 } | |
| 65 if (next_char(line[actual], &head)) { | |
| 66 state = 0; | |
| 67 return NULL; | |
| 68 } | |
| 69 } | |
| 70 } | |
| 71 | |
| OLD | NEW |