Use new chartable instead of ctype.h functions.
authorDaniel Carl <danielcarl@gmx.de>
Tue, 11 Mar 2014 00:37:52 +0000 (01:37 +0100)
committerDaniel Carl <danielcarl@gmx.de>
Tue, 11 Mar 2014 00:37:52 +0000 (01:37 +0100)
src/ex.c
src/hints.c
src/normal.c
src/util.c

index d1408c3..80df73a 100644 (file)
--- 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 <ctype.h>
 #include <sys/wait.h>
 #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 {
index a3e2d87..4bfc51c 100644 (file)
@@ -17,7 +17,6 @@
  * along with this program. If not, see http://www.gnu.org/licenses/.
  */
 
-#include <ctype.h>
 #include "config.h"
 #include <gdk/gdkkeysyms.h>
 #include <gdk/gdkkeysyms-compat.h>
@@ -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;
index e69f13e..3033572 100644 (file)
@@ -18,7 +18,6 @@
  */
 
 #include <gdk/gdkkeysyms.h>
-#include <ctype.h>
 #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') {
index f3fb470..38212d6 100644 (file)
@@ -20,7 +20,7 @@
 #include "config.h"
 #include <stdio.h>
 #include <pwd.h>
-#include "ctype.h"
+#include <ctype.h>
 #include "util.h"
 #include "ascii.h"