OSDN Git Service

* dcrt0.cc: Remove local variable alternate_charset_active.
authorcorinna <corinna>
Thu, 16 Oct 2003 14:08:26 +0000 (14:08 +0000)
committercorinna <corinna>
Thu, 16 Oct 2003 14:08:26 +0000 (14:08 +0000)
* fhandler.h: Add variable alternate_charset_active, functions
str_to_con, con_to_str to dev_console structure.
* fhandler_console.cc (con_to_str): Move function into dev_console
class.
(str_to_con): Ditto.
(fhandler_console::read): Call con_to_str on dev_state.
(fhandler_console::write_normal): Call str_to_con on dev_state.
(fhandler_console::char_command): Change active_charset_active
assignment to be on dev_state.
* winsup.h: Remove global external variable alternate_charset_active.

winsup/cygwin/ChangeLog
winsup/cygwin/dcrt0.cc
winsup/cygwin/fhandler.h
winsup/cygwin/fhandler_console.cc
winsup/cygwin/winsup.h

index 84cdb04..d455a08 100644 (file)
@@ -1,3 +1,17 @@
+2003-10-14  Micha Nelissen  <M.Nelissen@student.tue.nl>
+
+       * dcrt0.cc: Remove local variable alternate_charset_active.
+       * fhandler.h: Add variable alternate_charset_active, functions
+       str_to_con, con_to_str to dev_console structure.
+       * fhandler_console.cc (con_to_str): Move function into dev_console
+       class.
+       (str_to_con): Ditto.
+       (fhandler_console::read): Call con_to_str on dev_state.
+       (fhandler_console::write_normal): Call str_to_con on dev_state.
+       (fhandler_console::char_command): Change active_charset_active
+       assignment to be on dev_state.
+       * winsup.h: Remove global external variable alternate_charset_active.
+
 2003-10-13  Micha Nelissen  <M.Nelissen@student.tue.nl>
 
        * fhandler_console.cc (char_command): Add escape sequence for codepage
index e03c3af..b862ee1 100644 (file)
@@ -57,7 +57,6 @@ bool display_title;
 bool strip_title_path;
 bool allow_glob = TRUE;
 codepage_type current_codepage = ansi_cp;
-bool alternate_charset_active;
 
 int cygwin_finished_initializing;
 
index 00ce3a3..d88bb1b 100644 (file)
@@ -752,6 +752,7 @@ class dev_console
   int nargs_;
   unsigned rarg;
   bool saw_question_mark;
+  bool alternate_charset_active;
 
   char my_title_buf [TITLESIZE + 1];
 
@@ -788,6 +789,10 @@ class dev_console
   bool insert_mode;
   bool use_mouse;
   bool raw_win32_keyboard_mode;
+
+  BOOL con_to_str (char *d, const char *s, DWORD sz);
+  BOOL str_to_con (char *d, const char *s, DWORD sz);
+
   friend class fhandler_console;
 };
 
index 24c59c7..7386d9c 100644 (file)
@@ -54,27 +54,6 @@ cp_convert (UINT destcp, char *dest, UINT srccp, const char *src, DWORD size)
   return TRUE;
 }
 
-/* The results of GetConsoleCP() and GetConsoleOutputCP() cannot be
-   cached, because a program or the user can change these values at
-   any time. */
-inline BOOL
-con_to_str (char *d, const char *s, DWORD sz)
-{
-  return cp_convert (get_cp (), d, GetConsoleCP (), s, sz);
-}
-
-inline BOOL
-str_to_con (char *d, const char *s, DWORD sz)
-{
-  if (alternate_charset_active)
-    {
-      /* no translation when alternate charset is active */
-      memcpy(d, s, sz);
-      return TRUE;
-    }
-  return cp_convert (GetConsoleOutputCP (), d, get_cp (), s, sz);
-}
-
 /*
  * Scroll the screen context.
  * x1, y1 - ul corner
@@ -187,6 +166,27 @@ set_console_state_for_spawn ()
   return 1;
 }
 
+/* The results of GetConsoleCP() and GetConsoleOutputCP() cannot be
+   cached, because a program or the user can change these values at
+   any time. */
+inline BOOL
+dev_console::con_to_str (char *d, const char *s, DWORD sz)
+{
+  return cp_convert (get_cp (), d, GetConsoleCP (), s, sz);
+}
+
+inline BOOL
+dev_console::str_to_con (char *d, const char *s, DWORD sz)
+{
+  if (alternate_charset_active)
+    {
+      /* no translation when alternate charset is active */
+      memcpy(d, s, sz);
+      return TRUE;
+    }
+  return cp_convert (GetConsoleOutputCP (), d, get_cp (), s, sz);
+}
+
 BOOL
 fhandler_console::set_raw_win32_keyboard_mode (BOOL new_mode)
 {
@@ -375,7 +375,7 @@ fhandler_console::read (void *pv, size_t& buflen)
              /* Need this check since US code page seems to have a bug when
                 converting a CTRL-U. */
              if ((unsigned char) ich > 0x7f)
-               con_to_str (tmp + 1, tmp + 1, 1);
+               dev_state->con_to_str (tmp + 1, tmp + 1, 1);
              /* Determine if the keystroke is modified by META.  The tricky
                 part is to distinguish whether the right Alt key should be
                 recognized as Alt, or as AltGr. */
@@ -1118,10 +1118,10 @@ fhandler_console::char_command (char c)
               dev_state->intensity = INTENSITY_DIM;
               break;
              case 10:   /* end alternate charset */
-               alternate_charset_active = FALSE;
+               dev_state->alternate_charset_active = FALSE;
               break;
              case 11:   /* start alternate charset */
-               alternate_charset_active = TRUE;
+               dev_state->alternate_charset_active = TRUE;
               break;
             case 24:
               dev_state->underline = FALSE;
@@ -1434,7 +1434,7 @@ fhandler_console::write_normal (const unsigned char *src,
          DWORD buf_len;
          char buf[CONVERT_LIMIT];
          done = buf_len = min (sizeof (buf), len);
-         if (!str_to_con (buf, (const char *) src, buf_len))
+         if (!dev_state->str_to_con (buf, (const char *) src, buf_len))
            {
              debug_printf ("conversion error, handle %p",
                            get_output_handle ());
index a58e356..745519e 100644 (file)
@@ -90,7 +90,6 @@ extern "C" DWORD WINAPI GetLastError (void);
 
 enum codepage_type {ansi_cp, oem_cp};
 extern codepage_type current_codepage;
-extern bool alternate_charset_active;
 
 UINT get_cp ();