line breaking in strings without inserting newlines
parent
64b12b442b
commit
ccf24e95f5
|
@ -741,6 +741,19 @@ namespace util {
|
|||
ret += writer.put(str.front());
|
||||
break;
|
||||
}
|
||||
} else if (str.front() == '\\') {
|
||||
str.pop_front();
|
||||
if (str.empty()) {
|
||||
break;
|
||||
}
|
||||
char c = str.front();
|
||||
if ((c == '\r') || (c == '\n')) {
|
||||
if (!str.empty() && (c == '\r') && (str.front() == '\n')) {
|
||||
str.pop_front();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
ret += writer.put('\\');
|
||||
} else {
|
||||
ret += writer.put(str.front());
|
||||
}
|
||||
|
|
|
@ -45,6 +45,16 @@ static ostd::ConstCharRange cs_parse_str(ostd::ConstCharRange str) {
|
|||
break;
|
||||
}
|
||||
return str;
|
||||
case '\\':
|
||||
++str;
|
||||
if (!str.empty() && ((*str == '\r') || (*str == '\n'))) {
|
||||
char c = *str;
|
||||
++str;
|
||||
if (!str.empty() && (c == '\r') && (*str == '\n')) {
|
||||
++str;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
++str;
|
||||
}
|
||||
|
@ -67,6 +77,17 @@ ostd::ConstCharRange GenState::get_str() {
|
|||
break;
|
||||
}
|
||||
goto done;
|
||||
case '\\': {
|
||||
next_char();
|
||||
char c = current();
|
||||
if ((c == '\r') || (c == '\n')) {
|
||||
if ((c == '\r') && (current(1) == '\n')) {
|
||||
next_char();
|
||||
}
|
||||
next_char();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
done:
|
||||
|
|
|
@ -199,6 +199,16 @@ namespace util {
|
|||
break;
|
||||
}
|
||||
return str;
|
||||
case '\\':
|
||||
++str;
|
||||
if (!str.empty() && ((*str == '\r') || (*str == '\n'))) {
|
||||
char c = *str;
|
||||
++str;
|
||||
if (!str.empty() && (c == '\r') && (*str == '\n')) {
|
||||
++str;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
++str;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue