Skip to content

Commit

Permalink
Make macros::define() take the argument as a C++ string
Browse files Browse the repository at this point in the history
  • Loading branch information
pmatilai authored and ffesti committed Nov 28, 2024
1 parent 97d9ea3 commit 56c37fc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions rpmio/macro.cc
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ validName(rpmMacroBuf mb, const char *name, size_t namelen, const char *action)
* @return number of consumed characters
*/
static void
doDefine(rpmMacroBuf mb, const char * se, int level, int expandbody, size_t *parsed)
doDefine(rpmMacroBuf mb, const char *se, int level, int expandbody, size_t *parsed)
{
const char *start = se;
const char *s = se;
Expand Down Expand Up @@ -1799,15 +1799,15 @@ static void popMacro(rpmMacroContext mc, const std::string & n)
mc->tab.erase(entry);
}

static int defineMacro(rpmMacroContext mc, const char * macro, int level)
static int defineMacro(rpmMacroContext mc, const std::string macro, int level)
{
rpmMacroBuf mb = new rpmMacroBuf_s {};
int rc;
size_t parsed = 0;

/* XXX just enough to get by */
mb->mc = mc;
doDefine(mb, macro, level, 0, &parsed);
doDefine(mb, macro.c_str(), level, 0, &parsed);
rc = mb->error;
delete mb;
return rc;
Expand Down Expand Up @@ -2023,7 +2023,7 @@ void macros::copy(rpm::macros & dest, int level)
copyMacros(mc, dest.mc, level);
}

int macros::define(const char *macro, int level)
int macros::define(const std::string & macro, int level)
{
return defineMacro(mc, macro, level);
}
Expand Down
2 changes: 1 addition & 1 deletion rpmio/rpmmacro_internal.hh
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public:
void clear();
/* Copy all macros from this context to another one */
void copy(rpm::macros & dest, int level);
int define(const char *macro, int level);
int define(const std::string & macro, int level);
void dump(FILE *fp = stderr);
/* Expand macros to a C++ string, with a return code (rc, string) */
std::pair<int,std::string> expand(const std::string & src, int flags = 0);
Expand Down

0 comments on commit 56c37fc

Please sign in to comment.