Switch to unified view

a/src/utils/smallut.cpp b/src/utils/smallut.cpp
...
...
180
    tokens.clear();
180
    tokens.clear();
181
    enum states {SPACE, TOKEN, INQUOTE, ESCAPE};
181
    enum states {SPACE, TOKEN, INQUOTE, ESCAPE};
182
    states state = SPACE;
182
    states state = SPACE;
183
    for (unsigned int i = 0; i < s.length(); i++) {
183
    for (unsigned int i = 0; i < s.length(); i++) {
184
    switch (s[i]) {
184
    switch (s[i]) {
185
      case '"': 
185
        case '"': 
186
        switch(state) {
186
        switch(state) {
187
        case SPACE: 
187
            case SPACE: 
188
        state=INQUOTE; continue;
188
        state=INQUOTE; continue;
189
        case TOKEN: 
189
            case TOKEN: 
190
            current += '"';
190
            current += '"';
191
        continue;
191
        continue;
192
        case INQUOTE: 
192
            case INQUOTE: 
193
      tokens.push_back(current);
193
                tokens.insert(tokens.end(), current);
194
        current.clear();
194
        current.clear();
195
        state = SPACE;
195
        state = SPACE;
196
        continue;
196
        continue;
197
        case ESCAPE:
197
            case ESCAPE:
198
            current += '"';
198
            current += '"';
199
            state = INQUOTE;
199
            state = INQUOTE;
200
        continue;
200
                continue;
201
        }
201
        }
202
        break;
202
        break;
203
      case '\\': 
203
        case '\\': 
204
        switch(state) {
204
        switch(state) {
205
        case SPACE: 
205
            case SPACE: 
206
        case TOKEN: 
206
            case TOKEN: 
207
        current += '\\';
207
                current += '\\';
208
        state=TOKEN; 
208
                state=TOKEN; 
209
        continue;
209
                continue;
210
        case INQUOTE: 
210
            case INQUOTE: 
211
        state = ESCAPE;
211
                state = ESCAPE;
212
        continue;
212
                continue;
213
        case ESCAPE:
213
            case ESCAPE:
214
        current += '\\';
214
                current += '\\';
215
        state = INQUOTE;
215
                state = INQUOTE;
216
        continue;
216
                continue;
217
        }
217
        }
218
        break;
218
        break;
219
219
220
      case ' ': 
220
        case ' ': 
221
      case '\t': 
221
        case '\t': 
222
      case '\n': 
222
        case '\n': 
223
      case '\r': 
223
        case '\r': 
224
        switch(state) {
224
        switch(state) {
225
        case SPACE: 
225
            case SPACE: 
226
        continue;
226
                continue;
227
        case TOKEN: 
227
            case TOKEN: 
228
      tokens.push_back(current);
228
      tokens.insert(tokens.end(), current);
229
        current.clear();
229
        current.clear();
230
        state = SPACE;
230
        state = SPACE;
231
        continue;
231
        continue;
232
        case INQUOTE: 
232
            case INQUOTE: 
233
        case ESCAPE:
233
            case ESCAPE:
234
        current += s[i];
234
                current += s[i];
235
        continue;
235
                continue;
236
        }
236
        }
237
        break;
237
        break;
238
238
239
      default:
239
        default:
240
        switch(state) {
240
        switch(state) {
241
        case ESCAPE:
241
            case ESCAPE:
242
        state = INQUOTE;
242
                state = INQUOTE;
243
        break;
243
                break;
244
        case SPACE: 
244
            case SPACE: 
245
        state = TOKEN;
245
                state = TOKEN;
246
        break;
246
                break;
247
        case TOKEN: 
247
            case TOKEN: 
248
        case INQUOTE: 
248
            case INQUOTE: 
249
        break;
249
                break;
250
        }
250
        }
251
        current += s[i];
251
        current += s[i];
252
    }
252
    }
253
    }
253
    }
254
    switch(state) {
254
    switch(state) {
255
    case SPACE: 
255
    case SPACE: 
256
    break;
256
    break;
257
    case TOKEN: 
257
    case TOKEN: 
258
  tokens.push_back(current);
258
  tokens.insert(tokens.end(), current);
259
    break;
259
    break;
260
    case INQUOTE: 
260
    case INQUOTE: 
261
    case ESCAPE:
261
    case ESCAPE:
262
    return false;
262
    return false;
263
    }
263
    }
...
...
268
    return stringToStrings<list<string> >(s, tokens);
268
    return stringToStrings<list<string> >(s, tokens);
269
}
269
}
270
bool stringToStrings(const string &s, vector<string> &tokens)
270
bool stringToStrings(const string &s, vector<string> &tokens)
271
{
271
{
272
    return stringToStrings<vector<string> >(s, tokens);
272
    return stringToStrings<vector<string> >(s, tokens);
273
}
274
bool stringToStrings(const string &s, set<string> &tokens)
275
{
276
    return stringToStrings<set<string> >(s, tokens);
273
}
277
}
274
278
275
template <class T> void stringsToString(const T &tokens, string &s) 
279
template <class T> void stringsToString(const T &tokens, string &s) 
276
{
280
{
277
    for (typename T::const_iterator it = tokens.begin();
281
    for (typename T::const_iterator it = tokens.begin();