fix(preprocessor): initialize tm structure (#96)
This commit is contained in:
parent
cb339d6ae3
commit
d3690ff006
@ -83,6 +83,7 @@ private:
|
||||
auto eval_expr_factor() -> i32;
|
||||
auto eval_expr_unary() -> i32;
|
||||
auto eval_expr_primary() -> i32;
|
||||
auto get_local_time(std::tm& ltime) -> void;
|
||||
auto get_date_define(std::tm* time_p) -> void;
|
||||
auto get_time_define(std::tm* time_p) -> void;
|
||||
};
|
||||
|
@ -40,6 +40,7 @@ preprocessor::preprocessor(context* ctx, std::string const& name, char const* da
|
||||
directives_.insert({ "using_animtree", directive::USINGTREE });
|
||||
|
||||
std::tm l_time = {};
|
||||
get_local_time(l_time);
|
||||
get_date_define(&l_time);
|
||||
get_time_define(&l_time);
|
||||
}
|
||||
@ -1357,6 +1358,17 @@ auto preprocessor::eval_expr_primary() -> i32
|
||||
throw ppr_error(eval_peek().pos, "invalid preprocessor expression");
|
||||
}
|
||||
|
||||
auto preprocessor::get_local_time(std::tm& l_time) -> void
|
||||
{
|
||||
std::time_t t;
|
||||
time(&t);
|
||||
#ifndef _WIN32
|
||||
localtime_r(&t, &l_time);
|
||||
#else
|
||||
localtime_s(&l_time, &t);
|
||||
#endif
|
||||
}
|
||||
|
||||
auto preprocessor::get_date_define(std::tm* time_p) -> void
|
||||
{
|
||||
char buf[] = "??? ?? ????";
|
||||
|
Loading…
Reference in New Issue
Block a user