* 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 22:38:06 +00:00
parent b86b6a7bc7
commit 5c4add0e6e
11 changed files with 46 additions and 41 deletions

View File

@ -133,11 +133,11 @@ static void
display_init (int radio_sel, char *init_text, int _check_status,
char **_status)
{
static char *display_title = N_("Listing mode");
static const char *display_title = N_("Listing mode");
static int i18n_displays_flag;
char *user_mini_status = _("user &Mini status");
char *ok_button = _("&OK");
char *cancel_button = _("&Cancel");
const char *user_mini_status = _("user &Mini status");
const char *ok_button = _("&OK");
const char *cancel_button = _("&Cancel");
static int button_start = 30;
@ -217,7 +217,7 @@ display_box (WPanel *panel, char **userp, char **minip, int *use_msformat, int n
{
int result, i;
char *section = NULL;
char *p;
const char *p;
if (!panel) {
p = get_nth_panel_name (num);
@ -455,7 +455,7 @@ confirm_box (void)
static int new_mode;
static int new_meta;
static char *display_bits_str [] =
static const char *display_bits_str [] =
{ N_("Full 8 bits output"), N_("ISO 8859-1"), N_("7 bits") };
static QuickWidget display_widgets [] = {
@ -466,7 +466,7 @@ static QuickWidget display_widgets [] = {
{ quick_checkbox, 4, DISPX, 7, DISPY, N_("F&ull 8 bits input"),
0, 0, &new_meta, 0, "u" },
{ quick_radio, 4, DISPX, 3, DISPY, "", 3, 0,
&new_mode, display_bits_str, "r" },
&new_mode, const_cast(char **, display_bits_str), "r" },
NULL_QuickWidget
};
@ -932,7 +932,7 @@ task_cb (int action)
static struct
{
char* name;
const char* name;
int xpos;
int value;
int (*callback)(int);
@ -1009,8 +1009,8 @@ vfs_smb_get_authinfo (const char *host, const char *share, const char *domain,
static int dialog_x = 44;
enum { b0 = 3, dialog_y = 12};
struct smb_authinfo *return_value;
static char* labs[] = {N_("Domain:"), N_("Username:"), N_("Password:")};
static char* buts[] = {N_("&OK"), N_("&Cancel")};
static const char* labs[] = {N_("Domain:"), N_("Username:"), N_("Password:")};
static const char* buts[] = {N_("&OK"), N_("&Cancel")};
static int ilen = 30, istart = 14;
static int b2 = 30;
char *title;

View File

@ -121,7 +121,7 @@ free_codepages_list (void)
#define OTHER_8BIT "Other_8_bit"
char *
const char *
get_codepage_id (int n)
{
return (n < 0) ? OTHER_8BIT : codepages[n].id;

View File

@ -13,17 +13,17 @@ extern unsigned char conv_displ[256];
extern unsigned char conv_input[256];
struct codepage_desc {
char *id;
char *name;
const char *id;
const char *name;
};
extern struct codepage_desc *codepages;
char *get_codepage_id (int n);
const char *get_codepage_id (int n);
int get_codepage_index (const char *id);
int load_codepages_list (void);
void free_codepages_list (void);
char *init_translation_table (int cpsource, int cpdisplay);
const char *init_translation_table (int cpsource, int cpdisplay);
void convert_to_display (char *str);
void convert_from_input (char *str);
void convert_string (unsigned char *str);

View File

@ -63,13 +63,18 @@ static int mode_change, need_update;
static int c_file, end_chmod;
static umode_t and_mask, or_mask, c_stat;
static char *c_fname, *c_fown, *c_fgrp;
/* FIXME: these variables are superfluous, aren't they? (hint: name_trunc
* returns a pointer to a static buffer, and label_new creates its own copy
* of its argument)
* --rillig, 2004-08-29 */
static const char *c_fname, *c_fown, *c_fgrp;
static WLabel *statl;
static struct {
mode_t mode;
char *text;
const char *text;
int selected;
WCheck *check;
} check_perm[PERMISSIONS] =
@ -90,7 +95,7 @@ static struct {
static struct {
int ret_cmd, flags, y, x;
char *text;
const char *text;
} chmod_but[BUTTONS] =
{
{ B_CANCEL, NORMAL_BUTTON, 2, 33, N_("&Cancel") },

View File

@ -67,7 +67,7 @@ static WListbox *l_user, *l_group;
static struct {
int ret_cmd, flags, y, x;
char *text;
const char *text;
} chown_but[BUTTONS] = {
{ B_CANCEL, NORMAL_BUTTON, 0, 53, N_("&Cancel") },
{ B_ENTER, DEFPUSH_BUTTON, 0, 40, N_("&Set") },

View File

@ -85,7 +85,7 @@ int
view_file_at_line (const char *filename, int plain_view, int internal,
int start_line)
{
static char *viewer = 0;
static const char *viewer = NULL;
int move_dir = 0;
@ -265,7 +265,7 @@ filtered_view_cmd (void)
void do_edit_at_line (const char *what, int start_line)
{
static char *editor = 0;
static const char *editor = NULL;
#ifdef USE_INTERNAL_EDIT
if (use_internal_edit){
@ -421,7 +421,7 @@ static void
set_panel_filter (WPanel *p)
{
char *reg_exp;
char *x;
const char *x;
x = p->filter ? p->filter : easy_patterns ? "*" : ".";
@ -1062,7 +1062,7 @@ char *guess_message_value (void)
};
unsigned i = 0;
char *locale = NULL;
const char *locale = NULL;
while (var[i] != NULL) {
locale = getenv (var[i]);
@ -1120,7 +1120,7 @@ get_random_hint (int force)
#if defined(USE_NETCODE) || defined(USE_EXT2FSLIB)
static void
nice_cd (char *text, char *xtext, char *help, char *prefix, int to_home)
nice_cd (const char *text, const char *xtext, const char *help, const char *prefix, int to_home)
{
char *machine;
char *cd_path;
@ -1154,7 +1154,7 @@ nice_cd (char *text, char *xtext, char *help, char *prefix, int to_home)
#ifdef USE_NETCODE
static char *machine_str = N_(" Enter machine name (F1 for details): ");
static const char *machine_str = N_(" Enter machine name (F1 for details): ");
#ifdef WITH_MCFS
void netlink_cmd (void)

View File

@ -44,7 +44,7 @@ int alarm_colors [4];
#endif
struct colorpair {
char *name; /* Name of the entry */
const char *name; /* Name of the entry */
CTYPE fg; /* foreground color */
CTYPE bg; /* background color */
};
@ -99,7 +99,7 @@ static struct colorpair color_map [] = {
};
struct color_table_s {
char *name;
const char *name;
int value;
};
@ -124,7 +124,7 @@ static struct color_table_s const color_table [] = {
{ "default", 0 } /* default color of the terminal */
};
static char *default_colors =
static const char *default_colors =
"normal=lightgray,blue:"
"selected=black,cyan:"
"marked=yellow,blue:"
@ -166,7 +166,7 @@ static char *default_colors =
# define color_name(i) color_table [i].name
#endif
static void get_color (char *cpp, CTYPE *colp)
static void get_color (const char *cpp, CTYPE *colp)
{
size_t i;
@ -205,7 +205,7 @@ static void get_two_colors (char **cpp, struct colorpair *colorpairp)
get_color (*cpp, state ? &colorpairp->bg : &colorpairp->fg);
}
static void configure_colors_string (char *the_color_string)
static void configure_colors_string (const char *the_color_string)
{
char *color_string, *p;
size_t i;

View File

@ -80,7 +80,7 @@ extern int alarm_colors[4];
#define EDITOR_MARKED_COLOR IF_COLOR (36, A_REVERSE)
#ifdef HAVE_SLANG
# define CTYPE char *
# define CTYPE const char *
#else
# define CTYPE int
#endif

View File

@ -274,7 +274,7 @@ variable_completion_function (char *text, int state)
static char **hosts = NULL;
static char **hosts_p = NULL;
static int hosts_alloclen = 0;
static void fetch_hosts (char *filename)
static void fetch_hosts (const char *filename)
{
FILE *file = fopen (filename, "r");
char *temp, buffer[256], *name;
@ -352,7 +352,7 @@ hostname_completion_function (char *text, int state)
static int textstart, textlen;
if (!state){ /* Initialization stuff */
char *p;
const char *p;
if (hosts != NULL){
for (host_p = hosts; *host_p; host_p++)
@ -614,8 +614,8 @@ check_is_cd (const char *text, int start, int flags)
return 0;
/* Skip initial spaces */
p = text;
q = text + start;
p = (const unsigned char *) text;
q = (const unsigned char *) text + start;
while (p < q && *p && isspace (*p))
p++;
@ -633,7 +633,7 @@ try_complete (char *text, int *start, int *end, int flags)
int in_command_position = 0, i;
char *word, c;
char **matches = NULL;
char *command_separator_chars = ";|&{(`";
const char *command_separator_chars = ";|&{(`";
char *p = NULL, *q = NULL, *r = NULL;
int is_cd = check_is_cd (text, *start, flags);

View File

@ -79,7 +79,7 @@ typedef enum {
STRCOLL_TEST
} strcoll_status;
static int string_sortcomp (char *str1, char *str2)
static int string_sortcomp (const char *str1, const char *str2)
{
static strcoll_status use_strcoll = STRCOLL_TEST;
@ -126,7 +126,7 @@ sort_name (const file_entry *a, const file_entry *b)
int
sort_ext (const file_entry *a, const file_entry *b)
{
char *exta, *extb;
const char *exta, *extb;
int r;
int ad = MY_ISDIR (a);
int bd = MY_ISDIR (b);
@ -368,7 +368,7 @@ set_zero_dir (dir_list *list)
/* If you change handle_dirent then check also handle_path. */
/* Return values: -1 = failure, 0 = don't add, 1 = add to the list */
static int
handle_dirent (dir_list *list, char *filter, struct dirent *dp,
handle_dirent (dir_list *list, const char *filter, struct dirent *dp,
struct stat *buf1, int next_free, int *link_to_dir,
int *stale_link)
{

View File

@ -58,7 +58,7 @@ flush_extension_file (void)
}
}
typedef char *(*quote_func_t) (const char *name, int i);
typedef char *(*quote_func_t) (const char *name, int quote_percent);
static void
exec_extension (const char *filename, const char *data, int *move_dir,
@ -329,7 +329,7 @@ get_file_type_local (char *filename, char *buf, int buflen)
* Return 1 for match, 0 for no match, -1 errors.
*/
static int
regex_check_type (char *filename, char *ptr, int *have_type)
regex_check_type (const char *filename, const char *ptr, int *have_type)
{
int found = 0;