From 2994c738d0c8eb38d3ae762cc07f5888dddaaf1a Mon Sep 17 00:00:00 2001 From: Roland Illig Date: Sat, 18 Sep 2004 14:30:58 +0000 Subject: [PATCH] * help.c (search_string): Fixed a warning about a const qualifier. A local copy of the string is used for modifying. * menu.h: Removed the const qualifier from Menu.name and Menu.help_node as they are freed in destroy_menu. * menu.c (destroy_menu): Removed the (now unnecessary) casts. * popt.h: Removed a const qualifier to avoid compiler warnings. * profile.c (get_profile_string): Added const qualifiers to avoid compiler warnings. (GetSetProfile): likewise. (GetSetProfileChar): likewise. * profile.h (get_profile_string): likewise. * win.c (check_movement_keys): likewise. * win.h (check_movement_keys): likewise. --- src/ChangeLog | 15 +++++++++++++++ src/help.c | 21 +++++++++++++-------- src/menu.c | 4 ++-- src/menu.h | 4 ++-- src/popt.h | 2 +- src/profile.c | 6 +++--- src/profile.h | 2 +- src/win.c | 2 +- src/win.h | 4 ++-- 9 files changed, 40 insertions(+), 20 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index ee97a410a..08c1b9e54 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,18 @@ +2004-09-18 Roland Illig + + * help.c (search_string): Fixed a warning about a const qualifier. + A local copy of the string is used for modifying. + * menu.h: Removed the const qualifier from Menu.name and + Menu.help_node as they are freed in destroy_menu. + * menu.c (destroy_menu): Removed the (now unnecessary) casts. + * popt.h: Removed a const qualifier to avoid compiler warnings. + * profile.c (get_profile_string): Added const qualifiers to + avoid compiler warnings. (GetSetProfile): likewise. + (GetSetProfileChar): likewise. + * profile.h (get_profile_string): likewise. + * win.c (check_movement_keys): likewise. + * win.h (check_movement_keys): likewise. + 2004-09-17 Pavel Shirshov * ext.c (get_file_type_local): Fixes in diff --git a/src/help.c b/src/help.c index aafeece00..f0fb10627 100644 --- a/src/help.c +++ b/src/help.c @@ -125,12 +125,13 @@ static int acs2pc (int acscode) /* returns the position where text was found in the start buffer */ /* or 0 if not found */ static const char * -search_string (const char *start, char *text) +search_string (const char *start, const char *text) { - char *d = text; + const char *result = NULL; + char *local_text = g_strdup (text); + char *d = local_text; const char *e = start; - /* FIXME: correct this bug elsewhere, not in this function */ /* fmt sometimes replaces a space with a newline in the help file */ /* Replace the newlines in the link name with spaces to correct the situation */ while (*d){ @@ -139,15 +140,19 @@ search_string (const char *start, char *text) d++; } /* Do search */ - for (d = text; *e; e++){ + for (d = local_text; *e; e++){ if (*d == *e) d++; else - d = text; - if (!*d) - return e+1; + d = local_text; + if (!*d) { + result = e + 1; + goto cleanup; + } } - return 0; +cleanup: + g_free (local_text); + return result; } /* Searches text in the buffer pointed by start. Search ends */ diff --git a/src/menu.c b/src/menu.c index c9487ca11..7a6817518 100644 --- a/src/menu.c +++ b/src/menu.c @@ -526,8 +526,8 @@ menubar_arrange(WMenu* menubar) void destroy_menu (Menu *menu) { - g_free ((char *) menu->name); - g_free ((char *) menu->help_node); + g_free (menu->name); + g_free (menu->help_node); g_free (menu); } diff --git a/src/menu.h b/src/menu.h index 69da58785..fde6a2ff5 100644 --- a/src/menu.h +++ b/src/menu.h @@ -13,14 +13,14 @@ typedef struct { } menu_entry; typedef struct Menu { - const char *name; + char *name; int count; int max_entry_len; int selected; int hotkey; menu_entry *entries; int start_x; /* position relative to menubar start */ - const char *help_node; + char *help_node; } Menu; extern int menubar_visible; diff --git a/src/popt.h b/src/popt.h index 39e06185b..282b9b42d 100644 --- a/src/popt.h +++ b/src/popt.h @@ -57,7 +57,7 @@ struct poptOption { int argInfo; void * arg; /* depends on argInfo */ int val; /* 0 means don't return, just update flag */ - const char * descrip; /* description for autohelp -- may be NULL */ + char * descrip; /* description for autohelp -- may be NULL */ const char * argDescrip; /* argument description for autohelp */ }; diff --git a/src/profile.c b/src/profile.c index 3354a1a9c..939e81733 100644 --- a/src/profile.c +++ b/src/profile.c @@ -266,7 +266,7 @@ static void new_key (TSecHeader *section, const char *KeyName, const char *Value section->Keys = key; } -static char * +static const char * GetSetProfileChar (int set, const char *AppName, const char *KeyName, const char *Default, const char *FileName) { @@ -324,7 +324,7 @@ static short GetSetProfile (int set, const char * AppName, const char * KeyName, short Size, const char * FileName) { - char *s; + const char *s; s = GetSetProfileChar (set, AppName, KeyName, Default, FileName); if (!set) @@ -340,7 +340,7 @@ short GetPrivateProfileString (const char * AppName, const char * KeyName, return (GetSetProfile (0, AppName, KeyName, Default, ReturnedString, Size, FileName)); } -char *get_profile_string (const char *AppName, const char *KeyName, const char *Default, +const char *get_profile_string (const char *AppName, const char *KeyName, const char *Default, const char *FileName) { return GetSetProfileChar (0, AppName, KeyName, Default, FileName); diff --git a/src/profile.h b/src/profile.h index 56936a4c5..5f1f1b88f 100644 --- a/src/profile.h +++ b/src/profile.h @@ -22,7 +22,7 @@ int WriteProfileString (const char * AppName, const char * KeyName, const char * void sync_profiles (void); void free_profiles (void); -char *get_profile_string (const char *AppName, const char *KeyName, const char *Default, +const char *get_profile_string (const char *AppName, const char *KeyName, const char *Default, const char *FileName); /* New profile functions */ diff --git a/src/win.c b/src/win.c index 736cd4cf1..3a089d8b0 100644 --- a/src/win.c +++ b/src/win.c @@ -39,7 +39,7 @@ * the key was handled, 0 otherwise. */ int -check_movement_keys (int key, int page_size, void *data, movefn backfn, +check_movement_keys (int key, int page_size, const void *data, movefn backfn, movefn forfn, movefn topfn, movefn bottomfn) { switch (key) { diff --git a/src/win.h b/src/win.h index 2ca37b265..55b94ed2f 100644 --- a/src/win.h +++ b/src/win.h @@ -2,8 +2,8 @@ #define __WIN_H /* Keys management */ -typedef void (*movefn) (void *, int); -int check_movement_keys (int key, int page_size, void *data, movefn backfn, +typedef void (*movefn) (const void *, int); +int check_movement_keys (int key, int page_size, const void *data, movefn backfn, movefn forfn, movefn topfn, movefn bottomfn); int lookup_key (char *keyname);