Browse Source

Bugfix: Avoid using wide curses symbols/macros when USE_UNICODE is not defined

Luke Dashjr 12 years ago
parent
commit
d757ee5d18
1 changed files with 18 additions and 0 deletions
  1. 18 0
      miner.c

+ 18 - 0
miner.c

@@ -2809,7 +2809,11 @@ static
 void bfg_waddstr(WINDOW *win, const char *s)
 void bfg_waddstr(WINDOW *win, const char *s)
 {
 {
 	const char *p = s;
 	const char *p = s;
+#ifdef USE_UNICODE
 	wchar_t buf[2] = {0, 0};
 	wchar_t buf[2] = {0, 0};
+#else
+	char buf[1];
+#endif
 	
 	
 #define PREP_ADDCH  do {  \
 #define PREP_ADDCH  do {  \
 	if (p != s)  \
 	if (p != s)  \
@@ -2835,12 +2839,14 @@ def:
 				PREP_ADDCH;
 				PREP_ADDCH;
 				wattron(win, attr_bad);
 				wattron(win, attr_bad);
 				goto next;
 				goto next;
+#ifdef USE_UNICODE
 			case '|':
 			case '|':
 				if (!use_unicode)
 				if (!use_unicode)
 					goto def;
 					goto def;
 				PREP_ADDCH;
 				PREP_ADDCH;
 				wadd_wch(win, WACS_VLINE);
 				wadd_wch(win, WACS_VLINE);
 				goto next;
 				goto next;
+#endif
 			case '\xc1':
 			case '\xc1':
 			case '\xc4':
 			case '\xc4':
 				if (!use_unicode)
 				if (!use_unicode)
@@ -2848,14 +2854,20 @@ def:
 					buf[0] = '-';
 					buf[0] = '-';
 					break;
 					break;
 				}
 				}
+#ifdef USE_UNICODE
 				PREP_ADDCH;
 				PREP_ADDCH;
 				wadd_wch(win, (p[-1] == '\xc4') ? WACS_HLINE : WACS_BTEE);
 				wadd_wch(win, (p[-1] == '\xc4') ? WACS_HLINE : WACS_BTEE);
 				goto next;
 				goto next;
 			case '\xb0':  // Degrees symbol
 			case '\xb0':  // Degrees symbol
 				buf[0] = ((unsigned char *)p)[0];
 				buf[0] = ((unsigned char *)p)[0];
+#endif
 		}
 		}
 		PREP_ADDCH;
 		PREP_ADDCH;
+#ifdef USE_UNICODE
 		waddwstr(win, buf);
 		waddwstr(win, buf);
+#else
+		waddch(win, buf[0]);
+#endif
 	}
 	}
 done:
 done:
 	PREP_ADDCH;
 	PREP_ADDCH;
@@ -2866,9 +2878,11 @@ done:
 static inline
 static inline
 void bfg_hline(WINDOW *win, int y)
 void bfg_hline(WINDOW *win, int y)
 {
 {
+#ifdef USE_UNICODE
 	if (use_unicode)
 	if (use_unicode)
 		mvwhline_set(win, y, 0, WACS_HLINE, 80);
 		mvwhline_set(win, y, 0, WACS_HLINE, 80);
 	else
 	else
+#endif
 		mvwhline(win, y, 0, '-', 80);
 		mvwhline(win, y, 0, '-', 80);
 }
 }
 
 
@@ -2943,6 +2957,7 @@ static void curses_print_status(void)
 	logdiv = statusy - 1;
 	logdiv = statusy - 1;
 	bfg_hline(statuswin, 6);
 	bfg_hline(statuswin, 6);
 	bfg_hline(statuswin, logdiv);
 	bfg_hline(statuswin, logdiv);
+#ifdef USE_UNICODE
 	if (use_unicode)
 	if (use_unicode)
 	{
 	{
 		int offset = 8 /* device */ + 5 /* temperature */ + 1 /* padding space */;
 		int offset = 8 /* device */ + 5 /* temperature */ + 1 /* padding space */;
@@ -2956,6 +2971,7 @@ static void curses_print_status(void)
 		mvwadd_wch(statuswin, 6, offset, WACS_PLUS);
 		mvwadd_wch(statuswin, 6, offset, WACS_PLUS);
 		mvwadd_wch(statuswin, logdiv, offset, WACS_BTEE);
 		mvwadd_wch(statuswin, logdiv, offset, WACS_BTEE);
 	}
 	}
+#endif
 	
 	
 	wattron(statuswin, menu_attr);
 	wattron(statuswin, menu_attr);
 	mvwprintw(statuswin, 1, 0, " [M]anage devices [P]ool management [S]ettings [D]isplay options  [H]elp [Q]uit ");
 	mvwprintw(statuswin, 1, 0, " [M]anage devices [P]ool management [S]ettings [D]isplay options  [H]elp [Q]uit ");
@@ -9082,12 +9098,14 @@ void enable_curses(void) {
 		return;
 		return;
 	}
 	}
 
 
+#ifdef USE_UNICODE
 	if (use_unicode)
 	if (use_unicode)
 	{
 	{
 		setlocale(LC_CTYPE, "");
 		setlocale(LC_CTYPE, "");
 		if (iswprint(0xb0))
 		if (iswprint(0xb0))
 			have_unicode_degrees = true;
 			have_unicode_degrees = true;
 	}
 	}
+#endif
 	mainwin = initscr();
 	mainwin = initscr();
 	start_color();
 	start_color();
 	if (has_colors() && ERR != init_pair(1, COLOR_WHITE, COLOR_BLUE))
 	if (has_colors() && ERR != init_pair(1, COLOR_WHITE, COLOR_BLUE))