]> git.ozlabs.org Git - ccan/blobdiff - ccan/ccan_tokenizer/ccan_tokenizer.c
strsplit: remove nump argument
[ccan] / ccan / ccan_tokenizer / ccan_tokenizer.c
index 7d29e025552ba93e9a6aec802db00911b49534cb..cb1b2716a71e722f0578d1417e68609d4e9c3c51 100644 (file)
@@ -218,7 +218,7 @@ static void unbreak_backslash_broken_lines(struct token_list *tl, tok_message_qu
        txt.item[txt.size] = 0;
        
        //convert the line start offsets to pointers
-       array_for(i, tlines, *i = txt.item + (size_t)*i);
+       array_for_t(i, tlines, const char *, *i = txt.item + (size_t)*i);
        
        tl->olines = olines.item;
        tl->olines_size = olines.size;
@@ -401,7 +401,7 @@ struct token_list *tokenize(const char *orig, size_t orig_size,
        s = tl->txt;
        e = s + tl->txt_size;
        
-       array_appends(array, {
+       array_appends_t(array, struct token, {
                .type = TOK_STARTLINE,
                .txt = s,
                .txt_size = 0
@@ -473,12 +473,19 @@ struct token_list *tokenize(const char *orig, size_t orig_size,
                                
                                add(.type = type,
                                        {.include = include});
+                               
                        } else if (c=='\'' || c=='\"') { //character or string literal
                                array_char string = array_new(tl);
                                s = read_cstring(&string, s, e, c, mq);
                                if (s<e) s++; //advance past endquote (if available)
                                add(.type = c=='\'' ? TOK_CHAR : TOK_STRING,
                                    {.string = string});
+                               
+                               if (c=='\'' && string.size==0) {
+                                       tok_msg_error(empty_char_constant, orig,
+                                               "Empty character constant");
+                               }
+                               
                        } else if (c=='/' && s<e && (*s=='*' || *s=='/')) { //comment
                                if (*s++ == '*') { /* C-style comment */
                                        const char *comment_start = s-2;