fseek(f, 0, SEEK_END);
const size_t sz = ftell(f);
char c[sz + 1];
+ c[sz] = '\0';
rewind(f);
- (void)fread(c, 1, sz, f);
+ const size_t ret = fread(c, 1, sz, f);
+ if(ret != sz) {
+ xfun_handle(shred, "StringLoadException");
+ return;
+ }
fclose(f);
*(M_Object*)RETURN = new_string(shred->info->vm->gwion, c);
}
#include <string.h>
GWION_IMPORT(compile_file) {
DECL_OB(FILE *, file, = fopen("rm_me.gw", "w+"));
- fprintf(file, "1;");
- rewind(file);
- const m_bool ret =
+ if(fprintf(file, "1;") >= 0) {
+ rewind(file);
+ const m_bool ret =
compile_file(gwi->gwion, __FILE__, file) ? GW_OK : GW_ERROR;
- fclose(file);
- return ret;
+ fclose(file);
+ return ret;
+ }
+ return GW_ERROR;
}