aboutsummaryrefslogtreecommitdiffstats
path: root/src/ansi.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ansi.c')
-rw-r--r--src/ansi.c34
1 files changed, 19 insertions, 15 deletions
diff --git a/src/ansi.c b/src/ansi.c
index 4671dc4..bcdc63e 100644
--- a/src/ansi.c
+++ b/src/ansi.c
@@ -10,6 +10,9 @@ static char rcsid[] = "$Id$";
/*
* $Log$
+ * Revision 1.43 2008/03/06 01:41:48 james
+ * *** empty log message ***
+ *
* Revision 1.42 2008/03/03 06:04:42 james
* *** empty log message ***
*
@@ -828,22 +831,26 @@ static void
ansi_parse_ansikey (ANSI * a, Context * c)
{
ANSI_Parser *p = &a->parser;
+ int l = p->escape_ptr - 1;
+ char *end;
+ int k;
- if ((p->escape_buf[1] != '[') || (p->escape_buf[3] != '~'))
+ if ((p->escape_buf[1] != '[') || (p->escape_buf[l] != '~'))
{
ansi_flush_escape (a, c);
return;
}
- if ((p->escape_buf[2] >= '0') || (p->escape_buf[2] <= '9'))
- {
- ansi_key (a, c, KEY_180 + (p->escape_buf[2] - '0'));
- }
- else
+
+ k = strtol (&p->escape_buf[2], &end, 10);
+
+ if (end != &p->escape_buf[l])
{
ansi_flush_escape (a, c);
return;
}
+ ansi_key (a, c, KEY_180 + k);
+
p->in_escape = 0;
p->escape_ptr = 0;
}
@@ -884,16 +891,13 @@ ansi_parse_escape (ANSI * a, Context * c)
}
break;
case 4:
- switch (p->escape_buf[1])
- {
- case '[':
- ansi_parse_ansikey (a, c);
- break;
- default:
- ansi_flush_escape (a, c);
- }
- break;
case 5:
+ case 6:
+ case 7:
+ if (p->escape_buf[p->escape_ptr - 1] == '~')
+ ansi_parse_ansikey (a, c);
+ break;
+ default:
ansi_flush_escape (a, c);
}
}