diff options
author | Keith Vetter <keithv@fusion.com> | 1995-05-25 18:34:40 +0000 |
---|---|---|
committer | Keith Vetter <keithv@fusion.com> | 1995-05-25 18:34:40 +0000 |
commit | 066683e65ebc6c68543c4b268484ca4fcc214c14 (patch) | |
tree | ff95e2c0265c1a04c7067b0c1c841370681c7449 /src/windows/wintel/emul.c | |
parent | 901c313f3eef63271c1238ba54093ff754a17ee0 (diff) | |
download | krb5-066683e65ebc6c68543c4b268484ca4fcc214c14.tar.gz krb5-066683e65ebc6c68543c4b268484ca4fcc214c14.tar.xz krb5-066683e65ebc6c68543c4b268484ca4fcc214c14.zip |
Windows telnet --fixed eol wrapping and general cleanup
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@5875 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/windows/wintel/emul.c')
-rw-r--r-- | src/windows/wintel/emul.c | 392 |
1 files changed, 178 insertions, 214 deletions
diff --git a/src/windows/wintel/emul.c b/src/windows/wintel/emul.c index 0282866c3..e3f995cb5 100644 --- a/src/windows/wintel/emul.c +++ b/src/windows/wintel/emul.c @@ -3,86 +3,105 @@ #include "windows.h" #include "screen.h" -static int ScreenEmChar( + +static int ScreenEmChars( SCREEN *pScr, - unsigned char c) + char *c, + int len) { /* - Function: Send a character to the virtual screen with no translation. + Function: Send a string of characters to the screen. Placement + continues as long as the stream of characters does not contain any + control chracters or cause wrapping to another line. When a control + character is encountered or wrapping occurs, display stops and a + count of the number of characters is returned. + + Parameters: + pScr - the screen to place the characters on. + + c - the string of characters to place on the screen. + + len - the number of characters contained in the string + + Returns: The number of characters actually placed on the screen. */ - int sx; + int insert; int ocount; int attrib; int extra; - int offend; - char *acurrent; /* pointer to the attributes for characters drawn */ - char *current; /* pointer to the place to put characters */ + int nchars; + char *acurrent; /* place to put attributes */ + char *current; /* place to put characters */ char *start; SCREENLINE *pScrLine; + if (len <= 0) + return(0); + + if (pScr->x != pScr->width - 1) + pScr->bWrapPending = FALSE; + else { + if (pScr->bWrapPending) { + pScr->x = 0; + pScr->bWrapPending = FALSE; + ScreenIndex(pScr); + } + } + pScrLine = GetScreenLineFromY(pScr, pScr->y); if (pScrLine == NULL) - return(-1); - - current = start = &pScrLine->text[pScr->x]; + return(0); + + current = &pScrLine->text[pScr->x]; acurrent = &pScrLine->attrib[pScr->x]; + start = current; + ocount = pScr->x; + extra = 0; attrib = pScr->attrib; insert = pScr->IRM; - ocount = pScr->x; - offend = 0; - extra = 0; - sx = pScr->x; - if (pScr->x > pScr->width) { - if (pScr->DECAWM) { /* check for line wrapping on */ - pScr->x = 0; - ScreenIndex(pScr); - } - else /* no line wrapping */ - pScr->x = pScr->width; - current = start = &pScrLine->text[pScr->x]; - acurrent = &pScrLine->attrib[pScr->x]; - ocount = pScr->x; - sx = pScr->x; - } - if (insert) - ScreenInsChar(pScr, 1); - *current = c; - *acurrent = (char) attrib; - if (pScr->x < pScr->width) { - acurrent++; - current++; - pScr->x++; - } - else { - if(pScr->DECAWM) { + + for (nchars = 0; nchars < len && *c >= 32; nchars++) { + if (insert) + ScreenInsChar(pScr, 1); + + *current = *c; + *acurrent = (char) attrib; + c++; + if (pScr->x < pScr->width - 1) { + acurrent++; + current++; pScr->x++; - offend = 1; } else { - pScr->x = pScr->width; extra = 1; + if (pScr->DECAWM) { + pScr->bWrapPending = TRUE; + nchars++; + break; + } } } - if (insert) - ScreenInsString(pScr, pScr->x - ocount + offend + extra, start); /* actually just decides which RS to use */ - else - ScreenDraw(pScr, sx, pScr->y, pScr->attrib, pScr->x - ocount + offend + extra, start); -} /* ScreenEmChar */ + ScreenDraw(pScr, ocount, pScr->y, pScr->attrib, pScr->x - ocount + extra, start); + + return(nchars); + +} /* ScreenEmChars */ + void ScreenEm( LPSTR c, int len, SCREEN *pScr) { - SCREENLINE *pScrLine; - int escflg; /* vt100 escape level */ + int escflg; /* vt100 escape level */ RECT rc; unsigned int ic; char stat[20]; int i; + int nchars; if (pScr->screen_bottom != pScr->buffer_bottom) { ScreenUnscroll(pScr); @@ -94,7 +113,7 @@ void ScreenEm( escflg = pScr->escflg; #ifdef UM - if (pScr->localprint && len > 0) { /* see if printer needs anything */ + if (pScr->localprint && len > 0) { /* see if printer needs anything */ pcount = send_localprint(c, len); len -= pcount; c += pcount; @@ -105,44 +124,44 @@ void ScreenEm( while((*c < 32) && (escflg == 0) && (len > 0)) { /* look at first character in the vt100 string, if it is a non-printable ascii code */ switch(*c) { - case 0x1b: /* ESC found (begin vt100 control sequence) */ + case 0x1b: /* ESC found (begin vt100 control sequence) */ escflg++; break; - case -1: /* IAC from telnet session */ + case -1: /* IAC from telnet session */ escflg = 6; break; #ifdef CISB - case 0x05: /* CTRL-E found (answerback) */ + case 0x05: /* CTRL-E found (answerback) */ bp_ENQ(); break; #endif - case 0x07: /* CTRL-G found (bell) */ + case 0x07: /* CTRL-G found (bell) */ ScreenBell(pScr); break; - case 0x08: /* CTRL-H found (backspace) */ + case 0x08: /* CTRL-H found (backspace) */ ScreenBackspace(pScr); break; - case 0x09: /* CTRL-I found (tab) */ - ScreenTab(pScr); /* Later change for versatile tabbing */ + case 0x09: /* CTRL-I found (tab) */ + ScreenTab(pScr); /* Later change for versatile tabbing */ break; - case 0x0a: /* CTRL-J found (line feed) */ - case 0x0b: /* CTRL-K found (treat as line feed) */ - case 0x0c: /* CTRL-L found (treat as line feed) */ + case 0x0a: /* CTRL-J found (line feed) */ + case 0x0b: /* CTRL-K found (treat as line feed) */ + case 0x0c: /* CTRL-L found (treat as line feed) */ ScreenIndex(pScr); break; - case 0x0d: /* CTRL-M found (carriage feed) */ + case 0x0d: /* CTRL-M found (carriage feed) */ ScreenCarriageFeed(pScr); break; #if 0 - case 0x0e: /* CTRL-N found (invoke Graphics (G1) character set) */ + case 0x0e: /* CTRL-N found (invoke Graphics (G1) character set) */ if (pScr->G1) pScr->attrib = VSgraph(pScr->attrib); else @@ -150,7 +169,7 @@ void ScreenEm( pScr->charset = 1; break; - case 0x0f: /* CTRL-O found (invoke 'normal' (G0) character set) */ + case 0x0f: /* CTRL-O found (invoke 'normal' (G0) character set) */ if(pScr->G0) pScr->attrib = VSgraph(pScr->attrib); else @@ -160,178 +179,118 @@ void ScreenEm( #endif #ifdef CISB - case 0x10: /* CTRL-P found (undocumented in vt100) */ + case 0x10: /* CTRL-P found (undocumented in vt100) */ bp_DLE(c, len); len = 0; break; #endif #if 0 - case 0x11: /* CTRL-Q found (XON) (unused presently) */ - case 0x13: /* CTRL-S found (XOFF) (unused presently) */ - case 0x18: /* CTRL-X found (CAN) (unused presently) */ - case 0x1a: /* CTRL-Z found (SUB) (unused presently) */ + case 0x11: /* CTRL-Q found (XON) (unused presently) */ + case 0x13: /* CTRL-S found (XOFF) (unused presently) */ + case 0x18: /* CTRL-X found (CAN) (unused presently) */ + case 0x1a: /* CTRL-Z found (SUB) (unused presently) */ break; #endif } /* end switch */ - c++; /* advance to the next character in the string */ - len--; /* decrement the counter */ - - } /* end while */ - - if (escflg == 0) { /* check for normal character to print */ - while ((len > 0) && (*c >= 32)) { /* print out printable ascii chars, if we haven't found an ESCAPE char */ - int sx; - int insert; - int ocount; - int attrib; - int extra; - int offend; - char *acurrent; /* pointer to the attributes for characters drawn */ - char *current; /* pointer to the place to put characters */ - char *start; - - pScrLine = GetScreenLineFromY(pScr, pScr->y); - if (pScrLine == NULL) - return; - - current = start = &pScrLine->text[pScr->x]; - acurrent = &pScrLine->attrib[pScr->x]; - attrib = pScr->attrib; - insert = pScr->IRM; - ocount = pScr->x; - offend = 0; - extra = 0; - sx = pScr->x; - if (pScr->x > pScr->width) { - if (pScr->DECAWM) { /* check for line wrapping on */ - pScr->x = 0; - ScreenIndex(pScr); - } - else /* no line wrapping */ - pScr->x = pScr->width; - current = start = &pScrLine->text[pScr->x]; - acurrent = &pScrLine->attrib[pScr->x]; - ocount = pScr->x; - sx = pScr->x; - } - while ((len > 0) && (*c >= 32) && (offend == 0)) { - if (insert) - ScreenInsChar(pScr, 1); - *current = *c; - *acurrent = (char) attrib; - c++; - len--; - if (pScr->x < pScr->width) { - acurrent++; - current++; - pScr->x++; - } - else { - if (pScr->DECAWM) { - pScr->x++; - offend = 1; - } - else { - pScr->x = pScr->width; - extra = 1; - } - } - } - if (insert) - ScreenInsString(pScr, pScr->x - ocount + offend + extra, start); /* actually just decides which RS to use */ - else - ScreenDraw(pScr, sx, pScr->y, pScr->attrib, pScr->x - ocount + offend + extra, start); - } + c++; /* advance to the next character in the string */ + len--; /* decrement the counter */ + + } /* end while */ + + if (escflg == 0) { /* check for normal character to print */ + nchars = ScreenEmChars(pScr, c, len); + c += nchars; + len -= nchars; } - - while ((len > 0) && (escflg == 1)) { /* ESC character was found */ + + while ((len > 0) && (escflg == 1)) { /* ESC character was found */ switch(*c) { - case 0x08: /* CTRL-H found (backspace) */ + case 0x08: /* CTRL-H found (backspace) */ ScreenBackspace(pScr); break; - case '[': /* mostly cursor movement options, and DEC private stuff following */ + case '[': /* mostly cursor movement options, and DEC private stuff following */ ScreenApClear(pScr); escflg = 2; break; - case '#': /* various screen adjustments */ + case '#': /* various screen adjustments */ escflg = 3; break; - case '(': /* G0 character set options */ + case '(': /* G0 character set options */ escflg = 4; break; - case ')': /* G1 character set options */ + case ')': /* G1 character set options */ escflg = 5; break; - case '>': /* keypad numeric mode (DECKPAM) */ + case '>': /* keypad numeric mode (DECKPAM) */ pScr->DECPAM = 0; escflg = 0; break; - case '=': /* keypad application mode (DECKPAM) */ + case '=': /* keypad application mode (DECKPAM) */ pScr->DECPAM = 1; escflg = 0; break; - case '7': /* save cursor (DECSC) */ + case '7': /* save cursor (DECSC) */ ScreenSaveCursor(pScr); escflg = 0; break; - case '8': /* restore cursor (DECRC) */ + case '8': /* restore cursor (DECRC) */ ScreenRestoreCursor(pScr); escflg = 0; break; #if 0 - case 'c': /* reset to initial state (RIS) */ + case 'c': /* reset to initial state (RIS) */ ScreenReset(pScr); escflg = 0; break; #endif - case 'D': /* index (move down one line) (IND) */ + case 'D': /* index (move down one line) (IND) */ ScreenIndex(pScr); escflg = 0; break; - case 'E': /* next line (move down one line and to first column) (NEL) */ + case 'E': /* next line (move down one line and to first column) (NEL) */ pScr->x = 0; ScreenIndex(pScr); escflg = 0; break; - case 'H': /* horizontal tab set (HTS) */ + case 'H': /* horizontal tab set (HTS) */ pScr->tabs[pScr->x] = 'x'; escflg = 0; break; #ifdef CISB - case 'I': /* undoumented in vt100 */ + case 'I': /* undoumented in vt100 */ bp_ESC_I(); break; #endif - case 'M': /* reverse index (move up one line) (RI) */ + case 'M': /* reverse index (move up one line) (RI) */ ScreenRevIndex(pScr); escflg = 0; break; - case 'Z': /* identify terminal (DECID) */ + case 'Z': /* identify terminal (DECID) */ escflg = 0; break; default: - ScreenEmChar(pScr, 0x1b); /* put the ESC character into the Screen */ - ScreenEmChar(pScr, *c); /* put the next character into the Screen */ + ScreenEmChars(pScr, "\033", 1); /* put the ESC character into the Screen */ + ScreenEmChars(pScr, c, 1); /* put the next character into the Screen */ escflg = 0; break; @@ -344,7 +303,7 @@ void ScreenEm( while((escflg == 2) && (len > 0)) { /* '[' handling */ switch(*c) { - case 0x08: /* backspace */ + case 0x08: /* backspace */ ScreenBackspace(pScr); break; @@ -357,22 +316,23 @@ void ScreenEm( case '6': case '7': case '8': - case '9': /* numeric parameters */ + case '9': /* numeric parameters */ if (pScr->parms[pScr->parmptr] < 0) pScr->parms[pScr->parmptr] = 0; pScr->parms[pScr->parmptr] *= 10; pScr->parms[pScr->parmptr] += *c - '0'; break; - case '?': /* vt100 mode change */ + case '?': /* vt100 mode change */ pScr->parms[pScr->parmptr++] = -2; break; - case ';': /* parameter divider */ + case ';': /* parameter divider */ pScr->parmptr++; break; - case 'A': /* cursor up (CUU) */ + case 'A': /* cursor up (CUU) */ + pScr->bWrapPending = FALSE; rc.left = pScr->x * pScr->cxChar; rc.right = (pScr->x + 1) * pScr->cxChar; rc.top = pScr->cyChar * pScr->y; @@ -389,7 +349,8 @@ void ScreenEm( SendMessage(pScr->hWnd, WM_PAINT, NULL, NULL); break; - case 'B': /* cursor down (CUD) */ + case 'B': /* cursor down (CUD) */ + pScr->bWrapPending = FALSE; rc.left = pScr->x * pScr->cxChar; rc.right = (pScr->x + 1) * pScr->cxChar; rc.top = pScr->cyChar * pScr->y; @@ -406,7 +367,8 @@ void ScreenEm( SendMessage(pScr->hWnd, WM_PAINT, NULL, NULL); break; - case 'C': /* cursor forward (right) (CUF) */ + case 'C': /* cursor forward (right) (CUF) */ + pScr->bWrapPending = FALSE; rc.left = pScr->x * pScr->cxChar; rc.right = (pScr->x + 1) * pScr->cxChar; rc.top = pScr->cyChar * pScr->y; @@ -423,7 +385,8 @@ void ScreenEm( SendMessage(pScr->hWnd, WM_PAINT, NULL, NULL); break; - case 'D': /* cursor backward (left) (CUB) */ + case 'D': /* cursor backward (left) (CUB) */ + pScr->bWrapPending = FALSE; rc.left = pScr->x * pScr->cxChar; rc.right = (pScr->x + 1) * pScr->cxChar; rc.top = pScr->cyChar * pScr->y; @@ -438,8 +401,9 @@ void ScreenEm( SendMessage(pScr->hWnd, WM_PAINT, NULL, NULL); break; - case 'f': /* horizontal & vertical position (HVP) */ - case 'H': /* cursor position (CUP) */ + case 'f': /* horizontal & vertical position (HVP) */ + case 'H': /* cursor position (CUP) */ + pScr->bWrapPending = FALSE; rc.left = pScr->x * pScr->cxChar; rc.right = (pScr->x + 1) * pScr->cxChar; rc.top = pScr->cyChar * pScr->y; @@ -447,25 +411,25 @@ void ScreenEm( InvalidateRect(pScr->hWnd, &rc, TRUE); pScr->x = pScr->parms[1] - 1; pScr->y = pScr->parms[0] - 1; - ScreenRange(pScr); /* make certain the cursor position is valid */ + ScreenRange(pScr); /* make certain the cursor position is valid */ escflg = 0; SendMessage(pScr->hWnd, WM_PAINT, NULL, NULL); break; - case 'J': /* erase in display (ED) */ + case 'J': /* erase in display (ED) */ switch(pScr->parms[0]) { case -1: - case 0: /* erase from active position to end of screen */ + case 0: /* erase from active position to end of screen */ ScreenEraseToEndOfScreen(pScr); break; - case 1: /* erase from start of screen to active position */ + case 1: /* erase from start of screen to active position */ #if 0 ScreenEraseToPosition(pScr); #endif break; - case 2: /* erase whole screen */ + case 2: /* erase whole screen */ ScreenEraseScreen(pScr); break; @@ -476,18 +440,18 @@ void ScreenEm( escflg = 0; break; - case 'K': /* erase in line (EL) */ + case 'K': /* erase in line (EL) */ switch(pScr->parms[0]) { case -1: - case 0: /* erase to end of line */ + case 0: /* erase to end of line */ ScreenEraseToEOL(pScr); break; - case 1: /* erase to beginning of line */ + case 1: /* erase to beginning of line */ ScreenEraseToBOL(pScr); break; - case 2: /* erase whole line */ + case 2: /* erase whole line */ ScreenEraseLine(pScr, -1); break; @@ -498,21 +462,21 @@ void ScreenEm( escflg = 0; break; - case 'L': /* insert n lines preceding current line (IL) */ + case 'L': /* insert n lines preceding current line (IL) */ if (pScr->parms[0] < 1) pScr->parms[0] = 1; ScreenInsLines(pScr, pScr->parms[0], -1); escflg = 0; break; - case 'M': /* delete n lines from current position downward (DL) */ + case 'M': /* delete n lines from current position downward (DL) */ if (pScr->parms[0] < 1) pScr->parms[0] = 1; ScreenDelLines(pScr, pScr->parms[0], -1); escflg = 0; break; - case 'P': /* delete n chars from cursor to the left (DCH) */ + case 'P': /* delete n chars from cursor to the left (DCH) */ if (pScr->parms[0] < 1) pScr->parms[0] = 1; ScreenDelChars(pScr, pScr->parms[0]); @@ -520,19 +484,19 @@ void ScreenEm( break; #if 0 - case 'R': /* receive cursor position status from host */ + case 'R': /* receive cursor position status from host */ break; #endif #if 0 - case 'c': /* device attributes (DA) */ + case 'c': /* device attributes (DA) */ ScreenSendIdent(); escflg = 0; break; #endif - case 'g': /* tabulation clear (TBC) */ - if (pScr->parms[0] == 3) /* clear all tabs */ + case 'g': /* tabulation clear (TBC) */ + if (pScr->parms[0] == 3)/* clear all tabs */ ScreenTabClear(pScr); else if (pScr->parms[0] <= 0) /* clear tab stop at active position */ @@ -540,12 +504,12 @@ void ScreenEm( escflg = 0; break; - case 'h': /* set mode (SM) */ + case 'h': /* set mode (SM) */ // ScreenSetOption(pScr,1); escflg = 0; break; - case 'i': /* toggle printer */ + case 'i': /* toggle printer */ #if 0 if(pScr->parms[pScr->parmptr] == 5) pScr->localprint = 1; @@ -555,12 +519,12 @@ void ScreenEm( escflg = 0; break; - case 'l': /* reset mode (RM) */ + case 'l': /* reset mode (RM) */ // ScreenSetOption(pScr,0); escflg = 0; break; - case 'm': /* select graphics rendition (SGR) */ + case 'm': /* select graphics rendition (SGR) */ { int temp = 0; @@ -575,15 +539,15 @@ void ScreenEm( escflg = 0; break; - case 'n': /* device status report (DSR) */ + case 'n': /* device status report (DSR) */ switch (pScr->parms[0]) { #if 0 - case 0: /* response from vt100; ready, no malfunctions */ - case 3: /* response from vt100; malfunction, retry */ + case 0: /* response from vt100; ready, no malfunctions */ + case 3: /* response from vt100; malfunction, retry */ #endif - case 5: /* send status */ - case 6: /* send active position */ - wsprintf(stat, "\033[%d;%dR", pScr->y, pScr->x); + case 5: /* send status */ + case 6: /* send active position */ + wsprintf(stat, "\033[%d;%dR", pScr->y + 1, pScr->x + 1); for (i = 0; stat[i]; i++) SendMessage(pScr->hwndTel, WM_MYSCREENCHAR, stat[i], (LPARAM) pScr); break; @@ -591,11 +555,11 @@ void ScreenEm( escflg = 0; break; - case 'q': /* load LEDs (unsupported) (DECLL) */ + case 'q': /* load LEDs (unsupported) (DECLL) */ escflg = 0; break; - case 'r': /* set top & bottom margins (DECSTBM) */ + case 'r': /* set top & bottom margins (DECSTBM) */ if (pScr->parms[0] < 0) pScr->top = 0; else @@ -622,14 +586,14 @@ void ScreenEm( pScr->y = 0; #if 0 if (pScr->DECORG) - pScr->y = pScr->top; /* origin mode relative */ + pScr->y = pScr->top; /* origin mode relative */ #endif escflg = 0; break; #if 0 - case 'x': /* request/report terminal parameters (DECREQTPARM/DECREPTPARM) */ - case 'y': /* invoke confidence test (DECTST) */ + case 'x': /* request/report terminal parameters (DECREQTPARM/DECREPTPARM) */ + case 'y': /* invoke confidence test (DECTST) */ break; #endif @@ -653,19 +617,19 @@ void ScreenEm( while ((escflg == 3) && (len > 0)) { /* # Handling */ switch (*c) { - case 0x08: /* backspace */ + case 0x08: /* backspace */ ScreenBackspace(pScr); break; #if 0 - case '3': /* top half of double line (DECDHL) */ - case '4': /* bottom half of double line (DECDHL) */ - case '5': /* single width line (DECSWL) */ - case '6': /* double width line (DECDWL) */ + case '3': /* top half of double line (DECDHL) */ + case '4': /* bottom half of double line (DECDHL) */ + case '5': /* single width line (DECSWL) */ + case '6': /* double width line (DECDWL) */ break; #endif - case '8': /* screen alignment display (DECALN) */ + case '8': /* screen alignment display (DECALN) */ ScreenAlign(pScr); escflg = 0; break; @@ -683,7 +647,7 @@ void ScreenEm( while ((escflg == 4) && (len > 0)) { /* ( Handling (GO character set) */ switch (*c) { - case 0x08: /* backspace */ + case 0x08: /* backspace */ ScreenBackspace(pScr); break; @@ -719,7 +683,7 @@ void ScreenEm( while((escflg == 5) && (len > 0)) { /* ) Handling (G1 handling) */ switch (*c) { - case 0x08: /* backspace */ + case 0x08: /* backspace */ ScreenBackspace(pScr); break; @@ -755,33 +719,33 @@ void ScreenEm( ic = (unsigned char) *c; switch (escflg) { - case 6: /* Handling IAC xx */ - if (ic == 255) /* if IAC */ + case 6: /* Handling IAC xx */ + if (ic == 255) /* if IAC */ escflg = 0; - else if (ic == 250) /* if SB */ + else if (ic == 250) /* if SB */ escflg = 7; else escflg = 9; break; - case 7: /* Handling IAC SB xx */ - if (ic == 255) /* if IAC */ + case 7: /* Handling IAC SB xx */ + if (ic == 255) /* if IAC */ escflg = 8; break; - case 8: /* Handling IAC SB IAC xx */ - if (ic == 255) /* if IAC IAC */ + case 8: /* Handling IAC SB IAC xx */ + if (ic == 255) /* if IAC IAC */ escflg = 7; - else if (ic == 240) /* if IAC SE */ + else if (ic == 240) /* if IAC SE */ escflg = 0; break; - case 9: /* IAC xx xx */ + case 9: /* IAC xx xx */ escflg = 0; break; } - c++; /* advance to the next character in the string */ - len--; /* decrement the counter */ + c++; /* advance to the next character in the string */ + len--; /* decrement the counter */ } if (escflg > 2 && escflg < 6 && len > 0) { |