src/highlighter.c

changeset 94
48ebc3dd34a5
parent 92
fe4dfb4d074d
equal deleted inserted replaced
93:661dd5f26bfd 94:48ebc3dd34a5
53 } 53 }
54 } 54 }
55 55
56 static int check_keyword(cxstring word, const char** keywords) { 56 static int check_keyword(cxstring word, const char** keywords) {
57 for (int i = 0 ; keywords[i] ; i++) { 57 for (int i = 0 ; keywords[i] ; i++) {
58 if (cx_strcmp(word, cx_str(keywords[i])) == 0) { 58 if (cx_strcmp(word, keywords[i]) == 0) {
59 return 1; 59 return 1;
60 } 60 }
61 } 61 }
62 return 0; 62 return 0;
63 } 63 }
369 } else { 369 } else {
370 /* write buffered word, if any */ 370 /* write buffered word, if any */
371 if (wbuf->size > 0) { 371 if (wbuf->size > 0) {
372 cxstring word = cx_strn(wbuf->space, wbuf->size); 372 cxstring word = cx_strn(wbuf->space, wbuf->size);
373 int closespan = 1; 373 int closespan = 1;
374 cxstring typesuffix = CX_STR("_t");
375 if (check_keyword(word, ckeywords)) { 374 if (check_keyword(word, ckeywords)) {
376 start_span("keyword"); 375 start_span("keyword");
377 } else if (cx_strsuffix(word, typesuffix)) { 376 } else if (cx_strsuffix(word, "_t")) {
378 start_span("type"); 377 start_span("type");
379 } else if (word.ptr[0] == '#') { 378 } else if (word.ptr[0] == '#') {
380 isinclude = !cx_strcmp(word, CX_STR("#include")); 379 isinclude = !cx_strcmp(word, "#include");
381 start_span("directive"); 380 start_span("directive");
382 } else if (check_capsonly(word)) { 381 } else if (check_capsonly(word)) {
383 start_span("macroconst"); 382 start_span("macroconst");
384 } else { 383 } else {
385 closespan = 0; 384 closespan = 0;

mercurial