1. Ilya Arkhipov
  2. d4p

Commits

Ilya Arkhipov  committed 859e9d8

Consistently use C99 bool, true and false [tijl@]

  • Participants
  • Parent commits f2697ee
  • Branches default

Comments (0)

Files changed (3)

File dialog4ports.c

View file
  • Ignore whitespace
 #include <errno.h>
 #include <dialog.h>
 #include <dlg_keys.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stringlist.h>
 /* add item to items */
 static void
 add_item(dialog_mixedlist **items, char const *name, char const *text,
-		int state, int type, int grp)
+		bool state, int type, int grp)
 {
 
 	if ((list_no + 1 > items_sz) || *items == NULL) {
 static bool
 is_enable(char *name)
 {
-	if (sl_find(enable_items, name) != NULL)
-		return (TRUE);
-
-	return (FALSE);
+	return (sl_find(enable_items, name) != NULL);
 }
 
 static void
 			if (token[0] == '\0')
 				continue;
 			if (list_no != 0)
-				add_item(items, get_desc(token, token), "", 0, ITEM_SEPARATE,
-						group);
+				add_item(items, get_desc(token, token), "", false,
+						ITEM_SEPARATE, group);
 
 			snprintf(buf, sizeof(buf), "%s_%s", env_name, token);
 			env = getenv(buf);

File mixedlist.c

View file
  • Ignore whitespace
 
 #include <dialog.h>
 #include <dlg_keys.h>
+#include <stdbool.h>
 
 #include "mixedlist.h"
 
 	int result = DLG_EXIT_ERROR;
 
 	if (!dialog_vars.in_helpfile && file != 0 && *file != '\0') {
-		dialog_vars.in_helpfile = TRUE;
+		dialog_vars.in_helpfile = true;
 		result = dialog_textbox(title, file, height, width);
-		dialog_vars.in_helpfile = FALSE;
+		dialog_vars.in_helpfile = false;
 	}
 	return (result);
 }
 print_item(WINDOW *win,
 		dialog_mixedlist *items,
 		int choice,
-		int selected)
+		bool selected)
 {
 	chtype save = dlg_get_attrs(win);
 	int i, namelen, slsize;
 	int old_height = height;
 	int old_width = width;
 #endif
-	int i, j, key2, found, x, y, cur_x, cur_y, box_x, box_y;
+	int i, j, key2, x, y, cur_x, cur_y, box_x, box_y;
 	int key = 0, fkey;
 	int button = dialog_state.visit_items ? -1 : dlg_defaultno_button();
 	int choice = d4p_default_mixlistitem(items);
 	WINDOW *list;
 	char *prompt = dlg_strclone(cprompt);
 	const char **buttons = dlg_ok_labels();
-
+	bool found;
 
 	dlg_does_output();
 	dlg_tab_correct_str(prompt);
 	box_x = (width - list_width) / 2 - 1;
 
 	if (dialog_vars.help_file != NULL) {
-		dialog_vars.item_help = TRUE;
+		dialog_vars.item_help = true;
 		dlg_item_help("Detailed help is available hit F1 or ^E to view it");
 	}
 
 			box_x, box_y,
 			scrollamt, max_choice, item_no, use_height);
 
-	dlg_draw_buttons(dialog, height - 2, 0, buttons, button, FALSE, width);
+	dlg_draw_buttons(dialog, height - 2, 0, buttons, button, false, width);
 
 	while (result == DLG_EXIT_UNKNOWN) {
 		if (button < 0)		/* --visit-items */
 				/* De-highlight current item */
 				print_item(list,
 						&items[scrollamt + choice],
-						choice, FALSE);
+						choice, false);
 				/* Highlight new item */
 				choice = (key - KEY_MAX);
 				print_item(list,
 						&items[scrollamt + choice],
-						choice, TRUE);
+						choice, true);
 				(void) wnoutrefresh(list);
 				(void) wmove(dialog, cur_y, cur_x);
 
 				beep();
 				continue;
 			}
-			fkey = FALSE;
+			fkey = 0;
 		} else if (was_mouse && key >= KEY_MIN) {
 			key = dlg_lookup_key(dialog, key, &fkey);
 		}
 				break;
 			case CTRL_E:
 			case F1:
-				dialog_state.use_shadow = FALSE;
+				dialog_state.use_shadow = false;
 				d4p_helpwindow(" HELP ", dialog_vars.help_file, 0, 0);
