[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemacs-commit] qemacs clang.c
From: |
Charlie Gordon |
Subject: |
[Qemacs-commit] qemacs clang.c |
Date: |
Thu, 20 Dec 2007 11:52:33 +0000 |
CVSROOT: /cvsroot/qemacs
Module name: qemacs
Changes by: Charlie Gordon <chqrlie> 07/12/20 11:52:33
Modified files:
. : clang.c
Log message:
simplified string coloring
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/clang.c?cvsroot=qemacs&r1=1.18&r2=1.19
Patches:
Index: clang.c
===================================================================
RCS file: /cvsroot/qemacs/qemacs/clang.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- clang.c 18 Dec 2007 18:07:03 -0000 1.18
+++ clang.c 20 Dec 2007 11:52:33 -0000 1.19
@@ -79,7 +79,7 @@
void c_colorize_line(unsigned int *buf, int len,
int *colorize_state_ptr, __unused__ int state_only)
{
- int c, state, style, klen, type_decl;
+ int c, state, style, style1, type_decl, klen, delim;
unsigned int *p, *p_start, *p_end, *p1, *p2;
char kbuf[32];
@@ -148,9 +148,6 @@
state = C_PREPROCESS;
style = QE_STYLE_PREPROCESS;
break;
- set_preprocessor:
- set_color(p_start, p, QE_STYLE_PREPROCESS);
- continue;
case 'L': /* wide character and string literals */
if (*p == '\'') {
p++;
@@ -164,40 +161,33 @@
case '\'': /* character constant */
parse_string_q:
state |= C_STRING_Q;
- for (; p < p_end; p++) {
- if (*p == '\\') {
- p++;
- if (p >= p_end)
- break;
- } else
- if (*p == '\'') {
- p++;
- state &= ~C_STRING_Q;
- break;
- }
- }
- if (state & C_PREPROCESS)
- goto set_preprocessor;
- set_color(p_start, p, QE_STYLE_STRING_Q);
- continue;
- case '\"': /* strings literal */
+ style1 = QE_STYLE_STRING_Q;
+ delim = '\'';
+ goto string;
+ case '\"': /* string literal */
parse_string:
state |= C_STRING;
- for (; p < p_end; p++) {
+ style1 = QE_STYLE_STRING;
+ delim = '\"';
+ string:
+ while (p < p_end) {
if (*p == '\\') {
p++;
if (p >= p_end)
break;
+ p++;
} else
- if (*p == '\"') {
+ if ((int)*p == delim) {
p++;
- state &= ~C_STRING;
+ state &= ~(C_STRING | C_STRING_Q);
break;
+ } else {
+ p++;
}
}
if (state & C_PREPROCESS)
- goto set_preprocessor;
- set_color(p_start, p, QE_STYLE_STRING);
+ style1 = QE_STYLE_PREPROCESS;
+ set_color(p_start, p, style1);
continue;
case '=':
/* exit type declaration */
@@ -232,6 +222,11 @@
} while (qe_isalnum(c) || c == '_');
kbuf[klen] = '\0';
+ if (strfind(c_mode_keywords, kbuf, 0)) {
+ set_color(p_start, p, QE_STYLE_KEYWORD);
+ continue;
+ }
+
p1 = p;
while (qe_isblank(*p1))
p1++;
@@ -239,9 +234,6 @@
while (*p2 == '*' || qe_isblank(*p2))
p2++;
- if (strfind(c_mode_keywords, kbuf, 0)) {
- set_color(p_start, p, QE_STYLE_KEYWORD);
- } else
if (strfind(c_mode_types, kbuf, 0)
|| (klen > 2 && kbuf[klen - 2] == '_' && kbuf[klen - 1] ==
't')) {
/* c type */
@@ -250,12 +242,15 @@
type_decl = 1;
}
set_color(p_start, p, QE_STYLE_TYPE);
- } else
+ continue;
+ }
+
if (*p == '(') {
/* function call */
/* XXX: different styles for call and definition */
set_color(p_start, p, QE_STYLE_FUNCTION);
- } else {
+ continue;
+ }
/* assume typedef if starting at first column */
if (p_start == buf)
type_decl = 1;
@@ -268,7 +263,6 @@
set_color(p_start, p, QE_STYLE_VARIABLE);
}
}
- }
continue;
}
break;