We need to be careful about feeding FLTK @:s when they will be used in a
label as that is a formatting character.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4440 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/vncviewer/fltk_layout.h b/vncviewer/fltk_layout.h
index 5119188..61dea21 100644
--- a/vncviewer/fltk_layout.h
+++ b/vncviewer/fltk_layout.h
@@ -33,6 +33,40 @@
return (int)(len + 0.5f);
}
+/* Escapes all @ in text as those have special meaning in labels */
+static inline int fltk_escape(const char *in, char *out, size_t maxlen)
+{
+ int len;
+
+ len = 0;
+
+ while (*in != '\0') {
+ if (*in == '@') {
+ if (maxlen >= 3) {
+ *out++ = '@';
+ *out++ = '@';
+ maxlen -= 2;
+ }
+
+ len += 2;
+ } else {
+ if (maxlen >= 2) {
+ *out++ = *in;
+ maxlen--;
+ }
+
+ len += 1;
+ }
+
+ in++;
+ }
+
+ if (maxlen)
+ *out = '\0';
+
+ return len;
+}
+
/**** MARGINS ****/
#define OUTER_MARGIN 10