fix libFirm/cparser -Wsign-compare

This commit is contained in:
tg
2012-12-05 19:38:25 +00:00
parent 75af4e244a
commit f654a3dea4
7 changed files with 36 additions and 34 deletions

36
misc.c
View File

@ -30,7 +30,7 @@
#include <grp.h>
#endif
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.203 2012/12/04 01:18:31 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.204 2012/12/05 19:38:22 tg Exp $");
#define KSH_CHVT_FLAG
#ifdef MKSH_SMALL
@ -52,7 +52,7 @@ static const unsigned char *pat_scan(const unsigned char *,
const unsigned char *, bool);
static int do_gmatch(const unsigned char *, const unsigned char *,
const unsigned char *, const unsigned char *);
static const unsigned char *cclass(const unsigned char *, int);
static const unsigned char *cclass(const unsigned char *, unsigned char);
#ifdef KSH_CHVT_CODE
static void chvt(const char *);
#endif
@ -226,13 +226,13 @@ getoptions(void)
/* change a Flag(*) value; takes care of special actions */
void
change_flag(enum sh_flag f, int what, unsigned int newval)
change_flag(enum sh_flag f, int what, bool newset)
{
unsigned char oldval;
unsigned char newval;
oldval = Flag(f);
/* needed for tristates */
Flag(f) = newval ? 1 : 0;
Flag(f) = newval = (newset ? 1 : 0);
#ifndef MKSH_UNEMPLOYED
if (f == FMONITOR) {
if (what != OF_CMDLINE && newval != oldval)
@ -249,7 +249,7 @@ change_flag(enum sh_flag f, int what, unsigned int newval)
Flag(FVI) =
#endif
Flag(FEMACS) = Flag(FGMACS) = 0;
Flag(f) = (unsigned char)newval;
Flag(f) = newval;
} else
#endif
if (f == FPRIVILEGED && oldval && !newval) {
@ -278,12 +278,12 @@ change_flag(enum sh_flag f, int what, unsigned int newval)
#endif
} else if ((f == FPOSIX || f == FSH) && newval) {
Flag(FPOSIX) = Flag(FSH) = Flag(FBRACEEXPAND) = 0;
Flag(f) = (unsigned char)newval;
Flag(f) = newval;
}
/* Changing interactive flag? */
if (f == FTALKING) {
if ((what == OF_CMDLINE || what == OF_SET) && procpid == kshpid)
Flag(FTALKING_I) = (unsigned char)newval;
Flag(FTALKING_I) = newval;
}
}
@ -299,7 +299,8 @@ parse_args(const char **argv,
{
static char cmd_opts[NELEM(options) + 5]; /* o:T:\0 */
static char set_opts[NELEM(options) + 6]; /* A:o;s\0 */
char set, *opts;
bool set;
char *opts;
const char *array = NULL;
Getopt go;
size_t i;
@ -354,7 +355,7 @@ parse_args(const char **argv,
opts = set_opts;
ksh_getopt_reset(&go, GF_ERROR|GF_PLUSOPT);
while ((optc = ksh_getopt(argv, &go, opts)) != -1) {
set = (go.info & GI_PLUS) ? 0 : 1;
set = tobool(!(go.info & GI_PLUS));
switch (optc) {
case 'A':
if (what == OF_FIRSTTIME)
@ -378,7 +379,7 @@ parse_args(const char **argv,
break;
}
i = option(go.optarg);
if ((i != (size_t)-1) && set == Flag(i))
if ((i != (size_t)-1) && (set ? 1U : 0U) == Flag(i))
/*
* Don't check the context if the flag
* isn't changing - makes "set -o interactive"
@ -401,7 +402,7 @@ parse_args(const char **argv,
#ifndef KSH_CHVT_CODE
errorf("no TIOCSCTTY ioctl");
#else
change_flag(FTALKING, OF_CMDLINE, 1);
change_flag(FTALKING, OF_CMDLINE, true);
chvt(go.optarg);
break;
#endif
@ -706,7 +707,7 @@ static int
do_gmatch(const unsigned char *s, const unsigned char *se,
const unsigned char *p, const unsigned char *pe)
{
int sc, pc;
unsigned char sc, pc;
const unsigned char *prest, *psub, *pnext;
const unsigned char *srest;
@ -836,12 +837,13 @@ do_gmatch(const unsigned char *s, const unsigned char *se,
}
static const unsigned char *
cclass(const unsigned char *p, int sub)
cclass(const unsigned char *p, unsigned char sub)
{
int c, d, notp, found = 0;
unsigned char c, d;
bool notp, found = false;
const unsigned char *orig_p = p;
if ((notp = (ISMAGIC(*p) && *++p == '!')))
if ((notp = tobool(ISMAGIC(*p) && *++p == '!')))
p++;
do {
c = *p++;
@ -875,7 +877,7 @@ cclass(const unsigned char *p, int sub)
} else
d = c;
if (c == sub || (c <= sub && sub <= d))
found = 1;
found = true;
} while (!(ISMAGIC(p[0]) && p[1] == ']'));
return ((found != notp) ? p+2 : NULL);