get rid of u_char, u_int, u_long

This commit is contained in:
tg 2007-10-25 15:23:10 +00:00
parent 3b5bbaefcb
commit 6976ed8bc3
9 changed files with 46 additions and 55 deletions

View File

@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
# $MirOS: src/bin/mksh/Build.sh,v 1.274 2007/10/25 14:26:52 tg Exp $ # $MirOS: src/bin/mksh/Build.sh,v 1.275 2007/10/25 15:23:08 tg Exp $
#- #-
# Environment used: CC CFLAGS CPPFLAGS LDFLAGS LIBS NOWARN NROFF TARGET_OS # Environment used: CC CFLAGS CPPFLAGS LDFLAGS LIBS NOWARN NROFF TARGET_OS
# CPPFLAGS recognised: MKSH_SMALL MKSH_ASSUME_UTF8 MKSH_NOPWNAM MKSH_NOVI # CPPFLAGS recognised: MKSH_SMALL MKSH_ASSUME_UTF8 MKSH_NOPWNAM MKSH_NOVI
@ -660,23 +660,12 @@ ac_testn can_ucbints '!' can_inttypes 1 "for UCB 32-bit integer types" <<-'EOF'
#include <sys/types.h> #include <sys/types.h>
int main(int ac, char **av) { return ((u_int32_t)*av + (int32_t)ac); } int main(int ac, char **av) { return ((u_int32_t)*av + (int32_t)ac); }
EOF EOF
ac_testn can_uinttypes '!' stdint_h 1 "for u_char, u_int, u_long" <<-'EOF'
#include <sys/types.h>
int main(int ac, char **av) { u_int x = (u_int)**av;
return (x == (u_int)(u_long)(u_char)ac);
}
EOF
case $HAVE_CAN_INTTYPES$HAVE_CAN_UCBINTS in case $HAVE_CAN_INTTYPES$HAVE_CAN_UCBINTS in
01) HAVE_U_INT32_T=1 01) HAVE_U_INT32_T=1
echo 'typedef u_int32_t uint32_t;' >>stdint.h ;; echo 'typedef u_int32_t uint32_t;' >>stdint.h ;;
00) echo 'typedef signed int int32_t;' >>stdint.h 00) echo 'typedef signed int int32_t;' >>stdint.h
echo 'typedef unsigned int uint32_t;' >>stdint.h ;; echo 'typedef unsigned int uint32_t;' >>stdint.h ;;
esac esac
test 1 = $HAVE_CAN_UINTTYPES || cat >>stdint.h <<-'EOF'
typedef unsigned char u_char;
typedef unsigned int u_int;
typedef unsigned long u_long;
EOF
test -f stdint.h && HAVE_STDINT_H=1 test -f stdint.h && HAVE_STDINT_H=1
ac_cppflags STDINT_H ac_cppflags STDINT_H

45
edit.c
View File

