return NULL;
}
-static void pakfire_parser_strip_namespace(char** s) {
- char* pos = strrchr(*s, '.');
+static void pakfire_parser_strip_namespace(char* s) {
+ char* pos = strrchr(s, '.');
if (pos)
*pos = '\0';
static struct pakfire_parser_declaration* pakfire_parser_find_declaration(
struct pakfire_parser* parser, const char* namespace, const char* name) {
struct pakfire_parser_declaration* d = NULL;
- char* n = NULL;
+ char n[NAME_MAX] = "";
+ int r;
// Create a working copy of namespace
- if (namespace)
- n = strdupa(namespace);
+ if (namespace) {
+ r = pakfire_string_set(n, namespace);
+ if (r < 0)
+ return NULL;
+ }
for (;;) {
d = pakfire_parser_get_declaration_recursive(parser, n, name);
return d;
// End if we have exhausted the namespace
- if (!n || !*n)
+ if (!*n)
break;
// Strip namespace
- pakfire_parser_strip_namespace(&n);
+ pakfire_parser_strip_namespace(n);
}
// Nothing found
static int pakfire_parser_expand_variables(struct pakfire_parser* parser,
const char* namespace, char** buffer) {
+ char parent_namespace[NAME_MAX];
pcre2_match_data* match = NULL;
PCRE2_UCHAR* variable = NULL;
PCRE2_SIZE variable_length = 0;
// Move up one step and lookup there
if (namespace && *namespace) {
- char* parent_namespace = strdupa(namespace);
- pakfire_parser_strip_namespace(&parent_namespace);
+ r = pakfire_string_set(parent_namespace, namespace);
+ if (r < 0)
+ goto ERROR;
+
+ // Strip
+ pakfire_parser_strip_namespace(parent_namespace);
repl = pakfire_parser_get_raw(parser, parent_namespace, (const char*)variable);