+static PARSE_FUNC(parse_backslashed_char) {
+ switch (c) {
+ case '\r':
+ case '\n':
+ if (strs->len == cps->start)
+ break;
+ else if (
+ buffer_append_char_ptr(ptrs, (char*)cps->start) < 0
+ || buffer_append_char(strs, '\0') < 0
+ )
+ return ERR;
+ cps->start = strs->len - 1;
+ break;
+ default:
+ if (!isprint(c)) {
+ fprintf(stderr, "Error: invalid input: '%d'\n", c);
+ return ERR;
+ } else if (buffer_append_char(strs, c) < 0)
+ return ERR;
+ }
+ cps->parse_char = parse_unquoted_char;
+ return OK;
+}
+
+int parse(FILE *fh, struct buffer *strs, struct buffer *ptrs) {
+ struct cheapsh_parser_state cps = { parse_unquoted_char, 0 };
+ size_t i;