commit ada82930fd9f81b7da96ea11faec9f5b79df3bca
parent f36e3196585d0658f103954b6d3a188d1bdac9d7
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Thu, 19 Feb 2009 14:18:01 -0300
"homemade" version of ctype.h
Diffstat:
A | lctype.c | | | 44 | ++++++++++++++++++++++++++++++++++++++++++++ |
A | lctype.h | | | 34 | ++++++++++++++++++++++++++++++++++ |
2 files changed, 78 insertions(+), 0 deletions(-)
diff --git a/lctype.c b/lctype.c
@@ -0,0 +1,44 @@
+/*
+** $Id: $
+** 'ctype' functions for Lua
+** See Copyright Notice in lua.h
+*/
+
+#include <limits.h>
+
+#include "lctype.h"
+
+const char lctypecode[UCHAR_MAX + 1] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x0c, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
+ 0x06, 0x06, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
+ 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
+ 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
+ 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x04,
+ 0x04, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
+ 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
+ 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
+ 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
diff --git a/lctype.h b/lctype.h
@@ -0,0 +1,34 @@
+/*
+** $Id: $
+** 'ctype' functions for Lua
+** See Copyright Notice in lua.h
+*/
+
+#ifndef lctype_h
+#define lctype_h
+
+
+#include <limits.h>
+
+#include "lua.h"
+
+
+#define ALPHABIT 0
+#define DIGITBIT 1
+#define PRINTBIT 2
+#define SPACEBIT 3
+
+
+#define MASK(B) (1 << (B))
+
+
+#define lisalpha(x) (lctypecode[x] & MASK(ALPHABIT))
+#define lisalnum(x) (lctypecode[x] & (MASK(ALPHABIT) | MASK(DIGITBIT)))
+#define lisdigit(x) (lctypecode[x] & MASK(DIGITBIT))
+#define lisspace(x) (lctypecode[x] & MASK(SPACEBIT))
+#define lisprint(x) (lctypecode[x] & MASK(PRINTBIT))
+
+LUAI_DATA const char lctypecode[UCHAR_MAX + 1];
+
+#endif
+