* This file provides a shell like 'expr' function to return.
*/
-#include <common.h>
#include <config.h>
#include <command.h>
#include <ctype.h>
#include <log.h>
#include <malloc.h>
#include <mapmem.h>
+#include <vsprintf.h>
+#include <linux/errno.h>
#include <linux/sizes.h>
#include "printf.h"
* @olen: Length of @old excluding terminator
* @new: New string to replace @old with
* @nlen: Length of @new excluding terminator
- * @return pointer to immediately after the copied @new in @string, or NULL if
+ * Return: pointer to immediately after the copied @new in @string, or NULL if
* no replacement took place
*/
static char *substitute(char *string, int *slen, int ssize,
if (res == 0) {
if (loop == 0) {
- printf("%s: No match\n", data);
- return 1;
+ debug("%s: No match\n", data);
} else {
- break;
+ debug("## MATCH ## %s\n", data);
}
+ break;
}
- debug("## MATCH ## %s\n", data);
-
if (!s)
return 1;
if (ret)
return 1;
- printf("%s=%s\n", name, data);
+ debug("%s=%s\n", name, data);
return env_set(name, data);
}
" - For each substring matching the regular expression <r> in the\n"
" string <t>, substitute the string <s>. The result is\n"
" assigned to <name>. If <t> is not supplied, use the old\n"
- " value of <name>\n"
+ " value of <name>. If no substring matching <r> is found in <t>,\n"
+ " assign <t> to <name>.\n"
"setexpr name sub r s [t]\n"
" - Just like gsub(), but replace only the first matching substring"
#endif