Skip to contentSkip to conversation

curses: fix garbling when chtype != long

PATCH Applied Devin J. Pohly 2 participants 2 messages Sep 7, 2011 – Sep 9, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 curses: fix garbling when chtype != long

From: "Devin J. Pohly" <[email protected]>

Qemu currently assumes that chtype is typedef'd to unsigned long, but this is not necessarily the case (ncurses, for instance, can configure this at build-time). This patch uses the predefined chtype if qemu is configured for curses support and falls back to unsigned long otherwise.

Fixes bug 568614.

---
 console.c |    2 ++
 console.h |    5 +++++
 2 files changed, 7 insertions(+), 0 deletions(-)
console.c +2 -0
index 500b3fb..5c7a93b 100644
@@ -343,6 +343,7 @@ static const uint32_t dmask4[4] = {
 
 static uint32_t color_table[2][8];
 
+#ifndef CONFIG_CURSES
 enum color_names {
     COLOR_BLACK   = 0,
     COLOR_RED     = 1,
@@ -353,6 +354,7 @@ enum color_names {
     COLOR_CYAN    = 6,
     COLOR_WHITE   = 7
 };
+#endif
 
 static const uint32_t color_table_rgb[2][8] = {
     {   /* dark */
console.h +5 -0
index 67d1373..9c1487e 100644
@@ -328,7 +328,12 @@ static inline int ds_get_bytes_per_pixel(DisplayState *ds)
     return ds->surface->pf.bytes_per_pixel;
 }
 
+#ifdef CONFIG_CURSES
+#include <curses.h>
+typedef chtype console_ch_t;
+#else
 typedef unsigned long console_ch_t;
+#endif
 static inline void console_write_ch(console_ch_t *dest, uint32_t ch)
 {
     if (!(ch & 0xff))
Signature · 1 line
1.7.6.1
#1 lore raw
Quoted 10 lines · Devin J. Pohly

From: "Devin J. Pohly"<[email protected]>

Qemu currently assumes that chtype is typedef'd to unsigned long, but this is not necessarily the case (ncurses, for instance, can configure this at build-time). This patch uses the predefined chtype if qemu is configured for curses support and falls back to unsigned long otherwise.

Fixes bug 568614.

Applied. Thanks.

Regards,

Anthony Liguori

Quoted 42 lines
---
  console.c |    2 ++
  console.h |    5 +++++
  2 files changed, 7 insertions(+), 0 deletions(-)
console.c +2 -0
index 500b3fb..5c7a93b 100644
@@ -343,6 +343,7 @@ static const uint32_t dmask4[4] = {
 
  static uint32_t color_table[2][8];
 
+#ifndef CONFIG_CURSES
  enum color_names {
      COLOR_BLACK   = 0,
      COLOR_RED     = 1,
@@ -353,6 +354,7 @@ enum color_names {
      COLOR_CYAN    = 6,
      COLOR_WHITE   = 7
  };
+#endif
 
  static const uint32_t color_table_rgb[2][8] = {
      {   /* dark */
console.h +5 -0
index 67d1373..9c1487e 100644
@@ -328,7 +328,12 @@ static inline int ds_get_bytes_per_pixel(DisplayState *ds)
      return ds->surface->pf.bytes_per_pixel;
  }
 
+#ifdef CONFIG_CURSES
+#include<curses.h>
+typedef chtype console_ch_t;
+#else
  typedef unsigned long console_ch_t;
+#endif
  static inline void console_write_ch(console_ch_t *dest, uint32_t ch)
  {
      if (!(ch&  0xff))