Fix class names

This commit is contained in:
Augusto Gunsch 2021-01-04 17:20:57 -03:00
parent 2de711957a
commit cc60532d74
No known key found for this signature in database
GPG Key ID: F7EEFE29825C72DC
1 changed files with 4 additions and 7 deletions

View File

@ -21,16 +21,13 @@ void* compileunit(void* input) {
} }
char* getclassname(char* filename) { char* getclassname(char* filename) {
int count = 0; int len = strlen(filename) - 1;
int len = strlen(filename);
for(int i = len-1; i >= 0; i--) for(len = len; len >= 0; len--)
if(filename[i] == '.') { if(filename[len] == '.')
count = i;
break; break;
}
int sz = sizeof(char) * (len - count); int sz = sizeof(char) * (len + 1);
char* classname = (char*)malloc(sz); char* classname = (char*)malloc(sz);
snprintf(classname, sz, "%s", filename); // legitimately needs to be snprintf snprintf(classname, sz, "%s", filename); // legitimately needs to be snprintf
return classname; return classname;