since so many internal things hardcode 'C' locale anyway,
use own is{digit,lower,upper} macros that go via byte ranges doesn't affect utf-8 hack because these only operate on single bytes anyway saves 224t
This commit is contained in:
34
edit.c
34
edit.c
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.69 2006/11/10 06:45:27 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.70 2006/11/10 06:53:25 tg Exp $");
|
||||||
|
|
||||||
/* tty driver characters we are interested in */
|
/* tty driver characters we are interested in */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -3029,7 +3029,7 @@ x_set_arg(int c)
|
|||||||
int first = 1;
|
int first = 1;
|
||||||
|
|
||||||
c &= CHARMASK; /* strip command prefix */
|
c &= CHARMASK; /* strip command prefix */
|
||||||
for (; c >= 0 && isdigit((unsigned char)c); c = x_e_getc(), first = 0)
|
for (; c >= 0 && ksh_isdigit(c); c = x_e_getc(), first = 0)
|
||||||
n = n * 10 + (c - '0');
|
n = n * 10 + (c - '0');
|
||||||
if (c < 0 || first) {
|
if (c < 0 || first) {
|
||||||
x_e_putc2(7);
|
x_e_putc2(7);
|
||||||
@ -3208,26 +3208,20 @@ x_fold_case(int c)
|
|||||||
* a different action than for the rest.
|
* a different action than for the rest.
|
||||||
*/
|
*/
|
||||||
if (cp != xep) {
|
if (cp != xep) {
|
||||||
if (c == 'L') { /* lowercase */
|
if (c == 'L') /* lowercase */
|
||||||
if (isupper((unsigned char)*cp))
|
*cp = _tolower((unsigned char)*cp);
|
||||||
*cp = _tolower((unsigned char)*cp);
|
else /* uppercase, capitalise */
|
||||||
} else { /* uppercase, capitalise */
|
*cp = _toupper((unsigned char)*cp);
|
||||||
if (islower((unsigned char)*cp))
|
|
||||||
*cp = _toupper((unsigned char)*cp);
|
|
||||||
}
|
|
||||||
cp++;
|
cp++;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* now for the rest of the word
|
* now for the rest of the word
|
||||||
*/
|
*/
|
||||||
while (cp != xep && !is_mfs(*cp)) {
|
while (cp != xep && !is_mfs(*cp)) {
|
||||||
if (c == 'U') { /* uppercase */
|
if (c == 'U') /* uppercase */
|
||||||
if (islower((unsigned char)*cp))
|
*cp = _toupper((unsigned char)*cp);
|
||||||
*cp = _toupper((unsigned char)*cp);
|
else /* lowercase, capitalise */
|
||||||
} else { /* lowercase, capitalise */
|
*cp = _tolower((unsigned char)*cp);
|
||||||
if (isupper((unsigned char)*cp))
|
|
||||||
*cp = _tolower((unsigned char)*cp);
|
|
||||||
}
|
|
||||||
cp++;
|
cp++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3661,7 +3655,7 @@ vi_hook(int ch)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case VARG1:
|
case VARG1:
|
||||||
if (isdigit((unsigned char)ch))
|
if (ksh_isdigit(ch))
|
||||||
argc1 = argc1 * 10 + ch - '0';
|
argc1 = argc1 * 10 + ch - '0';
|
||||||
else {
|
else {
|
||||||
curcmd[cmdlen++] = ch;
|
curcmd[cmdlen++] = ch;
|
||||||
@ -3687,7 +3681,7 @@ vi_hook(int ch)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case VARG2:
|
case VARG2:
|
||||||
if (isdigit((unsigned char)ch))
|
if (ksh_isdigit(ch))
|
||||||
argc2 = argc2 * 10 + ch - '0';
|
argc2 = argc2 * 10 + ch - '0';
|
||||||
else {
|
else {
|
||||||
if (argc1 == 0)
|
if (argc1 == 0)
|
||||||
@ -4431,11 +4425,11 @@ vi_cmd(int argcnt, const char *cmd)
|
|||||||
return -1;
|
return -1;
|
||||||
for (i = 0; i < argcnt; i++) {
|
for (i = 0; i < argcnt; i++) {
|
||||||
p = &es->cbuf[es->cursor];
|
p = &es->cbuf[es->cursor];
|
||||||
if (islower((unsigned char)*p)) {
|
if (ksh_islower((unsigned char)*p)) {
|
||||||
modified = 1;
|
modified = 1;
|
||||||
hnum = hlast;
|
hnum = hlast;
|
||||||
*p = _toupper((unsigned char)*p);
|
*p = _toupper((unsigned char)*p);
|
||||||
} else if (isupper((unsigned char)*p)) {
|
} else if (ksh_isupper((unsigned char)*p)) {
|
||||||
modified = 1;
|
modified = 1;
|
||||||
hnum = hlast;
|
hnum = hlast;
|
||||||
*p = _tolower((unsigned char)*p);
|
*p = _tolower((unsigned char)*p);
|
||||||
|
4
funcs.c
4
funcs.c
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.34 2006/11/10 06:16:24 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.35 2006/11/10 06:53:26 tg Exp $");
|
||||||
|
|
||||||
int
|
int
|
||||||
c_cd(char **wp)
|
c_cd(char **wp)
|
||||||
@ -1104,7 +1104,7 @@ c_kill(char **wp)
|
|||||||
|
|
||||||
/* assume old style options if -digits or -UPPERCASE */
|
/* assume old style options if -digits or -UPPERCASE */
|
||||||
if ((p = wp[1]) && *p == '-' && (digit(p[1]) ||
|
if ((p = wp[1]) && *p == '-' && (digit(p[1]) ||
|
||||||
isupper((unsigned char)p[1]))) {
|
ksh_isupper((unsigned char)p[1]))) {
|
||||||
if (!(t = gettrap(p + 1, true))) {
|
if (!(t = gettrap(p + 1, true))) {
|
||||||
bi_errorf("bad signal '%s'", p + 1);
|
bi_errorf("bad signal '%s'", p + 1);
|
||||||
return 1;
|
return 1;
|
||||||
|
4
main.c
4
main.c
@ -13,7 +13,7 @@
|
|||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.58 2006/11/10 06:31:47 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/main.c,v 1.59 2006/11/10 06:53:26 tg Exp $");
|
||||||
|
|
||||||
extern char **environ;
|
extern char **environ;
|
||||||
|
|
||||||
@ -954,7 +954,7 @@ check_fd(char *name, int mode, const char **emsgp)
|
|||||||
{
|
{
|
||||||
int fd, fl;
|
int fd, fl;
|
||||||
|
|
||||||
if (isdigit((unsigned char)name[0]) && !name[1]) {
|
if (ksh_isdigit(name[0]) && !name[1]) {
|
||||||
fd = name[0] - '0';
|
fd = name[0] - '0';
|
||||||
if ((fl = fcntl(fd = name[0] - '0', F_GETFL, 0)) < 0) {
|
if ((fl = fcntl(fd = name[0] - '0', F_GETFL, 0)) < 0) {
|
||||||
if (emsgp)
|
if (emsgp)
|
||||||
|
4
misc.c
4
misc.c
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.35 2006/11/10 06:27:09 tg Exp $\t"
|
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.36 2006/11/10 06:53:27 tg Exp $\t"
|
||||||
MKSH_SH_H_ID);
|
MKSH_SH_H_ID);
|
||||||
|
|
||||||
#undef USE_CHVT
|
#undef USE_CHVT
|
||||||
@ -437,7 +437,7 @@ getn(const char *s, int *ai)
|
|||||||
c = *s++;
|
c = *s++;
|
||||||
*ai = i = 0;
|
*ai = i = 0;
|
||||||
do {
|
do {
|
||||||
if (!isdigit(c))
|
if (!ksh_isdigit(c))
|
||||||
goto getn_out;
|
goto getn_out;
|
||||||
i *= 10;
|
i *= 10;
|
||||||
if (i < *ai)
|
if (i < *ai)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/** $MirOS: src/bin/mksh/setmode.c,v 1.6 2006/11/09 22:51:49 tg Exp $ */
|
/** $MirOS: src/bin/mksh/setmode.c,v 1.7 2006/11/10 06:53:27 tg Exp $ */
|
||||||
/** _MirOS: src/lib/libc/gen/setmode.c,v 1.6 2006/11/08 23:18:04 tg Exp $ */
|
/** _MirOS: src/lib/libc/gen/setmode.c,v 1.6 2006/11/08 23:18:04 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.6 2006/11/09 22:51:49 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/setmode.c,v 1.7 2006/11/10 06:53:27 tg Exp $");
|
||||||
|
|
||||||
#define SET_LEN 6 /* initial # of bitcmd struct to malloc */
|
#define SET_LEN 6 /* initial # of bitcmd struct to malloc */
|
||||||
#define SET_LEN_INCR 4 /* # of bitcmd structs to add as needed */
|
#define SET_LEN_INCR 4 /* # of bitcmd structs to add as needed */
|
||||||
@ -210,7 +210,7 @@ setmode(const char *p)
|
|||||||
* If an absolute number, get it and return; disallow non-octal digits
|
* If an absolute number, get it and return; disallow non-octal digits
|
||||||
* or illegal bits.
|
* or illegal bits.
|
||||||
*/
|
*/
|
||||||
if (isdigit((unsigned char)*p)) {
|
if (ksh_isdigit((unsigned char)*p)) {
|
||||||
perml = strtoul(p, &ep, 8);
|
perml = strtoul(p, &ep, 8);
|
||||||
/* The test on perml will also catch overflow. */
|
/* The test on perml will also catch overflow. */
|
||||||
if (*ep != '\0' || (perml & ~(STANDARD_BITS|S_ISTXT))) {
|
if (*ep != '\0' || (perml & ~(STANDARD_BITS|S_ISTXT))) {
|
||||||
|
13
sh.h
13
sh.h
@ -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.77 2006/11/10 06:45:28 tg Exp $"
|
#define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.78 2006/11/10 06:53:27 tg Exp $"
|
||||||
#define MKSH_VERSION "R29 2006/11/10"
|
#define MKSH_VERSION "R29 2006/11/10"
|
||||||
|
|
||||||
#if HAVE_SYS_PARAM_H
|
#if HAVE_SYS_PARAM_H
|
||||||
@ -99,12 +99,11 @@
|
|||||||
} while (0)
|
} while (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef _tolower
|
#define ksh_isdigit(c) (((c) >= '0') && ((c) <= '9'))
|
||||||
#define _tolower(c) (((c) >= 'A') && ((c) <= 'Z') ? (c) - 'A' + 'a' : (c))
|
#define ksh_islower(c) (((c) >= 'a') && ((c) <= 'z'))
|
||||||
#endif
|
#define ksh_isupper(c) (((c) >= 'A') && ((c) <= 'Z'))
|
||||||
#ifndef _toupper
|
#define ksh_tolower(c) (((c) >= 'A') && ((c) <= 'Z') ? (c) - 'A' + 'a' : (c))
|
||||||
#define _toupper(c) (((c) >= 'a') && ((c) <= 'z') ? (c) - 'a' + 'A' : (c))
|
#define ksh_toupper(c) (((c) >= 'a') && ((c) <= 'z') ? (c) - 'a' + 'A' : (c))
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef S_ISTXT
|
#ifndef S_ISTXT
|
||||||
#define S_ISTXT 0001000
|
#define S_ISTXT 0001000
|
||||||
|
18
var.c
18
var.c
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.28 2006/11/10 06:45:28 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.29 2006/11/10 06:53:27 tg Exp $");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Variables
|
* Variables
|
||||||
@ -439,12 +439,12 @@ getint(struct tbl *vp, long int *nump, bool arith)
|
|||||||
num = 0;
|
num = 0;
|
||||||
have_base = 1;
|
have_base = 1;
|
||||||
} else if (letnum(c)) {
|
} else if (letnum(c)) {
|
||||||
if (isdigit(c))
|
if (ksh_isdigit(c))
|
||||||
c -= '0';
|
c -= '0';
|
||||||
else if (islower(c))
|
else if (ksh_islower(c))
|
||||||
c -= 'a' - 10; /* todo: assumes ascii */
|
c -= 'a' - 10;
|
||||||
else if (isupper(c))
|
else if (ksh_isupper(c))
|
||||||
c -= 'A' - 10; /* todo: assumes ascii */
|
c -= 'A' - 10;
|
||||||
else
|
else
|
||||||
c = -1; /* _: force error */
|
c = -1; /* _: force error */
|
||||||
if (c < 0 || c >= base)
|
if (c < 0 || c >= base)
|
||||||
@ -533,12 +533,10 @@ formatstr(struct tbl *vp, const char *s)
|
|||||||
|
|
||||||
if (vp->flag & UCASEV_AL) {
|
if (vp->flag & UCASEV_AL) {
|
||||||
for (q = p; *q; q++)
|
for (q = p; *q; q++)
|
||||||
if (islower((unsigned char)*q))
|
*q = _toupper((unsigned char)*q);
|
||||||
*q = _toupper((unsigned char)*q);
|
|
||||||
} else if (vp->flag & LCASEV) {
|
} else if (vp->flag & LCASEV) {
|
||||||
for (q = p; *q; q++)
|
for (q = p; *q; q++)
|
||||||
if (isupper((unsigned char)*q))
|
*q = _tolower((unsigned char)*q);
|
||||||
*q = _tolower((unsigned char)*q);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
|
Reference in New Issue
Block a user