[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemacs-commit] qemacs extra-modes.c
From: |
Charlie Gordon |
Subject: |
[Qemacs-commit] qemacs extra-modes.c |
Date: |
Sat, 09 May 2015 22:15:46 +0000 |
CVSROOT: /sources/qemacs
Module name: qemacs
Changes by: Charlie Gordon <chqrlie> 15/05/09 22:15:46
Modified files:
. : extra-modes.c
Log message:
added check_fcall() function to factorize function call detection
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/extra-modes.c?cvsroot=qemacs&r1=1.34&r2=1.35
Patches:
Index: extra-modes.c
===================================================================
RCS file: /sources/qemacs/qemacs/extra-modes.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -b -r1.34 -r1.35
--- extra-modes.c 4 May 2015 19:48:52 -0000 1.34
+++ extra-modes.c 9 May 2015 22:15:45 -0000 1.35
@@ -22,6 +22,12 @@
#define MAX_KEYWORD_SIZE 16
+static int check_fcall(unsigned int *str, int i) {
+ while (str[i] == ' ')
+ i++;
+ return str[i] == '(';
+}
+
/*---------------- x86 Assembly language coloring ----------------*/
static char const asm_prepkeywords1[] = {
@@ -511,7 +517,7 @@
}
}
if (style == VIM_STYLE_IDENTIFIER) {
- if (str[i] == '(' || (str[i] == ' ' && str[i + 1] == '('))
+ if (check_fcall(str, i))
style = VIM_STYLE_FUNCTION;
}
SET_COLOR(str, start, i, style);
@@ -864,15 +870,12 @@
} else
if (strfind(syn->types, keyword)) {
style = ADA_STYLE_TYPE;
- } else {
- k = i;
- if (qe_isblank(str[k]))
- k++;
- if (str[k] == '(')
+ } else
+ if (check_fcall(str, i))
style = ADA_STYLE_FUNCTION;
else
style = ADA_STYLE_IDENTIFIER;
- }
+
SET_COLOR(str, start, i, style);
continue;
}
@@ -933,7 +936,7 @@
unsigned int *str, int n, ModeDef *syn)
{
char keyword[MAX_KEYWORD_SIZE];
- int i = 0, start = i, c, k, style, len, w;
+ int i = 0, start = i, c, style, len, w;
int colstate = cp->colorize_state;
for (w = 0; qe_isspace(str[w]); w++)
@@ -1011,15 +1014,12 @@
} else
if (strfind(syn->types, keyword)) {
style = FORTRAN_STYLE_TYPE;
- } else {
- k = i;
- if (qe_isblank(str[k]))
- k++;
- if (str[k] == '(')
+ } else
+ if (check_fcall(str, i))
style = FORTRAN_STYLE_FUNCTION;
else
style = FORTRAN_STYLE_IDENTIFIER;
- }
+
SET_COLOR(str, start, i, style);
continue;
}
@@ -1683,9 +1683,7 @@
SET_COLOR(str, start, i, LUA_STYLE_KEYWORD);
continue;
}
- if (qe_isblank(str[i]))
- i++;
- if (str[i] == '(') {
+ if (check_fcall(str, i)) {
SET_COLOR(str, start, i, LUA_STYLE_FUNCTION);
continue;
}
@@ -1952,9 +1950,7 @@
SET_COLOR(str, start, i, JULIA_STYLE_TYPE);
continue;
}
- if (qe_isblank(str[i]))
- i++;
- if (str[i] == '(') {
+ if (check_fcall(str, i)) {
SET_COLOR(str, start, i, JULIA_STYLE_FUNCTION);
continue;
}
@@ -2155,9 +2151,7 @@
SET_COLOR(str, start, i, HASKELL_STYLE_KEYWORD);
continue;
}
- if (qe_isblank(str[i]))
- i++;
- if (str[i] == '(') {
+ if (check_fcall(str, i)) {
SET_COLOR(str, start, i, HASKELL_STYLE_FUNCTION);
continue;
}
@@ -2382,9 +2376,7 @@
SET_COLOR(str, start, i, PYTHON_STYLE_KEYWORD);
continue;
}
- if (qe_isblank(str[i]))
- i++;
- if (str[i] == '(') {
+ if (check_fcall(str, i)) {
SET_COLOR(str, start, i, PYTHON_STYLE_FUNCTION);
continue;
}
@@ -2990,7 +2982,7 @@
unsigned int *str, int n, ModeDef *syn)
{
char keyword[MAX_KEYWORD_SIZE];
- int i = 0, start = i, c, k, style, len, base;
+ int i = 0, start = i, c, style, len, base;
int colstate = cp->colorize_state;
if (colstate & IN_ERLANG_STRING)
@@ -3105,11 +3097,8 @@
} else
if (strfind(syn->keywords, keyword)) {
style = ERLANG_STYLE_KEYWORD;
- } else {
- k = i;
- if (qe_isblank(str[k]))
- k++;
- if (str[k] == '(') {
+ } else
+ if (check_fcall(str, i)) {
style = ERLANG_STYLE_FUNCTION;
} else
if (qe_islower(keyword[0])) {
@@ -3117,7 +3106,6 @@
} else {
style = ERLANG_STYLE_IDENTIFIER;
}
- }
SET_COLOR(str, start, i, style);
continue;
}
@@ -3361,9 +3349,7 @@
SET_COLOR(str, start, i, ELIXIR_STYLE_TAG);
continue;
}
- if (qe_isblank(str[i]))
- i++;
- if (str[i] == '(') {
+ if (check_fcall(str, i)) {
SET_COLOR(str, start, i, ELIXIR_STYLE_FUNCTION);
continue;
}
- [Qemacs-commit] qemacs extra-modes.c, Charlie Gordon, 2015/05/03
- [Qemacs-commit] qemacs extra-modes.c, Charlie Gordon, 2015/05/04
- [Qemacs-commit] qemacs extra-modes.c, Charlie Gordon, 2015/05/04
- [Qemacs-commit] qemacs extra-modes.c,
Charlie Gordon <=
- [Qemacs-commit] qemacs extra-modes.c, Charlie Gordon, 2015/05/09
- [Qemacs-commit] qemacs extra-modes.c, Charlie Gordon, 2015/05/09
- [Qemacs-commit] qemacs extra-modes.c, Charlie Gordon, 2015/05/09
- [Qemacs-commit] qemacs extra-modes.c, Charlie Gordon, 2015/05/09
- [Qemacs-commit] qemacs extra-modes.c, Charlie Gordon, 2015/05/14