Switch to unified view

a/src/utils/smallut.cpp b/src/utils/smallut.cpp
...
...
355
    if (pos != string::npos && pos != s.length()-1)
355
    if (pos != string::npos && pos != s.length()-1)
356
    s.replace(pos+1, string::npos, string());
356
    s.replace(pos+1, string::npos, string());
357
}
357
}
358
358
359
// Remove some chars and replace them with spaces
359
// Remove some chars and replace them with spaces
360
string neutchars(const string &str, string delims)
360
string neutchars(const string &str, const string &chars)
361
{
361
{
362
    string out;
362
    string out;
363
    neutchars(str, out, chars);
364
    return out;
365
}
366
void neutchars(const string &str, string &out, const string& chars)
367
{
363
    string::size_type startPos, pos;
368
    string::size_type startPos, pos;
364
369
365
    for (pos = 0;;) { 
370
    for (pos = 0;;) { 
366
        // Skip initial delims, break if this eats all.
371
        // Skip initial chars, break if this eats all.
367
        if ((startPos = str.find_first_not_of(delims, pos)) == string::npos)
372
        if ((startPos = str.find_first_not_of(chars, pos)) == string::npos)
368
        break;
373
        break;
369
        // Find next delimiter or end of string (end of token)
374
        // Find next delimiter or end of string (end of token)
370
        pos = str.find_first_of(delims, startPos);
375
        pos = str.find_first_of(chars, startPos);
371
        // Add token to the output. Note: token cant be empty here
376
        // Add token to the output. Note: token cant be empty here
372
    if (pos == string::npos) {
377
    if (pos == string::npos) {
373
        out += str.substr(startPos);
378
        out += str.substr(startPos);
374
    } else {
379
    } else {
375
        out += str.substr(startPos, pos - startPos) + " ";
380
        out += str.substr(startPos, pos - startPos) + " ";
376
    }
381
    }
377
    }
382
    }
378
    return out;
379
}
383
}
380
384
381
385
382
/* Truncate a string to a given maxlength, avoiding cutting off midword
386
/* Truncate a string to a given maxlength, avoiding cutting off midword
383
 * if reasonably possible. Note: we could also use textsplit, stopping when
387
 * if reasonably possible. Note: we could also use textsplit, stopping when
...
...
709
    cout << testit << endl;
713
    cout << testit << endl;
710
    }
714
    }
711
#elif 1
715
#elif 1
712
    std::string testit("ligne\ndeuxieme ligne\r3eme ligne\r\n");
716
    std::string testit("ligne\ndeuxieme ligne\r3eme ligne\r\n");
713
    cout << "[" << neutchars(testit, "\r\n") << "]" << endl;
717
    cout << "[" << neutchars(testit, "\r\n") << "]" << endl;
718
    string i, o;
719
    cout << "neutchars(null) is [" << neutchars(i, "\r\n") << "]" << endl;
714
#endif
720
#endif
715
721
716
}
722
}
717
723
718
#endif
724
#endif