From 8b1e87523aa3911532de8c93ed5a992d42fed9f7 Mon Sep 17 00:00:00 2001 From: Roland Illig Date: Sat, 25 Sep 2004 13:46:23 +0000 Subject: [PATCH] * boxes.c (display_unit): Added const qualifier. * file.c (check_hardlinks): Likewise. * find.c (find_do_view_edit): Likewise. (find_file): Likewise. * global.h (home_dir): Likewise. * main.c (get_parent_dir_name): Likewise. (init_xterm_support): Likewise. (OS_Setup): Likewise. * menu.c (create_menu): Likewise. * mountlist.c (xatoi): Likewise. (read_filesystem_list): Likewise. * poptconfig.c (poptReadDefaultConfig): Likewise. * popthelp.c (showHelpIntro): Likewise. * rxvt.c (look_for_rxvt_extensions): Likewise. * slint.c (has_colors): Likewise. * subshell.c (check_sid): Likewise. * user.c (check_format_var): Likewise. * widget.c (radio_callback): Likewise. --- src/ChangeLog | 16 ++++++++++++++++ src/boxes.c | 2 +- src/file.c | 7 ++++--- src/find.c | 5 +++-- src/global.h | 2 +- src/main.c | 12 ++++++------ src/menu.c | 2 +- src/mountlist.c | 4 ++-- src/poptconfig.c | 3 ++- src/popthelp.c | 2 +- src/rxvt.c | 2 +- src/slint.c | 2 +- src/subshell.c | 2 +- src/user.c | 2 +- src/widget.c | 11 +++-------- 15 files changed, 44 insertions(+), 30 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index bf2668d7c..948c53c80 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -2,7 +2,23 @@ * view.c (display): Recognize "+\bo" as a list item in nroff mode. Display "_\b_" correctly in both colors. + * view.c (hex_search): Added const qualifier. + * boxes.c (display_unit): Likewise. + * file.c (check_hardlinks): Likewise. + * find.c (find_do_view_edit): Likewise. (find_file): Likewise. + * global.h (home_dir): Likewise. + * main.c (get_parent_dir_name): Likewise. (init_xterm_support): + Likewise. (OS_Setup): Likewise. + * menu.c (create_menu): Likewise. + * mountlist.c (xatoi): Likewise. (read_filesystem_list): Likewise. + * poptconfig.c (poptReadDefaultConfig): Likewise. + * popthelp.c (showHelpIntro): Likewise. + * rxvt.c (look_for_rxvt_extensions): Likewise. + * slint.c (has_colors): Likewise. + * subshell.c (check_sid): Likewise. + * user.c (check_format_var): Likewise. + * widget.c (radio_callback): Likewise. 2004-09-25 Pavel Shirshov diff --git a/src/boxes.c b/src/boxes.c index 17838d02b..ee4815ced 100644 --- a/src/boxes.c +++ b/src/boxes.c @@ -145,7 +145,7 @@ display_init (int radio_sel, char *init_text, int _check_status, if (!i18n_displays_flag) { int i, l, maxlen = 0; - char *cp; + const char *cp; display_title = _(display_title); for (i = 0; i < LIST_TYPES; i++) { diff --git a/src/file.c b/src/file.c index 36ce5b36e..b5d89b4de 100644 --- a/src/file.c +++ b/src/file.c @@ -296,7 +296,7 @@ check_hardlinks (const char *src_name, const char *dst_name, struct stat *pstat) ino_t ino = pstat->st_ino; dev_t dev = pstat->st_dev; struct stat link_stat; - char *p; + const char *p; if (vfs_file_class_flags (src_name) & VFSF_NOLINKS) return 0; @@ -321,12 +321,13 @@ check_hardlinks (const char *src_name, const char *dst_name, struct stat *pstat) lp = (struct link *) g_malloc (sizeof (struct link) + strlen (src_name) + strlen (dst_name) + 1); if (lp) { + char *lpdstname; lp->vfs = my_vfs; lp->ino = ino; lp->dev = dev; strcpy (lp->name, src_name); - p = strchr (lp->name, 0) + 1; - strcpy (p, dst_name); + lpdstname = lp->name + strlen(lp->name) + 1; + strcpy (lpdstname, dst_name); lp->next = linklist; linklist = lp; } diff --git a/src/find.c b/src/find.c index cf5ff26f8..d1c34485b 100644 --- a/src/find.c +++ b/src/find.c @@ -709,7 +709,8 @@ init_find_vars (void) static void find_do_view_edit (int unparsed_view, int edit, char *dir, char *file) { - char *fullname, *filename; + char *fullname; + const char *filename; int line; if (content_pattern){ @@ -944,7 +945,7 @@ find_file (char *start_dir, char *pattern, char *content, char **dirname, for (i = 0; entry && i < find_list->count; entry = entry->next, i++) { - char *filename; + const char *filename; if (!entry->text || !entry->data) continue; diff --git a/src/global.h b/src/global.h index d88c2fbd6..682a09ef6 100644 --- a/src/global.h +++ b/src/global.h @@ -157,7 +157,7 @@ struct timeval { #include "vfsdummy.h" #endif -extern char *home_dir; +extern const char *home_dir; #ifdef min #undef min diff --git a/src/main.c b/src/main.c index 2eadd8fbe..196dea377 100644 --- a/src/main.c +++ b/src/main.c @@ -230,7 +230,7 @@ Dlg_head *midnight_dlg; int update_prompt = 0; /* The home directory */ -char *home_dir = NULL; +const char *home_dir = NULL; /* The value of the other directory, only used when loading the setup */ char *other_dir = NULL; @@ -544,10 +544,10 @@ directory_history_add (struct WPanel *panel, const char *dir) * * You do _NOT_ want to add any vfs aware code here. */ -static char * +static const char * get_parent_dir_name (const char *cwd, const char *lwd) { - char *p; + const char *p; if (strlen (lwd) > strlen (cwd)) if ((p = strrchr (lwd, PATH_SEP)) && !strncmp (cwd, lwd, p - lwd)) { return (p + 1); @@ -1333,7 +1333,7 @@ setup_pre (void) static void init_xterm_support (void) { - char *termvalue; + const char *termvalue; #ifdef HAVE_SLANG char *term_entry; #endif @@ -1346,7 +1346,7 @@ init_xterm_support (void) /* Check mouse capabilities */ #ifdef HAVE_SLANG - term_entry = SLtt_tigetent (termvalue); + term_entry = SLtt_tigetent (const_cast(char *, termvalue)); xmouse_seq = SLtt_tigetstr ("Km", &term_entry); #else xmouse_seq = tigetstr ("kmous"); @@ -1763,7 +1763,7 @@ do_nc (void) static void OS_Setup (void) { - char *mc_libdir; + const char *mc_libdir; shell = getenv ("SHELL"); if (!shell || !*shell) { struct passwd *pwd; diff --git a/src/menu.c b/src/menu.c index 7a6817518..a1d2bd9c0 100644 --- a/src/menu.c +++ b/src/menu.c @@ -49,7 +49,7 @@ Menu * create_menu (const char *name, menu_entry *entries, int count, const char *help_node) { Menu *menu; - char *cp; + const char *cp; menu = (Menu *) g_malloc (sizeof (*menu)); menu->count = count; diff --git a/src/mountlist.c b/src/mountlist.c index e4fdf984a..0d8ecfcc2 100644 --- a/src/mountlist.c +++ b/src/mountlist.c @@ -150,7 +150,7 @@ static struct mount_entry *mount_list = NULL; No prefix (like '0x') or suffix (like 'h') is expected to be part of CP. */ -static int xatoi (char *cp) +static int xatoi (const char *cp) { int val; @@ -242,7 +242,7 @@ read_filesystem_list (int need_fs_type, int all_fs) { struct mntent *mnt; FILE *fp; - char *devopt; + const char *devopt; fp = setmntent (MOUNTED, "r"); if (fp == NULL) diff --git a/src/poptconfig.c b/src/poptconfig.c index b3e33342c..7a471e911 100644 --- a/src/poptconfig.c +++ b/src/poptconfig.c @@ -126,7 +126,8 @@ int poptReadConfigFile(poptContext con, const char * fn) { } int poptReadDefaultConfig(poptContext con, int useEnv) { - char * fn, * home; + char *fn; + const char* home; int rc; if (!con->appName) return 0; diff --git a/src/popthelp.c b/src/popthelp.c index f129fcf08..33ad0207c 100644 --- a/src/popthelp.c +++ b/src/popthelp.c @@ -174,7 +174,7 @@ static void singleTableHelp(FILE * f, const struct poptOption * table, static int showHelpIntro(poptContext con, FILE * f) { int len = 6; - char * fn; + const char * fn; fprintf(f, _("Usage:")); if (!(con->flags & POPT_CONTEXT_KEEP_FIRST)) { diff --git a/src/rxvt.c b/src/rxvt.c index 4170c883d..605954c52 100644 --- a/src/rxvt.c +++ b/src/rxvt.c @@ -33,7 +33,7 @@ static int rxvt_extensions = 0; int look_for_rxvt_extensions (void) { static int been_called = 0; - char *e; + const char *e; if (!been_called) { rxvt_extensions = 0; e = getenv ("RXVT_EXT"); diff --git a/src/slint.c b/src/slint.c index a095588c8..89dc1a2b7 100644 --- a/src/slint.c +++ b/src/slint.c @@ -359,7 +359,7 @@ vline (int character, int len) int has_colors (void) { - char *terminal = getenv ("TERM"); + const char *terminal = getenv ("TERM"); char *cts = color_terminal_string, *s; size_t i; diff --git a/src/subshell.c b/src/subshell.c index 8743d080a..241084a1b 100644 --- a/src/subshell.c +++ b/src/subshell.c @@ -298,7 +298,7 @@ static int check_sid (void) { pid_t my_sid, old_sid; - char *sid_str; + const char *sid_str; int r; sid_str = getenv ("MC_SID"); diff --git a/src/user.c b/src/user.c index f8565140b..72fa8a8b1 100644 --- a/src/user.c +++ b/src/user.c @@ -116,7 +116,7 @@ int check_format_var (const char *p, char **v) { const char *q = p; char *var_name; - char *value; + const char *value; const char *dots = 0; *v = 0; diff --git a/src/widget.c b/src/widget.c index 8d23a4d49..9e70b1ca4 100644 --- a/src/widget.c +++ b/src/widget.c @@ -259,7 +259,7 @@ radio_callback (WRadio *r, int msg, int parm) case WIDGET_HOTKEY: { int i, lp = tolower (parm); - char *cp; + const char *cp; for (i = 0; i < r->count; i++) { cp = strchr (r->texts[i], '&'); @@ -506,7 +506,7 @@ label_callback (WLabel *l, int msg, int parm) case WIDGET_DRAW: { - char *p = l->text, *q, c = 0; + const char *p = l->text, *q; int y = 0; if (!l->text) @@ -520,18 +520,13 @@ label_callback (WLabel *l, int msg, int parm) int xlen; q = strchr (p, '\n'); - if (q) { - c = *q; - *q = 0; - } widget_move (&l->widget, y, 0); - printw ("%s", p); + printw ("%.*s", q - p, p); xlen = l->widget.cols - strlen (p); if (xlen > 0) printw ("%*s", xlen, " "); if (!q) break; - *q = c; p = q + 1; y++; }