diff --git a/src/builtin_string.cpp b/src/builtin_string.cpp index ae5cae999..f7edbff16 100644 --- a/src/builtin_string.cpp +++ b/src/builtin_string.cpp @@ -517,8 +517,8 @@ static int string_escape_url(options_t &opts, int optind, wchar_t **argv, io_str escape_flags_t flags = 0; arg_iterator_t aiter(argv, optind, streams); - while (const wchar_t *arg = aiter.next()) { - streams.out.append(escape_string(arg, flags, STRING_STYLE_URL)); + while (auto arg = aiter.nextstr()) { + streams.out.append(escape_string(*arg, flags, STRING_STYLE_URL)); streams.out.append(L'\n'); nesc++; } @@ -533,8 +533,8 @@ static int string_escape_var(options_t &opts, int optind, wchar_t **argv, io_str escape_flags_t flags = 0; arg_iterator_t aiter(argv, optind, streams); - while (const wchar_t *arg = aiter.next()) { - streams.out.append(escape_string(arg, flags, STRING_STYLE_VAR)); + while (auto arg = aiter.nextstr()) { + streams.out.append(escape_string(*arg, flags, STRING_STYLE_VAR)); streams.out.append(L'\n'); nesc++; } diff --git a/src/common.cpp b/src/common.cpp index 8c3a1cf6b..69c71185e 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -804,9 +804,8 @@ wcstring reformat_for_screen(const wcstring &msg) { } /// Escape a string in a fashion suitable for using as a URL. Store the result in out_str. -static void escape_string_url(const wchar_t *orig_in, wcstring &out) { - const std::string &in = wcs2string(orig_in); - for (auto c1 : in) { +static void escape_string_url(wcstring in, wcstring &out) { + for (auto& c1 : in) { // This silliness is so we get the correct result whether chars are signed or unsigned. unsigned int c2 = (unsigned int)c1 & 0xFF; if (!(c2 & 0x80) && @@ -855,9 +854,8 @@ static bool unescape_string_url(const wchar_t *in, wcstring *out) { } /// Escape a string in a fashion suitable for using as a fish var name. Store the result in out_str. -static void escape_string_var(const wchar_t *orig_in, wcstring &out) { +static void escape_string_var(const wcstring in, wcstring &out) { bool prev_was_hex_encoded = false; - const std::string &in = wcs2string(orig_in); for (auto c1 : in) { // This silliness is so we get the correct result whether chars are signed or unsigned. unsigned int c2 = (unsigned int)c1 & 0xFF; @@ -1109,11 +1107,11 @@ wcstring escape_string(const wcstring &in, escape_flags_t flags, escape_string_s break; } case STRING_STYLE_URL: { - escape_string_url(in.c_str(), result); + escape_string_url(in, result); break; } case STRING_STYLE_VAR: { - escape_string_var(in.c_str(), result); + escape_string_var(in, result); break; } }