1
1

* Code cleanup: Added const qualifier for variables and

function declarations where possible. No functional changes.
Этот коммит содержится в:
Roland Illig 2004-08-29 18:45:56 +00:00
родитель 263ea5c1d5
Коммит 243e84706e
10 изменённых файлов: 33 добавлений и 32 удалений

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

@ -54,7 +54,7 @@ int option_edit_left_extreme = 0;
int option_edit_top_extreme = 0; int option_edit_top_extreme = 0;
int option_edit_bottom_extreme = 0; int option_edit_bottom_extreme = 0;
char *option_whole_chars_search = "0123456789abcdefghijklmnopqrstuvwxyz_"; const char *option_whole_chars_search = "0123456789abcdefghijklmnopqrstuvwxyz_";
char *option_backup_ext = "~"; char *option_backup_ext = "~";
/* /*
@ -175,7 +175,7 @@ edit_load_file_fast (WEdit *edit, const char *filename)
whether you read everything or not. */ whether you read everything or not. */
/* FIXME: add proper `triple_pipe_open' to read, write and check errors. */ /* FIXME: add proper `triple_pipe_open' to read, write and check errors. */
static const struct edit_filters { static const struct edit_filters {
char *read, *write, *extension; const char *read, *write, *extension;
} all_filters[] = { } all_filters[] = {
{ {

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

@ -130,7 +130,7 @@ void edit_init_menu_emacs (void);
void edit_init_menu_normal (void); void edit_init_menu_normal (void);
void edit_done_menu (void); void edit_done_menu (void);
void menu_save_mode_cmd (void); void menu_save_mode_cmd (void);
int edit_raw_key_query (char *heading, char *query, int cancel); int edit_raw_key_query (const char *heading, const char *query, int cancel);
int edit (const char *_file, int line); int edit (const char *_file, int line);
int edit_translate_key (WEdit *edit, long x_key, int *cmd, int *ch); int edit_translate_key (WEdit *edit, long x_key, int *cmd, int *ch);
@ -234,7 +234,7 @@ void edit_paste_from_history (WEdit *edit);
void edit_set_filename (WEdit *edit, const char *name); void edit_set_filename (WEdit *edit, const char *name);
void edit_load_syntax (WEdit * edit, char **names, char *type); void edit_load_syntax (WEdit * edit, char **names, const char *type);
void edit_free_syntax_rules (WEdit * edit); void edit_free_syntax_rules (WEdit * edit);
void edit_get_syntax_color (WEdit * edit, long byte_index, int *color); void edit_get_syntax_color (WEdit * edit, long byte_index, int *color);
@ -318,7 +318,7 @@ extern int option_edit_left_extreme;
extern int option_edit_top_extreme; extern int option_edit_top_extreme;
extern int option_edit_bottom_extreme; extern int option_edit_bottom_extreme;
extern char *option_whole_chars_search; extern const char *option_whole_chars_search;
extern char *option_backup_ext; extern char *option_backup_ext;
extern int edit_confirm_save; extern int edit_confirm_save;

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

@ -371,7 +371,7 @@ void menu_save_mode_cmd (void)
#define DLG_Y 10 #define DLG_Y 10
static char *str_result; static char *str_result;
static int save_mode_new; static int save_mode_new;
static char *str[] = static const char *str[] =
{ {
N_("Quick save "), N_("Quick save "),
N_("Safe save "), N_("Safe save "),
@ -554,7 +554,7 @@ raw_callback (struct Dlg_head *h, dlg_msg_t msg, int parm)
will return the next key pressed. ctrl-a (=B_CANCEL), ctrl-g, ctrl-c, will return the next key pressed. ctrl-a (=B_CANCEL), ctrl-g, ctrl-c,
and Esc are cannot returned */ and Esc are cannot returned */
int int
edit_raw_key_query (char *heading, char *query, int cancel) edit_raw_key_query (const char *heading, const char *query, int cancel)
{ {
int w = strlen (query) + 7; int w = strlen (query) + 7;
struct Dlg_head *raw_dlg = struct Dlg_head *raw_dlg =
@ -1617,7 +1617,7 @@ edit_find (long search_start, unsigned char *exp, int *len, long last_byte, int
*p1++ = *p++; \ *p1++ = *p++; \
*p1 = '\0'; \ *p1 = '\0'; \
n = snprintf(s,e-s,q1,v); \ n = snprintf(s,e-s,q1,v); \
if (n >= e - s) goto nospc; \ if (n >= (size_t) (e - s)) goto nospc; \
s += n; \ s += n; \
} }
@ -1643,7 +1643,7 @@ static int snprintf_p (char *str, size_t size, const char *fmt,...)
while ((p = strchr (p, '%'))) { while ((p = strchr (p, '%'))) {
n = p - q; n = p - q;
if (n >= e - s) if (n >= (size_t) (e - s))
goto nospc; goto nospc;
memcpy (s, q, n); /* copy stuff between format specifiers */ memcpy (s, q, n); /* copy stuff between format specifiers */
s += n; s += n;
@ -1721,7 +1721,7 @@ static int snprintf_p (char *str, size_t size, const char *fmt,...)
} }
va_end (ap); va_end (ap);
n = strlen (q); n = strlen (q);
if (n >= e - s) if (n >= (size_t) (e - s))
return -1; return -1;
memcpy (s, q, n + 1); memcpy (s, q, n + 1);
return s + n - str; return s + n - str;

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

@ -50,9 +50,10 @@ struct lock_s {
/* Build user@host.domain.pid string (need to be freed) */ /* Build user@host.domain.pid string (need to be freed) */
static char * static char *
lock_build_name (char *fname) lock_build_name (const char *fname)
{ {
char host[BUF_SIZE], *user; char host[BUF_SIZE];
const char *user;
if (! if (!
((user = getpwuid (getuid ())->pw_name) || (user = getenv ("USER")) ((user = getpwuid (getuid ())->pw_name) || (user = getenv ("USER"))
@ -68,10 +69,10 @@ lock_build_name (char *fname)
/* Extract pid from user@host.domain.pid string */ /* Extract pid from user@host.domain.pid string */
static struct lock_s * static struct lock_s *
lock_extract_info (char *str) lock_extract_info (const char *str)
{ {
int i; int i;
char *p, *s; const char *p, *s;
static char pid[PID_BUF_SIZE], who[BUF_SIZE]; static char pid[PID_BUF_SIZE], who[BUF_SIZE];
static struct lock_s lock; static struct lock_s lock;
@ -99,7 +100,7 @@ lock_extract_info (char *str)
/* Extract user@host.domain.pid from lock file (static string) */ /* Extract user@host.domain.pid from lock file (static string) */
static char * static char *
lock_get_info (char *lockfname) lock_get_info (const char *lockfname)
{ {
int cnt; int cnt;
static char buf[BUF_SIZE]; static char buf[BUF_SIZE];
@ -116,7 +117,7 @@ lock_get_info (char *lockfname)
Returns 1 on success, 0 on failure, -1 if abort Returns 1 on success, 0 on failure, -1 if abort
Warning: Might do screen refresh and lose edit->force */ Warning: Might do screen refresh and lose edit->force */
int int
edit_lock_file (char *fname) edit_lock_file (const char *fname)
{ {
char *lockfname, *newlock, *msg, *lock; char *lockfname, *newlock, *msg, *lock;
struct stat statbuf; struct stat statbuf;
@ -181,7 +182,7 @@ edit_lock_file (char *fname)
/* Lowers file lock if possible /* Lowers file lock if possible
Always returns 0 to make 'lock = edit_unlock_file (f)' possible */ Always returns 0 to make 'lock = edit_unlock_file (f)' possible */
int int
edit_unlock_file (char *fname) edit_unlock_file (const char *fname)
{ {
char *lockfname, *lock; char *lockfname, *lock;
struct stat statbuf; struct stat statbuf;

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

@ -1,7 +1,7 @@
#ifndef __EDIT_LOCK_H #ifndef __EDIT_LOCK_H
#define __EDIT_LOCK_H #define __EDIT_LOCK_H
int edit_lock_file (char *fname); int edit_lock_file (const char *fname);
int edit_unlock_file (char *fname); int edit_unlock_file (const char *fname);
#endif /* !__EDIT_LOCK_H */ #endif /* !__EDIT_LOCK_H */

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

@ -32,14 +32,14 @@
#define USE_INTERNAL_EDIT 1 #define USE_INTERNAL_EDIT 1
#endif #endif
static char *key_emu_str[] = static const char *key_emu_str[] =
{N_("Intuitive"), N_("Emacs"), NULL}; {N_("Intuitive"), N_("Emacs"), NULL};
static char *wrap_str[] = static const char *wrap_str[] =
{N_("None"), N_("Dynamic paragraphing"), N_("Type writer wrap"), NULL}; {N_("None"), N_("Dynamic paragraphing"), N_("Type writer wrap"), NULL};
static void static void
i18n_translate_array (char *array[]) i18n_translate_array (const char *array[])
{ {
while (*array!=NULL) { while (*array!=NULL) {
*array = _(*array); *array = _(*array);
@ -106,14 +106,14 @@ edit_options_dialog (void)
OPT_DLG_H, N_("&Fake half tabs"), 0, 0, 0, 0, NULL}, OPT_DLG_H, N_("&Fake half tabs"), 0, 0, 0, 0, NULL},
/* 13 */ /* 13 */
{quick_radio, 5, OPT_DLG_W, OPT_DLG_H - 7, OPT_DLG_H, "", 3, 0, 0, {quick_radio, 5, OPT_DLG_W, OPT_DLG_H - 7, OPT_DLG_H, "", 3, 0, 0,
wrap_str, "wrapm"}, const_cast(char **, wrap_str), "wrapm"},
/* 14 */ /* 14 */
{quick_label, 4, OPT_DLG_W, OPT_DLG_H - 8, OPT_DLG_H, {quick_label, 4, OPT_DLG_W, OPT_DLG_H - 8, OPT_DLG_H,
N_("Wrap mode"), 0, 0, N_("Wrap mode"), 0, 0,
0, 0, NULL}, 0, 0, NULL},
/* 15 */ /* 15 */
{quick_radio, 5, OPT_DLG_W, OPT_DLG_H - 13, OPT_DLG_H, "", 2, 0, 0, {quick_radio, 5, OPT_DLG_W, OPT_DLG_H - 13, OPT_DLG_H, "", 2, 0, 0,
key_emu_str, "keyemu"}, const_cast(char **, key_emu_str), "keyemu"},
/* 16 */ /* 16 */
{quick_label, 4, OPT_DLG_W, OPT_DLG_H - 14, OPT_DLG_H, {quick_label, 4, OPT_DLG_W, OPT_DLG_H - 14, OPT_DLG_H,
N_("Key emulation"), 0, 0, 0, 0, NULL}, N_("Key emulation"), 0, 0, 0, 0, NULL},

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

@ -1096,7 +1096,7 @@ static char *get_first_editor_line (WEdit * edit)
* NULL, then the type will be selected according to the filename. * NULL, then the type will be selected according to the filename.
*/ */
void void
edit_load_syntax (WEdit *edit, char **names, char *type) edit_load_syntax (WEdit *edit, char **names, const char *type)
{ {
int r; int r;
char *f; char *f;

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

@ -63,7 +63,7 @@ static struct Dlg_head *ch_dlg;
static struct { static struct {
int ret_cmd, flags, y, x; int ret_cmd, flags, y, x;
char *text; const char *text;
} chown_advanced_but [BUTTONS] = { } chown_advanced_but [BUTTONS] = {
{ B_CANCEL, NORMAL_BUTTON, 4, 53, N_("&Cancel") }, { B_CANCEL, NORMAL_BUTTON, 4, 53, N_("&Cancel") },
{ B_ENTER, DEFPUSH_BUTTON,4, 40, N_("&Set") }, { B_ENTER, DEFPUSH_BUTTON,4, 40, N_("&Set") },
@ -94,7 +94,7 @@ static char *fname;
static void get_ownership (void) static void get_ownership (void)
{ /* set buttons - ownership */ { /* set buttons - ownership */
char *name_t; const char *name_t;
name_t = name_trunc (get_owner (sf_stat->st_uid), 15); name_t = name_trunc (get_owner (sf_stat->st_uid), 15);
memset (b_user->text, ' ', 15); memset (b_user->text, ' ', 15);

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

@ -33,7 +33,7 @@ typedef struct WRadio {
unsigned int state; /* radio button state */ unsigned int state; /* radio button state */
int pos, sel; int pos, sel;
int count; /* number of members */ int count; /* number of members */
char **texts; /* texts of labels */ const char **texts; /* texts of labels */
int upper_letter_is_hotkey; /* If true, then the capital letter is a hk */ int upper_letter_is_hotkey; /* If true, then the capital letter is a hk */
} WRadio; } WRadio;

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

@ -35,20 +35,20 @@ typedef struct {
int relative_y; int relative_y;
int y_divisions; int y_divisions;
char *text; /* Text */ const char *text; /* Text */
int hotkey_pos; /* the hotkey position */ int hotkey_pos; /* the hotkey position */
int value; /* Buttons only: value of button */ int value; /* Buttons only: value of button */
int *result; /* Checkbutton: where to store result */ int *result; /* Checkbutton: where to store result */
char **str_result; /* Input lines: destination */ char **str_result; /* Input lines: destination */
char *histname; /* Name of the section for saving history */ const char *histname; /* Name of the section for saving history */
} QuickWidget; } QuickWidget;
#define NULL_QuickWidget { 0, 0, 0, 0, 0, NULL, 0, 0, NULL, NULL, NULL } #define NULL_QuickWidget { 0, 0, 0, 0, 0, NULL, 0, 0, NULL, NULL, NULL }
typedef struct { typedef struct {
int xlen, ylen; int xlen, ylen;
int xpos, ypos; /* if -1, then center the dialog */ int xpos, ypos; /* if -1, then center the dialog */
char *title; const char *title;
char *help; const char *help;
QuickWidget *widgets; QuickWidget *widgets;
int i18n; /* If true, internationalization has happened */ int i18n; /* If true, internationalization has happened */
} QuickDialog; } QuickDialog;