mirror of
https://github.com/rfivet/uemacs.git
synced 2024-12-18 07:16:23 -05:00
Review macroes for character classification.
This commit is contained in:
parent
e11ed9187f
commit
9c1ec4fdf8
8
Makefile
8
Makefile
@ -161,7 +161,7 @@ file.o: file.c file.h buffer.h line.h retcode.h utf8.h defines.h \
|
|||||||
fileio.o: fileio.c fileio.h defines.h retcode.h utf8.h
|
fileio.o: fileio.c fileio.h defines.h retcode.h utf8.h
|
||||||
flook.o: flook.c flook.h retcode.h defines.h fileio.h
|
flook.o: flook.c flook.h retcode.h defines.h fileio.h
|
||||||
input.o: input.c input.h bind.h estruct.h bindable.h display.h utf8.h \
|
input.o: input.c input.h bind.h estruct.h bindable.h display.h utf8.h \
|
||||||
exec.h retcode.h names.h terminal.h defines.h wrapper.h
|
exec.h retcode.h isa.h names.h terminal.h defines.h wrapper.h
|
||||||
isearch.o: isearch.c isearch.h basic.h retcode.h buffer.h line.h utf8.h \
|
isearch.o: isearch.c isearch.h basic.h retcode.h buffer.h line.h utf8.h \
|
||||||
display.h estruct.h exec.h input.h bind.h search.h terminal.h defines.h \
|
display.h estruct.h exec.h input.h bind.h search.h terminal.h defines.h \
|
||||||
util.h window.h
|
util.h window.h
|
||||||
@ -184,8 +184,8 @@ random.o: random.c random.h retcode.h basic.h buffer.h line.h utf8.h \
|
|||||||
region.o: region.c region.h line.h retcode.h utf8.h buffer.h estruct.h \
|
region.o: region.c region.h line.h retcode.h utf8.h buffer.h estruct.h \
|
||||||
mlout.h random.h window.h defines.h
|
mlout.h random.h window.h defines.h
|
||||||
search.o: search.c search.h line.h retcode.h utf8.h basic.h buffer.h \
|
search.o: search.c search.h line.h retcode.h utf8.h basic.h buffer.h \
|
||||||
display.h estruct.h input.h bind.h mlout.h terminal.h defines.h util.h \
|
display.h estruct.h input.h bind.h isa.h mlout.h terminal.h defines.h \
|
||||||
window.h
|
util.h window.h
|
||||||
spawn.o: spawn.c spawn.h defines.h buffer.h line.h retcode.h utf8.h \
|
spawn.o: spawn.c spawn.h defines.h buffer.h line.h retcode.h utf8.h \
|
||||||
display.h estruct.h exec.h file.h flook.h input.h bind.h terminal.h \
|
display.h estruct.h exec.h file.h flook.h input.h bind.h terminal.h \
|
||||||
window.h
|
window.h
|
||||||
@ -197,7 +197,7 @@ util.o: util.c util.h
|
|||||||
window.o: window.c window.h defines.h buffer.h line.h retcode.h utf8.h \
|
window.o: window.c window.h defines.h buffer.h line.h retcode.h utf8.h \
|
||||||
basic.h display.h estruct.h execute.h terminal.h wrapper.h
|
basic.h display.h estruct.h execute.h terminal.h wrapper.h
|
||||||
word.o: word.c word.h basic.h retcode.h buffer.h line.h utf8.h estruct.h \
|
word.o: word.c word.h basic.h retcode.h buffer.h line.h utf8.h estruct.h \
|
||||||
mlout.h random.h region.h window.h defines.h
|
isa.h mlout.h random.h region.h window.h defines.h
|
||||||
wrapper.o: wrapper.c wrapper.h
|
wrapper.o: wrapper.c wrapper.h
|
||||||
wscreen.o: wscreen.c wscreen.h
|
wscreen.o: wscreen.c wscreen.h
|
||||||
|
|
||||||
|
73
estruct.h
73
estruct.h
@ -124,23 +124,13 @@
|
|||||||
|
|
||||||
#define CLEAN 0 /* de-alloc memory on exit */
|
#define CLEAN 0 /* de-alloc memory on exit */
|
||||||
|
|
||||||
#define ASCII 1 /* always using ASCII char sequences for now */
|
|
||||||
#define EBCDIC 0 /* later IBM mainfraim versions will use EBCDIC */
|
|
||||||
|
|
||||||
#ifndef AUTOCONF
|
#ifndef AUTOCONF
|
||||||
|
# define XONXOFF 0 /* don't disable XON-XOFF flow control P.K. */
|
||||||
#define XONXOFF 0 /* don't disable XON-XOFF flow control P.K. */
|
|
||||||
#define NATIONL 0 /* interprete [,],\,{,},| as characters P.K. */
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
# define XONXOFF UNIX
|
||||||
#define XONXOFF UNIX
|
|
||||||
#define NATIONL UNIX
|
|
||||||
|
|
||||||
#endif /* Autoconf. */
|
#endif /* Autoconf. */
|
||||||
|
|
||||||
#define PKCODE 1 /* include my extensions P.K., define always */
|
#define PKCODE 1 /* include my extensions P.K., define always */
|
||||||
#define IBMCHR MSDOS /* use IBM PC character set P.K. */
|
|
||||||
#define SCROLLCODE 1 /* scrolling code P.K. */
|
#define SCROLLCODE 1 /* scrolling code P.K. */
|
||||||
|
|
||||||
/* Define some ability flags. */
|
/* Define some ability flags. */
|
||||||
@ -157,65 +147,6 @@
|
|||||||
# define ENVFUNC 0
|
# define ENVFUNC 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* DIFCASE represents the integer difference between upper
|
|
||||||
and lower case letters. It is an xor-able value, which is
|
|
||||||
fortunate, since the relative positions of upper to lower
|
|
||||||
case letters is the opposite of ascii in ebcdic.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef islower
|
|
||||||
#undef islower
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if PKCODE
|
|
||||||
#ifdef isupper
|
|
||||||
#undef isupper
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if ASCII
|
|
||||||
|
|
||||||
#define DIFCASE 0x20
|
|
||||||
|
|
||||||
#if NATIONL
|
|
||||||
#define LASTUL ']'
|
|
||||||
#define LASTLL '}'
|
|
||||||
#else
|
|
||||||
#define LASTUL 'Z'
|
|
||||||
#define LASTLL 'z'
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if IBMCHR
|
|
||||||
|
|
||||||
#define isletter(c) (('a' <= c && LASTLL >= c) || ('A' <= c && LASTUL >= c) || (128<=c && c<=167))
|
|
||||||
#define islower(c) (('a' <= c && LASTLL >= c))
|
|
||||||
#define isupper(c) (('A' <= c && LASTUL >= c))
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
#define isletter(c) __isxletter((0xFF & (c)))
|
|
||||||
#define islower(c) isxlower((0xFF & (c)))
|
|
||||||
#define isupper(c) isxupper((0xFF & (c)))
|
|
||||||
|
|
||||||
#define __isxletter(c) (('a' <= c && LASTLL >= c) || ('A' <= c && LASTUL >= c) || (192<=c /* && c<=255 */))
|
|
||||||
#define isxlower(c) (('a' <= c && LASTLL >= c) || (224 <= c && 252 >= c))
|
|
||||||
#define isxupper(c) (('A' <= c && LASTUL >= c) || (192 <= c && 220 >= c))
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if EBCDIC
|
|
||||||
|
|
||||||
#define DIFCASE 0x40
|
|
||||||
#define isletter(c) (('a' <= c && 'i' >= c) || ('j' <= c && 'r' >= c) || ('s' <= c && 'z' >= c) || ('A' <= c && 'I' >= c) || ('J' <= c && 'R' >= c) || ('S' <= c && 'Z' >= c))
|
|
||||||
#define islower(c) (('a' <= c && 'i' >= c) || ('j' <= c && 'r' >= c) || ('s' <= c && 'z' >= c))
|
|
||||||
#if PKCODE
|
|
||||||
#define isupper(c) (('A' <= c && 'I' >= c) || ('J' <= c && 'R' >= c) || ('S' <= c && 'Z' >= c))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Dynamic RAM tracking and reporting redefinitions */
|
/* Dynamic RAM tracking and reporting redefinitions */
|
||||||
|
|
||||||
#if RAMSIZE
|
#if RAMSIZE
|
||||||
|
13
input.c
13
input.c
@ -19,6 +19,7 @@
|
|||||||
#include "bindable.h"
|
#include "bindable.h"
|
||||||
#include "display.h"
|
#include "display.h"
|
||||||
#include "exec.h"
|
#include "exec.h"
|
||||||
|
#include "isa.h"
|
||||||
#include "names.h"
|
#include "names.h"
|
||||||
#include "terminal.h"
|
#include "terminal.h"
|
||||||
#include "utf8.h"
|
#include "utf8.h"
|
||||||
@ -427,9 +428,9 @@ handle_CSI:
|
|||||||
goto proc_metac;
|
goto proc_metac;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (islower(c)) /* Force to upper */
|
if( islower( c)) /* Force to upper */
|
||||||
c ^= DIFCASE;
|
c = flipcase( c) ;
|
||||||
if (c >= 0x00 && c <= 0x1F) /* control key */
|
else if( c >= 0x00 && c <= 0x1F) /* control key */
|
||||||
c = CONTROL | (c + '@');
|
c = CONTROL | (c + '@');
|
||||||
return META | c;
|
return META | c;
|
||||||
}
|
}
|
||||||
@ -442,9 +443,9 @@ handle_CSI:
|
|||||||
goto proc_metac;
|
goto proc_metac;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (islower(c)) /* Force to upper */
|
if( islower( c)) /* Force to upper */
|
||||||
c ^= DIFCASE;
|
c = flipcase( c) ;
|
||||||
if (c >= 0x00 && c <= 0x1F) /* control key */
|
else if( c >= 0x00 && c <= 0x1F) /* control key */
|
||||||
c = CONTROL | (c + '@');
|
c = CONTROL | (c + '@');
|
||||||
return META | c;
|
return META | c;
|
||||||
}
|
}
|
||||||
|
44
isa.h
Normal file
44
isa.h
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/* isa.h -- isletter, islower, isupper, flipcase */
|
||||||
|
|
||||||
|
#ifndef __ISA_H__
|
||||||
|
#define __ISA_H__
|
||||||
|
|
||||||
|
#define NATIONL 0 /* if 1, interpret [,],\,{,},| as characters P.K. */
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef islower
|
||||||
|
#undef islower
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef isupper
|
||||||
|
#undef isupper
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if NATIONL
|
||||||
|
#define LASTUL ']'
|
||||||
|
#define LASTLL '}'
|
||||||
|
#else
|
||||||
|
#define LASTUL 'Z'
|
||||||
|
#define LASTLL 'z'
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define isletter(c) __isxletter((0xFF & (c)))
|
||||||
|
#define islower(c) isxlower((0xFF & (c)))
|
||||||
|
#define isupper(c) isxupper((0xFF & (c)))
|
||||||
|
|
||||||
|
#define __isxletter(c) (('a' <= c && LASTLL >= c) || ('A' <= c && LASTUL >= c) || (192<=c /* && c<=255 */))
|
||||||
|
#define isxlower(c) (('a' <= c && LASTLL >= c) || (224 <= c && 252 >= c))
|
||||||
|
#define isxupper(c) (('A' <= c && LASTUL >= c) || (192 <= c && 220 >= c))
|
||||||
|
|
||||||
|
/* DIFCASE represents the integer difference between upper and lower
|
||||||
|
case letters. It is an xor-able value, which is fortunate, since the
|
||||||
|
relative positions of upper to lower case letters is the opposite of
|
||||||
|
ascii in ebcdic.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define DIFCASE 0x20 /* ASCII 'a' - 'A' */
|
||||||
|
#define flipcase( c) ((c) ^ DIFCASE) /* Toggle the case of a letter. */
|
||||||
|
|
||||||
|
#endif /* __ISA_H__ */
|
||||||
|
|
||||||
|
/* end of isa.h */
|
14
search.c
14
search.c
@ -69,6 +69,7 @@
|
|||||||
#include "display.h"
|
#include "display.h"
|
||||||
#include "estruct.h"
|
#include "estruct.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
|
#include "isa.h"
|
||||||
#include "line.h"
|
#include "line.h"
|
||||||
#include "mlout.h"
|
#include "mlout.h"
|
||||||
#include "terminal.h"
|
#include "terminal.h"
|
||||||
@ -124,7 +125,6 @@ spat_t rpat ; /* replacement pattern */
|
|||||||
#define MC_ESC '\\' /* Escape - suppress meta-meaning. */
|
#define MC_ESC '\\' /* Escape - suppress meta-meaning. */
|
||||||
|
|
||||||
#define BIT(n) (1 << (n)) /* An integer with one bit set. */
|
#define BIT(n) (1 << (n)) /* An integer with one bit set. */
|
||||||
#define CHCASE(c) ((c) ^ DIFCASE) /* Toggle the case of a letter. */
|
|
||||||
|
|
||||||
/* HICHAR - 1 is the largest character we will deal with.
|
/* HICHAR - 1 is the largest character we will deal with.
|
||||||
* HIBYTE represents the number of bytes in the bitmap.
|
* HIBYTE represents the number of bytes in the bitmap.
|
||||||
@ -673,11 +673,11 @@ int scanner(const char *patrn, int direct, int beg_or_end)
|
|||||||
int eq(unsigned char bc, unsigned char pc)
|
int eq(unsigned char bc, unsigned char pc)
|
||||||
{
|
{
|
||||||
if ((curwp->w_bufp->b_mode & MDEXACT) == 0) {
|
if ((curwp->w_bufp->b_mode & MDEXACT) == 0) {
|
||||||
if (islower(bc))
|
if( islower( bc))
|
||||||
bc ^= DIFCASE;
|
bc = flipcase( bc) ;
|
||||||
|
|
||||||
if (islower(pc))
|
if( islower( pc))
|
||||||
pc ^= DIFCASE;
|
pc = flipcase( pc) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
return bc == pc;
|
return bc == pc;
|
||||||
@ -1455,7 +1455,7 @@ static int mceq(int bc, struct magic *mt)
|
|||||||
if (!(result = biteq(bc, mt->u.cclmap))) {
|
if (!(result = biteq(bc, mt->u.cclmap))) {
|
||||||
if ((curwp->w_bufp->b_mode & MDEXACT) == 0 &&
|
if ((curwp->w_bufp->b_mode & MDEXACT) == 0 &&
|
||||||
(isletter(bc))) {
|
(isletter(bc))) {
|
||||||
result = biteq(CHCASE(bc), mt->u.cclmap);
|
result = biteq( flipcase( bc), mt->u.cclmap) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1465,7 +1465,7 @@ static int mceq(int bc, struct magic *mt)
|
|||||||
|
|
||||||
if ((curwp->w_bufp->b_mode & MDEXACT) == 0 &&
|
if ((curwp->w_bufp->b_mode & MDEXACT) == 0 &&
|
||||||
(isletter(bc))) {
|
(isletter(bc))) {
|
||||||
result &= !biteq(CHCASE(bc), mt->u.cclmap);
|
result &= !biteq( flipcase( bc), mt->u.cclmap) ;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
64
word.c
64
word.c
@ -15,6 +15,7 @@
|
|||||||
#include "basic.h"
|
#include "basic.h"
|
||||||
#include "buffer.h"
|
#include "buffer.h"
|
||||||
#include "estruct.h"
|
#include "estruct.h"
|
||||||
|
#include "isa.h"
|
||||||
#include "line.h"
|
#include "line.h"
|
||||||
#include "mlout.h"
|
#include "mlout.h"
|
||||||
#include "random.h"
|
#include "random.h"
|
||||||
@ -145,12 +146,8 @@ int upperword(int f, int n)
|
|||||||
}
|
}
|
||||||
while (inword() != FALSE) {
|
while (inword() != FALSE) {
|
||||||
c = lgetc(curwp->w_dotp, curwp->w_doto);
|
c = lgetc(curwp->w_dotp, curwp->w_doto);
|
||||||
#if PKCODE
|
if( islower( c)) {
|
||||||
if (islower(c)) {
|
c = flipcase( c) ;
|
||||||
#else
|
|
||||||
if (c >= 'a' && c <= 'z') {
|
|
||||||
#endif
|
|
||||||
c -= 'a' - 'A';
|
|
||||||
lputc(curwp->w_dotp, curwp->w_doto, c);
|
lputc(curwp->w_dotp, curwp->w_doto, c);
|
||||||
lchange(WFHARD);
|
lchange(WFHARD);
|
||||||
}
|
}
|
||||||
@ -181,12 +178,8 @@ int lowerword(int f, int n)
|
|||||||
}
|
}
|
||||||
while (inword() != FALSE) {
|
while (inword() != FALSE) {
|
||||||
c = lgetc(curwp->w_dotp, curwp->w_doto);
|
c = lgetc(curwp->w_dotp, curwp->w_doto);
|
||||||
#if PKCODE
|
if( isupper( c)) {
|
||||||
if (isupper(c)) {
|
c = flipcase( c) ;
|
||||||
#else
|
|
||||||
if (c >= 'A' && c <= 'Z') {
|
|
||||||
#endif
|
|
||||||
c += 'a' - 'A';
|
|
||||||
lputc(curwp->w_dotp, curwp->w_doto, c);
|
lputc(curwp->w_dotp, curwp->w_doto, c);
|
||||||
lchange(WFHARD);
|
lchange(WFHARD);
|
||||||
}
|
}
|
||||||
@ -218,12 +211,8 @@ int capword(int f, int n)
|
|||||||
}
|
}
|
||||||
if (inword() != FALSE) {
|
if (inword() != FALSE) {
|
||||||
c = lgetc(curwp->w_dotp, curwp->w_doto);
|
c = lgetc(curwp->w_dotp, curwp->w_doto);
|
||||||
#if PKCODE
|
if( islower( c)) {
|
||||||
if (islower(c)) {
|
c = flipcase( c) ;
|
||||||
#else
|
|
||||||
if (c >= 'a' && c <= 'z') {
|
|
||||||
#endif
|
|
||||||
c -= 'a' - 'A';
|
|
||||||
lputc(curwp->w_dotp, curwp->w_doto, c);
|
lputc(curwp->w_dotp, curwp->w_doto, c);
|
||||||
lchange(WFHARD);
|
lchange(WFHARD);
|
||||||
}
|
}
|
||||||
@ -231,12 +220,8 @@ int capword(int f, int n)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
while (inword() != FALSE) {
|
while (inword() != FALSE) {
|
||||||
c = lgetc(curwp->w_dotp, curwp->w_doto);
|
c = lgetc(curwp->w_dotp, curwp->w_doto);
|
||||||
#if PKCODE
|
if( isupper( c)) {
|
||||||
if (isupper(c)) {
|
c = flipcase( c) ;
|
||||||
#else
|
|
||||||
if (c >= 'A' && c <= 'Z') {
|
|
||||||
#endif
|
|
||||||
c += 'a' - 'A';
|
|
||||||
lputc(curwp->w_dotp, curwp->w_doto,
|
lputc(curwp->w_dotp, curwp->w_doto,
|
||||||
c);
|
c);
|
||||||
lchange(WFHARD);
|
lchange(WFHARD);
|
||||||
@ -385,24 +370,14 @@ int delbword(int f, int n)
|
|||||||
* Return TRUE if the character at dot is a character that is considered to be
|
* Return TRUE if the character at dot is a character that is considered to be
|
||||||
* part of a word. The word character list is hard coded. Should be setable.
|
* part of a word. The word character list is hard coded. Should be setable.
|
||||||
*/
|
*/
|
||||||
static int inword(void)
|
static int inword( void) {
|
||||||
{
|
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
if (curwp->w_doto == llength(curwp->w_dotp))
|
if( curwp->w_doto == llength( curwp->w_dotp))
|
||||||
return FALSE;
|
return FALSE ;
|
||||||
c = lgetc(curwp->w_dotp, curwp->w_doto);
|
|
||||||
#if PKCODE
|
c = lgetc( curwp->w_dotp, curwp->w_doto) ;
|
||||||
if (isletter(c))
|
return isletter( c) || ( c >= '0' && c <= '9') ;
|
||||||
#else
|
|
||||||
if (c >= 'a' && c <= 'z')
|
|
||||||
return TRUE;
|
|
||||||
if (c >= 'A' && c <= 'Z')
|
|
||||||
#endif
|
|
||||||
return TRUE;
|
|
||||||
if (c >= '0' && c <= '9')
|
|
||||||
return TRUE;
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if WORDPRO
|
#if WORDPRO
|
||||||
@ -699,14 +674,7 @@ int wordcount(int f, int n)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* and tabulate it */
|
/* and tabulate it */
|
||||||
wordflag = (
|
wordflag = isletter( ch) || (ch >= '0' && ch <= '9') ;
|
||||||
#if PKCODE
|
|
||||||
(isletter(ch)) ||
|
|
||||||
#else
|
|
||||||
(ch >= 'a' && ch <= 'z') ||
|
|
||||||
(ch >= 'A' && ch <= 'Z') ||
|
|
||||||
#endif
|
|
||||||
(ch >= '0' && ch <= '9'));
|
|
||||||
if (wordflag == TRUE && lastword == FALSE)
|
if (wordflag == TRUE && lastword == FALSE)
|
||||||
++nwords;
|
++nwords;
|
||||||
lastword = wordflag;
|
lastword = wordflag;
|
||||||
|
Loading…
Reference in New Issue
Block a user