summaryrefslogtreecommitdiffhomepage
path: root/ir/common
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2015-12-06 00:24:02 +0100
committerMatthias Braun <matze@braunis.de>2015-12-06 00:29:18 +0100
commit58ba744e62460ebd7fc399606c601c89aff09831 (patch)
treef5f31ccc60c1fcf67b7feaa4fde8710d15438708 /ir/common
parent4272639ec4ac96a88cf0235a5ce29d7a5394ac5f (diff)
Avoid unnecessary inclusion of strings.h
Diffstat (limited to 'ir/common')
-rw-r--r--ir/common/debugger.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/ir/common/debugger.c b/ir/common/debugger.c
index 33a9f12..dae2e7a 100644
--- a/ir/common/debugger.c
+++ b/ir/common/debugger.c
@@ -18,15 +18,13 @@
#include "debugger.h"
-#include <stdlib.h>
-#include <stdio.h>
+#include <ctype.h>
#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
-#include <strings.h>
#include <time.h>
-#include <ctype.h>
-
#include "set.h"
#include "ident.h"
#include "irhooks.h"
@@ -844,6 +842,22 @@ static void get_text(void)
}
/**
+ * Simple custom strncasecmp variant to avoid posix strings.h inclusion.
+ */
+static bool firm_strncaseequal(const char *str0, const char *str1, size_t len)
+{
+ for (size_t i = 0; i < len; ++i) {
+ unsigned char const c0 = str0[i];
+ unsigned char const c1 = str1[i];
+ if (toupper(c0) != toupper(c1))
+ return false;
+ if (c0 == '\0')
+ break;
+ }
+ return true;
+}
+
+/**
* The lexer.
*/
static unsigned get_token(void)
@@ -868,7 +882,7 @@ static unsigned get_token(void)
--len;
}
for (size_t i = ARRAY_SIZE(reserved); i-- != 0;) {
- if (strncasecmp(tok_start, reserved[i], len) == 0
+ if (firm_strncaseequal(tok_start, reserved[i], len)
&& reserved[i][len] == '\0')
return first_token + i;
}