patch 9.0.1738: Duplicate code to reverse a string
Problem: Duplicate code to reverse a string
Solution: Move reverse_text() to strings.c and remove string_reverse().
closes: #12847
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
diff --git a/src/list.c b/src/list.c
index 28799d5..6210fd6 100644
--- a/src/list.c
+++ b/src/list.c
@@ -3001,7 +3001,13 @@
if (argvars[0].v_type == VAR_BLOB)
blob_reverse(argvars[0].vval.v_blob, rettv);
else if (argvars[0].v_type == VAR_STRING)
- string_reverse(argvars[0].vval.v_string, rettv);
+ {
+ rettv->v_type = VAR_STRING;
+ if (argvars[0].vval.v_string != NULL)
+ rettv->vval.v_string = reverse_text(argvars[0].vval.v_string);
+ else
+ rettv->vval.v_string = NULL;
+ }
else if (argvars[0].v_type == VAR_LIST)
list_reverse(argvars[0].vval.v_list, rettv);
}