-				dialog_state.use_shadow = TRUE;
+				dialog_state.use_shadow = true;
 				goto retry;
 				break;
 		}
 				items[current].state = next;
 				print_item(list,
 						&items[scrollamt + choice],
-						choice, TRUE);
+						choice, true);
 			} else if (items[current].type == ITEM_RADIO) {		/* radiolist */
 				for (i = 0; i < item_no; i++) {
 					if (i != current && items[i].group == items[current].group)
 					items[current].state = 0;
 					print_item(list,
 							&items[current],
-							choice, TRUE);
+							choice, true);
 				} else {
 					items[current].state = 1;
 					for (i = 0; i < max_choice; i++) {
 		 * list.  If there is more than one match, we will cycle through
 		 * each one as the same key is pressed repeatedly.
 		 */
-		found = FALSE;
+		found = false;
 		if (!fkey) {
 			if (button < 0 || !dialog_state.visit_items) {
 				for (j = scrollamt + choice + 1; j < item_no; j++) {
 					if (dlg_match_char(dlg_last_getc(), items[j].name) &&
 						items[j].type != ITEM_SEPARATE ) {
-							found = TRUE;
+							found = true;
 							i = j - scrollamt;
 							break;
 					}
 					for (j = 0; j <= scrollamt + choice; j++) {
 						if (dlg_match_char(dlg_last_getc(), items[j].name) &&
 							items[j].type != ITEM_SEPARATE) {
-								found = TRUE;
+								found = true;
 								i = j - scrollamt;
 								break;
 						}
 				&& (key <= '9')
 				&& (key > '0')
 				&& (key - '1' < max_choice)) {
-			found = TRUE;
+			found = true;
 			i = key - '1';
 		}
 
 		if (!found) {
 			if (fkey) {
-				found = TRUE;
+				found = true;
 				switch (key) {
 					case DLGK_ITEM_FIRST:
 						i = -scrollamt;
 							continue;
 						break;
 					default:
-						found = FALSE;
+						found = false;
 						break;
 				}
 			}
 							/* De-highlight current first item */
 							print_item(list,
 									&items[scrollamt],
-									0, FALSE);
-							scrollok(list, TRUE);
+									0, false);
+							scrollok(list, true);
 							wscrl(list, -1);
-							scrollok(list, FALSE);
+							scrollok(list, false);
 						}
 						scrollamt--;
 						print_item(list,
 								&items[scrollamt],
-								0, TRUE);
+								0, true);
 					} else if (i == max_choice) {
 						if (use_height > 1) {
 							/* De-highlight current last item before
 							 */
 							print_item(list,
 									&items[scrollamt + max_choice - 1],
-									max_choice - 1, FALSE);
-							scrollok(list, TRUE);
+									max_choice - 1, false);
+							scrollok(list, true);
 							wscrl(list, 1);
-							scrollok(list, FALSE);
+							scrollok(list, false);
 						}
 						scrollamt++;
 						print_item(list,
 								&items[scrollamt + max_choice - 1],
-								max_choice - 1, TRUE);
+								max_choice - 1, true);
 					} else
 #endif
 					{
 					/* De-highlight current item */
 					print_item(list,
 							&items[scrollamt + choice],
-							choice, FALSE);
+							choice, false);
 					/* Highlight new item */
 					choice = i;
 					print_item(list,
 							&items[scrollamt + choice],
-							choice, TRUE);
+							choice, true);
 					(void) wnoutrefresh(list);
 					d4p_print_arrows(dialog,
 							box_x, box_y,
 				case DLGK_FIELD_PREV:
 					button = dlg_prev_button(buttons, button);
 					dlg_draw_buttons(dialog, height - 2, 0, buttons, button,
-							FALSE, width);
+							0, width);
 					break;
 				case DLGK_FIELD_NEXT:
 					button = dlg_next_button(buttons, button);
 					dlg_draw_buttons(dialog, height - 2, 0, buttons, button,
-							FALSE, width);
+							0, width);
 					break;
 #ifdef KEY_RESIZE
 				case KEY_RESIZE:

File mixedlist.h

View file
  • Ignore whitespace
 typedef struct {
         char *name;
         char *text;
-        int state;
         int type;
         int group;
+        bool state;
 } dialog_mixedlist;
 
 /*