kconfig/lxdialog/yesno.c
author "Benoît Thébaudeau" <benoit.thebaudeau@advansee.com>
Wed Dec 14 16:55:22 2011 +0100 (2011-12-14)
branch1.13
changeset 2848 1ff89596dab0
parent 1 eeea35fbf182
permissions -rw-r--r--
libc/eglibc: fix localedef 2.14 build

The localedef of eglibc 2.14 requires NOT_IN_libc to be defined in order to
compile intl/l10nflist.c.

This is because localedef is built separately from eglibc and uses some parts of
eglibc that don't compile in standalone without this preprocessor definition.

This fixes the following error:

[ALL ] gcc -g -O2 -DNO_SYSCONF -DNO_UNCOMPRESS
-DLOCALE_PATH='"/usr/lib/locale:/usr/share/i18n"'
-DLOCALEDIR='"/usr/lib/locale"' -DLOCALE_ALIAS_PATH='"/usr/share/locale"'
-DCHARMAP_PATH='"/usr/share/i18n/charmaps"'
-DREPERTOIREMAP_PATH='"/usr/share/i18n/repertoiremaps"'
-DLOCSRCDIR='"/usr/share/i18n/locales"' -Iglibc/locale/programs -Iglibc/locale
-I/<snip>/.build/src/eglibc-localedef-2_14/include
-I/<snip>/.build/src/eglibc-localedef-2_14 -I.
-include /<snip>/.build/src/eglibc-localedef-2_14/include/always.h -Wall
-Wno-format -c -o locarchive.o glibc/locale/programs/locarchive.c
[ALL ] glibc/locale/programs/locarchive.c: In function 'enlarge_archive':
[ALL ] glibc/locale/programs/locarchive.c:303:21: warning: variable
'oldlocrectab' set but not used [-Wunused-but-set-variable]
[ALL ] In file included from glibc/locale/programs/locarchive.c:651:0:
[ALL ] glibc/locale/programs/../../intl/l10nflist.c: In function
'_nl_normalize_codeset':
[ERROR] glibc/locale/programs/../../intl/l10nflist.c:342:9: error:
'_nl_C_locobj_ptr' undeclared (first use in this function)
[ALL ] glibc/locale/programs/../../intl/l10nflist.c:342:9: note: each
undeclared identifier is reported only once for each function it appears in
[ALL ] glibc/locale/programs/locarchive.c: In function
'add_locales_to_archive':
[ALL ] glibc/locale/programs/locarchive.c:1450:7: warning: passing argument
1 of '__xpg_basename' discards 'const' qualifier from pointer target type
[enabled by default]
[ALL ] /usr/include/libgen.h:35:14: note: expected 'char *' but argument is
of type 'const char *'
[ERROR] make[1]: *** [locarchive.o] Error 1

Signed-off-by: "Benoît Thébaudeau" <benoit.thebaudeau@advansee.com>
(transplanted from 4cd9134739b594451794cf61a6e1b137422cdafd)
     1 /*
     2  *  yesno.c -- implements the yes/no box
     3  *
     4  *  ORIGINAL AUTHOR: Savio Lam (lam836@cs.cuhk.hk)
     5  *  MODIFIED FOR LINUX KERNEL CONFIG BY: William Roadcap (roadcap@cfw.com)
     6  *
     7  *  This program is free software; you can redistribute it and/or
     8  *  modify it under the terms of the GNU General Public License
     9  *  as published by the Free Software Foundation; either version 2
    10  *  of the License, or (at your option) any later version.
    11  *
    12  *  This program is distributed in the hope that it will be useful,
    13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    15  *  GNU General Public License for more details.
    16  *
    17  *  You should have received a copy of the GNU General Public License
    18  *  along with this program; if not, write to the Free Software
    19  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    20  */
    21 
    22 #include "dialog.h"
    23 
    24 /*
    25  * Display termination buttons
    26  */
    27 static void print_buttons(WINDOW * dialog, int height, int width, int selected)
    28 {
    29 	int x = width / 2 - 10;
    30 	int y = height - 2;
    31 
    32 	print_button(dialog, gettext(" Yes "), y, x, selected == 0);
    33 	print_button(dialog, gettext("  No  "), y, x + 13, selected == 1);
    34 
    35 	wmove(dialog, y, x + 1 + 13 * selected);
    36 	wrefresh(dialog);
    37 }
    38 
    39 /*
    40  * Display a dialog box with two buttons - Yes and No
    41  */
    42 int dialog_yesno(const char *title, const char *prompt, int height, int width)
    43 {
    44 	int i, x, y, key = 0, button = 0;
    45 	WINDOW *dialog;
    46 
    47 do_resize:
    48 	if (getmaxy(stdscr) < (height + 4))
    49 		return -ERRDISPLAYTOOSMALL;
    50 	if (getmaxx(stdscr) < (width + 4))
    51 		return -ERRDISPLAYTOOSMALL;
    52 
    53 	/* center dialog box on screen */
    54 	x = (COLS - width) / 2;
    55 	y = (LINES - height) / 2;
    56 
    57 	draw_shadow(stdscr, y, x, height, width);
    58 
    59 	dialog = newwin(height, width, y, x);
    60 	keypad(dialog, TRUE);
    61 
    62 	draw_box(dialog, 0, 0, height, width,
    63 		 dlg.dialog.atr, dlg.border.atr);
    64 	wattrset(dialog, dlg.border.atr);
    65 	mvwaddch(dialog, height - 3, 0, ACS_LTEE);
    66 	for (i = 0; i < width - 2; i++)
    67 		waddch(dialog, ACS_HLINE);
    68 	wattrset(dialog, dlg.dialog.atr);
    69 	waddch(dialog, ACS_RTEE);
    70 
    71 	print_title(dialog, title, width);
    72 
    73 	wattrset(dialog, dlg.dialog.atr);
    74 	print_autowrap(dialog, prompt, width - 2, 1, 3);
    75 
    76 	print_buttons(dialog, height, width, 0);
    77 
    78 	while (key != KEY_ESC) {
    79 		key = wgetch(dialog);
    80 		switch (key) {
    81 		case 'Y':
    82 		case 'y':
    83 			delwin(dialog);
    84 			return 0;
    85 		case 'N':
    86 		case 'n':
    87 			delwin(dialog);
    88 			return 1;
    89 
    90 		case TAB:
    91 		case KEY_LEFT:
    92 		case KEY_RIGHT:
    93 			button = ((key == KEY_LEFT ? --button : ++button) < 0) ? 1 : (button > 1 ? 0 : button);
    94 
    95 			print_buttons(dialog, height, width, button);
    96 			wrefresh(dialog);
    97 			break;
    98 		case ' ':
    99 		case '\n':
   100 			delwin(dialog);
   101 			return button;
   102 		case KEY_ESC:
   103 			key = on_key_esc(dialog);
   104 			break;
   105 		case KEY_RESIZE:
   106 			delwin(dialog);
   107 			on_key_resize();
   108 			goto do_resize;
   109 		}
   110 	}
   111 
   112 	delwin(dialog);
   113 	return key;		/* ESC pressed */
   114 }