2005-10-31 Andrew Stubbs <andrew.stubbs@st.com>
authorAndrew Stubbs <andrew.stubbs@st.com>
Mon, 31 Oct 2005 19:11:35 +0000 (19:11 +0000)
committerAndrew Stubbs <andrew.stubbs@st.com>
Mon, 31 Oct 2005 19:11:35 +0000 (19:11 +0000)
* tui/tui-command.c (tui_dispatch_ctrl_char): Test output of
getenv() before using it.

gdb/ChangeLog
gdb/tui/tui-command.c

index de5d48c48ea3cab7a3a3bc1b4b5e03ec0da35ff1..87e270f09ba75ab2818470ab7d0803abc2b25b14 100644 (file)
@@ -1,3 +1,8 @@
+2005-10-31  Andrew Stubbs  <andrew.stubbs@st.com>
+
+       * tui/tui-command.c (tui_dispatch_ctrl_char): Test output of
+       getenv() before using it.
+
 2005-10-29  Mark Kettenis  <kettenis@gnu.org>
 
        * hppa-tdep.h (HPPA_INSN_SIZE): New define.
index 399ef85b8c552d99758ff660ce2a6e7ae9bbe478..7f3fc7599b29f1fb961e88a0f2a9ae792732489f 100644 (file)
@@ -68,33 +68,36 @@ tui_dispatch_ctrl_char (unsigned int ch)
          ** Seems like a bug in the curses library?
        */
       term = (char *) getenv ("TERM");
-      for (i = 0; (term && term[i]); i++)
-       term[i] = toupper (term[i]);
-      if ((strcmp (term, "XTERM") == 0) && key_is_start_sequence (ch))
+      if (term)
        {
-         unsigned int page_ch = 0;
-         unsigned int tmp_char;
-
-         tmp_char = 0;
-         while (!key_is_end_sequence (tmp_char))
+         for (i = 0; term[i]; i++)
+           term[i] = toupper (term[i]);
+         if ((strcmp (term, "XTERM") == 0) && key_is_start_sequence (ch))
            {
-             tmp_char = (int) wgetch (w);
-             if (tmp_char == ERR)
-               {
-                 return ch;
-               }
-             if (!tmp_char)
-               break;
-             if (tmp_char == 53)
-               page_ch = KEY_PPAGE;
-             else if (tmp_char == 54)
-               page_ch = KEY_NPAGE;
-             else
+             unsigned int page_ch = 0;
+             unsigned int tmp_char;
+
+             tmp_char = 0;
+             while (!key_is_end_sequence (tmp_char))
                {
-                 return 0;
+                 tmp_char = (int) wgetch (w);
+                 if (tmp_char == ERR)
+                   {
+                     return ch;
+                   }
+                 if (!tmp_char)
+                   break;
+                 if (tmp_char == 53)
+                   page_ch = KEY_PPAGE;
+                 else if (tmp_char == 54)
+                   page_ch = KEY_NPAGE;
+                 else
+                   {
+                     return 0;
+                   }
                }
+             ch_copy = page_ch;
            }
-         ch_copy = page_ch;
        }
 
       switch (ch_copy)