mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2024-11-24 04:41:25 +00:00
parser_strdup to wrap util_strdup and actually dup empty strings
This commit is contained in:
parent
076503770d
commit
6b1a0541c9
1 changed files with 12 additions and 1 deletions
13
parser.c
13
parser.c
|
@ -171,6 +171,17 @@ ast_value* parser_const_float_0(parser_t *parser)
|
|||
return parser->imm_float_zero;
|
||||
}
|
||||
|
||||
char *parser_strdup(const char *str)
|
||||
{
|
||||
if (str && !*str) {
|
||||
/* actually dup empty strings */
|
||||
char *out = mem_a(1);
|
||||
*out = 0;
|
||||
return out;
|
||||
}
|
||||
return util_strdup(str);
|
||||
}
|
||||
|
||||
ast_value* parser_const_string(parser_t *parser, const char *str)
|
||||
{
|
||||
size_t i;
|
||||
|
@ -181,7 +192,7 @@ ast_value* parser_const_string(parser_t *parser, const char *str)
|
|||
}
|
||||
out = ast_value_new(parser_ctx(parser), "#IMMEDIATE", TYPE_STRING);
|
||||
out->isconst = true;
|
||||
out->constval.vstring = util_strdup(str);
|
||||
out->constval.vstring = parser_strdup(str);
|
||||
if (!parser_t_imm_string_add(parser, out)) {
|
||||
ast_value_delete(out);
|
||||
return NULL;
|
||||
|
|
Loading…
Reference in a new issue