* Code cleanup: Added const qualifier for variables and

function declarations where possible. No functional changes.
This commit is contained in:
Roland Illig 2004-08-29 23:27:40 +00:00
parent 17714fd8d9
commit 03913065b4
20 changed files with 61 additions and 60 deletions

View File

@ -237,7 +237,8 @@ edit_save_file (WEdit *edit, const char *filename)
} }
if (this_save_mode != EDIT_QUICK_SAVE) { if (this_save_mode != EDIT_QUICK_SAVE) {
char *savedir, *slashpos, *saveprefix; char *savedir, *saveprefix;
const char *slashpos;
slashpos = strrchr (filename, PATH_SEP); slashpos = strrchr (filename, PATH_SEP);
if (slashpos) { if (slashpos) {
savedir = g_strdup (filename); savedir = g_strdup (filename);

View File

@ -109,7 +109,7 @@ static struct {
static struct _hotlist_but { static struct _hotlist_but {
int ret_cmd, flags, y, x; int ret_cmd, flags, y, x;
char *text; const char *text;
int type; int type;
} hotlist_but[] = { } hotlist_but[] = {
{ B_MOVE, NORMAL_BUTTON, 1, 42, N_("&Move"), LIST_HOTLIST}, { B_MOVE, NORMAL_BUTTON, 1, 42, N_("&Move"), LIST_HOTLIST},
@ -163,7 +163,8 @@ hotlist_refresh (Dlg_head * dlg)
static inline void static inline void
update_path_name (void) update_path_name (void)
{ {
char *text, *p; const char *text;
char *p;
WListbox *list = hotlist_state.moving ? l_movelist : l_hotlist; WListbox *list = hotlist_state.moving ? l_movelist : l_hotlist;
Dlg_head *dlg = list->widget.parent; Dlg_head *dlg = list->widget.parent;
@ -520,7 +521,7 @@ static int
init_i18n_stuff(int list_type, int cols) init_i18n_stuff(int list_type, int cols)
{ {
register int i; register int i;
static char* cancel_but = N_("&Cancel"); static const char* cancel_but = N_("&Cancel");
#ifdef ENABLE_NLS #ifdef ENABLE_NLS
static int hotlist_i18n_flag = 0; static int hotlist_i18n_flag = 0;
@ -594,7 +595,7 @@ static void
init_hotlist (int list_type) init_hotlist (int list_type)
{ {
size_t i; size_t i;
char *title, *help_node; const char *title, *help_node;
int hotlist_cols; int hotlist_cols;
hotlist_cols = init_i18n_stuff (list_type, COLS - 6); hotlist_cols = init_i18n_stuff (list_type, COLS - 6);
@ -819,7 +820,7 @@ static void add_widgets_i18n(QuickWidget* qw, int len)
} }
#endif /* ENABLE_NLS */ #endif /* ENABLE_NLS */
static int add_new_entry_input (char *header, char *text1, char *text2, char *help, char **r1, char **r2) static int add_new_entry_input (const char *header, const char *text1, const char *text2, const char *help, char **r1, char **r2)
{ {
#define RELATIVE_Y_BUTTONS 4 #define RELATIVE_Y_BUTTONS 4
#define RELATIVE_Y_LABEL_PTH 3 #define RELATIVE_Y_LABEL_PTH 3
@ -1346,7 +1347,7 @@ hot_load_file (struct hotlist * grp)
} }
static void static void
clean_up_hotlist_groups (char *section) clean_up_hotlist_groups (const char *section)
{ {
char *grp_section; char *grp_section;
void *profile_keys; void *profile_keys;

View File

@ -202,7 +202,7 @@ void channels_up (void)
typedef const struct { typedef const struct {
int code; int code;
char *seq; const char *seq;
int action; int action;
} key_define_t; } key_define_t;
@ -500,7 +500,7 @@ xmouse_get_event (Gpm_Event *ev)
ev->y = getch () - 32; ev->y = getch () - 32;
} }
static key_def *create_sequence (char *seq, int code, int action) static key_def *create_sequence (const char *seq, int code, int action)
{ {
key_def *base, *p, *attach; key_def *base, *p, *attach;

View File

@ -69,8 +69,8 @@ int get_key_code (int nodelay);
typedef const struct { typedef const struct {
int code; int code;
char *name; const char *name;
char *longname; const char *longname;
} key_code_name_t; } key_code_name_t;
extern key_code_name_t key_name_conv_tab []; extern key_code_name_t key_name_conv_tab [];

View File

@ -895,7 +895,7 @@ void set_display_type (int num, int type)
{ {
int x, y, cols, lines; int x, y, cols, lines;
int the_other; /* Index to the other panel */ int the_other; /* Index to the other panel */
char *file_name = 0; /* For Quick view */ const char *file_name = NULL; /* For Quick view */
Widget *new_widget, *old_widget; Widget *new_widget, *old_widget;
WPanel *the_other_panel; WPanel *the_other_panel;

View File

@ -53,7 +53,7 @@
static struct { static struct {
int ret_cmd, flags, y, x; int ret_cmd, flags, y, x;
char *text; const char *text;
} learn_but[BUTTONS] = { } learn_but[BUTTONS] = {
{ B_CANCEL, NORMAL_BUTTON, 0, 39, N_("&Cancel") }, { B_CANCEL, NORMAL_BUTTON, 0, 39, N_("&Cancel") },
{ B_ENTER, DEFPUSH_BUTTON, 0, 25, N_("&Save") } { B_ENTER, DEFPUSH_BUTTON, 0, 25, N_("&Save") }
@ -70,7 +70,7 @@ static learnkey *learnkeys = NULL;
static int learn_total; static int learn_total;
static int learnok; static int learnok;
static int learnchanged; static int learnchanged;
static char* learn_title = N_("Learn keys"); static const char* learn_title = N_("Learn keys");
static int learn_button (int action) static int learn_button (int action)

View File

@ -106,7 +106,7 @@ static void menubar_paint_idx (WMenu *menubar, int idx, int color)
widget_move (&menubar->widget, y, x + 1); widget_move (&menubar->widget, y, x + 1);
hline (slow_terminal ? ' ' : ACS_HLINE, menubar->max_entry_len); hline (slow_terminal ? ' ' : ACS_HLINE, menubar->max_entry_len);
} else { } else {
unsigned char *text; const unsigned char *text;
addch((unsigned char)menu->entries [idx].first_letter); addch((unsigned char)menu->entries [idx].first_letter);
for (text = menu->entries [idx].text; *text; text++) for (text = menu->entries [idx].text; *text; text++)

View File

@ -22,8 +22,8 @@
struct my_statfs { struct my_statfs {
int type; int type;
char *typename; char *typename;
char *mpoint; const char *mpoint;
char *device; const char *device;
int avail; int avail;
int total; int total;
int nfree; int nfree;

View File

@ -31,7 +31,7 @@
#include "key.h" /* define sequence */ #include "key.h" /* define sequence */
int mouse_enabled = 0; int mouse_enabled = 0;
char *xmouse_seq; const char *xmouse_seq;
#ifdef HAVE_LIBGPM #ifdef HAVE_LIBGPM
void show_mouse_pointer (int x, int y) void show_mouse_pointer (int x, int y)

View File

@ -65,7 +65,7 @@ extern Mouse_Type use_mouse_p;
extern int mouse_enabled; extern int mouse_enabled;
/* String indicating that a mouse event has occured, usually "\E[M" */ /* String indicating that a mouse event has occured, usually "\E[M" */
extern char *xmouse_seq; extern const char *xmouse_seq;
void init_mouse (void); void init_mouse (void);
void enable_mouse (void); void enable_mouse (void);

View File

@ -47,7 +47,7 @@ static Dlg_head *conf_dlg;
static int first_width, second_width; static int first_width, second_width;
static struct { static struct {
char *text; const char *text;
int *variable; int *variable;
void (*toggle_function)(void); void (*toggle_function)(void);
WCheck *widget; WCheck *widget;

View File

@ -61,7 +61,7 @@ static WInput *pname;
static struct { static struct {
int ret_cmd, flags, y, x; int ret_cmd, flags, y, x;
char *text; const char *text;
} panelize_but [BUTTONS] = { } panelize_but [BUTTONS] = {
{ B_CANCEL, NORMAL_BUTTON, 0, 53, N_("&Cancel") }, { B_CANCEL, NORMAL_BUTTON, 0, 53, N_("&Cancel") },
{ B_ADD, NORMAL_BUTTON, 0, 28, N_("&Add new") }, { B_ADD, NORMAL_BUTTON, 0, 28, N_("&Add new") },
@ -69,7 +69,7 @@ static struct {
{ B_ENTER, DEFPUSH_BUTTON, 0, 0, N_("Pane&lize") }, { B_ENTER, DEFPUSH_BUTTON, 0, 0, N_("Pane&lize") },
}; };
static char *panelize_section = "Panelize"; static const char *panelize_section = "Panelize";
static void do_external_panelize (char *command); static void do_external_panelize (char *command);
/* Directory panelize */ /* Directory panelize */

View File

@ -58,7 +58,7 @@ static void invokeCallbacks(poptContext con, const struct poptOption * table,
} }
} }
poptContext poptGetContext(char * name, int argc, char ** argv, poptContext poptGetContext(const char * name, int argc, char ** argv,
const struct poptOption * options, int flags) { const struct poptOption * options, int flags) {
poptContext con = malloc(sizeof(*con)); poptContext con = malloc(sizeof(*con));

View File

@ -85,7 +85,7 @@ typedef void (*poptCallbackType)(poptContext con,
const struct poptOption * opt, const struct poptOption * opt,
const char * arg, void * data); const char * arg, void * data);
poptContext poptGetContext(char * name, int argc, char ** argv, poptContext poptGetContext(const char * name, int argc, char ** argv,
const struct poptOption * options, int flags); const struct poptOption * options, int flags);
void poptResetContext(poptContext con); void poptResetContext(poptContext con);
@ -102,7 +102,7 @@ char * poptBadOption(poptContext con, int flags);
void poptFreeContext(poptContext con); void poptFreeContext(poptContext con);
int poptStuffArgs(poptContext con, char ** argv); int poptStuffArgs(poptContext con, char ** argv);
int poptAddAlias(poptContext con, struct poptAlias alias, int flags); int poptAddAlias(poptContext con, struct poptAlias alias, int flags);
int poptReadConfigFile(poptContext con, char * fn); int poptReadConfigFile(poptContext con, const char * fn);
/* like above, but reads /etc/popt and $HOME/.popt along with environment /* like above, but reads /etc/popt and $HOME/.popt along with environment
vars */ vars */
int poptReadDefaultConfig(poptContext con, int useEnv); int poptReadDefaultConfig(poptContext con, int useEnv);

View File

@ -66,7 +66,7 @@ static void configLine(poptContext con, unsigned char * line) {
} }
} }
int poptReadConfigFile(poptContext con, char * fn) { int poptReadConfigFile(poptContext con, const char * fn) {
char * file, * chptr, * end; char * file, * chptr, * end;
char * buf, * dst; char * buf, * dst;
int fd, rc; int fd, rc;

View File

@ -79,8 +79,8 @@ typedef struct format_e {
int just_mode; int just_mode;
int expand; int expand;
const char *(*string_fn)(file_entry *, int len); const char *(*string_fn)(file_entry *, int len);
char *title; const char *title;
char *id; const char *id;
} format_e; } format_e;
/* If true, show the mini-info on the panel */ /* If true, show the mini-info on the panel */
@ -107,8 +107,8 @@ Hook *select_file_hook = 0;
static cb_ret_t panel_callback (WPanel *p, widget_msg_t msg, int parm); static cb_ret_t panel_callback (WPanel *p, widget_msg_t msg, int parm);
static int panel_event (Gpm_Event *event, WPanel *panel); static int panel_event (Gpm_Event *event, WPanel *panel);
static void paint_frame (WPanel *panel); static void paint_frame (WPanel *panel);
static char *panel_format (WPanel *panel); static const char *panel_format (WPanel *panel);
static char *mini_status_format (WPanel *panel); static const char *mini_status_format (WPanel *panel);
/* This macro extracts the number of available lines in a panel */ /* This macro extracts the number of available lines in a panel */
#define llines(p) (p->widget.lines-3 - (show_mini_info ? 2 : 0)) #define llines(p) (p->widget.lines-3 - (show_mini_info ? 2 : 0))
@ -393,11 +393,11 @@ string_dot (file_entry *fe, int len)
#define GT 1 #define GT 1
static struct { static struct {
char *id; const char *id;
int min_size; int min_size;
int expands; int expands;
int default_just; int default_just;
char *title; const char *title;
int use_in_gui; int use_in_gui;
const char *(*string_fn)(file_entry *, int); const char *(*string_fn)(file_entry *, int);
sortfn *sort_routine; sortfn *sort_routine;
@ -644,7 +644,7 @@ display_mini_info (WPanel *panel)
/* Status displays total marked size */ /* Status displays total marked size */
if (panel->marked){ if (panel->marked){
char buffer [BUF_SMALL]; char buffer [BUF_SMALL];
char *p = " %-*s"; const char *p = " %-*s";
int cols = panel->widget.cols-2; int cols = panel->widget.cols-2;
attrset (MARKED_COLOR); attrset (MARKED_COLOR);
@ -1060,7 +1060,7 @@ paint_frame (WPanel *panel)
int spaces, extra; int spaces, extra;
int side, width; int side, width;
char *txt; const char *txt;
if (!panel->split) if (!panel->split)
adjust_top_file (panel); adjust_top_file (panel);
@ -1108,8 +1108,8 @@ paint_frame (WPanel *panel)
} }
} }
static char * static const char *
parse_panel_size (WPanel *panel, char *format, int isstatus) parse_panel_size (WPanel *panel, const char *format, int isstatus)
{ {
int frame = frame_half; int frame = frame_half;
format = skip_separators (format); format = skip_separators (format);
@ -1158,7 +1158,7 @@ parse_panel_size (WPanel *panel, char *format, int isstatus)
*/ */
static format_e * static format_e *
parse_display_format (WPanel *panel, char *format, char **error, int isstatus, int *res_total_cols) parse_display_format (WPanel *panel, const char *format, char **error, int isstatus, int *res_total_cols)
{ {
format_e *darr, *old = 0, *home = 0; /* The formats we return */ format_e *darr, *old = 0, *home = 0; /* The formats we return */
int total_cols = 0; /* Used columns by the format */ int total_cols = 0; /* Used columns by the format */
@ -1275,14 +1275,13 @@ parse_display_format (WPanel *panel, char *format, char **error, int isstatus, i
break; break;
} }
if (!found){ if (!found){
char old_char; char *tmp_format = g_strdup (format);
int pos = min (8, strlen (format)); int pos = min (8, strlen (format));
delete_format (home); delete_format (home);
old_char = format [pos]; tmp_format [pos] = 0;
format [pos] = 0; *error = g_strconcat (_("Unknown tag on display format: "), tmp_format, NULL);
*error = g_strconcat (_("Unknown tag on display format: "), format, NULL); g_free (tmp_format);
format [pos] = old_char;
return 0; return 0;
} }
total_cols += darr->requested_field_len; total_cols += darr->requested_field_len;
@ -1293,13 +1292,13 @@ parse_display_format (WPanel *panel, char *format, char **error, int isstatus, i
} }
static format_e * static format_e *
use_display_format (WPanel *panel, char *format, char **error, int isstatus) use_display_format (WPanel *panel, const char *format, char **error, int isstatus)
{ {
#define MAX_EXPAND 4 #define MAX_EXPAND 4
int expand_top = 0; /* Max used element in expand */ int expand_top = 0; /* Max used element in expand */
int usable_columns; /* Usable columns in the panel */ int usable_columns; /* Usable columns in the panel */
int total_cols; int total_cols;
char *expand_list [MAX_EXPAND]; /* Expand at most 4 fields. */ const char *expand_list [MAX_EXPAND]; /* Expand at most 4 fields. */
int i; int i;
format_e *darr, *home; format_e *darr, *home;
@ -1421,7 +1420,7 @@ set_panel_formats (WPanel *p)
} }
/* Given the panel->view_type returns the format string to be parsed */ /* Given the panel->view_type returns the format string to be parsed */
static char * static const char *
panel_format (WPanel *panel) panel_format (WPanel *panel)
{ {
switch (panel->list_type){ switch (panel->list_type){
@ -1441,7 +1440,7 @@ panel_format (WPanel *panel)
} }
} }
static char * static const char *
mini_status_format (WPanel *panel) mini_status_format (WPanel *panel)
{ {
if (panel->user_mini_status) if (panel->user_mini_status)

View File

@ -81,7 +81,7 @@ int startup_right_mode;
int saving_setup; int saving_setup;
static const struct { static const struct {
char *key; const char *key;
sortfn *sort_type; sortfn *sort_type;
} sort_names [] = { } sort_names [] = {
{ "name", (sortfn *) sort_name }, { "name", (sortfn *) sort_name },
@ -96,7 +96,7 @@ static const struct {
}; };
static const struct { static const struct {
char *key; const char *key;
int list_type; int list_type;
} list_types [] = { } list_types [] = {
{ "full", list_full }, { "full", list_full },
@ -107,7 +107,7 @@ static const struct {
}; };
static const struct { static const struct {
char *opt_name; const char *opt_name;
int opt_type; int opt_type;
} panel_types [] = { } panel_types [] = {
{ "listing", view_listing }, { "listing", view_listing },
@ -118,7 +118,7 @@ static const struct {
}; };
static const struct { static const struct {
char *opt_name; const char *opt_name;
int *opt_addr; int *opt_addr;
} layout [] = { } layout [] = {
{ "equal_split", &equal_split }, { "equal_split", &equal_split },
@ -136,7 +136,7 @@ static const struct {
}; };
static const struct { static const struct {
char *opt_name; const char *opt_name;
int *opt_addr; int *opt_addr;
} options [] = { } options [] = {
{ "show_backups", &show_backups }, { "show_backups", &show_backups },
@ -291,7 +291,7 @@ save_configure (void)
} }
static void static void
panel_save_type (char *section, int type) panel_save_type (const char *section, int type)
{ {
int i; int i;
@ -419,7 +419,7 @@ load_layout (char *profile_name)
} }
static int static int
load_mode (char *section) load_mode (const char *section)
{ {
char buffer [20]; char buffer [20];
int i; int i;
@ -440,7 +440,7 @@ load_mode (char *section)
#ifdef USE_NETCODE #ifdef USE_NETCODE
static char * static char *
do_load_string (char *s, char *ss, char *def) do_load_string (const char *s, const char *ss, const char *def)
{ {
char *buffer = g_malloc (BUF_SMALL); char *buffer = g_malloc (BUF_SMALL);
char *p; char *p;
@ -583,7 +583,7 @@ void done_setup (void)
} }
static void static void
load_keys_from_section (char *terminal, char *profile_name) load_keys_from_section (const char *terminal, const char *profile_name)
{ {
char *section_name; char *section_name;
void *profile_keys; void *profile_keys;

View File

@ -438,7 +438,7 @@ attrset (int color)
*/ */
static const struct { static const struct {
int key_code; int key_code;
char *key_name; const char *key_name;
} key_table [] = { } key_table [] = {
{ KEY_F(0), "k0" }, { KEY_F(0), "k0" },
{ KEY_F(1), "k1" }, { KEY_F(1), "k1" },
@ -476,7 +476,7 @@ static const struct {
}; };
static void static void
do_define_key (int code, char *strcap) do_define_key (int code, const char *strcap)
{ {
char *seq; char *seq;

View File

@ -579,7 +579,7 @@ static int tree_forget_cmd (WTree *tree)
return 1; return 1;
} }
static void tree_copy (WTree *tree, char *default_dest) static void tree_copy (WTree *tree, const char *default_dest)
{ {
char *dest; char *dest;
off_t count = 0; off_t count = 0;
@ -619,7 +619,7 @@ static int tree_copy_cmd (WTree *tree)
return 1; return 1;
} }
static void tree_move (WTree *tree, char *default_dest) static void tree_move (WTree *tree, const char *default_dest)
{ {
char *dest; char *dest;
struct stat buf; struct stat buf;

View File

@ -742,7 +742,7 @@ process_special_dirs(GList ** special_dirs, char *file)
} }
static gboolean static gboolean
should_skip_directory(char *dir) should_skip_directory(const char *dir)
{ {
static GList *special_dirs; static GList *special_dirs;
GList *l; GList *l;