OSDN Git Service

change xputc2 to take strings instead of two chars
authorSHIRAKATA Kentaro <argrath@ub32.org>
Fri, 27 Aug 2021 20:54:08 +0000 (05:54 +0900)
committerSHIRAKATA Kentaro <argrath@ub32.org>
Sat, 9 Oct 2021 20:28:03 +0000 (05:28 +0900)
include/extern.h
include/wintty.h
japanese/jlib.c
sys/winnt/nttty.c
sys/winnt/stubs.c

index 889b79e..a27aaaa 100644 (file)
@@ -3025,8 +3025,8 @@ E const char *FDECL(str2ic, (const char *));
 #ifdef SJIS_FILESYSTEM
 E const char *FDECL(ic2str, (const char *));
 #endif
-E int FDECL(jbuffer, (unsigned int, unsigned int *, void (*)(unsigned int), void (*)(unsigned int, unsigned int)));
-E int FDECL(cbuffer, (unsigned int, unsigned int *, void (*)(unsigned int), void (*)(unsigned int, unsigned int)));
+E int FDECL(jbuffer, (unsigned int, unsigned int *, void (*)(unsigned int), void (*)(unsigned char *)));
+E int FDECL(cbuffer, (unsigned int, unsigned int *, void (*)(unsigned int), void (*)(unsigned char *)));
 E void FDECL(cputchar,(int));
 E void FDECL(jputchar,(int));
 E void FDECL(jputs,(const char *));
index 868c477..110bd15 100644 (file)
@@ -116,7 +116,7 @@ E void NDECL(tty_shutdown);
 #endif
 E int FDECL(xputc, (int));
 # if 1 /*JP*/
-E void FDECL(xputc2, (int, int));
+E void FDECL(xputc2, (unsigned char *));
 # endif
 E void FDECL(xputs, (const char *));
 #if defined(SCREEN_VGA) || defined(SCREEN_8514)
index 816b2cf..0777da2 100644 (file)
@@ -11,7 +11,7 @@
 #endif
 
 int xputc(CHAR_P);
-int xputc2(int, int);
+int xputc2(unsigned char *);
 
 
 #define EUC     0
@@ -304,13 +304,14 @@ tty_cputc(unsigned int c)
 
 /* print out 2 bytes character to tty (no conversion) */
 static void
-tty_cputc2(unsigned int c, unsigned int c2)
+tty_cputc2(unsigned char *str)
 {
 #if defined(NO_TERMS) && (defined(MSDOS) || defined(WIN32CON))
-    xputc2(c, c2);
+    xputc2(str);
 #else
-    putchar(c);
-    putchar(c2);
+    while(*str){
+      putchar(*str++);
+    }
 #endif
 } 
 
@@ -327,13 +328,14 @@ tty_jputc(unsigned int c)
 
 /* print out 2 bytes character to tty (IC->output_kcode) */
 static void
-tty_jputc2(unsigned int c, unsigned int c2)
+tty_jputc2(unsigned char *str)
 {
 #if defined(NO_TERMS) && (defined(MSDOS) || defined(WIN32CON))
-    xputc2(c, c2);
+    xputc2(str);
 #else
-    putchar(c);
-    putchar(c2);
+    while(*str){
+      putchar(*str++);
+    }
 #endif
 }
 
