static const struct rust_op *
crate_name (const struct rust_op *name)
{
- char *crate = rust_crate_for_block (expression_context_block);
+ std::string crate = rust_crate_for_block (expression_context_block);
struct stoken result;
gdb_assert (name->opcode == OP_VAR_VALUE);
- if (crate == NULL)
+ if (crate.empty ())
error (_("Could not find crate for current location"));
- result = make_stoken (obconcat (&work_obstack, "::", crate, "::",
+ result = make_stoken (obconcat (&work_obstack, "::", crate.c_str (), "::",
name->left.sval.ptr, (char *) NULL));
- xfree (crate);
return ast_path (result, name->right.params);
}
/* Return true if STR looks like the end of a raw string that had N
hashes at the start. */
-static int
+static bool
ends_raw_string (const char *str, int n)
{
int i;
gdb_assert (str[0] == '"');
for (i = 0; i < n; ++i)
if (str[i + 1] != '#')
- return 0;
- return 1;
+ return false;
+ return true;
}
/* Lex a string constant. */
/* Return true if STRING starts with whitespace followed by a digit. */
-static int
+static bool
space_then_number (const char *string)
{
const char *p = string;
while (p[0] == ' ' || p[0] == '\t')
++p;
if (p == string)
- return 0;
+ return false;
return *p >= '0' && *p <= '9';
}
/* Return true if C can start an identifier. */
-static int
+static bool
rust_identifier_start_p (char c)
{
return ((c >= 'a' && c <= 'z')
/* The parser error handler. */
void
-rustyyerror (char *msg)
+rustyyerror (const char *msg)
{
const char *where = prev_lexptr ? prev_lexptr : lexptr;
error (_("%s in expression, near `%s'."), (msg ? msg : "Error"), where);