std::string
ada_decode (const char *encoded, bool wrap)
{
- int i, j;
+ int i;
int len0;
const char *p;
int at_start_name;
if (len0 > 1 && startswith (encoded + len0 - 1, "B"))
len0 -= 1;
- /* Make decoded big enough for possible expansion by operator name. */
-
- decoded.resize (2 * len0 + 1, 'X');
-
/* Remove trailing __{digit}+ or trailing ${digit}+. */
if (len0 > 1 && isdigit (encoded[len0 - 1]))
/* The first few characters that are not alphabetic are not part
of any encoding we use, so we can copy them over verbatim. */
- for (i = 0, j = 0; i < len0 && !isalpha (encoded[i]); i += 1, j += 1)
- decoded[j] = encoded[i];
+ for (i = 0; i < len0 && !isalpha (encoded[i]); i += 1)
+ decoded.push_back (encoded[i]);
at_start_name = 1;
while (i < len0)
op_len - 1) == 0)
&& !isalnum (encoded[i + op_len]))
{
- strcpy (&decoded.front() + j, ada_opname_table[k].decoded);
+ decoded.append (ada_opname_table[k].decoded);
at_start_name = 0;
i += op_len;
- j += strlen (ada_opname_table[k].decoded);
break;
}
}
else if (i < len0 - 2 && encoded[i] == '_' && encoded[i + 1] == '_')
{
/* Replace '__' by '.'. */
- decoded[j] = '.';
+ decoded.push_back ('.');
at_start_name = 1;
i += 2;
- j += 1;
}
else
{
/* It's a character part of the decoded name, so just copy it
over. */
- decoded[j] = encoded[i];
+ decoded.push_back (encoded[i]);
i += 1;
- j += 1;
}
}
- decoded.resize (j);
/* Decoded names should never contain any uppercase character.
Double-check this, and abort the decoding if we find one. */