Skip to content

Commit

Permalink
Merge branch 'spooonsss-macro_redefined_hint' into asar_2_beta
Browse files Browse the repository at this point in the history
  • Loading branch information
randomdude999 committed Jan 27, 2024
2 parents 97b66c8 + 8cf8436 commit e747ed8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/asar/errors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ static asar_error_mapping asar_errors[] =

{ ERR(invalid_macro_name), "Invalid macro name." },
{ ERR(macro_not_found), "Macro '%s' wasn't found." },
{ ERR(macro_redefined), "Macro '%s' redefined." },
{ ERR(macro_redefined), "Macro '%s' redefined. First defined at: %s:%d" },
{ ERR(broken_macro_declaration), "Broken macro declaration." },
{ ERR(invalid_macro_param_name), "Invalid macro parameter name." },
{ ERR(macro_param_not_found), "Macro parameter '%s' wasn't found.%s" },
Expand Down
9 changes: 8 additions & 1 deletion src/asar/macro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,14 @@ void startmacro(const char * line_)
if (c==',' && is_digit(startpar[i+1])) asar_throw_error(0, error_type_block, error_id_broken_macro_declaration);
}
if (*startpar==',' || is_digit(*startpar) || strstr(startpar, ",,") || endpar[-1]==',') asar_throw_error(0, error_type_block, error_id_broken_macro_declaration);
if (macros.exists(defining_macro_name)) asar_throw_error(0, error_type_block, error_id_macro_redefined, defining_macro_name.data());
if (macros.exists(defining_macro_name))
{
const auto macro = macros[defining_macro_name];
// i think theoretically it would be "more correct" to print the entire
// callstack here, but this should be good enough for an error message.
// needs +1 because startline is 0-indexed
asar_throw_error(0, error_type_block, error_id_macro_redefined, defining_macro_name.data(), macro->fname, macro->startline + 1);
}
thisone=(macrodata*)malloc(sizeof(macrodata));
new(thisone) macrodata;
if (*startpar)
Expand Down

0 comments on commit e747ed8

Please sign in to comment.