From 7220e03e7d4cd21f27038b6ce73ab2c77390a348 Mon Sep 17 00:00:00 2001 From: Chris Young Date: Tue, 16 Mar 2010 23:55:39 +0000 Subject: Help hints, mainly for the tabs but also massage messages strings HelpToolbar0-4 & 14 into a format we can use on the main toolbar gadgets. A couple of gadgets still missing strings. svn path=/trunk/netsurf/; revision=10134 --- amiga/misc.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'amiga/misc.c') diff --git a/amiga/misc.c b/amiga/misc.c index cedff5d77..cee6aa688 100755 --- a/amiga/misc.c +++ b/amiga/misc.c @@ -82,3 +82,40 @@ char *path_to_url(const char *path) return r; } + +/** + * returns a string without escape chars or |M chars. + * (based on remove_underscores from utils.c) + * \param translate true to insert a linebreak where there was |M, + * and capitalise initial characters after escape chars. + */ + +char *remove_escape_chars(const char *s, bool translate) +{ + size_t i, ii, len; + char *ret; + bool nextcharupper = false; + len = strlen(s); + ret = malloc(len + 1); + if (ret == NULL) + return NULL; + for (i = 0, ii = 0; i < len; i++) { + if ((s[i] != '\\') && (s[i] != '|')) { + if(nextcharupper) { + ret[ii++] = toupper(s[i]); + nextcharupper = false; + } + else ret[ii++] = s[i]; + } + else if ((translate) && (s[i] == '|') && (s[i+1] == 'M')) { + ret[ii++] = '\n'; + i++; + } + else { + if(translate) nextcharupper = true; + i++; + } + } + ret[ii] = '\0'; + return ret; +} -- cgit v1.2.3