state = read_quoted;
}
else if (*p == '\r' || *p == '\n') {
- /* Reset line length */
- cur_len = 0;
-
- while (g_ascii_isspace (*p)) {
- p ++;
+ if (cur_len > fold_max && !first_token) {
+ fold_type = fold_before;
+ state = fold_token;
+ next_state = read_token;
}
+ else {
+ /* Reset line length */
+ cur_len = 0;
- g_string_append_len (res, c, p - c);
- c = p;
+ while (g_ascii_isspace (*p)) {
+ p ++;
+ }
+
+ g_string_append_len (res, c, p - c);
+ c = p;
+ first_token = TRUE;
+ }
}
else if (g_ascii_isspace (*p)) {
if (cur_len > fold_max * 0.8 && cur_len < fold_max) {
c = p;
first_token = FALSE;
p ++;
+ cur_len ++;
}
}
else {
break;
case fold_token:
/* Here, we have token start at 'c' and token end at 'p' */
+ g_assert (p > c);
+
if (fold_type == fold_after) {
g_string_append_len (res, c, p - c);
if (g_ascii_isspace (*p)) {
p ++;
}
+
+ cur_len = 0;
}
else {
/* Skip space if needed */
- if (g_ascii_isspace (*c)) {
+ if (g_ascii_isspace (*c) && p > c) {
c ++;
}
}
g_string_append_len (res, c, p - c);
+ cur_len = p - c;
}
+ first_token = TRUE;
c = p;
state = next_state;
- cur_len = 0;
- first_token = TRUE;
break;
case read_quoted: