* Code cleanup: Added const qualifier for variables and
function declarations where possible. No functional changes.
Этот коммит содержится в:
родитель
03913065b4
Коммит
3957415603
65
src/help.c
65
src/help.c
@ -65,24 +65,24 @@
|
|||||||
static char *data; /* Pointer to the loaded data file */
|
static char *data; /* Pointer to the loaded data file */
|
||||||
static int help_lines; /* Lines in help viewer */
|
static int help_lines; /* Lines in help viewer */
|
||||||
static int history_ptr; /* For the history queue */
|
static int history_ptr; /* For the history queue */
|
||||||
static char *main_node; /* The main node */
|
static const char *main_node; /* The main node */
|
||||||
static char *last_shown = 0; /* Last byte shown in a screen */
|
static const char *last_shown = NULL; /* Last byte shown in a screen */
|
||||||
static int end_of_node = 0; /* Flag: the last character of the node shown? */
|
static int end_of_node = 0; /* Flag: the last character of the node shown? */
|
||||||
static char *currentpoint, *startpoint;
|
static const char *currentpoint, *startpoint;
|
||||||
static char *selected_item;
|
static const char *selected_item;
|
||||||
|
|
||||||
/* The widget variables */
|
/* The widget variables */
|
||||||
static Dlg_head *whelp;
|
static Dlg_head *whelp;
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
char *page; /* Pointer to the selected page */
|
const char *page; /* Pointer to the selected page */
|
||||||
char *link; /* Pointer to the selected link */
|
const char *link; /* Pointer to the selected link */
|
||||||
} history [HISTORY_SIZE];
|
} history [HISTORY_SIZE];
|
||||||
|
|
||||||
/* Link areas for the mouse */
|
/* Link areas for the mouse */
|
||||||
typedef struct Link_Area {
|
typedef struct Link_Area {
|
||||||
int x1, y1, x2, y2;
|
int x1, y1, x2, y2;
|
||||||
char *link_name;
|
const char *link_name;
|
||||||
struct Link_Area *next;
|
struct Link_Area *next;
|
||||||
} Link_Area;
|
} Link_Area;
|
||||||
|
|
||||||
@ -124,12 +124,13 @@ static int acs2pc (int acscode)
|
|||||||
|
|
||||||
/* returns the position where text was found in the start buffer */
|
/* returns the position where text was found in the start buffer */
|
||||||
/* or 0 if not found */
|
/* or 0 if not found */
|
||||||
static char *
|
static const char *
|
||||||
search_string (char *start, char *text)
|
search_string (const char *start, char *text)
|
||||||
{
|
{
|
||||||
char *d = text;
|
char *d = text;
|
||||||
char *e = start;
|
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 */
|
/* 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 */
|
/* Replace the newlines in the link name with spaces to correct the situation */
|
||||||
while (*d){
|
while (*d){
|
||||||
@ -151,10 +152,10 @@ search_string (char *start, char *text)
|
|||||||
|
|
||||||
/* Searches text in the buffer pointed by start. Search ends */
|
/* Searches text in the buffer pointed by start. Search ends */
|
||||||
/* if the CHAR_NODE_END is found in the text. Returns 0 on failure */
|
/* if the CHAR_NODE_END is found in the text. Returns 0 on failure */
|
||||||
static char *search_string_node (char *start, char *text)
|
static const char *search_string_node (const char *start, const char *text)
|
||||||
{
|
{
|
||||||
char *d = text;
|
const char *d = text;
|
||||||
char *e = start;
|
const char *e = start;
|
||||||
|
|
||||||
if (!start)
|
if (!start)
|
||||||
return 0;
|
return 0;
|
||||||
@ -172,9 +173,9 @@ static char *search_string_node (char *start, char *text)
|
|||||||
|
|
||||||
/* Searches the_char in the buffer pointer by start and searches */
|
/* Searches the_char in the buffer pointer by start and searches */
|
||||||
/* it can search forward (direction = 1) or backward (direction = -1) */
|
/* it can search forward (direction = 1) or backward (direction = -1) */
|
||||||
static char *search_char_node (char *start, char the_char, int direction)
|
static const char *search_char_node (const char *start, char the_char, int direction)
|
||||||
{
|
{
|
||||||
char *e;
|
const char *e;
|
||||||
|
|
||||||
e = start;
|
e = start;
|
||||||
|
|
||||||
@ -186,9 +187,9 @@ static char *search_char_node (char *start, char the_char, int direction)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Returns the new current pointer when moved lines lines */
|
/* Returns the new current pointer when moved lines lines */
|
||||||
static char *move_forward2 (char *c, int lines)
|
static const char *move_forward2 (const char *c, int lines)
|
||||||
{
|
{
|
||||||
char *p;
|
const char *p;
|
||||||
int line;
|
int line;
|
||||||
|
|
||||||
currentpoint = c;
|
currentpoint = c;
|
||||||
@ -201,9 +202,9 @@ static char *move_forward2 (char *c, int lines)
|
|||||||
return currentpoint = c;
|
return currentpoint = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *move_backward2 (char *c, int lines)
|
static const char *move_backward2 (const char *c, int lines)
|
||||||
{
|
{
|
||||||
char *p;
|
const char *p;
|
||||||
int line;
|
int line;
|
||||||
|
|
||||||
currentpoint = c;
|
currentpoint = c;
|
||||||
@ -253,10 +254,10 @@ static void move_to_bottom (int dummy)
|
|||||||
move_backward (help_lines - 1);
|
move_backward (help_lines - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *help_follow_link (char *start, char *selected_item)
|
static const char *help_follow_link (const char *start, const char *selected_item)
|
||||||
{
|
{
|
||||||
char link_name [MAXLINKNAME];
|
char link_name [MAXLINKNAME];
|
||||||
char *p;
|
const char *p;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
if (!selected_item)
|
if (!selected_item)
|
||||||
@ -279,9 +280,9 @@ static char *help_follow_link (char *start, char *selected_item)
|
|||||||
return _(" Help file format error\n");
|
return _(" Help file format error\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *select_next_link (char *start, char *current_link)
|
static const char *select_next_link (const char *start, const char *current_link)
|
||||||
{
|
{
|
||||||
char *p;
|
const char *p;
|
||||||
|
|
||||||
if (!current_link)
|
if (!current_link)
|
||||||
return 0;
|
return 0;
|
||||||
@ -295,9 +296,9 @@ static char *select_next_link (char *start, char *current_link)
|
|||||||
return p - 1;
|
return p - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *select_prev_link (char *start, char *current_link)
|
static const char *select_prev_link (const char *start, const char *current_link)
|
||||||
{
|
{
|
||||||
char *p;
|
const char *p;
|
||||||
|
|
||||||
if (!current_link)
|
if (!current_link)
|
||||||
return 0;
|
return 0;
|
||||||
@ -310,7 +311,7 @@ static char *select_prev_link (char *start, char *current_link)
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void start_link_area (int x, int y, char *link_name)
|
static void start_link_area (int x, int y, const char *link_name)
|
||||||
{
|
{
|
||||||
Link_Area *new;
|
Link_Area *new;
|
||||||
|
|
||||||
@ -355,9 +356,9 @@ static void clear_link_areas (void)
|
|||||||
inside_link_area = 0;
|
inside_link_area = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void help_show (Dlg_head *h, char *paint_start)
|
static void help_show (Dlg_head *h, const char *paint_start)
|
||||||
{
|
{
|
||||||
char *p;
|
const char *p;
|
||||||
int col, line, c;
|
int col, line, c;
|
||||||
int painting = 1;
|
int painting = 1;
|
||||||
int acs; /* Flag: Alternate character set active? */
|
int acs; /* Flag: Alternate character set active? */
|
||||||
@ -548,7 +549,7 @@ help_help_cmd (Dlg_head *h)
|
|||||||
static void
|
static void
|
||||||
help_index_cmd (Dlg_head * h)
|
help_index_cmd (Dlg_head * h)
|
||||||
{
|
{
|
||||||
char *new_item;
|
const char *new_item;
|
||||||
|
|
||||||
if (!(new_item = search_string (data, "[Contents]"))) {
|
if (!(new_item = search_string (data, "[Contents]"))) {
|
||||||
message (1, MSG_ERROR, _(" Cannot find node %s in help file "),
|
message (1, MSG_ERROR, _(" Cannot find node %s in help file "),
|
||||||
@ -601,7 +602,7 @@ mousedispatch_new (int y, int x, int yl, int xl)
|
|||||||
static cb_ret_t
|
static cb_ret_t
|
||||||
help_handle_key (struct Dlg_head *h, int c)
|
help_handle_key (struct Dlg_head *h, int c)
|
||||||
{
|
{
|
||||||
char *new_item;
|
const char *new_item;
|
||||||
|
|
||||||
if (c != KEY_UP && c != KEY_DOWN &&
|
if (c != KEY_UP && c != KEY_DOWN &&
|
||||||
check_movement_keys (c, help_lines, currentpoint,
|
check_movement_keys (c, help_lines, currentpoint,
|
||||||
@ -753,7 +754,7 @@ interactive_display (const char *filename, const char *node)
|
|||||||
{
|
{
|
||||||
WButtonBar *help_bar;
|
WButtonBar *help_bar;
|
||||||
Widget *md;
|
Widget *md;
|
||||||
char *hlpfile = filename;
|
char *hlpfile = NULL;
|
||||||
|
|
||||||
if (filename)
|
if (filename)
|
||||||
data = load_file (filename);
|
data = load_file (filename);
|
||||||
@ -761,7 +762,7 @@ interactive_display (const char *filename, const char *node)
|
|||||||
data = load_mc_home_file ("mc.hlp", &hlpfile);
|
data = load_mc_home_file ("mc.hlp", &hlpfile);
|
||||||
|
|
||||||
if (data == NULL) {
|
if (data == NULL) {
|
||||||
message (1, MSG_ERROR, _(" Cannot open file %s \n %s "), hlpfile,
|
message (1, MSG_ERROR, _(" Cannot open file %s \n %s "), filename ? filename : hlpfile,
|
||||||
unix_error_string (errno));
|
unix_error_string (errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ static TSecHeader *load (const char *file)
|
|||||||
int state;
|
int state;
|
||||||
TSecHeader *SecHeader = 0;
|
TSecHeader *SecHeader = 0;
|
||||||
char CharBuffer [STRSIZE];
|
char CharBuffer [STRSIZE];
|
||||||
char *next = ""; /* Not needed */
|
char *next = NULL; /* Not needed */
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
if ((f = fopen (file, "r"))==NULL)
|
if ((f = fopen (file, "r"))==NULL)
|
||||||
@ -267,8 +267,8 @@ static void new_key (TSecHeader *section, const char *KeyName, const char *Value
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
GetSetProfileChar (int set, const char *AppName, char *KeyName,
|
GetSetProfileChar (int set, const char *AppName, const char *KeyName,
|
||||||
char *Default, char *FileName)
|
const char *Default, const char *FileName)
|
||||||
{
|
{
|
||||||
|
|
||||||
TProfile *Current;
|
TProfile *Current;
|
||||||
@ -319,9 +319,9 @@ GetSetProfileChar (int set, const char *AppName, char *KeyName,
|
|||||||
return Default;
|
return Default;
|
||||||
}
|
}
|
||||||
|
|
||||||
static short GetSetProfile (int set, const char * AppName, char * KeyName,
|
static short GetSetProfile (int set, const char * AppName, const char * KeyName,
|
||||||
char * Default, char * ReturnedString,
|
const char * Default, char * ReturnedString,
|
||||||
short Size, char * FileName)
|
short Size, const char * FileName)
|
||||||
|
|
||||||
{
|
{
|
||||||
char *s;
|
char *s;
|
||||||
@ -334,21 +334,21 @@ static short GetSetProfile (int set, const char * AppName, char * KeyName,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
short GetPrivateProfileString (const char * AppName, char * KeyName,
|
short GetPrivateProfileString (const char * AppName, const char * KeyName,
|
||||||
char * Default, char * ReturnedString,
|
const char * Default, char * ReturnedString,
|
||||||
short Size, char * FileName)
|
short Size, const char * FileName)
|
||||||
{
|
{
|
||||||
return (GetSetProfile (0, AppName, KeyName, Default, ReturnedString, Size, FileName));
|
return (GetSetProfile (0, AppName, KeyName, Default, ReturnedString, Size, FileName));
|
||||||
}
|
}
|
||||||
|
|
||||||
char *get_profile_string (const char *AppName, char *KeyName, char *Default,
|
char *get_profile_string (const char *AppName, const char *KeyName, const char *Default,
|
||||||
char *FileName)
|
const char *FileName)
|
||||||
{
|
{
|
||||||
return GetSetProfileChar (0, AppName, KeyName, Default, FileName);
|
return GetSetProfileChar (0, AppName, KeyName, Default, FileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetPrivateProfileInt (const char * AppName, char * KeyName, int Default,
|
int GetPrivateProfileInt (const char * AppName, const char * KeyName, int Default,
|
||||||
char * File)
|
const char * File)
|
||||||
{
|
{
|
||||||
char IntBuf [BUF_TINY];
|
char IntBuf [BUF_TINY];
|
||||||
char buf [BUF_TINY];
|
char buf [BUF_TINY];
|
||||||
@ -364,10 +364,10 @@ int GetPrivateProfileInt (const char * AppName, char * KeyName, int Default,
|
|||||||
return (int) atol (IntBuf);
|
return (int) atol (IntBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
int WritePrivateProfileString (const char * AppName, char * KeyName, char * String,
|
int WritePrivateProfileString (const char * AppName, const char * KeyName, const char * String,
|
||||||
char * FileName)
|
const char * FileName)
|
||||||
{
|
{
|
||||||
return GetSetProfile (1, AppName, KeyName, String, "", 0, FileName);
|
return GetSetProfile (1, AppName, KeyName, String, NULL, 0, FileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dump_keys (FILE * profile, TKeys * p)
|
static void dump_keys (FILE * profile, TKeys * p)
|
||||||
@ -448,7 +448,7 @@ static void free_profile (TProfile *p)
|
|||||||
g_free (p);
|
g_free (p);
|
||||||
}
|
}
|
||||||
|
|
||||||
void free_profile_name (char *s)
|
void free_profile_name (const char *s)
|
||||||
{
|
{
|
||||||
TProfile *p;
|
TProfile *p;
|
||||||
|
|
||||||
@ -470,7 +470,7 @@ void free_profiles (void)
|
|||||||
free_profile (Base);
|
free_profile (Base);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *profile_init_iterator (char *appname, char *file)
|
void *profile_init_iterator (const char *appname, const char *file)
|
||||||
{
|
{
|
||||||
TProfile *Current;
|
TProfile *Current;
|
||||||
TSecHeader *section;
|
TSecHeader *section;
|
||||||
@ -504,7 +504,7 @@ void *profile_iterator_next (void *s, char **key, char **value)
|
|||||||
return keys;
|
return keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
void profile_clean_section (const char *appname, char *file)
|
void profile_clean_section (const char *appname, const char *file)
|
||||||
{
|
{
|
||||||
TSecHeader *section;
|
TSecHeader *section;
|
||||||
|
|
||||||
@ -523,7 +523,7 @@ void profile_clean_section (const char *appname, char *file)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int profile_has_section (char *section_name, char *profile)
|
int profile_has_section (const char *section_name, const char *profile)
|
||||||
{
|
{
|
||||||
TSecHeader *section;
|
TSecHeader *section;
|
||||||
|
|
||||||
@ -539,7 +539,7 @@ int profile_has_section (char *section_name, char *profile)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void profile_forget_profile (char *file)
|
void profile_forget_profile (const char *file)
|
||||||
{
|
{
|
||||||
TProfile *p;
|
TProfile *p;
|
||||||
|
|
||||||
|
@ -2,46 +2,46 @@
|
|||||||
#define __PROFILE_H
|
#define __PROFILE_H
|
||||||
/* Prototypes for the profile management functions */
|
/* Prototypes for the profile management functions */
|
||||||
|
|
||||||
short GetPrivateProfileString (const char * AppName, char * KeyName,
|
short GetPrivateProfileString (const char * AppName, const char * KeyName,
|
||||||
char * Default, char * ReturnedString,
|
const char * Default, char * ReturnedString,
|
||||||
short Size, char * FileName);
|
short Size, const char * FileName);
|
||||||
|
|
||||||
int GetProfileString (const char * AppName, char * KeyName, char * Default,
|
int GetProfileString (const char * AppName, const char * KeyName, const char * Default,
|
||||||
char * ReturnedString, int Size);
|
char * ReturnedString, int Size);
|
||||||
|
|
||||||
int GetPrivateProfileInt (const char * AppName, char * KeyName, int Default,
|
int GetPrivateProfileInt (const char * AppName, const char * KeyName, int Default,
|
||||||
char * File);
|
const char * File);
|
||||||
|
|
||||||
int GetProfileInt (const char * AppName, char * KeyName, int Default);
|
int GetProfileInt (const char * AppName, const char * KeyName, int Default);
|
||||||
|
|
||||||
int WritePrivateProfileString (const char * AppName, char * KeyName, char * String,
|
int WritePrivateProfileString (const char * AppName, const char * KeyName, const char * String,
|
||||||
char * FileName);
|
const char * FileName);
|
||||||
|
|
||||||
int WriteProfileString (const char * AppName, char * KeyName, char * String);
|
int WriteProfileString (const char * AppName, const char * KeyName, const char * String);
|
||||||
|
|
||||||
void sync_profiles (void);
|
void sync_profiles (void);
|
||||||
|
|
||||||
void free_profiles (void);
|
void free_profiles (void);
|
||||||
char *get_profile_string (const char *AppName, char *KeyName, char *Default,
|
char *get_profile_string (const char *AppName, const char *KeyName, const char *Default,
|
||||||
char *FileName);
|
const char *FileName);
|
||||||
|
|
||||||
/* New profile functions */
|
/* New profile functions */
|
||||||
|
|
||||||
/* Returns a pointer for iterating on appname section, on profile file */
|
/* Returns a pointer for iterating on appname section, on profile file */
|
||||||
void *profile_init_iterator (char *appname, char *file);
|
void *profile_init_iterator (const char *appname, const char *file);
|
||||||
|
|
||||||
/* Returns both the key and the value of the current section. */
|
/* Returns both the key and the value of the current section. */
|
||||||
/* You pass the current iterating pointer and it returns the new pointer */
|
/* You pass the current iterating pointer and it returns the new pointer */
|
||||||
void *profile_iterator_next (void *s, char **key, char **value);
|
void *profile_iterator_next (void *s, char **key, char **value);
|
||||||
|
|
||||||
/* Removes all the definitions from section appname on file */
|
/* Removes all the definitions from section appname on file */
|
||||||
void profile_clean_section (const char *appname, char *file);
|
void profile_clean_section (const char *appname, const char *file);
|
||||||
int profile_has_section (char *section_name, char *profile);
|
int profile_has_section (const char *section_name, const char *profile);
|
||||||
|
|
||||||
/* Forgets about a .ini file, to disable updating of it */
|
/* Forgets about a .ini file, to disable updating of it */
|
||||||
void profile_forget_profile (char *file);
|
void profile_forget_profile (const char *file);
|
||||||
|
|
||||||
/* Removes information from a profile */
|
/* Removes information from a profile */
|
||||||
void free_profile_name (char *s);
|
void free_profile_name (const char *s);
|
||||||
|
|
||||||
#endif /* __PROFILE_H */
|
#endif /* __PROFILE_H */
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user