>From 5aa8b0d419518889a8d6f392c2d38fdd438ce39f Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sat, 9 Sep 2017 12:01:28 +0200 Subject: [PATCH 1/6] gnulib-tool.py: Fix subend function. Make subend('a','b','Laura') return 'Laurb' instead of 'bL'. --- pygnulib/constants.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pygnulib/constants.py b/pygnulib/constants.py index 9e0f194..9428e1f 100644 --- a/pygnulib/constants.py +++ b/pygnulib/constants.py @@ -397,6 +397,10 @@ def filter_filelist(separator, filelist, def substart(orig, repl, data): + '''Replaces the start portion of a string. + + Returns data with orig replaced by repl, but only at the beginning of data. + Like data.replace(orig,repl), except only at the beginning of data.''' result = data if data.startswith(orig): result = repl + data[len(orig):] @@ -404,9 +408,13 @@ def substart(orig, repl, data): def subend(orig, repl, data): + '''Replaces the end portion of a string. + + Returns data with orig replaced by repl, but only at the end of data. + Like data.replace(orig,repl), except only at the end of data.''' result = data if data.endswith(orig): - result = repl + data[:len(repl)] + result = data[:-len(orig)] + repl return(result) -- 2.7.4