From 8aeea3256f4bd3d18a96fe4ea934b1765379706d Mon Sep 17 00:00:00 2001 From: Roland Illig Date: Mon, 16 Aug 2004 15:45:05 +0000 Subject: [PATCH] Added more const-ness to the function arguments. --- src/dialog.c | 4 ++-- src/dialog.h | 2 +- src/wtools.c | 22 +++++++++++----------- src/wtools.h | 8 ++++---- vfs/utilvfs.c | 4 ++-- vfs/utilvfs.h | 2 +- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/dialog.c b/src/dialog.c index a2cfd8561..b1bf20e70 100644 --- a/src/dialog.c +++ b/src/dialog.c @@ -183,7 +183,7 @@ cb_ret_t default_dlg_callback (Dlg_head *h, dlg_msg_t msg, int parm) Dlg_head * create_dlg (int y1, int x1, int lines, int cols, const int *color_set, - dlg_cb_fn callback, char *help_ctx, const char *title, + dlg_cb_fn callback, const char *help_ctx, const char *title, int flags) { Dlg_head *new_d; @@ -198,7 +198,7 @@ create_dlg (int y1, int x1, int lines, int cols, const int *color_set, new_d = g_new0 (Dlg_head, 1); new_d->color = color_set; - new_d->help_ctx = help_ctx; + new_d->help_ctx = const_cast(char *, help_ctx); new_d->callback = callback ? callback : default_dlg_callback; new_d->x = x1; new_d->y = y1; diff --git a/src/dialog.h b/src/dialog.h index 62a014956..a7798efac 100644 --- a/src/dialog.h +++ b/src/dialog.h @@ -143,7 +143,7 @@ void draw_double_box (Dlg_head *h, int y, int x, int ys, int xs); /* Creates a dialog head */ Dlg_head *create_dlg (int y1, int x1, int lines, int cols, const int *color_set, dlg_cb_fn callback, - char *help_ctx, const char *title, int flags); + const char *help_ctx, const char *title, int flags); /* The flags: */ diff --git a/src/wtools.c b/src/wtools.c index 1dfeefea6..9b8029aa7 100644 --- a/src/wtools.c +++ b/src/wtools.c @@ -39,11 +39,11 @@ Listbox * -create_listbox_window (int cols, int lines, char *title, char *help) +create_listbox_window (int cols, int lines, const char *title, const char *help) { int xpos, ypos, len; Listbox *listbox = g_new (Listbox, 1); - char *cancel_string = _("&Cancel"); + const char *cancel_string = _("&Cancel"); /* Adjust sizes */ lines = (lines > LINES - 6) ? LINES - 6 : lines; @@ -68,7 +68,7 @@ create_listbox_window (int cols, int lines, char *title, char *help) add_widget (listbox->dlg, button_new (lines + 3, (cols / 2 + 2) - len / 2, B_CANCEL, - NORMAL_BUTTON, cancel_string, 0)); + NORMAL_BUTTON, const_cast(char *, cancel_string), 0)); add_widget (listbox->dlg, listbox->list); return listbox; @@ -431,8 +431,8 @@ int quick_dialog (QuickDialog *qd) /* Show dialog, not background safe */ static char * -fg_input_dialog_help (char *header, char *text, char *help, - char *def_text) +fg_input_dialog_help (const char *header, const char *text, const char *help, + const char *def_text) { QuickDialog Quick_input; QuickWidget quick_widgets[] = { @@ -483,11 +483,11 @@ fg_input_dialog_help (char *header, char *text, char *help, Quick_input.xlen = len; Quick_input.xpos = -1; - Quick_input.title = header; - Quick_input.help = help; + Quick_input.title = const_cast(char *, header); + Quick_input.help = const_cast(char *, help); Quick_input.i18n = 0; quick_widgets[INPUT_INDEX + 1].text = g_strstrip (g_strdup (text)); - quick_widgets[INPUT_INDEX].text = def_text; + quick_widgets[INPUT_INDEX].text = const_cast(char *, def_text); for (i = 0; i < 4; i++) quick_widgets[i].y_divisions = lines + 6; @@ -510,7 +510,7 @@ fg_input_dialog_help (char *header, char *text, char *help, /* Show input dialog, background safe */ char * -input_dialog_help (char *header, char *text, char *help, char *def_text) +input_dialog_help (const char *header, const char *text, const char *help, const char *def_text) { #ifdef WITH_BACKGROUND if (we_are_background) @@ -524,13 +524,13 @@ input_dialog_help (char *header, char *text, char *help, char *def_text) } /* Show input dialog with default help, background safe */ -char *input_dialog (char *header, char *text, char *def_text) +char *input_dialog (const char *header, const char *text, const char *def_text) { return input_dialog_help (header, text, "[Input Line Keys]", def_text); } char * -input_expand_dialog (char *header, char *text, char *def_text) +input_expand_dialog (const char *header, const char *text, const char *def_text) { char *result; char *expanded; diff --git a/src/wtools.h b/src/wtools.h index d90e734f6..4f7520eba 100644 --- a/src/wtools.h +++ b/src/wtools.h @@ -10,7 +10,7 @@ typedef struct { struct WListbox *list; } Listbox; -Listbox *create_listbox_window (int cols, int lines, char *title, char *help); +Listbox *create_listbox_window (int cols, int lines, const char *title, const char *help); #define LISTBOX_APPEND_TEXT(l,h,t,d) \ listbox_add_item (l->list, 0, h, t, d); @@ -61,9 +61,9 @@ int quick_dialog_skip (QuickDialog *qd, int nskip); /* Pass this as def_text to request a password */ #define INPUT_PASSWORD ((char *) -1) -char *input_dialog (char *header, char *text, char *def_text); -char *input_dialog_help (char *header, char *text, char *help, char *def_text); -char *input_expand_dialog (char *header, char *text, char *def_text); +char *input_dialog (const char *header, const char *text, const char *def_text); +char *input_dialog_help (const char *header, const char *text, const char *help, const char *def_text); +char *input_expand_dialog (const char *header, const char *text, const char *def_text); void query_set_sel (int new_sel); diff --git a/vfs/utilvfs.c b/vfs/utilvfs.c index c470be627..57f395a8d 100644 --- a/vfs/utilvfs.c +++ b/vfs/utilvfs.c @@ -857,8 +857,8 @@ vfs_die (const char *m) } char * -vfs_get_password (char *msg) +vfs_get_password (const char *msg) { - return (char *) input_dialog (msg, _("Password:"), INPUT_PASSWORD); + return input_dialog (msg, _("Password:"), INPUT_PASSWORD); } diff --git a/vfs/utilvfs.h b/vfs/utilvfs.h index 3c56ce8be..fc83b1262 100644 --- a/vfs/utilvfs.h +++ b/vfs/utilvfs.h @@ -20,7 +20,7 @@ int vfs_split_text (char *p); int vfs_mkstemps (char **pname, const char *prefix, const char *basename); void vfs_die (const char *msg); -char *vfs_get_password (char *msg); +char *vfs_get_password (const char *msg); int vfs_parse_ls_lga (const char *p, struct stat *s, char **filename, char **linkname);