1
1

* Code cleanup: Added const qualifier for variables and

function declarations where possible. No functional changes.
Этот коммит содержится в:
Roland Illig 2004-08-29 23:27:40 +00:00
родитель 17714fd8d9
Коммит 03913065b4
20 изменённых файлов: 61 добавлений и 60 удалений

Просмотреть файл

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

Просмотреть файл

@ -109,7 +109,7 @@ static struct {
static struct _hotlist_but {
int ret_cmd, flags, y, x;
char *text;
const char *text;
int type;
} hotlist_but[] = {
{ B_MOVE, NORMAL_BUTTON, 1, 42, N_("&Move"), LIST_HOTLIST},
@ -163,7 +163,8 @@ hotlist_refresh (Dlg_head * dlg)
static inline void
update_path_name (void)
{
char *text, *p;
const char *text;
char *p;
WListbox *list = hotlist_state.moving ? l_movelist : l_hotlist;
Dlg_head *dlg = list->widget.parent;
@ -520,7 +521,7 @@ static int
init_i18n_stuff(int list_type, int cols)
{
register int i;
static char* cancel_but = N_("&Cancel");
static const char* cancel_but = N_("&Cancel");
#ifdef ENABLE_NLS
static int hotlist_i18n_flag = 0;
@ -594,7 +595,7 @@ static void
init_hotlist (int list_type)
{
size_t i;
char *title, *help_node;
const char *title, *help_node;
int hotlist_cols;
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 */
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_LABEL_PTH 3
@ -1346,7 +1347,7 @@ hot_load_file (struct hotlist * grp)
}
static void
clean_up_hotlist_groups (char *section)
clean_up_hotlist_groups (const char *section)
{
char *grp_section;
void *profile_keys;

Просмотреть файл

@ -202,7 +202,7 @@ void channels_up (void)
typedef const struct {
int code;
char *seq;
const char *seq;
int action;
} key_define_t;
@ -500,7 +500,7 @@ xmouse_get_event (Gpm_Event *ev)
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;

Просмотреть файл

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

Просмотреть файл

@ -895,7 +895,7 @@ void set_display_type (int num, int type)
{
int x, y, cols, lines;
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;
WPanel *the_other_panel;

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -65,7 +65,7 @@ extern Mouse_Type use_mouse_p;
extern int mouse_enabled;
/* 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 enable_mouse (void);

Просмотреть файл

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

Просмотреть файл

@ -61,7 +61,7 @@ static WInput *pname;
static struct {
int ret_cmd, flags, y, x;
char *text;
const char *text;
} panelize_but [BUTTONS] = {
{ B_CANCEL, NORMAL_BUTTON, 0, 53, N_("&Cancel") },
{ B_ADD, NORMAL_BUTTON, 0, 28, N_("&Add new") },
@ -69,7 +69,7 @@ static struct {
{ 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);
/* Directory panelize */

Просмотреть файл

@ -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) {
poptContext con = malloc(sizeof(*con));

Просмотреть файл

@ -85,7 +85,7 @@ typedef void (*poptCallbackType)(poptContext con,
const struct poptOption * opt,
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);
void poptResetContext(poptContext con);
@ -102,7 +102,7 @@ char * poptBadOption(poptContext con, int flags);
void poptFreeContext(poptContext con);
int poptStuffArgs(poptContext con, char ** argv);
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
vars */
int poptReadDefaultConfig(poptContext con, int useEnv);

Просмотреть файл

@ -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 * buf, * dst;
int fd, rc;

Просмотреть файл

@ -79,8 +79,8 @@ typedef struct format_e {
int just_mode;
int expand;
const char *(*string_fn)(file_entry *, int len);
char *title;
char *id;
const char *title;
const char *id;
} format_e;
/* 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 int panel_event (Gpm_Event *event, WPanel *panel);
static void paint_frame (WPanel *panel);
static char *panel_format (WPanel *panel);
static char *mini_status_format (WPanel *panel);
static const char *panel_format (WPanel *panel);
static const char *mini_status_format (WPanel *panel);
/* This macro extracts the number of available lines in a panel */
#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
static struct {
char *id;
const char *id;
int min_size;
int expands;
int default_just;
char *title;
const char *title;
int use_in_gui;
const char *(*string_fn)(file_entry *, int);
sortfn *sort_routine;
@ -644,7 +644,7 @@ display_mini_info (WPanel *panel)
/* Status displays total marked size */
if (panel->marked){
char buffer [BUF_SMALL];
char *p = " %-*s";
const char *p = " %-*s";
int cols = panel->widget.cols-2;
attrset (MARKED_COLOR);
@ -1060,7 +1060,7 @@ paint_frame (WPanel *panel)
int spaces, extra;
int side, width;
char *txt;
const char *txt;
if (!panel->split)
adjust_top_file (panel);
@ -1108,8 +1108,8 @@ paint_frame (WPanel *panel)
}
}
static char *
parse_panel_size (WPanel *panel, char *format, int isstatus)
static const char *
parse_panel_size (WPanel *panel, const char *format, int isstatus)
{
int frame = frame_half;
format = skip_separators (format);
@ -1158,7 +1158,7 @@ parse_panel_size (WPanel *panel, char *format, int isstatus)
*/
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 */
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;
}
if (!found){
char old_char;
char *tmp_format = g_strdup (format);
int pos = min (8, strlen (format));
delete_format (home);
old_char = format [pos];
format [pos] = 0;
*error = g_strconcat (_("Unknown tag on display format: "), format, NULL);
format [pos] = old_char;
tmp_format [pos] = 0;
*error = g_strconcat (_("Unknown tag on display format: "), tmp_format, NULL);
g_free (tmp_format);
return 0;
}
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 *
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
int expand_top = 0; /* Max used element in expand */
int usable_columns; /* Usable columns in the panel */
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;
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 */
static char *
static const char *
panel_format (WPanel *panel)
{
switch (panel->list_type){
@ -1441,7 +1440,7 @@ panel_format (WPanel *panel)
}
}
static char *
static const char *
mini_status_format (WPanel *panel)
{
if (panel->user_mini_status)

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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