diff --git a/builtin_ulimit.cpp b/builtin_ulimit.cpp index 37bebd61f..23524543a 100644 --- a/builtin_ulimit.cpp +++ b/builtin_ulimit.cpp @@ -160,7 +160,7 @@ static void print_all(int hard) for (i=0; resource_arr[i].desc; i++) { - w=maxi(w, my_wcswidth(resource_arr[i].desc)); + w=maxi(w, fish_wcswidth(resource_arr[i].desc)); } for (i=0; resource_arr[i].desc; i++) diff --git a/common.cpp b/common.cpp index ad35470e5..7429fcbe6 100644 --- a/common.cpp +++ b/common.cpp @@ -513,13 +513,14 @@ bool wcsvarchr(wchar_t chr) return iswalnum(chr) || chr == L'_'; } - -/** - The glibc version of wcswidth seems to hang on some strings. fish uses this replacement. -*/ -int my_wcswidth(const wchar_t *c) +int fish_wcswidth(const wchar_t *str) { - return fish_wcswidth(c, wcslen(c)); + return fish_wcswidth(str, wcslen(str)); +} + +int fish_wcswidth(const wcstring& str) +{ + return fish_wcswidth(str.c_str(), str.size()); } wchar_t *quote_end(const wchar_t *pos) diff --git a/common.h b/common.h index 832883cd9..7932c8700 100644 --- a/common.h +++ b/common.h @@ -713,11 +713,13 @@ const wchar_t *wcsfuncname(const wchar_t *str); bool wcsvarchr(wchar_t chr); - /** - A wcswidth workalike. Fish uses this since the regular wcswidth seems flaky. + Convenience variants on fish_wcwswidth(). + + See fallback.h for the normal definitions. */ -int my_wcswidth(const wchar_t *c); +int fish_wcswidth(const wchar_t *str); +int fish_wcswidth(const wcstring& str); /** This functions returns the end of the quoted substring beginning at diff --git a/output.cpp b/output.cpp index 312a90777..2c9f7d486 100644 --- a/output.cpp +++ b/output.cpp @@ -535,7 +535,7 @@ void writestr_ellipsis(const wchar_t *str, int max_width) CHECK(str,); - tot = my_wcswidth(str); + tot = fish_wcswidth(str); if (tot <= max_width) { @@ -575,7 +575,7 @@ int write_escaped_str(const wchar_t *str, int max_len) CHECK(str, 0); out = escape(str, 1); - len = my_wcswidth(out); + len = fish_wcswidth(out); if (max_len && (max_len < len)) { diff --git a/pager.cpp b/pager.cpp index 8d19c9bdc..04be06195 100644 --- a/pager.cpp +++ b/pager.cpp @@ -319,7 +319,7 @@ static comp_info_list_t process_completions_into_infos(const completion_list_t & void pager_t::measure_completion_infos(comp_info_list_t *infos, const wcstring &prefix) const { - size_t prefix_len = my_wcswidth(prefix.c_str()); + size_t prefix_len = fish_wcswidth(prefix.c_str()); for (size_t i=0; i < infos->size(); i++) { comp_t *comp = &infos->at(i); @@ -332,11 +332,11 @@ void pager_t::measure_completion_infos(comp_info_list_t *infos, const wcstring & if (j >= 1) comp->comp_width += 2; - comp->comp_width += prefix_len + my_wcswidth(comp_strings.at(j).c_str()); + comp->comp_width += prefix_len + fish_wcswidth(comp_strings.at(j).c_str()); } // Compute desc_width - comp->desc_width = my_wcswidth(comp->desc.c_str()); + comp->desc_width = fish_wcswidth(comp->desc.c_str()); // Compute preferred width comp->pref_width = comp->comp_width + comp->desc_width + (comp->desc_width?4:0);