};
/**
- * simple search and replace routine
+ * Simple search and replace routine.
*
- * \param src source string
- * \param macro_name the name of the macro
- * \param replacement the replacement format string
+ * \param src Source String.
+ * \param macro_name The name of the macro.
+ * \param replacement The replacement format string.
*
* In \p src, replace each occurence of \p macro_name(arg) by the string
* determined by the \p replacement format string. \p replacement may (but
* replaced by \p arg.
*
* \return A string in which all matches in \p src are replaced, or \p NULL if
- * an syntax error was encountered. Caller must free the result.
+ * an error was encountered. Caller must free the result.
*
* \sa regcomp(3)
*/
if (!macro_name || !replacement || !src)
return para_strdup(src);
- regcomp(&preg, macro_name, 0);
+ if (regcomp(&preg, macro_name, 0) != 0)
+ return NULL;
while (regexec(&preg, bufptr, nmatch, pmatch, eflags)
!= REG_NOMATCH) {
char *tmp, *arg, *o_bracket, *c_bracket;