Skip to content

Commit

Permalink
wdl: use locale independent atof
Browse files Browse the repository at this point in the history
  • Loading branch information
JoepVanlier committed Jan 26, 2025
1 parent 211faa1 commit fc72705
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion thirdparty/WDL/source/WDL/eel2/nseel-compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ FILE *g_eel_dump_fp, *g_eel_dump_fp2;
#define COMPUTABLE_EXTRA_SPACE 16 // safety buffer, if EEL_VALIDATE_WORKTABLE_USE set, used for magic-value-checking
#endif

#ifdef NSEEL_ATOF
double NSEEL_ATOF(const char *);
#else
#define NSEEL_ATOF atof
#endif


/*
P1 is rightmost parameter
Expand Down Expand Up @@ -5798,7 +5804,7 @@ opcodeRec *nseel_translate(compileContext *ctx, const char *tmp, size_t tmplen)
return nseel_createCompiledValue(ctx,ctx->onNamedString(ctx->caller_this,buf+1));
}
}
return nseel_createCompiledValue(ctx,(EEL_F)atof(tmp));
return nseel_createCompiledValue(ctx,(EEL_F)NSEEL_ATOF(tmp));
}

void NSEEL_VM_set_var_resolver(NSEEL_VMCTX _ctx, EEL_F *(*res)(void *userctx, const char *name), void *userctx)
Expand Down
8 changes: 7 additions & 1 deletion thirdparty/WDL/source/WDL/lineparse.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@
#define WDL_LINEPARSER_HAS_LINEPARSERINT
#endif

#ifdef WDL_LINEPARSE_ATOF
extern "C" double WDL_LINEPARSE_ATOF(const char *);
#else
#define WDL_LINEPARSE_ATOF atof
#endif

#ifndef WDL_LINEPARSE_IMPL_ONLY
class LineParserInt // version which does not have any temporary space for buffers (requires use of parseDestroyBuffer)
{
Expand Down Expand Up @@ -159,7 +165,7 @@ class LineParserInt // version which does not have any temporary space for buffe
buf[ot++]=c;
}
buf[ot] = 0;
return atof(buf);
return WDL_LINEPARSE_ATOF(buf);
}

int WDL_LINEPARSE_PREFIX gettoken_int(int token) const
Expand Down

0 comments on commit fc72705

Please sign in to comment.