Skip to content

Commit

Permalink
[imcc] represent constants with \0 as fixed_8:"\x00"
Browse files Browse the repository at this point in the history
  • Loading branch information
Reini Urban committed Oct 15, 2014
1 parent adaf39c commit 907ab30
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions compilers/imcc/symreg.c
Expand Up @@ -860,10 +860,17 @@ mk_const(ARGMOD(imc_info_t * imcc), ARGIN(const char *name), int t)
create_symhash(imcc, h);

if (t != 'U') {
if (*name == '"') { /* but we need to keep escaped \0 */
if (*name == '"') {
STRING *unescaped = Parrot_str_unescape(imcc->interp, name+1, '"', NULL);
if (!memchr(unescaped->strstart, 0, unescaped->bufused))
const_name = Parrot_str_to_cstring(imcc->interp, unescaped);
/* but we need to keep escaped \0. represent it encoded */
if (memchr(unescaped->strstart, 0, unescaped->bufused)) {
int len = strlen(name);
const_name = (char*)mem_internal_allocate(len + 8 + 1); /* 8 = strlen("fixed_8:") */
strcpy(const_name, "fixed_8:");
strcat(const_name, name);
const_name[len + 7 + 1] = 0;
if (t == 'S') t = 'U';
}
}
else if (*name == '\'') {
const_name = mem_sys_strdup(name + 1);
Expand Down

0 comments on commit 907ab30

Please sign in to comment.