aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/common.h
diff options
context:
space:
mode:
authorGravatar Kurtis Rader <krader@skepticism.us>2016-06-01 22:03:27 -0700
committerGravatar Kurtis Rader <krader@skepticism.us>2016-06-01 22:19:03 -0700
commitdb1ec847f989a71b2cb1e0c39194e277613931fd (patch)
treec007ab7d9b64b3d325fd7074357dc849d4d4d0d9 /src/common.h
parentaee9d2c9d7c558268717d887683529399bd8d95f (diff)
fix lint error in wgettext()
Cppcheck was complaining about the `return val.c_str()` at the end of the `wgettext()` function. That would normally a bug since the lifetime of `val` ends when the function returns. In this particular case that's not true because the string is interned in a cache. Nonetheless, rather than suppress the lint warning I decided to modify the API to be more idiomatic. In the process of fixing the aforementioned lint warning I fixed several other lint errors in that module. This required making our copy of `wgetopt()` compatible with the rest of the fish code. Specifically, by removing its local definitions of the "_" macro so it uses the same macro used everywhere else in the fish code. The sooner we kill the use of wide chars the better.
Diffstat (limited to 'src/common.h')
-rw-r--r--src/common.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/common.h b/src/common.h
index e59dfc0e..07342436 100644
--- a/src/common.h
+++ b/src/common.h
@@ -226,8 +226,8 @@ void write_ignore(int fd, const void *buff, size_t count);
return retval; \
}
-/// Shorthand for wgettext call.
-#define _(wstr) wgettext(wstr)
+/// Shorthand for wgettext call in situations where a C-style string is needed (e.g., fwprintf()).
+#define _(wstr) wgettext(wstr).c_str()
/// Noop, used to tell xgettext that a string should be translated, even though it is not directly
/// sent to wgettext.