[pkg-fso-commits] [SCM] libframeworkd-phonegui branch, upstream, updated. 640da47bfcff755388d0fb8f443eb34e0dea3c72
Klaus Kurzmann
mok at fluxnetz.de
Sat Dec 27 20:50:08 UTC 2008
The following commit has been merged in the upstream branch:
commit eb791f2ab90c982bcae3286cdd8e629b606ecc95
Author: Klaus Kurzmann <mok at fluxnetz.de>
Date: Tue Dec 16 15:20:21 2008 +0100
helper: add a string helper to replace newlines and tabs with tags
This explodes \n to <br>
and \t to <tab>.
Signed-off-by: Klaus Kurzmann <mok at fluxnetz.de>
diff --git a/libframeworkd-phonegui-efl/src/util/helper.c b/libframeworkd-phonegui-efl/src/util/helper.c
index c237bdf..d64ec1e 100644
--- a/libframeworkd-phonegui-efl/src/util/helper.c
+++ b/libframeworkd-phonegui-efl/src/util/helper.c
@@ -49,6 +49,54 @@ void string_replace_newline(char *string) {
}
+
+char *string_replace_with_tags(char *string)
+{
+ int newlen = 0;
+ char *in_p = string, *out_p;
+
+ /* scan the string to see how much longer we have to get */
+ while (*in_p) {
+ switch (*in_p++) {
+ case '\n': newlen += 3; break;
+ case '\t': newlen += 4; break;
+ }
+ }
+
+ if (!newlen)
+ return (string);
+
+ newlen += strlen(string);
+ char *newstring = malloc(newlen+1);
+ in_p = string;
+ out_p = newstring;
+ while (*in_p) {
+ switch (*in_p) {
+ case '\n':
+ *out_p++ = '<';
+ *out_p++ = 'b';
+ *out_p++ = 'r';
+ *out_p++ = '>';
+ break;
+ case '\t':
+ *out_p++ = '<';
+ *out_p++ = 't';
+ *out_p++ = 'a';
+ *out_p++ = 'b';
+ *out_p++ = '>';
+ break;
+ default:
+ *out_p++ = *in_p;
+ break;
+ }
+ in_p++;
+ }
+ *out_p = '\0';
+
+ return (newstring);
+}
+
+
gboolean string_is_number(const char *string) {
if(!strlen(string)) {
return FALSE;
diff --git a/libframeworkd-phonegui-efl/src/util/helper.h b/libframeworkd-phonegui-efl/src/util/helper.h
index 20f86b2..12bb530 100644
--- a/libframeworkd-phonegui-efl/src/util/helper.h
+++ b/libframeworkd-phonegui-efl/src/util/helper.h
@@ -7,6 +7,7 @@
time_t time_stringtotimestamp(const char *str);
void string_strip_html(char *string);
void string_replace_newline(char *string);
+char *string_replace_with_tags(char *string);
gboolean string_is_number(const char *string);
gboolean string_is_pin(const char *string);
gboolean string_is_puk(const char *string);
--
libframeworkd-phonegui
More information about the pkg-fso-commits
mailing list