--- stack/stack.c 2002/02/07 05:24:19 1.49 +++ stack/stack.c 2002/02/08 00:25:57 1.54 @@ -1,14 +1,12 @@ -/* printf */ +/* printf, sscanf, fgets, fprintf */ #include -/* EXIT_SUCCESS */ +/* exit, EXIT_SUCCESS, malloc, free */ #include /* NULL */ #include /* dlopen, dlsym, dlerror */ #include -/* assert */ -#include -/* strcat */ +/* strcmp, strcpy, strlen, strcat, strdup */ #include #define HASHTBLSIZE 65536 @@ -101,7 +99,9 @@ } free(val); /* Free the actual list value */ break; - default: + case integer: + case func: + case symb: break; } } @@ -198,17 +198,17 @@ } /* Mangle a symbol name to a valid C identifier name */ -char *mangle_(const char *old_string){ +char *mangle_str(const char *old_string){ char validchars[] ="0123456789abcdef"; char *new_string, *current; - new_string=malloc(strlen(old_string)+4); + new_string=malloc((strlen(old_string)*2)+4); strcpy(new_string, "sx_"); /* Stack eXternal */ current=new_string+3; while(old_string[0] != '\0'){ - current[0]=validchars[old_string[0]/16]; - current[1]=validchars[old_string[0]%16]; + current[0]=validchars[(unsigned char)(old_string[0])/16]; + current[1]=validchars[(unsigned char)(old_string[0])%16]; current+=2; old_string++; } @@ -233,7 +233,7 @@ return; } - new_string= mangle_((const char *)(env->head->item->content.ptr)); + new_string= mangle_str((const char *)(env->head->item->content.ptr)); toss(env); if(env->err) return; @@ -296,7 +296,7 @@ funcptr= dlsym(handle, in_string); /* Get function pointer */ dlerr=dlerror(); if(dlerr != NULL) { /* If no function was found */ - mangled=mangle_(in_string); + mangled=mangle_str(in_string); funcptr= dlsym(handle, mangled); /* try mangling it */ free(mangled); dlerr=dlerror(); @@ -541,7 +541,8 @@ free(temp_string); break; - default: + case integer: + break; } }