Clean up uses of Replace()

We were passing flags of DOH_REPLACE_ANY|DOH_REPLACE_FIRST in three
places, which doesn't make sense as those are mutually exclusive
concepts.  In the current implementation DOH_REPLACE_FIRST wins in
this situation, so replace with that and clarify the docs.
This commit is contained in:
Olly Betts 2022-02-06 09:54:21 +13:00
commit 9d7c962ee8
4 changed files with 8 additions and 3 deletions

View file

@ -1132,6 +1132,11 @@ DOH_REPLACE_FIRST - Replace first occurrence only.
Returns the number of replacements made (if any).
</p>
<p>
At most one of <tt>DOH_REPLACE_ANY</tt> and <tt>DOH_REPLACE_FIRST</tt> should be specified.
<tt>DOH_REPLACE_ANY</tt> is the default if neither is specified.
</p>
</div>
<H3><a name="Extending_nn16">40.5.2 Hashes</a></H3>

View file

@ -249,7 +249,7 @@ String *partial_arg(String *s, String *p) {
}
prefix = NewStringWithSize(cp, (int)(c - cp));
newarg = Copy(s);
Replace(newarg, prefix, "", DOH_REPLACE_ANY | DOH_REPLACE_FIRST);
Replace(newarg, prefix, "", DOH_REPLACE_FIRST);
Delete(prefix);
return newarg;
}

View file

@ -477,7 +477,7 @@ static void getoptions(int argc, char *argv[]) {
Swig_mark_arg(i);
} else if (strncmp(argv[i], "-D", 2) == 0) {
String *d = NewString(argv[i] + 2);
Replace(d, "=", " ", DOH_REPLACE_ANY | DOH_REPLACE_FIRST);
Replace(d, "=", " ", DOH_REPLACE_FIRST);
Preprocessor_define((DOH *) d, 0);
Delete(d);
// Create a symbol

View file

@ -407,7 +407,7 @@ public:
printf("Fatal error. SwigType_del_pointer applied to non-pointer.\n");
abort();
}
Replace(t, "r.", "", DOH_REPLACE_ANY | DOH_REPLACE_FIRST);
Replace(t, "r.", "", DOH_REPLACE_FIRST);
}
void oc_SwigType_del_array(SwigType *t) {