From 886290c12361bfab1276ed5555c928f30849638f Mon Sep 17 00:00:00 2001 From: Andrew Prokhorenkov Date: Wed, 17 Jun 2020 23:18:27 -0500 Subject: [PATCH] builtin_string: change npad --- src/builtin_string.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/builtin_string.cpp b/src/builtin_string.cpp index 66771649c..2c777aba3 100644 --- a/src/builtin_string.cpp +++ b/src/builtin_string.cpp @@ -1277,7 +1277,6 @@ static int string_pad(parser_t &parser, io_streams_t &streams, int argc, wchar_t arg_iterator_t aiter(argv, optind, streams); while (const wcstring *arg = aiter.nextstr()) { - size_t begin = 0, end = arg->size(); wcstring padded_arg = wcstring(*arg, 0, arg->size()); if (opts.right) { padded_arg.append(opts.count, opts.char_to_pad); @@ -1286,7 +1285,7 @@ static int string_pad(parser_t &parser, io_streams_t &streams, int argc, wchar_t padded_arg.insert(0, opts.count, opts.char_to_pad); } // assert(begin <= end && end <= arg->size()); - npad += arg->size() - (end - begin); + npad += arg->size() + 2 * opts.count; if (!opts.quiet) { streams.out.append(padded_arg); streams.out.append(L'\n');