diff -ur tf-40s2.orig/src/output.c tf-40s2/src/output.c --- tf-40s2.orig/src/output.c Sun Jun 24 10:18:41 2001 +++ tf-40s2/src/output.c Sun Jun 24 12:14:05 2001 @@ -997,8 +997,6 @@ addlines = -1; } else if (visual != screen_mode) { /* %visual changed */ addlines = isize; - } else if (!visual) { /* other changes have no effect */ - addlines = -1; #ifdef SCREEN } else if (isize != old_isize) { /* %isize changed */ if (ystatus > (lines - isize)) /* larger */ @@ -1144,7 +1142,7 @@ char c; for (attrflag = 0; n > 0; s++, n--) { - c = unmapchar(localize(*s)); + c = localize(*s); if (is_cntrl(c)) { if (!attrflag) attributes_on(F_BOLD | F_REVERSE), attrflag = 1; @@ -1648,7 +1646,7 @@ new &= ~F_BGCOLORMASK; new |= line->partials[i]; } - c = unmapchar(localize(line->str[i])); + c = line->str[i]; ctrl = (emulation != EMUL_RAW && is_cntrl(c)); if (ctrl) new |= F_BOLD | F_REVERSE; @@ -1784,31 +1782,34 @@ int len; int indent; /* flag */ { - int total, max; - - if (emulation == EMUL_RAW) return len; + int total, max, visible, incode=FALSE; max = (indent && wrapspace < Wrap) ? (Wrap - wrapspace) : Wrap; -#if 0 - /* Don't count nonprinting chars or "ansi" display codes (anything - * starting with ESC and ending with a letter, for our purposes). - */ - for (visible = total = 0; total < len && visible < max; total++) { - if (incode) { - if (is_alpha(str[total])) incode = FALSE; - } else { - if (is_print(str[total])) - visible++; - incode = (str[total] == '\33'); - } + if(emulation == EMUL_RAW) { + /* Don't count nonprinting chars or "ansi" display codes (anything + * starting with ESC and ending with a letter, for our purposes). + */ + for (visible = total = 0; total < len; total++) { + if(str[total] == '\033') { + incode=TRUE; + continue; + } + if(incode) { + if(isalpha(str[total])) incode=FALSE; + continue; + } + if(visible >= max) + break; + if(str[total] >= 16 || str[total] <= 6) + visible++; + } + } else { + /* Nonprinting characters from server were already stripped; others will be + * displayed in bold-reverse notation, so should be counted. + */ + total = (len < max) ? len : max; } -#else - /* Nonprinting characters from server were already stripped; others will be - * displayed in bold-reverse notation, so should be counted. - */ - total = (len < max) ? len : max; -#endif if (total == len) return len; len = total; if (wrapflag) diff -ur tf-40s2.orig/src/socket.c tf-40s2/src/socket.c --- tf-40s2.orig/src/socket.c Sat Mar 6 17:43:25 1999 +++ tf-40s2/src/socket.c Sun Jun 24 10:55:06 2001 @@ -1764,13 +1764,20 @@ for (place = buffer; place - buffer < count; place++) { /* We always accept 8-bit data, even though RFCs 854 and 1123 - * say server shouldn't transmit it unless in BINARY mode. What - * we do with it depends on the locale. + * say server shouldn't transmit it unless in BINARY mode. */ - localchar = localize(*place); + localchar = *place; - if (xsock->state == TN_IAC) { - switch (xsock->state = *place) { + if (*place == TN_IAC) { + if (!(xsock->flags & SOCKTELNET)) { + /* We now know server groks TELNET */ + xsock->flags |= SOCKTELNET; + preferred_telnet_options(); + } + xsock->state = TN_IAC; + continue; + } if(xsock->state == TN_IAC) { + switch(*place) { case TN_GA: case TN_EOR: /* This is definitely a prompt. */ telnet_recv(*place, 0); @@ -1780,6 +1787,7 @@ handle_prompt(xsock->buffer->s, TRUE); Stringterm(xsock->buffer, 0); } + xsock->state='\0'; break; #if 0 case TN_SB: @@ -1800,6 +1808,7 @@ case TN_WILL: case TN_WONT: case TN_DO: case TN_DONT: /* just change state */ + xsock->state=*place; break; case TN_IAC: Stringadd(xsock->buffer, localchar); /* literal IAC */ @@ -1874,14 +1883,6 @@ } xsock->state = '\0'; - } else if (*place == TN_IAC) { - if (!(xsock->flags & SOCKTELNET)) { - /* We now know server groks TELNET */ - xsock->flags |= SOCKTELNET; - preferred_telnet_options(); - } - xsock->state = *place; - } else if (*place == '\n') { /* Complete line received. Process it. */ handle_socket_line(); @@ -1902,7 +1903,7 @@ /* Ignore CR and NUL. */ xsock->state = *place; - } else if (*place == '\b' && emulation >= EMUL_PRINT) { + } else if (*place == '\b') { if (xsock->state == '*') { /* "*\b" is an LP editor prompt. */ if (do_hook(H_PROMPT, NULL, "%S", xsock->buffer)) { @@ -1946,14 +1947,15 @@ } else { /* Normal character. The is_print() loop is a fast heuristic * to find next potentially interesting character. */ - char *end; + unsigned char *end; Stringadd(xsock->buffer, localchar); end=++place; - while (is_print(*end) && *end != TN_IAC && end - buffer < count) + while (((*end >= 28 && *end <= 254) || (*end >= 16 && *end <= 26) || + (*end >= 1 && *end <= 6)) && (char*)end - buffer < count) end++; - Stringfncat(xsock->buffer, (char*)place, end - place); + Stringfncat(xsock->buffer, (char*)place, (char*)end - place); place = end - 1; - xsock->state = *place; + xsock->state = ((unsigned char)(*place) < 251)?*place:0; } } diff -ur tf-40s2.orig/src/util.h tf-40s2/src/util.h --- tf-40s2.orig/src/util.h Sun Jun 24 10:18:41 2001 +++ tf-40s2/src/util.h Sat Apr 24 16:35:43 1999 @@ -27,7 +27,7 @@ #define unmapchar(c) ((char)(((c) == (char)0x80) ? 0x0 : (c))) /* Map character into set allowed by locale */ -#define localize(c) ((is_print(c) || is_cntrl(c)) ? (c) : (c) & 0x7F) +#define localize(c) (c) /* Modulo arithmetic: remainder is positive, even if numerator is negative. */ #define nmod(n, d) (((n) >= 0) ? ((n)%(d)) : ((d) - ((-(n)-1)%(d)) - 1)) diff -ur tf-40s2.orig/unix/Config tf-40s2/unix/Config --- tf-40s2.orig/unix/Config Sun Jun 24 10:18:41 2001 +++ tf-40s2/unix/Config Sun Jun 24 10:33:40 2001 @@ -109,8 +109,8 @@ # If unixmake told you to set CC=cc, be sure to uncomment the line below # by removing the leading "#". -# CC=cc -# CCFLAGS="-g" +CC=gcc +CCFLAGS="-O2" ### Stripping. diff -ur tf-40s2/src/history.c tf-40s2/src/history.c --- tf-40s2.orig/src/history.c 1999-03-06 17:43:24.000000000 -0500 +++ tf-40s2/src/history.c 2008-05-24 12:41:09.000000000 -0400 @@ -38,18 +38,6 @@ #define LOCALSIZE 100 /* local history size */ #define INPUTSIZE 100 /* command history buffer size */ -typedef struct History { /* circular list of Alines, and logfile */ - struct Aline **alines; - int size; /* actual number of lines currently saved */ - int maxsize; /* maximum number of lines that can be saved */ - int first; /* position of first line in circular array */ - int last; /* position of last line in circular array */ - int index; /* current recall position */ - int total; /* total number of lines ever saved */ - TFILE *logfile; - CONST char *logname; -} History; - #define empty(hist) (!(hist)->alines || !(hist)->size) static void FDECL(alloc_history,(History *hist, int maxsize)); diff -ur tf-40s2/src/history.h tf-40s2/src/history.h --- tf-40s2.orig/src/history.h 1999-03-06 17:43:24.000000000 -0500 +++ tf-40s2/src/history.h 2008-05-24 12:41:27.000000000 -0400 @@ -12,6 +12,18 @@ # ifndef NO_HISTORY +typedef struct History { /* circular list of Alines, and logfile */ + struct Aline **alines; + int size; /* actual number of lines currently saved */ + int maxsize; /* maximum number of lines that can be saved */ + int first; /* position of first line in circular array */ + int last; /* position of last line in circular array */ + int index; /* current recall position */ + int total; /* total number of lines ever saved */ + TFILE *logfile; + CONST char *logname; +} History; + extern void NDECL(init_histories); extern struct History *FDECL(init_history,(struct History *hist, int maxsize)); extern void FDECL(free_history,(struct History *hist));