
Dear Wolfgang Denk,
Add "setexpr name gsub r s [t]" and "setexpr name sub r s [t]" commands which implement substring matching for the regular expression <r> in the string <t>, and substitution of the string <s>. The result is assigned to the environment variable <name>. If <t> is not supplied, the previous value of <name> is used instead. "gsub" performs global substitution, while "sub" will replace only the first substring.
[...]
+static char *memstr(const char *s1, int l1, const char *s2, int l2) +{
- if (!l2)
return (char *) s1;
- while (l1 >= l2) {
l1--;
if (!memcmp(s1, s2, l2))
return (char *) s1;
s1++;
- }
- return NULL;
+}
Will this memstr() not crash with wrong parameters? Or is this safe?
btw. there is a checkpatch issue and two warnings: ERROR: space required after that ';' (ctx:WxV) #294: FILE: common/cmd_setexpr.c:177: + for (loop = 0; ;loop++) { ^
I think the warnings are ok.
Best regards, Marek Vasut