aboutsummaryrefslogtreecommitdiffstats
path: root/main/term.c
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2006-11-15 00:19:05 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2006-11-15 00:19:05 +0000
commitce446ec9d6b38caa1ef98ba10e28de4884862778 (patch)
tree5d7d22dc09a20c080e017e536be1c8ea9c16bdfb /main/term.c
parent64673197395d496cee953f92e7b1aa16fcedb700 (diff)
more formatting cleanup, and avoid running off the end of the string
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@47641 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/term.c')
-rw-r--r--main/term.c32
1 files changed, 15 insertions, 17 deletions
diff --git a/main/term.c b/main/term.c
index bdafa49e2..940396ee3 100644
--- a/main/term.c
+++ b/main/term.c
@@ -266,28 +266,26 @@ char *term_prompt(char *outbuf, const char *inbuf, int maxout)
/* filter escape sequences */
void term_filter_escapes(char *line)
- {
- int i;
-
- for (i = 0; i < strlen(line); i++) {
+{
+ int i;
+ int len = strlen(line);
+
+ for (i = 0; i < len; i++) {
if (line[i] != ESC)
continue;
- if (line[i + 1] == '\x5b') {
+ if ((i < (len - 2)) &&
+ (line[i + 1] == 0x5B)) {
switch (line[i + 2]) {
- case '\x30':
- case '\x31':
- case '\x33':
- break;
- default:
- /* replace ESC with a space */
- line[i] = ' ';
+ case 0x30:
+ case 0x31:
+ case 0x33:
+ continue;
}
- } else {
- /* replace ESC with a space */
- line[i] = ' ';
}
- }
- }
+ /* replace ESC with a space */
+ line[i] = ' ';
+ }
+}
char *term_prep(void)
{