From f3dbe1cf68ac321907c1d02bc538cc20fd4f7027 Mon Sep 17 00:00:00 2001 From: Daniel Carl Date: Tue, 11 Mar 2014 01:37:52 +0100 Subject: [PATCH] Use new chartable instead of ctype.h functions. --- src/ex.c | 20 +++++++++----------- src/hints.c | 3 +-- src/normal.c | 5 ++--- src/util.c | 2 +- 4 files changed, 13 insertions(+), 17 deletions(-) diff --git a/src/ex.c b/src/ex.c index d1408c3..80df73a 100644 --- a/src/ex.c +++ b/src/ex.c @@ -21,7 +21,6 @@ * This file contains function to handle input editing, parsing of called ex * commands from inputbox and the ex commands. */ -#include #include #include "config.h" #include "main.h" @@ -429,7 +428,7 @@ static gboolean parse(const char **input, ExArg *arg) g_string_truncate(arg->rhs, 0); /* remove leading whitespace and : */ - while (**input && (**input == ':' || **input == ' ')) { + while (**input && (**input == ':' || VB_IS_SPACE(**input))) { (*input)++; } parse_count(input, arg); @@ -467,13 +466,13 @@ static gboolean parse(const char **input, ExArg *arg) */ static gboolean parse_count(const char **input, ExArg *arg) { - if (!*input || !isdigit(**input)) { + if (!*input || !VB_IS_DIGIT(**input)) { arg->count = 0; } else { do { arg->count = arg->count * 10 + (**input - '0'); (*input)++; - } while (isdigit(**input)); + } while (VB_IS_DIGIT(**input)); } return true; } @@ -508,13 +507,13 @@ static gboolean parse_command_name(const char **input, ExArg *arg) } } (*input)++; - } while (matches > 0 && **input && **input != ' ' && **input != '!'); + } while (matches > 0 && **input && !VB_IS_SPACE(**input) && **input != '!'); if (!matches) { /* read until next whitespace or end of input to get command name for * error message - vim uses the whole rest of the input string - but * the first word seems to bee enough for the error message */ - for (; len < LENGTH(cmd) && *input && **input != ' '; (*input)++) { + for (; len < LENGTH(cmd) && *input && !VB_IS_SPACE(**input); (*input)++) { cmd[len++] = **input; } cmd[len] = '\0'; @@ -556,7 +555,7 @@ static gboolean parse_lhs(const char **input, ExArg *arg) /* get the char until the next none escaped whitespace and save it into * the lhs */ - while (**input && **input != ' ') { + while (**input && !VB_IS_SPACE(**input)) { /* if we find a backslash this escapes the next whitespace */ if (**input == quote) { /* move pointer to the next char */ @@ -655,8 +654,7 @@ static gboolean execute(const ExArg *arg) static void skip_whitespace(const char **input) { - /* TODO should \t also be skipped here? */ - while (**input && **input == ' ') { + while (**input && VB_IS_SPACE(**input)) { (*input)++; } } @@ -956,7 +954,7 @@ static gboolean complete(short direction) * if tha command name parsing fails */ before_cmdname = in; - if (parse_command_name(&in, arg) && *in == ' ') { + if (parse_command_name(&in, arg) && VB_IS_SPACE(*in)) { const char *token; /* get only the last word of input string for the completion for * bookmark tag completion */ @@ -964,7 +962,7 @@ static gboolean complete(short direction) /* find the end of the input and search for the next * whitespace toward the beginning */ token = strrchr(in, '\0'); - while (token >= in && *token != ' ') { + while (token >= in && !VB_IS_SPACE(*token)) { token--; } } else { diff --git a/src/hints.c b/src/hints.c index a3e2d87..4bfc51c 100644 --- a/src/hints.c +++ b/src/hints.c @@ -17,7 +17,6 @@ * along with this program. If not, see http://www.gnu.org/licenses/. */ -#include #include "config.h" #include #include @@ -82,7 +81,7 @@ VbResult hints_keypress(int key) if (call_hints_function("update", 1, arguments)) { return RESULT_COMPLETE; } - } else if (isdigit(key)) { + } else if (VB_IS_DIGIT(key)) { arguments[0] = JSValueMakeNumber(hints.ctx, key - '0'); if (call_hints_function("update", 1, arguments)) { return RESULT_COMPLETE; diff --git a/src/normal.c b/src/normal.c index e69f13e..3033572 100644 --- a/src/normal.c +++ b/src/normal.c @@ -18,7 +18,6 @@ */ #include -#include #include "config.h" #include "mode.h" #include "main.h" @@ -257,7 +256,7 @@ VbResult normal_keypress(int key) } else if (info.phase == PHASE_KEY3) { info.key3 = key; info.phase = PHASE_COMPLETE; - } else if (info.phase == PHASE_START && isdigit(key)) { + } else if (info.phase == PHASE_START && VB_IS_DIGIT(key)) { info.count = info.count * 10 + key - '0'; } else if (strchr(";zg[]'m", (char)key)) { /* handle commands that needs additional char */ @@ -785,7 +784,7 @@ static VbResult normal_zoom(const NormalCmdInfo *info) setting = webkit_web_view_get_settings(view); g_object_get(G_OBJECT(setting), "zoom-step", &step, NULL); - webkit_web_view_set_full_content_zoom(view, isupper(info->key2)); + webkit_web_view_set_full_content_zoom(view, VB_IS_UPPER(info->key2)); /* calculate the new zoom level */ if (info->key2 == 'i' || info->key2 == 'I') { diff --git a/src/util.c b/src/util.c index f3fb470..38212d6 100644 --- a/src/util.c +++ b/src/util.c @@ -20,7 +20,7 @@ #include "config.h" #include #include -#include "ctype.h" +#include #include "util.h" #include "ascii.h" -- 2.20.1