@ -5,7 +5,7 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.116 2007/10/25 15:19:15 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/edit.c,v 1.117 2007/10/25 15:23:08 tg Exp $");
/* tty driver characters we are interested in */ /* tty driver characters we are interested in */
typedef struct { typedef struct {
@ -762,20 +762,21 @@ static void utf_ptradj(char *, char **);
/* UTF-8 hack: high-level functions */ /* UTF-8 hack: high-level functions */
#if HAVE_EXPSTMT #if HAVE_EXPSTMT
#define utf_backch(c) (!Flag(FUTFHACK) ? (c) - 1 : ({ \ #define utf_backch(c) (!Flag(FUTFHACK) ? (c) - 1 : ({ \
u_char *utf_backch_cp = (u_char *)(c); \ unsigned char *utf_backch_cp = (unsigned char *)(c); \
--utf_backch_cp; \ --utf_backch_cp; \
while ((*utf_backch_cp >= 0x80) && \ while ((*utf_backch_cp >= 0x80) && \
(*utf_backch_cp < 0xC0)) \ (*utf_backch_cp < 0xC0)) \
--utf_backch_cp; \ --utf_backch_cp; \
(__typeof__ (c))utf_backch_cp; \ (__typeof__ (c))utf_backch_cp; \
})) }))
#else #else
#define utf_backch(c) (!Flag(FUTFHACK) ? (c) - 1 : \ #define utf_backch(c) (!Flag(FUTFHACK) ? (c) - 1 : \
(c) + (ptrdiff_t)(utf_backch_((u_char *)c) - ((u_char *)(c)))) (c) + (ptrdiff_t)(utf_backch_((unsigned char *)c) - \
static u_char *utf_backch_(u_char *); ((unsigned char *)(c))))
static u_char * static unsigned char *utf_backch_(unsigned char *);
utf_backch_(u_char *utf_backch_cp) static unsigned char *
utf_backch_(unsigned char *utf_backch_cp)
{ {
--utf_backch_cp; --utf_backch_cp;
while ((*utf_backch_cp >= 0x80) && (*utf_backch_cp < 0xC0)) while ((*utf_backch_cp >= 0x80) && (*utf_backch_cp < 0xC0))
@ -1085,8 +1086,8 @@ static int xlp_valid;
static char **x_histp; /* history position */ static char **x_histp; /* history position */
static int x_nextcmd; /* for newline-and-next */ static int x_nextcmd; /* for newline-and-next */
static char *xmp; /* mark pointer */ static char *xmp; /* mark pointer */
static u_char x_last_command; static unsigned char x_last_command;
static u_char (*x_tab)[X_TABSZ]; /* key definition */ static unsigned char (*x_tab)[X_TABSZ]; /* key definition */
static char *(*x_atab)[X_TABSZ]; /* macro definitions */ static char *(*x_atab)[X_TABSZ]; /* macro definitions */
static unsigned char x_bound[(X_TABSZ * X_NTABS + 7) / 8]; static unsigned char x_bound[(X_TABSZ * X_NTABS + 7) / 8];
#define KILLSIZE 20 #define KILLSIZE 20
@ -1455,7 +1456,7 @@ static int
x_emacs(char *buf, size_t len) x_emacs(char *buf, size_t len)
{ {
int c, i; int c, i;
u_char f; unsigned char f;
xbp = xbuf = buf; xend = buf + len; xbp = xbuf = buf; xend = buf + len;
xlp = xcp = xep = buf; xlp = xcp = xep = buf;
@ -1862,7 +1863,7 @@ x_size2(char *cp, char **dcp)
if (c == '\t') if (c == '\t')
return 4; /* Kludge, tabs are always four spaces. */ return 4; /* Kludge, tabs are always four spaces. */
if (c < ' ' || c == 0x7f) if (c < ' ' || c == 0x7f)
return 2; /* control u_char */ return 2; /* control unsigned char */
return 1; return 1;
} }
@ -2105,7 +2106,7 @@ x_search_hist(int c)
int offset = -1; /* offset of match in xbuf, else -1 */ int offset = -1; /* offset of match in xbuf, else -1 */
char pat[256 + 1]; /* pattern buffer */ char pat[256 + 1]; /* pattern buffer */
char *p = pat; char *p = pat;
u_char f; unsigned char f;
*p = '\0'; *p = '\0';
while (1) { while (1) {
@ -2569,7 +2570,7 @@ x_bind(const char *a1, const char *a2,
int macro, /* bind -m */ int macro, /* bind -m */
int list) /* bind -l */ int list) /* bind -l */
{ {
u_char f; unsigned char f;
int prefix, key; int prefix, key;
char *sp = NULL; char *sp = NULL;
char *m1, *m2; char *m1, *m2;
@ -2601,7 +2602,7 @@ x_bind(const char *a1, const char *a2,
m2 = m1 = x_mapin(a1, ATEMP); m2 = m1 = x_mapin(a1, ATEMP);
prefix = key = 0; prefix = key = 0;
for (;; m1++) { for (;; m1++) {
key = (u_char)*m1; key = (unsigned char)*m1;
f = x_tab[prefix][key] & 0x7F; f = x_tab[prefix][key] & 0x7F;
if (f == XFUNC_meta1) if (f == XFUNC_meta1)
prefix = 1; prefix = 1;
@ -2667,7 +2668,7 @@ x_init_emacs(void)
ainit(AEDIT); ainit(AEDIT);
x_nextcmd = -1; x_nextcmd = -1;
x_tab = (u_char (*)[X_TABSZ])alloc(sizeofN(*x_tab, X_NTABS), AEDIT); x_tab = (unsigned char (*)[X_TABSZ])alloc(sizeofN(*x_tab, X_NTABS), AEDIT);
for (j = 0; j < X_TABSZ; j++) for (j = 0; j < X_TABSZ; j++)
x_tab[0][j] = XFUNC_insert; x_tab[0][j] = XFUNC_insert;
for (i = 1; i < X_NTABS; i++) for (i = 1; i < X_NTABS; i++)
@ -2921,7 +2922,7 @@ x_e_getc(void)
c = unget_char; c = unget_char;
unget_char = -1; unget_char = -1;
} else if (macroptr) { } else if (macroptr) {
c = (u_char)*macroptr++; c = (unsigned char)*macroptr++;
if (!*macroptr) if (!*macroptr)
macroptr = NULL; macroptr = NULL;
} else } else

View File

@ -5,7 +5,7 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.66 2007/10/18 20:32:32 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.67 2007/10/25 15:23:09 tg Exp $");
/* A leading = means assignments before command are kept; /* A leading = means assignments before command are kept;
* a leading * means a POSIX special builtin; * a leading * means a POSIX special builtin;
@ -903,7 +903,7 @@ c_typeset(const char **wp)
if ((vp->flag&ARRAY) && any_set) if ((vp->flag&ARRAY) && any_set)
shprintf("%s[%lu]", shprintf("%s[%lu]",
vp->name, vp->name,
(u_long)vp->index); (unsigned long)vp->index);
else else
shprintf("%s", vp->name); shprintf("%s", vp->name);
if (thing == '-' && (vp->flag&ISSET)) { if (thing == '-' && (vp->flag&ISSET)) {

4
jobs.c
View File

@ -2,7 +2,7 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/jobs.c,v 1.31 2007/10/25 14:18:56 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/jobs.c,v 1.32 2007/10/25 15:23:09 tg Exp $");
/* Order important! */ /* Order important! */
#define PRUNNING 0 #define PRUNNING 0
@ -372,7 +372,7 @@ exchild(struct op *t, int flags, /* used if XPCLOSE or XCCLOSE */ int close_fd)
p->pid = i; p->pid = i;
/* Ensure next child gets a (slightly) different $RANDOM sequence */ /* Ensure next child gets a (slightly) different $RANDOM sequence */
change_random(((u_long)p->pid << 1) | (ischild ? 1 : 0)); change_random(((unsigned long)p->pid << 1) | (ischild ? 1 : 0));
/* job control set up */ /* job control set up */
if (Flag(FMONITOR) && !(flags&XXCOM)) { if (Flag(FMONITOR) && !(flags&XXCOM)) {

5
main.c
View File

@ -13,7 +13,7 @@
#include <locale.h> #include <locale.h>
#endif #endif
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.88 2007/10/25 15:19:16 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/main.c,v 1.89 2007/10/25 15:23:10 tg Exp $");
extern char **environ; extern char **environ;
@ -221,7 +221,8 @@ main(int argc, const char *argv[])
setstr(pwd_v, current_wd, KSH_RETURN_ERROR); setstr(pwd_v, current_wd, KSH_RETURN_ERROR);
} }
ppid = getppid(); ppid = getppid();
change_random(((u_long)kshname) ^ ((u_long)time(NULL) * kshpid * ppid)); change_random(((unsigned long)kshname) ^
((unsigned long)time(NULL) * kshpid * ppid));
#if HAVE_ARC4RANDOM #if HAVE_ARC4RANDOM
Flag(FARC4RANDOM) = 2; /* use arc4random(3) until $RANDOM is written */ Flag(FARC4RANDOM) = 2; /* use arc4random(3) until $RANDOM is written */
#endif #endif

View File

@ -1,5 +1,5 @@
/** $MirOS: src/bin/mksh/setmode.c,v 1.8 2007/03/04 03:47:37 tg Exp $ */ /** $MirOS: src/bin/mksh/setmode.c,v 1.9 2007/10/25 15:23:10 tg Exp $ */
/** $miros: src/lib/libc/gen/setmode.c,v 1.8 2007/03/04 03:47:14 tg Exp $ */ /** $miros: src/lib/libc/gen/setmode.c,v 1.9 2007/10/25 15:13:39 tg Exp $ */
/* $OpenBSD: setmode.c,v 1.17 2005/08/08 08:05:34 espie Exp $ */ /* $OpenBSD: setmode.c,v 1.17 2005/08/08 08:05:34 espie Exp $ */
/* $NetBSD: setmode.c,v 1.15 1997/02/07 22:21:06 christos Exp $ */ /* $NetBSD: setmode.c,v 1.15 1997/02/07 22:21:06 christos Exp $ */
@ -58,7 +58,7 @@
#endif #endif
__SCCSID("@(#)setmode.c 8.2 (Berkeley) 3/25/94"); __SCCSID("@(#)setmode.c 8.2 (Berkeley) 3/25/94");
__RCSID("$MirOS: src/bin/mksh/setmode.c,v 1.8 2007/03/04 03:47:37 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/setmode.c,v 1.9 2007/10/25 15:23:10 tg Exp $");
/* for mksh */ /* for mksh */
#ifdef ksh_isdigit #ifdef ksh_isdigit
@ -81,7 +81,7 @@ typedef struct bitcmd {
#define CMD2_OBITS 0x08 #define CMD2_OBITS 0x08
#define CMD2_UBITS 0x10 #define CMD2_UBITS 0x10
static BITCMD *addcmd(BITCMD *, int, int, int, u_int); static BITCMD *addcmd(BITCMD *, int, int, int, unsigned);
static void compress_mode(BITCMD *); static void compress_mode(BITCMD *);
#ifdef SETMODE_DEBUG #ifdef SETMODE_DEBUG
static void dumpmode(BITCMD *); static void dumpmode(BITCMD *);
@ -188,7 +188,7 @@ setmode(const char *p)
sigset_t signset, sigoset; sigset_t signset, sigoset;
mode_t mask; mode_t mask;
int equalopdone = 0, permXbits, setlen; int equalopdone = 0, permXbits, setlen;
u_long perml; unsigned long perml;
if (!*p) if (!*p)
return (NULL); return (NULL);
@ -207,7 +207,7 @@ setmode(const char *p)
setlen = SET_LEN + 2; setlen = SET_LEN + 2;
if ((set = malloc((u_int)(sizeof(BITCMD) * setlen))) == NULL) if ((set = calloc(sizeof(BITCMD), setlen)) == NULL)
return (NULL); return (NULL);
saveset = set; saveset = set;
endset = set + (setlen - 2); endset = set + (setlen - 2);
@ -357,7 +357,7 @@ setmode(const char *p)
} }
static BITCMD * static BITCMD *
addcmd(BITCMD *set, int op, int who, int oparg, u_int mask) addcmd(BITCMD *set, int op, int who, int oparg, unsigned mask)
{ {
switch (op) { switch (op) {
case '=': case '=':

4
sh.h
View File

@ -8,7 +8,7 @@
/* $OpenBSD: c_test.h,v 1.4 2004/12/20 11:34:26 otto Exp $ */ /* $OpenBSD: c_test.h,v 1.4 2004/12/20 11:34:26 otto Exp $ */
/* $OpenBSD: tty.h,v 1.5 2004/12/20 11:34:26 otto Exp $ */ /* $OpenBSD: tty.h,v 1.5 2004/12/20 11:34:26 otto Exp $ */
#define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.182 2007/10/25 15:19:16 tg Exp $" #define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.183 2007/10/25 15:23:10 tg Exp $"
#define MKSH_VERSION "R32 2007/10/25" #define MKSH_VERSION "R32 2007/10/25"
#if HAVE_SYS_PARAM_H #if HAVE_SYS_PARAM_H
@ -1490,7 +1490,7 @@ const char *skip_wdvarname(const char *, int);
int is_wdvarname(const char *, int); int is_wdvarname(const char *, int);
int is_wdvarassign(const char *); int is_wdvarassign(const char *);
char **makenv(void); char **makenv(void);
void change_random(u_long); void change_random(unsigned long);
int array_ref_len(const char *); int array_ref_len(const char *);
char *arrayname(const char *); char *arrayname(const char *);
void set_array(const char *, int, const char **); void set_array(const char *, int, const char **);

4
shf.c
View File

@ -2,7 +2,7 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/shf.c,v 1.15 2007/06/06 23:28:17 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/shf.c,v 1.16 2007/10/25 15:23:10 tg Exp $");
/* flags to shf_emptybuf() */ /* flags to shf_emptybuf() */
#define EB_READSW 0x01 /* about to switch to reading */ #define EB_READSW 0x01 /* about to switch to reading */
@ -553,7 +553,7 @@ shf_putchar(int c, struct shf *shf)
return EOF; return EOF;
if (shf->flags & SHF_UNBUF) { if (shf->flags & SHF_UNBUF) {
u_char cc = (u_char)c; unsigned char cc = (unsigned char)c;
int n; int n;
if (shf->fd < 0) if (shf->fd < 0)

8
var.c
View File

@ -2,7 +2,7 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.48 2007/10/25 14:26:53 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/var.c,v 1.49 2007/10/25 15:23:10 tg Exp $");
/* /*
* Variables * Variables
@ -25,7 +25,7 @@ static void unsetspec(struct tbl *);
static struct tbl *arraysearch(struct tbl *, uint32_t); static struct tbl *arraysearch(struct tbl *, uint32_t);
static const char *array_index_calc(const char *, bool *, uint32_t *); static const char *array_index_calc(const char *, bool *, uint32_t *);
static int rnd_get(void); static int rnd_get(void);
static void rnd_set(u_long); static void rnd_set(unsigned long);
/* /*
* create a new block for function calls and simple commands * create a new block for function calls and simple commands
@ -902,7 +902,7 @@ rnd_get(void)
} }
static void static void
rnd_set(u_long newval) rnd_set(unsigned long newval)
{ {
#if HAVE_ARC4RANDOM #if HAVE_ARC4RANDOM
rnd_cache[0] ^= (newval << 15) | rand(); rnd_cache[0] ^= (newval << 15) | rand();
@ -923,7 +923,7 @@ rnd_set(u_long newval)
* if the parent doesn't use $RANDOM. * if the parent doesn't use $RANDOM.
*/ */
void void
change_random(u_long newval) change_random(unsigned long newval)
{ {
int rval = 0; int rval = 0;