Line discipline module now uses dynamically allocated data. Also
[u/mdw/putty] / unix / uxucs.c
index 7d56b32..ff8f3a1 100644 (file)
@@ -4,6 +4,7 @@
 
 #include <time.h>
 #include "putty.h"
+#include "terminal.h"
 #include "misc.h"
 
 /*
  * are ISO8859-1.
  */
 
-void lpage_send(int codepage, char *buf, int len, int interactive)
+void lpage_send(void *ldisc, int codepage, char *buf, int len, int interactive)
 {
-    ldisc_send(buf, len, interactive);
+    ldisc_send(ldisc, buf, len, interactive);
 }
 
-void luni_send(wchar_t * widebuf, int len, int interactive)
+void luni_send(void *ldisc, wchar_t * widebuf, int len, int interactive)
 {
     static char *linebuffer = 0;
     static int linesize = 0;
-    int ratio = (in_utf)?6:1;
+    int ratio = (in_utf(term))?6:1;
     int i;
     char *p;
 
@@ -32,7 +33,7 @@ void luni_send(wchar_t * widebuf, int len, int interactive)
        linesize = len * ratio * 2;
     }
 
-    if (in_utf) {
+    if (in_utf(term)) {
        /* UTF is a simple algorithm */
        for (p = linebuffer, i = 0; i < len; i++) {
            wchar_t ch = widebuf[i];
@@ -78,7 +79,7 @@ void luni_send(wchar_t * widebuf, int len, int interactive)
        }
     }
     if (p > linebuffer)
-       ldisc_send(linebuffer, p - linebuffer, interactive);
+       ldisc_send(ldisc, linebuffer, p - linebuffer, interactive);
 }
 
 int is_dbcs_leadbyte(int codepage, char byte)
@@ -131,6 +132,6 @@ void init_ucs(void)
 
     for (i = 0; i < 256; i++) {
        unitab_line[i] = unitab_scoacs[i] = i;
-       unitab_xterm[i] = (i+1) & 0x1F;
+       unitab_xterm[i] = (i >= 0x5F && i < 0x7F) ? ((i+1) & 0x1F) : i;
     }
-}
\ No newline at end of file
+}