@@ -346,7 +348,7 @@ jbuffer(
      unsigned int c,
      unsigned int *buf,
      void (*f1)(unsigned int),
-     void (*f2)(unsigned int, unsigned int))
+     void (*f2)(unsigned char *))
 {
     static unsigned int ibuf[2];
     unsigned int c1, c2;
@@ -354,6 +356,7 @@ jbuffer(
     unsigned char uc[2];
     unsigned char *p;
 #endif
+    unsigned char f2buf[16];
 
     if(!buf) buf = ibuf;
     if(!f1) f1 = tty_jputc;
@@ -372,7 +375,12 @@ jbuffer(
 
         if(IC == output_kcode)
 #ifdef POSIX_ICONV
-            f2(c1, c2);
+        {
+            f2buf[0] = c1;
+            f2buf[1] = c2;
+            f2buf[2] = '\0';
+            f2(f2buf);
+        }
         else if (output_dsc) {
             char buf_in[2], buf_out[16];
             char *src = buf_in, *dst=buf_out;
@@ -381,7 +389,10 @@ jbuffer(
             *(buf_in + 1) = c2;
             if (iconv(output_dsc, &src,
                       &src_len, &dst, &dst_len) == (size_t)-1) {
-                f2(c1, c2);
+                f2buf[0] = c1;
+                f2buf[1] = c2;
+                f2buf[2] = '\0';
+                f2(f2buf);
             } else {
                 *dst = '\0';
                 dst = buf_out;
@@ -416,7 +427,10 @@ jbuffer(
                 break;
             }
         }
-        f2(c1, c2);
+        f2buf[0] = c1;
+        f2buf[1] = c2;
+        f2buf[2] = '\0';
+        f2(f2buf);
 #endif
         buf[0] = 0;
         return 2;
@@ -437,9 +451,10 @@ cbuffer(
      unsigned int c,
      unsigned int *buf,
      void (*f1)(unsigned int),
-     void (*f2)(unsigned int, unsigned int))
+     void (*f2)(unsigned char *))
 {
     static unsigned int ibuf[2];
+    unsigned char f2buf[16];
 
     if(!buf) buf = ibuf;
     if(!f1) f1 = tty_cputc;
@@ -460,7 +475,10 @@ cbuffer(
         return 0;
     }
     else if(buf[0]){
-        f2(buf[1], c);
+        f2buf[0] = buf[1];
+        f2buf[1] = c;
+        f2buf[2] = '\0';
+        f2(f2buf);
         buf[0] = 0;
         return 2;
     }
index 5ebdef4..3da2b6a 100644 (file)
@@ -82,7 +82,7 @@ cell_t undefined_cell = { CONSOLE_UNDEFINED_CHARACTER,
 static BOOL FDECL(CtrlHandler, (DWORD));
 static void FDECL(xputc_core, (char));
 #if 1 /*JP*/
-static void FDECL(xputc2_core, (unsigned int, unsigned int));
+static void FDECL(xputc2_core, (unsigned char *));
 #endif
 void FDECL(cmov, (int, int));
 void FDECL(nocmov, (int, int));
@@ -617,16 +617,14 @@ int ch;
 
 #if 1 /*JP*/
 void
-xputc2_core(ch1, ch2)
-unsigned int ch1;
-unsigned int ch2;
+xputc2_core(str)
+unsigned char *str;
 {
     nhassert(console.cursor.X >= 0 && console.cursor.X < console.width);
     nhassert(console.cursor.Y >= 0 && console.cursor.Y < console.height);
 
     boolean inverse = FALSE;
     cell_t cell;
-    unsigned char buf[2];
     wchar_t wbuf[1];
 
     /* xputc_core()\82©\82ç\82Ì\83R\83s\81[ */
@@ -657,13 +655,11 @@ unsigned int ch2;
         }
     }
 
-    buf[0] = (unsigned char)(ch1);
-    buf[1] = (unsigned char)(ch2);
     int ret = MultiByteToWideChar(
         CP_ACP,
         MB_PRECOMPOSED,
-        buf,
-        2,
+        str,
+        strlen(str),
         wbuf,
         1);
 
@@ -692,17 +688,16 @@ unsigned int ch2;
 }
 
 void
-xputc2(ch1, ch2)
-int ch1;
-int ch2;
+xputc2(str)
+unsigned char *str;
 {
     /* wintty.c \82Å\82Í 1 \83o\83C\83g\96\88\82É curx \82ð\89Á\8eZ\82·\82é\82ª\81A\82±\82±\82Í
-       \83o\83C\83g\82½\82Ü\82Á\82Ä\82©\82ç\8cÄ\82Ñ\8fo\82³\82ê\82é\82Ì\82Å\81A\95\8e\9a\95ª\90æ\82É\90i\82ñ\82Å
-      \82µ\82Ü\82Á\82Ä\82¢\82é\81B\8f]\82Á\82Ä 1 \82ð\88ø\82­\81B */
-    console.cursor.X = ttyDisplay->curx - 1;
+       \83o\83C\83g\82½\82Ü\82Á\82Ä\82©\82ç\8cÄ\82Ñ\8fo\82³\82ê\82é\82Ì\82Å\81An-\95\8e\9a\95ª\90æ\82É\90i\82ñ\82Å
+      \82µ\82Ü\82Á\82Ä\82¢\82é\81B\8f]\82Á\82Ä n-\82ð\88ø\82­\81B */
+    console.cursor.X = ttyDisplay->curx - (strlen(str) - 1);
     console.cursor.Y = ttyDisplay->cury;
 
-    xputc2_core(ch1, ch2);
+    xputc2_core(str);
 }
 #endif
 
index 9c97276..2ee65bf 100644 (file)
@@ -91,9 +91,8 @@ int ch;
 
 #if 1 /*JP*/
 void
-xputc2(ch1, ch2)
-int ch1;
-int ch2;
+xputc2(str)
+unsigned char *str;
 {
     return;
 }