Switch to unified view

a/src/utils/conftree.cpp b/src/utils/conftree.cpp
...
...
39
#define LOGDEB(X) fprintf X
39
#define LOGDEB(X) fprintf X
40
#else
40
#else
41
#define LOGDEB(X)
41
#define LOGDEB(X)
42
#endif
42
#endif
43
43
44
#define LL 1024
45
void ConfSimple::parseinput(istream &input)
44
void ConfSimple::parseinput(istream &input)
46
{
45
{
47
    string submapkey;
46
    string submapkey;
48
    char cline[LL];
47
    string cline;
49
    bool appending = false;
48
    bool appending = false;
50
    string line;
49
    string line;
51
    bool eof = false;
50
    bool eof = false;
52
51
53
    for (;;) {
52
    for (;;) {
54
        cline[0] = 0;
53
        cline.clear();
55
  input.getline(cline, LL-1);
54
        std::getline(input, cline);
56
    LOGDEB((stderr, "Parse:line: [%s] status %d\n", cline, int(status)));
55
    LOGDEB((stderr, "Parse:line: [%s] status %d\n",
56
                cline.c_str(), int(status)));
57
    if (!input.good()) {
57
    if (!input.good()) {
58
        if (input.bad()) {
58
        if (input.bad()) {
59
                LOGDEB((stderr, "Parse: input.bad()\n"));
59
                LOGDEB((stderr, "Parse: input.bad()\n"));
60
        status = STATUS_ERROR;
60
        status = STATUS_ERROR;
61
        return;
61
        return;
...
...
66
        // eof ends with a backslash, or there is no final \n
66
        // eof ends with a backslash, or there is no final \n
67
            eof = true;
67
            eof = true;
68
    }
68
    }
69
69
70
        {
70
        {
71
            size_t ll = strlen(cline);
71
            string::size_type pos = cline.find_last_not_of("\n\r");
72
            while (ll > 0 && (cline[ll-1] == '\n' || cline[ll-1] == '\r')) {
72
            if (pos == string::npos) {
73
                cline[ll-1] = 0;
74
                ll--;
73
                cline.clear();
74
            } else if (pos != cline.length()-1) {
75
                cline.erase(pos+1);
75
            }
76
            }
76
        }
77
        }
77
78
78
    if (appending)
79
    if (appending)
79
        line += cline;
80
        line += cline;