htable: fix tools/speed.
[ccan] / ccan / ccan_tokenizer / read_cstring.c
index 2302180c856943e452b1d016e5b4dc532af5073e..d1277ca12315425111ad47c217a1b21fc46c87a3 100644 (file)
@@ -11,16 +11,16 @@ static char *strdup_rng(const char *s, const char *e) {
 
 //Reads a C string starting at s until quoteChar is found or e is reached
 //  Returns the pointer to the terminating quote character or e if none was found
-char *read_cstring(array_char *out, const char *s, const char *e, char quoteChar, tok_message_queue *mq) {
+char *read_cstring(darray_char *out, const char *s, const char *e, char quoteChar, tok_message_queue *mq) {
        const char * const tokstart = s;
        const char *p;
        int has_endquote=0, has_newlines=0;
        
        //tok_msg_debug(called, s, "Called read_cstring on `%s`", s);
        
-       #define append(startptr,endptr) array_append_items(*out, startptr, (endptr)-(startptr))
-       #define append_char(theChar) array_append(*out, theChar)
-       #define append_zero() do {array_append(*out, 0); out->size--;} while(0)
+       #define append(startptr,endptr) darray_append_items(*out, startptr, (endptr)-(startptr))
+       #define append_char(theChar) darray_append(*out, theChar)
+       #define append_zero() do {darray_append(*out, 0); out->size--;} while(0)
        
        p = s;
        while (p<e) {
@@ -125,6 +125,8 @@ char *read_cstring(array_char *out, const char *s, const char *e, char quoteChar
                                                                "Double quote characters need not be escaped within single quotes"); */
                                                        break;
                                                }
+                                               if (c=='?') // \? is needed in some situations to avoid building a trigraph
+                                                       break;
                                                tok_msg_warn(unknown_escape, s-2,
                                                        "Unknown escape sequence '\\%c'", c);
                                                break;