use tolower_() and toupper_() macros (if not available, our quick 'C' ones)

76t 8d 2i
This commit is contained in:
tg 2006-11-10 06:45:28 +00:00
parent ca2b1d88ca
commit b323a22b59
3 changed files with 22 additions and 15 deletions

20
edit.c
View File

@ -5,7 +5,7 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/edit.c,v 1.68 2006/11/10 06:40:04 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/edit.c,v 1.69 2006/11/10 06:45:27 tg Exp $");
/* tty driver characters we are interested in */ /* tty driver characters we are interested in */
typedef struct { typedef struct {
@ -3183,7 +3183,7 @@ x_fold_capitalize(int c __attribute__((unused)))
* *
* DESCRIPTION: * DESCRIPTION:
* This function is used to implement M-U,M-u,M-L,M-l,M-C and M-c * This function is used to implement M-U,M-u,M-L,M-l,M-C and M-c
* to UPPER case, lower case or Capitalize words. * to UPPER case, lower case or Capitalise words.
* *
* RETURN VALUE: * RETURN VALUE:
* None * None
@ -3210,10 +3210,10 @@ x_fold_case(int c)
if (cp != xep) { if (cp != xep) {
if (c == 'L') { /* lowercase */ if (c == 'L') { /* lowercase */
if (isupper((unsigned char)*cp)) if (isupper((unsigned char)*cp))
*cp = tolower((unsigned char)*cp); *cp = _tolower((unsigned char)*cp);
} else { /* uppercase, capitalize */ } else { /* uppercase, capitalise */
if (islower((unsigned char)*cp)) if (islower((unsigned char)*cp))
*cp = toupper((unsigned char)*cp); *cp = _toupper((unsigned char)*cp);
} }
cp++; cp++;
} }
@ -3223,10 +3223,10 @@ x_fold_case(int c)
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)) if (islower((unsigned char)*cp))
*cp = toupper((unsigned char)*cp); *cp = _toupper((unsigned char)*cp);
} else { /* lowercase, capitalize */ } else { /* lowercase, capitalise */
if (isupper((unsigned char)*cp)) if (isupper((unsigned char)*cp))
*cp = tolower((unsigned char)*cp); *cp = _tolower((unsigned char)*cp);
} }
cp++; cp++;
} }
@ -4434,11 +4434,11 @@ vi_cmd(int argcnt, const char *cmd)
if (islower((unsigned char)*p)) { if (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 (isupper((unsigned char)*p)) {
modified = 1; modified = 1;
hnum = hlast; hnum = hlast;
*p = tolower((unsigned char)*p); *p = _tolower((unsigned char)*p);
} }
if (es->cursor < es->linelen - 1) if (es->cursor < es->linelen - 1)
es->cursor++; es->cursor++;

9
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.76 2006/11/10 06:27:09 tg 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_VERSION "R29 2006/11/10" #define MKSH_VERSION "R29 2006/11/10"
#if HAVE_SYS_PARAM_H #if HAVE_SYS_PARAM_H
@ -99,6 +99,13 @@
} while (0) } while (0)
#endif #endif
#ifndef _tolower
#define _tolower(c) (((c) >= 'A') && ((c) <= 'Z') ? (c) - 'A' + 'a' : (c))
#endif
#ifndef _toupper
#define _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
#endif #endif

8
var.c
View File

@ -2,7 +2,7 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/var.c,v 1.27 2006/11/10 06:16:25 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/var.c,v 1.28 2006/11/10 06:45:28 tg Exp $");
/* /*
* Variables * Variables
@ -75,7 +75,7 @@ popblock(void)
afree(l, ATEMP); afree(l, ATEMP);
} }
/* called by main() to initialize variable data structures */ /* called by main() to initialise variable data structures */
void void
initvar(void) initvar(void)
{ {
@ -534,11 +534,11 @@ 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)) 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)) if (isupper((unsigned char)*q))
*q = tolower((unsigned char)*q); *q = _tolower((unsigned char)*q);
} }
return p; return p;