Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mumble-voip/mumble.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavide Beatrici <davidebeatrici@gmail.com>2019-10-12 09:17:37 +0300
committerDavide Beatrici <davidebeatrici@gmail.com>2019-10-12 10:01:00 +0300
commit7779447ee4df80c80219d19e8e63c080e9319fb7 (patch)
tree56beb2d9e60581531c3a4c9e76583a0e9ec23c16 /plugins
parentb54351cfba2c76a03703c5a2ee45dfc7b59080d0 (diff)
mumble_plugin_utils.h: declare escape() as inline, minor improvements
Fixes the following warning: ../mumble_plugin_utils.h:33:13: error: 'void escape(char*, size_t)' defined but not used [-Werror=unused-function] static void escape(char *str, size_t size) { ^ It appeared after bb248cc, due to "ut99.cpp" not using escape(). This commit also: - Changes the "size" argument so that it is passed as reference. - Indents the function using tabs.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mumble_plugin_utils.h48
1 files changed, 23 insertions, 25 deletions
diff --git a/plugins/mumble_plugin_utils.h b/plugins/mumble_plugin_utils.h
index 307dc76ff..2775a352f 100644
--- a/plugins/mumble_plugin_utils.h
+++ b/plugins/mumble_plugin_utils.h
@@ -30,31 +30,29 @@ static inline std::string utf16ToUtf8(const std::wstring &wstr) {
// string is NUL-terminated by always
// setting the last byte of the input
// string to the value 0.
-static void escape(char *str, size_t size) {
- // Ensure the input string is properly NUL-terminated.
- str[size-1] = 0;
- char *c = str;
-
- while (*c != '\0') {
- // For JSON compatibility, the string
- // can't contain double quotes.
- // If a double quote is found, replace
- // it with an ASCII space.
- if (*c == '"') {
- *c = ' ';
- }
-
- // Ensure the string is within printable
- // ASCII. If not, replace the offending
- // byte with an ASCII space.
- if (*c < 32) {
- *c = ' ';
- } else if (*c > 126) {
- *c = ' ';
- }
-
- c += 1;
- }
+static inline void escape(char *str, const size_t &size) {
+ // Ensure the input string is properly NUL-terminated.
+ str[size - 1] = 0;
+ char *c = str;
+
+ while (*c != '\0') {
+ // For JSON compatibility, the string
+ // can't contain double quotes.
+ // If a double quote is found, replace
+ // it with an ASCII space.
+ if (*c == '"') {
+ *c = ' ';
+ }
+
+ // Ensure the string is within printable
+ // ASCII. If not, replace the offending
+ // byte with an ASCII space.
+ if (*c < 32 || *c > 126) {
+ *c = ' ';
+ }
+
+ c += 1;
+ }
}
#endif