[gjs: 6/12] text-encoding: Clarify whitespace-stripped encoding
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs: 6/12] text-encoding: Clarify whitespace-stripped encoding
- Date: Tue, 10 Aug 2021 04:08:01 +0000 (UTC)
commit db46e46e5d85459366a8298d1634c35dffba0f07
Author: Philip Chimento <philip chimento gmail com>
Date: Mon Jul 12 17:10:38 2021 -0700
text-encoding: Clarify whitespace-stripped encoding
The previous code was correct, because g_strstrip() modifies a string in
place, but it looked wrong. Separate the call to g_strstrip() so that it
doesn't look like we are comparing the unstripped string in the second
call to strcmp().
gjs/text-encoding.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
---
diff --git a/gjs/text-encoding.cpp b/gjs/text-encoding.cpp
index a77bd19f..09e68962 100644
--- a/gjs/text-encoding.cpp
+++ b/gjs/text-encoding.cpp
@@ -59,7 +59,8 @@ static const char* UTF16_CODESET = "UTF-16BE";
return true;
GjsAutoChar stripped(g_strdup(encoding));
- return g_ascii_strcasecmp(g_strstrip(stripped), "utf-8") == 0 ||
+ g_strstrip(stripped); // modifies in place
+ return g_ascii_strcasecmp(stripped, "utf-8") == 0 ||
g_ascii_strcasecmp(stripped, "utf8") == 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]