Changeset: a553a306377a for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/a553a306377a
Modified Files:
clients/mapiclient/ReadlineTools.c
clients/odbc/driver/ODBCUtil.c
monetdb5/mal/mal.c
monetdb5/mal/mal_embedded.c
monetdb5/mal/mal_parser.c
monetdb5/mal/mal_parser.h
monetdb5/modules/atoms/strptime.c
sql/server/rel_dump.c
sql/storage/bat/bat_logger.c
Branch: default
Log Message:
Use (unsigned char) cast for all ctype macros; use static initialization.
diffs (279 lines):
diff --git a/clients/mapiclient/ReadlineTools.c
b/clients/mapiclient/ReadlineTools.c
--- a/clients/mapiclient/ReadlineTools.c
+++ b/clients/mapiclient/ReadlineTools.c
@@ -393,7 +393,7 @@ invoke_editor(int cnt, int key) {
/* Remove trailing whitespace */
idx = read_bytes - 1;
- while(isspace(*(read_buff + idx))) {
+ while (isspace((unsigned char) read_buff[idx])) {
read_buff[idx] = 0;
idx--;
}
diff --git a/clients/odbc/driver/ODBCUtil.c b/clients/odbc/driver/ODBCUtil.c
--- a/clients/odbc/driver/ODBCUtil.c
+++ b/clients/odbc/driver/ODBCUtil.c
@@ -1229,7 +1229,7 @@ ODBCTranslateSQL(ODBCDbc *dbc, const SQL
}
break;
}
- if (!seenarg && !isspace((signed char)
rest[j])) {
+ if (!seenarg && !isspace((unsigned
char) rest[j])) {
lastarg = j;
seenarg = true;
}
diff --git a/monetdb5/mal/mal.c b/monetdb5/mal/mal.c
--- a/monetdb5/mal/mal.c
+++ b/monetdb5/mal/mal.c
@@ -172,7 +172,6 @@ mal_init(char *modules[], bool embedded,
}
#endif
initNamespace();
- initParser();
err = malBootstrap(modules, embedded, initpasswd);
if (err != MAL_SUCCEED) {
diff --git a/monetdb5/mal/mal_embedded.c b/monetdb5/mal/mal_embedded.c
--- a/monetdb5/mal/mal_embedded.c
+++ b/monetdb5/mal/mal_embedded.c
@@ -97,7 +97,6 @@ malEmbeddedBoot(int workerlimit, int mem
#endif
// monet_memory = MT_npages() * MT_pagesize();
initNamespace();
- initParser();
initHeartbeat();
// initResource();
c_old = setClientContext(NULL); //save context
diff --git a/monetdb5/mal/mal_parser.c b/monetdb5/mal/mal_parser.c
--- a/monetdb5/mal/mal_parser.c
+++ b/monetdb5/mal/mal_parser.c
@@ -180,32 +180,145 @@ advance(Client cntxt, size_t length)
* instruction datastructures.
*/
-short opCharacter[256];
-short idCharacter[256];
-short idCharacter2[256];
-
-void
-initParser(void)
-{
- int i;
-
- for (i = 0; i < 256; i++) {
- idCharacter2[i] = isalnum(i);
- idCharacter[i] = isalpha(i);
- }
- for (i = 0; i < 256; i++)
- switch (i) {
- case '-': case '!': case '\\': case '$': case '%':
- case '^': case '*': case '~': case '+': case '&':
- case '|': case '<': case '>': case '=': case '/':
- case ':':
- opCharacter[i] = 1;
- }
-
- idCharacter[TMPMARKER] = 1;
- idCharacter2[TMPMARKER] = 1;
- idCharacter2['@'] = 1;
-}
+static const bool opCharacter[256] = {
+ ['$'] = true,
+ ['!'] = true,
+ ['%'] = true,
+ ['&'] = true,
+ ['*'] = true,
+ ['+'] = true,
+ ['-'] = true,
+ ['/'] = true,
+ [':'] = true,
+ ['<'] = true,
+ ['='] = true,
+ ['>'] = true,
+ ['\\'] = true,
+ ['^'] = true,
+ ['|'] = true,
+ ['~'] = true,
+};
+static const bool idCharacter[256] = {
+ ['a'] = true,
+ ['b'] = true,
+ ['c'] = true,
+ ['d'] = true,
+ ['e'] = true,
+ ['f'] = true,
+ ['g'] = true,
+ ['h'] = true,
+ ['i'] = true,
+ ['j'] = true,
+ ['k'] = true,
+ ['l'] = true,
+ ['m'] = true,
+ ['n'] = true,
+ ['o'] = true,
+ ['p'] = true,
+ ['q'] = true,
+ ['r'] = true,
+ ['s'] = true,
+ ['t'] = true,
+ ['u'] = true,
+ ['v'] = true,
+ ['w'] = true,
+ ['x'] = true,
+ ['y'] = true,
+ ['z'] = true,
+ ['A'] = true,
+ ['B'] = true,
+ ['C'] = true,
+ ['D'] = true,
+ ['E'] = true,
+ ['F'] = true,
+ ['G'] = true,
+ ['H'] = true,
+ ['I'] = true,
+ ['J'] = true,
+ ['K'] = true,
+ ['L'] = true,
+ ['M'] = true,
+ ['N'] = true,
+ ['O'] = true,
+ ['P'] = true,
+ ['Q'] = true,
+ ['R'] = true,
+ ['S'] = true,
+ ['T'] = true,
+ ['U'] = true,
+ ['V'] = true,
+ ['W'] = true,
+ ['X'] = true,
+ ['Y'] = true,
+ ['Z'] = true,
+ [TMPMARKER] = true,
+};
+static const bool idCharacter2[256] = {
+ ['a'] = true,
+ ['b'] = true,
+ ['c'] = true,
+ ['d'] = true,
+ ['e'] = true,
+ ['f'] = true,
+ ['g'] = true,
+ ['h'] = true,
+ ['i'] = true,
+ ['j'] = true,
+ ['k'] = true,
+ ['l'] = true,
+ ['m'] = true,
+ ['n'] = true,
+ ['o'] = true,
+ ['p'] = true,
+ ['q'] = true,
+ ['r'] = true,
+ ['s'] = true,
+ ['t'] = true,
+ ['u'] = true,
+ ['v'] = true,
+ ['w'] = true,
+ ['x'] = true,
+ ['y'] = true,
+ ['z'] = true,
+ ['A'] = true,
+ ['B'] = true,
+ ['C'] = true,
+ ['D'] = true,
+ ['E'] = true,
+ ['F'] = true,
+ ['G'] = true,
+ ['H'] = true,
+ ['I'] = true,
+ ['J'] = true,
+ ['K'] = true,
+ ['L'] = true,
+ ['M'] = true,
+ ['N'] = true,
+ ['O'] = true,
+ ['P'] = true,
+ ['Q'] = true,
+ ['R'] = true,
+ ['S'] = true,
+ ['T'] = true,
+ ['U'] = true,
+ ['V'] = true,
+ ['W'] = true,
+ ['X'] = true,
+ ['Y'] = true,
+ ['Z'] = true,
+ ['0'] = true,
+ ['1'] = true,
+ ['2'] = true,
+ ['3'] = true,
+ ['4'] = true,
+ ['5'] = true,
+ ['6'] = true,
+ ['7'] = true,
+ ['8'] = true,
+ ['9'] = true,
+ [TMPMARKER] = true,
+ ['@'] = true,
+};
static int
idLength(Client cntxt)
diff --git a/monetdb5/mal/mal_parser.h b/monetdb5/mal/mal_parser.h
--- a/monetdb5/mal/mal_parser.h
+++ b/monetdb5/mal/mal_parser.h
@@ -22,7 +22,6 @@
#ifdef LIBMONETDB5
#define MAXERRORS 250
-extern void initParser(void); /* needed in src/mal/mal.c */
extern void parseMAL(Client cntxt, Symbol curPrg, int skipcomments, int lines,
MALfcn address);
#endif
diff --git a/monetdb5/modules/atoms/strptime.c
b/monetdb5/modules/atoms/strptime.c
--- a/monetdb5/modules/atoms/strptime.c
+++ b/monetdb5/modules/atoms/strptime.c
@@ -109,8 +109,8 @@ strptime(const char *buf, const char *fm
alt_format = 0;
/* Eat up white-space. */
- if (isspace(c)) {
- while (isspace(*bp))
+ if (isspace((unsigned char) c)) {
+ while (isspace((unsigned char) *bp))
bp++;
fmt++;
@@ -356,7 +356,7 @@ literal:
case 'n': /* Any kind of white-space. */
case 't':
LEGAL_ALT(0);
- while (isspace(*bp))
+ while (isspace((unsigned char) *bp))
bp++;
break;
default: /* Unknown/unsupported conversion. */
diff --git a/sql/server/rel_dump.c b/sql/server/rel_dump.c
--- a/sql/server/rel_dump.c
+++ b/sql/server/rel_dump.c
@@ -1041,7 +1041,7 @@ function_error_string(mvc *sql, const ch
static unsigned int /* keep updating the label count */
try_update_label_count(mvc *sql, const char *label)
{
- if (label && label[0] == '%' && isdigit(label[1])) {
+ if (label && label[0] == '%' && isdigit((unsigned char) label[1])) {
char *eptr = NULL;
unsigned int value = (unsigned int) strtol(label + 1, &eptr,
10);
if (eptr && eptr[0] == '\0') {
diff --git a/sql/storage/bat/bat_logger.c b/sql/storage/bat/bat_logger.c
--- a/sql/storage/bat/bat_logger.c
+++ b/sql/storage/bat/bat_logger.c
@@ -2805,7 +2805,7 @@ bl_postversion(void *Store, void *Lg)
const char *e;
if (!strNil(f) &&
(e = strstr(f, "external")) != NULL &&
- e > f && isspace(e[-1]) && isspace(e[8]) &&
strncmp(e + 9, "name", 4) == 0 && isspace(e[13]) &&
+ e > f && isspace((unsigned char) e[-1]) &&
isspace((unsigned char) e[8]) && strncmp(e + 9, "name", 4) == 0 &&
isspace((unsigned char) e[13]) &&
BUNreplace(b2, o, &(int){FUNC_LANG_MAL}, false)
!= GDK_SUCCEED) {
bat_destroy(b2);
bat_destroy(func_func);
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]