Commit 58ba744e authored by Matthias Braun's avatar Matthias Braun
Browse files

Avoid unnecessary inclusion of strings.h

parent 4272639e
...@@ -18,15 +18,13 @@ ...@@ -18,15 +18,13 @@
#include "debugger.h" #include "debugger.h"
#include <stdlib.h> #include <ctype.h>
#include <stdio.h>
#include <signal.h> #include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h> #include <string.h>
#include <strings.h>
#include <time.h> #include <time.h>
#include <ctype.h>
#include "set.h" #include "set.h"
#include "ident.h" #include "ident.h"
#include "irhooks.h" #include "irhooks.h"
...@@ -843,6 +841,22 @@ static void get_text(void) ...@@ -843,6 +841,22 @@ static void get_text(void)
lexer.len = len; lexer.len = len;
} }
/**
* 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. * The lexer.
*/ */
...@@ -868,7 +882,7 @@ static unsigned get_token(void) ...@@ -868,7 +882,7 @@ static unsigned get_token(void)
--len; --len;
} }
for (size_t i = ARRAY_SIZE(reserved); i-- != 0;) { 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') && reserved[i][len] == '\0')
return first_token + i; return first_token + i;
} }
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <strings.h>
#include "bitfiddle.h" #include "bitfiddle.h"
#include "hashptr.h" #include "hashptr.h"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment