summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaiStevenson <kai@kaistevenson.com>2023-03-04 14:37:05 -0800
committerKaiStevenson <kai@kaistevenson.com>2023-03-04 14:37:05 -0800
commit4ece2801b980358ed0a81efb78b4c4cadee03f6e (patch)
tree050152bf2af0cbca0fd31fbbdee38d21b05e3e6a
parent2127b746f0eecb657b31653ad5967623f994cbaf (diff)
fixed compiler warnings on windows
-rw-r--r--.gitignore2
-rw-r--r--src/eval.c7
-rw-r--r--src/parse.c6
-rw-r--r--src/precedent.c2
4 files changed, 8 insertions, 9 deletions
diff --git a/.gitignore b/.gitignore
index 6c1ffbb..49231a0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,6 @@
*.swp
precedent
-precedent.exe
+*.exe*
*.core
vgcore.*
*.dSYM/
diff --git a/src/eval.c b/src/eval.c
index 8b41f38..f140ed0 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -62,8 +62,8 @@ void exec_all(sym_t** symbols, int count, hashtable_t* symbolScope) {
}
sym_t* eval_with_args(sym_t* symbol, sym_t** args, int argCount, hashtable_t* symbolScope) {
sym_t** addedArgs = malloc(100 * sizeof(sym_t*));
- for (int i = 0; i < argCount && i < 100; i++) {
- char* keyName = malloc(6 * sizeof(char));
+ for (unsigned int i = 0; i < (unsigned int)argCount && i < 100; i++) {
+ char keyName[6];
strcpy(keyName, "arg");
char index[3];
snprintf(index, 3, "%d", i);
@@ -71,7 +71,6 @@ sym_t* eval_with_args(sym_t* symbol, sym_t** args, int argCount, hashtable_t* sy
sym_t* argV = eval(args[i], symbolScope->parent);
addedArgs[i] = argV;
pair_t argPair = init_pair(keyName, argV);
- free(keyName);
hashtable_add_pair(symbolScope, argPair);
}
sym_t* v = eval(symbol, symbolScope);
@@ -82,7 +81,7 @@ sym_t* eval_with_args(sym_t* symbol, sym_t** args, int argCount, hashtable_t* sy
free(addedArgs);
return v;
}
-/* internal functions?
+/* internal functions
this function has side-effects */
sym_t* try_eval_internal(sym_t* symbol, hashtable_t* symbolScope) {
unsigned int hash = get_hash((char*)symbol->name);
diff --git a/src/parse.c b/src/parse.c
index f8749ac..b7596d4 100644
--- a/src/parse.c
+++ b/src/parse.c
@@ -82,7 +82,7 @@ symset_t* parse_symbols(char** str, int* sLine) {
symbolSet->count = 0;
while (1) {
/* clear whitespace */
- while (!isalnum(**str) && **str != '"' && **str != '-' && **str != '(' && **str != ')' && **str != '\0') {
+ while (!isalnum((unsigned char)**str) && **str != '"' && **str != '-' && **str != '(' && **str != ')' && **str != '\0') {
/* increment line counter if newline read */
if (**str == '\n') {
(*sLine)++;
@@ -126,7 +126,7 @@ symset_t* parse_symbols(char** str, int* sLine) {
isFloat = 1;
}
/* we've hit a character that cannot be part of the symbol. parse the prior characters as the symbol name */
- else if (!isalnum(**str) && **str != '-' && **str != '(') {
+ else if (!isalnum((unsigned char)**str) && **str != '-' && **str != '(') {
/* move the pointer back, because the close paren is needed to return the calling function */
if (**str == ')') {
(*str)--;
@@ -134,7 +134,7 @@ symset_t* parse_symbols(char** str, int* sLine) {
(*str)++;
symbolName[i] = '\0';
sym_t* symbol;
- if (isalpha(symbolName[0])) {
+ if (isalpha((unsigned int)symbolName[0])) {
/* reference */
symbol = init_sym_key(symbolName);
}
diff --git a/src/precedent.c b/src/precedent.c
index a2791ac..11d662b 100644
--- a/src/precedent.c
+++ b/src/precedent.c
@@ -95,7 +95,7 @@ char* preprocess(char* str, char* baseDir) {
i++;
char* includeName = malloc(20 * sizeof(char));
int f = 0;
- while (isalnum(str[i]) || str[i] == '/' || str[i] == '.' || str[i] == '_') {
+ while (isalnum((unsigned char)str[i]) || str[i] == '/' || str[i] == '.' || str[i] == '_') {
includeName[f] = str[i];
str[i] = ' ';
i++;