Fixed gm_ansi_strip

This commit is contained in:
Jesse van den Kieboom 2005-11-19 13:09:12 +00:00
parent 371e2a47d6
commit 31c733b972
1 changed files with 25 additions and 17 deletions

View File

@ -20,7 +20,7 @@
#include "gm-support.h"
#include "gm-debug.h"
#include "gm-pixbuf.h"
//#include "if_main.h"
#include "gm-string.h"
#define URL_REGEXP "(((mailto|news|telnet|nttp|file|http|sftp|ftp|https|dav|callto)://)|(www|ftp)[-A-Za-z0-9]*\\.)[-A-Za-z0-9\\.@:]+[^]''\\.}>\\) ,\\/\\\"\\!]+(:[0-9]*)?(/|/[-A-Za-z0-9_\\$\\.\\+\\!\\*\\(\\),;:@&=\\?/~\\#\\%]*[^]'\\.}>\\) ,\\\"\\!])?"
static regex_t url_regexp;
@ -58,23 +58,31 @@ gm_fix_decimal_point_rev(gchar *line, int len) {
}
gchar *
gm_ansi_strip(gchar * s) {
int i, j = 0;
gm_ansi_strip(gchar *s) {
gchar *ptr, *fptr;
gunichar c;
ptr = s;
fptr = s;
while (*ptr != '\0') {
c = g_utf8_get_char(ptr);
// Escape sequence, advance to character after 'm'
if (c == '\x1B') {
gm_string_skip_till((const gchar **)(&ptr), "m");
} else if (c != '\x07') {
// Store any other character (excluding bell char)
fptr += g_unichar_to_utf8(c, fptr);
}
if (*ptr != '\0') {
ptr = g_utf8_next_char(ptr);
}
}
for (i = 0; s[i] != '\0'; i++) {
// Escape sequence, advance to character after 'm'
if (s[i] == '\x1B') {
while (s[i] != '\0' && s[i] != 'm') {
i++;
}
} else if (s[i] != '\x07') {
s[j] = s[i];
j++;
}
}
s[j] = '\0';
return s;
*fptr = '\0';
return s;
}
int