mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
* .c: Sanitize all calls to functions from ctype.h. Fix gcc 4.0
warnings.
This commit is contained in:
parent
92fec3431c
commit
c90d263d2c
@ -1,5 +1,8 @@
|
||||
2005-05-10 Pavel Roskin <proski@gnu.org>
|
||||
|
||||
* .c: Sanitize all calls to functions from ctype.h. Fix gcc 4.0
|
||||
warnings.
|
||||
|
||||
* file.c: Remove unneeded WANT_WIDGETS.
|
||||
* layout.c: Likewise.
|
||||
* setup.c: Likewise.
|
||||
|
@ -178,7 +178,7 @@ display_init (int radio_sel, char *init_text, int _check_status,
|
||||
/* get hotkey of user-defined format string */
|
||||
cp = strchr (displays[USER_TYPE], '&');
|
||||
if (cp != NULL && *++cp != '\0')
|
||||
user_hotkey = tolower (*cp);
|
||||
user_hotkey = tolower ((unsigned char) *cp);
|
||||
|
||||
i18n_displays_flag = 1;
|
||||
}
|
||||
|
@ -597,7 +597,7 @@ completion_matches (char *text, CompletionFunction entry_function)
|
||||
static int
|
||||
check_is_cd (const char *text, int start, int flags)
|
||||
{
|
||||
const unsigned char *p, *q;
|
||||
const char *p, *q;
|
||||
|
||||
if (flags & INPUT_COMPLETE_CD)
|
||||
return 1;
|
||||
@ -606,13 +606,14 @@ check_is_cd (const char *text, int start, int flags)
|
||||
return 0;
|
||||
|
||||
/* Skip initial spaces */
|
||||
p = (const unsigned char *) text;
|
||||
q = (const unsigned char *) text + start;
|
||||
while (p < q && *p && isspace (*p))
|
||||
p = text;
|
||||
q = text + start;
|
||||
while (p < q && *p && isspace ((unsigned char) *p))
|
||||
p++;
|
||||
|
||||
/* Check if the command is "cd" and the cursor is after it */
|
||||
if (p[0] == 'c' && p[1] == 'd' && isspace (p[2]) && (p + 2 < q))
|
||||
if (p[0] == 'c' && p[1] == 'd' && isspace ((unsigned char) p[2])
|
||||
&& (p + 2 < q))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
|
30
src/file.c
30
src/file.c
@ -141,33 +141,33 @@ static int files_error (const char *format, const char *file1,
|
||||
enum CaseConvs { NO_CONV = 0, UP_CHAR = 1, LOW_CHAR = 2, UP_SECT =
|
||||
4, LOW_SECT = 8 };
|
||||
|
||||
static int
|
||||
convert_case (int c, enum CaseConvs *conversion)
|
||||
static char
|
||||
convert_case (char c, enum CaseConvs *conversion)
|
||||
{
|
||||
if (*conversion & UP_CHAR) {
|
||||
*conversion &= ~UP_CHAR;
|
||||
return toupper (c);
|
||||
return toupper ((unsigned char) c);
|
||||
} else if (*conversion & LOW_CHAR) {
|
||||
*conversion &= ~LOW_CHAR;
|
||||
return tolower (c);
|
||||
return tolower ((unsigned char) c);
|
||||
} else if (*conversion & UP_SECT) {
|
||||
return toupper (c);
|
||||
return toupper ((unsigned char) c);
|
||||
} else if (*conversion & LOW_SECT) {
|
||||
return tolower (c);
|
||||
return tolower ((unsigned char) c);
|
||||
} else
|
||||
return c;
|
||||
}
|
||||
|
||||
static int transform_error = 0;
|
||||
|
||||
static const unsigned char *
|
||||
do_transform_source (FileOpContext *ctx, const unsigned char *source)
|
||||
static const char *
|
||||
do_transform_source (FileOpContext *ctx, const char *source)
|
||||
{
|
||||
size_t j, k, l, len;
|
||||
unsigned const char *fnsource = x_basename (source);
|
||||
const char *fnsource = x_basename (source);
|
||||
int next_reg;
|
||||
enum CaseConvs case_conv = NO_CONV;
|
||||
static unsigned char fntarget[MC_MAXPATHLEN];
|
||||
static char fntarget[MC_MAXPATHLEN];
|
||||
|
||||
len = strlen (fnsource);
|
||||
j = re_match (&ctx->rx, fnsource, len, 0, &ctx->regs);
|
||||
@ -233,12 +233,12 @@ do_transform_source (FileOpContext *ctx, const unsigned char *source)
|
||||
return fntarget;
|
||||
}
|
||||
|
||||
static const unsigned char *
|
||||
transform_source (FileOpContext *ctx, const unsigned char *source)
|
||||
static const char *
|
||||
transform_source (FileOpContext *ctx, const char *source)
|
||||
{
|
||||
unsigned char *s = g_strdup (source);
|
||||
unsigned char *q;
|
||||
const unsigned char *p;
|
||||
char *s = g_strdup (source);
|
||||
char *q;
|
||||
const char *p;
|
||||
|
||||
/* We remove \n from the filename since regex routines would use \n as an anchor */
|
||||
/* this is just to be allowed to maniupulate file names with \n on it */
|
||||
|
@ -76,7 +76,7 @@ static const char* learn_title = N_("Learn keys");
|
||||
|
||||
static int learn_button (int action)
|
||||
{
|
||||
unsigned char *seq;
|
||||
char *seq;
|
||||
Dlg_head *d = create_message (D_ERROR, _(" Teach me a key "),
|
||||
_("Please press the %s\n"
|
||||
"and then wait until this message disappears.\n\n"
|
||||
|
@ -1604,12 +1604,12 @@ midnight_callback (struct Dlg_head *h, dlg_msg_t msg, int parm)
|
||||
void
|
||||
update_xterm_title_path (void)
|
||||
{
|
||||
unsigned char *p, *s;
|
||||
char *p, *s;
|
||||
|
||||
if (xterm_flag && xterm_title) {
|
||||
p = s = g_strdup (strip_home_and_password (current_panel->cwd));
|
||||
do {
|
||||
if (!is_printable (*s))
|
||||
if (!is_printable ((unsigned char) *s))
|
||||
*s = '?';
|
||||
} while (*++s);
|
||||
fprintf (stdout, "\33]0;mc - %s\7", p);
|
||||
|
@ -43,7 +43,7 @@ menu_scan_hotkey (Menu *menu)
|
||||
|
||||
if (cp != NULL && cp[1] != '\0') {
|
||||
g_strlcpy (cp, cp + 1, strlen (cp));
|
||||
menu->hotkey = tolower (*cp);
|
||||
menu->hotkey = tolower ((unsigned char) *cp);
|
||||
} else
|
||||
menu->hotkey = 0;
|
||||
}
|
||||
@ -69,7 +69,7 @@ create_menu (const char *name, menu_entry *entries, int count, const char *help_
|
||||
cp = strchr (mp->text,'&');
|
||||
|
||||
if (cp != NULL && *(cp+1) != '\0') {
|
||||
mp->hot_key = tolower (*(cp+1));
|
||||
mp->hot_key = tolower ((unsigned char) *(cp+1));
|
||||
menu->max_entry_len = max ((int) (strlen (mp->text) - 1),
|
||||
menu->max_entry_len);
|
||||
} else {
|
||||
@ -109,7 +109,7 @@ static void menubar_paint_idx (WMenu *menubar, int idx, int color)
|
||||
widget_move (&menubar->widget, y, x + 1);
|
||||
hline (slow_terminal ? ' ' : ACS_HLINE, menubar->max_entry_len);
|
||||
} else {
|
||||
const unsigned char *text;
|
||||
const char *text;
|
||||
|
||||
addch((unsigned char)menu->entries [idx].first_letter);
|
||||
for (text = menu->entries [idx].text; *text; text++)
|
||||
|
@ -17,7 +17,7 @@
|
||||
#include "popt.h"
|
||||
#include "poptint.h"
|
||||
|
||||
static void configLine(poptContext con, unsigned char * line) {
|
||||
static void configLine(poptContext con, char * line) {
|
||||
int nameLength = strlen(con->appName);
|
||||
char * opt;
|
||||
struct poptAlias alias;
|
||||
@ -27,19 +27,19 @@ static void configLine(poptContext con, unsigned char * line) {
|
||||
|
||||
if (strncmp(line, con->appName, nameLength)) return;
|
||||
line += nameLength;
|
||||
if (!*line || !isspace(*line)) return;
|
||||
while (*line && isspace(*line)) line++;
|
||||
if (!*line || !isspace((unsigned char) *line)) return;
|
||||
while (*line && isspace((unsigned char) *line)) line++;
|
||||
entryType = line;
|
||||
|
||||
while (!*line || !isspace(*line)) line++;
|
||||
while (!*line || !isspace((unsigned char) *line)) line++;
|
||||
*line++ = '\0';
|
||||
while (*line && isspace(*line)) line++;
|
||||
while (*line && isspace((unsigned char) *line)) line++;
|
||||
if (!*line) return;
|
||||
opt = line;
|
||||
|
||||
while (!*line || !isspace(*line)) line++;
|
||||
while (!*line || !isspace((unsigned char) *line)) line++;
|
||||
*line++ = '\0';
|
||||
while (*line && isspace(*line)) line++;
|
||||
while (*line && isspace((unsigned char) *line)) line++;
|
||||
if (!*line) return;
|
||||
|
||||
if (opt[0] == '-' && opt[1] == '-')
|
||||
@ -101,7 +101,7 @@ int poptReadConfigFile(poptContext con, const char * fn) {
|
||||
case '\n':
|
||||
*dst = '\0';
|
||||
dst = buf;
|
||||
while (*dst && isspace((unsigned)*dst)) dst++;
|
||||
while (*dst && isspace((unsigned char) *dst)) dst++;
|
||||
if (*dst && *dst != '#') {
|
||||
configLine(con, dst);
|
||||
}
|
||||
|
@ -73,9 +73,9 @@ static void singleOptionHelp(FILE * f, int maxLeftCol,
|
||||
const char *translation_domain) {
|
||||
int indentLength = maxLeftCol + 5;
|
||||
int lineLength = 79 - indentLength;
|
||||
const unsigned char * help = D_(translation_domain, opt->descrip);
|
||||
const char * help = D_(translation_domain, opt->descrip);
|
||||
int helpLength;
|
||||
const unsigned char * ch;
|
||||
const char * ch;
|
||||
char * left;
|
||||
const char * argDescrip = getArgDescrip(opt, translation_domain);
|
||||
|
||||
@ -104,14 +104,14 @@ static void singleOptionHelp(FILE * f, int maxLeftCol,
|
||||
helpLength = strlen(help);
|
||||
while (helpLength > lineLength) {
|
||||
ch = help + lineLength - 1;
|
||||
while (ch > help && !isspace(*ch)) ch--;
|
||||
while (ch > help && !isspace((unsigned char) *ch)) ch--;
|
||||
if (ch == help) break; /* give up */
|
||||
while (ch > (help + 1) && isspace(*ch)) ch--;
|
||||
while (ch > (help + 1) && isspace((unsigned char) *ch)) ch--;
|
||||
ch++;
|
||||
|
||||
fprintf(f, "%.*s\n%*s", (int) (ch - help), help, indentLength, " ");
|
||||
help = ch;
|
||||
while (isspace(*help) && *help) help++;
|
||||
while (isspace((unsigned char) *help) && *help) help++;
|
||||
helpLength = strlen(help);
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ int poptParseArgvString(const char * s, int * argcPtr, char *** argvPtr) {
|
||||
if (*src != quote) *buf++ = '\\';
|
||||
}
|
||||
*buf++ = *src;
|
||||
} else if (isspace((unsigned)*src)) {
|
||||
} else if (isspace((unsigned char) *src)) {
|
||||
if (*argv[argc]) {
|
||||
buf++, argc++;
|
||||
if (argc == argvAlloced) {
|
||||
|
@ -180,7 +180,7 @@ expand_format (struct WEdit *edit_widget, char c, int quote)
|
||||
if (c == '%')
|
||||
return g_strdup ("%");
|
||||
|
||||
if (islower ((unsigned) c))
|
||||
if (islower ((unsigned char) c))
|
||||
panel = current_panel;
|
||||
else {
|
||||
if (get_other_type () != view_listing)
|
||||
@ -195,7 +195,7 @@ expand_format (struct WEdit *edit_widget, char c, int quote)
|
||||
else
|
||||
quote_func = fake_name_quote;
|
||||
|
||||
c_lc = tolower (c);
|
||||
c_lc = tolower ((unsigned char) c);
|
||||
fname = panel->dir.list[panel->selected].fname;
|
||||
|
||||
switch (c_lc) {
|
||||
@ -605,9 +605,9 @@ execute_menu_command (WEdit *edit_widget, const char *commands)
|
||||
}
|
||||
} else if (expand_prefix_found){
|
||||
expand_prefix_found = 0;
|
||||
if (isdigit ((unsigned)*commands)) {
|
||||
if (isdigit ((unsigned char) *commands)) {
|
||||
do_quote = atoi (commands);
|
||||
while (isdigit ((unsigned)*commands))
|
||||
while (isdigit ((unsigned char) *commands))
|
||||
commands++;
|
||||
}
|
||||
if (*commands == '{')
|
||||
|
13
src/util.c
13
src/util.c
@ -821,7 +821,7 @@ const char *skip_separators (const char *s)
|
||||
const char *skip_numbers (const char *s)
|
||||
{
|
||||
for (;*s; s++)
|
||||
if (!isdigit ((int) (unsigned char) *s))
|
||||
if (!isdigit ((unsigned char) *s))
|
||||
break;
|
||||
return s;
|
||||
}
|
||||
@ -1424,15 +1424,14 @@ save_file_position (const char *filename, long line, long column)
|
||||
extern const char *
|
||||
cstrcasestr (const char *haystack, const char *needle)
|
||||
{
|
||||
const unsigned char *uhaystack = (const unsigned char *) haystack;
|
||||
const unsigned char *uneedle = (const unsigned char *) needle;
|
||||
const unsigned char *hptr;
|
||||
const char *hptr;
|
||||
size_t i, needle_len;
|
||||
|
||||
needle_len = strlen(needle);
|
||||
for (hptr = uhaystack; *hptr != '\0'; hptr++) {
|
||||
needle_len = strlen (needle);
|
||||
for (hptr = haystack; *hptr != '\0'; hptr++) {
|
||||
for (i = 0; i < needle_len; i++) {
|
||||
if (toupper(hptr[i]) != toupper(uneedle[i]))
|
||||
if (toupper ((unsigned char) hptr[i]) !=
|
||||
toupper ((unsigned char) needle[i]))
|
||||
goto next_try;
|
||||
}
|
||||
return hptr;
|
||||
|
@ -1890,7 +1890,7 @@ regexp_view_search (WView *view, char *pattern, char *string,
|
||||
old_pattern = 0;
|
||||
}
|
||||
for (i = 0; pattern[i] != 0; i++) {
|
||||
if (isupper ((byte) pattern[i])) {
|
||||
if (isupper ((unsigned char) pattern[i])) {
|
||||
flags = 0;
|
||||
break;
|
||||
}
|
||||
@ -3041,7 +3041,7 @@ static void
|
||||
view_set_datasource_string (WView *view, const char *s)
|
||||
{
|
||||
view->datasource = DS_STRING;
|
||||
view->ds_string_data = g_strdup (s);
|
||||
view->ds_string_data = (byte *) g_strdup (s);
|
||||
view->ds_string_len = strlen (s);
|
||||
|
||||
view_update_last_byte (view);
|
||||
|
28
src/widget.c
28
src/widget.c
@ -78,7 +78,7 @@ button_callback (WButton *b, widget_msg_t msg, int parm)
|
||||
return MSG_HANDLED;
|
||||
}
|
||||
|
||||
if (b->hotkey == parm || toupper (b->hotkey) == parm) {
|
||||
if (b->hotkey == tolower (parm)) {
|
||||
button_callback (b, WIDGET_KEY, ' ');
|
||||
return MSG_HANDLED;
|
||||
}
|
||||
@ -212,7 +212,7 @@ button_scan_hotkey (WButton *b)
|
||||
|
||||
if (cp != NULL && cp[1] != '\0') {
|
||||
g_strlcpy (cp, cp + 1, strlen (cp));
|
||||
b->hotkey = tolower (*cp);
|
||||
b->hotkey = tolower ((unsigned char) *cp);
|
||||
b->hotpos = cp - b->text;
|
||||
}
|
||||
}
|
||||
@ -275,7 +275,7 @@ radio_callback (WRadio *r, int msg, int parm)
|
||||
for (i = 0; i < r->count; i++) {
|
||||
cp = strchr (r->texts[i], '&');
|
||||
if (cp != NULL && cp[1] != '\0') {
|
||||
int c = tolower (cp[1]);
|
||||
int c = tolower ((unsigned char) cp[1]);
|
||||
|
||||
if (c != lp)
|
||||
continue;
|
||||
@ -324,7 +324,7 @@ radio_callback (WRadio *r, int msg, int parm)
|
||||
case WIDGET_FOCUS:
|
||||
case WIDGET_DRAW:
|
||||
for (i = 0; i < r->count; i++) {
|
||||
register const unsigned char *cp;
|
||||
register const char *cp;
|
||||
attrset ((i == r->pos
|
||||
&& msg == WIDGET_FOCUS) ? FOCUSC : NORMALC);
|
||||
widget_move (&r->widget, i, 0);
|
||||
@ -490,7 +490,7 @@ check_new (int y, int x, int state, const char *text)
|
||||
}
|
||||
s++;
|
||||
if (*s){
|
||||
c->hotkey = tolower (*s);
|
||||
c->hotkey = tolower ((unsigned char) *s);
|
||||
c->hotpos = t - c->text;
|
||||
}
|
||||
*t = *s;
|
||||
@ -1173,13 +1173,15 @@ forward_char (WInput *in)
|
||||
}
|
||||
|
||||
static void
|
||||
forward_word (WInput *in)
|
||||
forward_word (WInput * in)
|
||||
{
|
||||
unsigned char *p = in->buffer+in->point;
|
||||
char *p = in->buffer + in->point;
|
||||
|
||||
while (*p && (isspace (*p) || ispunct (*p)))
|
||||
while (*p
|
||||
&& (isspace ((unsigned char) *p)
|
||||
|| ispunct ((unsigned char) *p)))
|
||||
p++;
|
||||
while (*p && isalnum (*p))
|
||||
while (*p && isalnum ((unsigned char) *p))
|
||||
p++;
|
||||
in->point = p - in->buffer;
|
||||
}
|
||||
@ -1187,11 +1189,13 @@ forward_word (WInput *in)
|
||||
static void
|
||||
backward_word (WInput *in)
|
||||
{
|
||||
unsigned char *p = in->buffer+in->point;
|
||||
char *p = in->buffer + in->point;
|
||||
|
||||
while (p-1 > in->buffer-1 && (isspace (*(p-1)) || ispunct (*(p-1))))
|
||||
while (p - 1 > in->buffer - 1 && (isspace ((unsigned char) *(p - 1))
|
||||
|| ispunct ((unsigned char)
|
||||
*(p - 1))))
|
||||
p--;
|
||||
while (p-1 > in->buffer-1 && isalnum (*(p-1)))
|
||||
while (p - 1 > in->buffer - 1 && isalnum ((unsigned char) *(p - 1)))
|
||||
p--;
|
||||
in->point = p - in->buffer;
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ typedef struct {
|
||||
int first; /* Is first keystroke? */
|
||||
int disable_update; /* Do we want to skip updates? */
|
||||
int is_password; /* Is this a password input line? */
|
||||
unsigned char *buffer; /* pointer to editing buffer */
|
||||
char *buffer; /* pointer to editing buffer */
|
||||
GList *history; /* The history */
|
||||
int need_push; /* need to push the current Input on hist? */
|
||||
char **completions; /* Possible completions array */
|
||||
|
Loading…
Reference in New Issue
Block a user