[Helper] Add more error checking/reporting.

This commit is contained in:
Dave Davenport 2019-02-10 14:32:21 +01:00
parent f49866bd8b
commit 3c56761a76
1 changed files with 6 additions and 3 deletions

View File

@ -1288,11 +1288,14 @@ char *helper_string_replace_if_exists ( char * string, ... )
*/
char *helper_string_replace_if_exists_v ( char * string, GHashTable *h )
{
GError *error = NULL;
GError *error = NULL;
char *res = NULL;
// Replace hits within {-\w+}.
GRegex *reg = g_regex_new ( "\\[(.*)({[-\\w]+})(.*)\\]|({[\\w-]+})", 0, 0, NULL );
char *res = g_regex_replace_eval ( reg, string, -1, 0, 0, helper_eval_cb2, h, NULL );
GRegex *reg = g_regex_new ( "\\[(.*)({[-\\w]+})(.*)\\]|({[\\w-]+})", 0, 0, &error );
if ( error == NULL ){
res = g_regex_replace_eval ( reg, string, -1, 0, 0, helper_eval_cb2, h, &error );
}
// Free regex.
g_regex_unref ( reg );
// Throw error if shell parsing fails.