diff -ur joe/Makefile joe.locale/Makefile --- joe/Makefile Mon Jan 23 09:01:28 1995 +++ joe.locale/Makefile Sat Jan 27 00:23:25 2001 @@ -27,7 +27,9 @@ # C compiler options: make's built-in rules use this variable -CFLAGS = -O +#CFLAGS = -O +# add -DNOISBLANK if there is no isblank() function (Sun Sparc 4) +CFLAGS = -O -funsigned-char -DLOCALE # C compiler to use: make's built-in rules use this variable @@ -46,6 +48,7 @@ # depending on the system. EXTRALIBS = +#EXTRALIBS = -lcurses # Object files Only in joe.locale: README.locale diff -ur joe/kbd.c joe.locale/kbd.c --- joe/kbd.c Thu Oct 6 09:20:35 1994 +++ joe.locale/kbd.c Fri Jan 26 16:40:36 2001 @@ -184,7 +184,8 @@ #else s=jgetstr(cap,seq+1); seq[x]=c; - if(s && (s=tcompile(cap,s)) && (sLEN(s)>1 || s[0]<0)) + if(s && (s=tcompile(cap,s)) && (sLEN(s)>1 || s[0]>127)) +// if(s && (s=tcompile(cap,s)) && (sLEN(s)>1 || s[0]<0)) { capseq=s; seql=sLEN(s); diff -ur joe/main.c joe.locale/main.c --- joe/main.c Sun Jan 22 03:21:08 1995 +++ joe.locale/main.c Fri Jan 26 19:07:29 2001 @@ -34,6 +34,11 @@ #include "termcap.h" #include "main.h" +#ifdef LOCALE + #include +#endif + + extern int mid, dspasis, force, help, pgamnt, nobackups, lightoff, exask, skiptop, noxon, lines, staen, columns, Baud, dopadding, marking, beep; @@ -47,6 +52,7 @@ SCREEN *maint; /* Main edit screen */ + /* Make windows follow cursor */ void dofollows() @@ -168,6 +174,11 @@ int omid; int backopt; int c; + +#ifdef LOCALE + setlocale(LC_CTYPE, "" ); + setlocale(LC_COLLATE, "" ); +#endif mainenv=envv; diff -ur joe/tty.c joe.locale/tty.c --- joe/tty.c Mon Jan 23 08:17:20 1995 +++ joe.locale/tty.c Mon Jan 29 03:37:03 2001 @@ -24,7 +24,9 @@ #include #include #include +#include #include +#include "zstr.h" extern int errno; int idleout=1; diff -ur joe/uedit.c joe.locale/uedit.c --- joe/uedit.c Sun Jan 8 18:47:01 1995 +++ joe.locale/uedit.c Fri Jan 26 16:30:58 2001 @@ -32,6 +32,7 @@ #include "macro.h" #include "main.h" #include "uedit.h" +#include "stdio.h" /* Global options */ @@ -103,7 +104,8 @@ lp: d=' '; while(c=prgetc(bw->cursor), - c!= MAXINT && !crest(c) && (!cwhitel(c) || cwhitel(d))) + ( c == MAXINT ) ? 0 : ( !crest(c) && (!cwhitel(c) || cwhitel(d) )) ) + //c!= MAXINT && !crest(c) && (!cwhitel(c) || cwhitel(d))) d=c; if(c==' ') { @@ -112,7 +114,8 @@ } if(c!= MAXINT) pgetc(bw->cursor); /* Move to beginning of current word */ - while(crest(c=prgetc(bw->cursor))); + while(c=prgetc(bw->cursor), ( c == MAXINT ) ? 0 : crest(c)); +// while(crest(c=prgetc(bw->cursor))); if(c!= MAXINT) pgetc(bw->cursor); return 0; } @@ -128,7 +131,8 @@ lp: d=' '; while(c=brc(bw->cursor), - c!= MAXINT && !crest(c) && (!cwhitel(c) || cwhitel(d))) + ( c == MAXINT ) ? 0 : ( !crest(c) && (!cwhitel(c) || cwhitel(d) )) ) + // c!= MAXINT && !crest(c) && (!cwhitel(c) || cwhitel(d))) d=pgetc(bw->cursor); if(c==' ') { @@ -136,7 +140,7 @@ if(!cwhitel(d)) goto lp; } /* Move to end of current word */ - while(c=brc(bw->cursor), crest(c)) pgetc(bw->cursor); + while(c=brc(bw->cursor), ( c == MAXINT ) ? 0 : crest(c)) pgetc(bw->cursor); return 0; } @@ -589,7 +593,8 @@ P *p=pdup(bw->cursor); int c=brc(p); if(crest(c)) - while(c=brc(p), crest(c)) pgetc(p); + while(c=brc(p), ( c == MAXINT ) ? 0 : crest(c)) pgetc(p); +// while(c=brc(p), crest(c)) pgetc(p); else if(cwhitel(c) || c=='\r') while(c=brc(p), (cwhitel(c) || c=='\r')) pgetc(p); else pgetc(p); @@ -610,7 +615,8 @@ int c=prgetc(bw->cursor); if(crest(c)) { - while(c=prgetc(bw->cursor), crest(c)); + while(c=prgetc(bw->cursor), ( c == MAXINT ) ? 0 : crest(c)); +// while(c=prgetc(bw->cursor), crest(c)); if(c!= MAXINT) pgetc(bw->cursor); } else if(cwhitel(c)) diff -ur joe/usearch.c joe.locale/usearch.c --- joe/usearch.c Wed Dec 21 19:32:48 1994 +++ joe.locale/usearch.c Fri Jan 26 15:21:47 2001 @@ -9,6 +9,7 @@ #include "main.h" #include "undo.h" #include "usearch.h" +#include "zstr.h" int smode=0; /* Decremented to zero by execmd */ int csmode=0; /* Set for continued search mode */ diff -ur joe/utag.c joe.locale/utag.c --- joe/utag.c Thu Oct 6 09:20:35 1994 +++ joe.locale/utag.c Fri Jan 26 18:17:40 2001 @@ -150,8 +150,10 @@ P *p=pdup(bw->cursor); P *q=pdup(p); int c; - while(crest(c=prgetc(p))); if(c!=MAXINT) pgetc(p); - pset(q,p); while(crest(c=pgetc(q))); if(c!=MAXINT) prgetc(q); + while(c=prgetc(p),crest(c)); if(c!=MAXINT) pgetc(p); +// while(crest(c=prgetc(p))); if(c!=MAXINT) pgetc(p); + pset(q,p); while(c=pgetc(q),crest(c)); if(c!=MAXINT) prgetc(q); +// pset(q,p); while(crest(c=pgetc(q))); if(c!=MAXINT) prgetc(q); binsb(pbw->cursor,bcpy(p,q)); pset(pbw->cursor,pbw->b->eof); pbw->cursor->xcol=piscol(pbw->cursor); prm(p); prm(q); diff -ur joe/zstr.c joe.locale/zstr.c --- joe/zstr.c Mon Jan 16 21:02:47 1995 +++ joe.locale/zstr.c Fri Jan 26 21:19:29 2001 @@ -42,8 +42,6 @@ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; -int toup(a) { return clower(a) ? a+'A'-'a' : a; } -int todn(a) { return cupper(a) ? a+'a'-'A' : a; } unsigned Umin(a,b) unsigned a,b; { return ab?a:b; } int Imin(a,b) { return a=0?a:-a; } long Labs(a) long a; { return a>=0?a:-a; } -int zlen(s) -char *s; +#ifdef LOCALE +int zcmp( char *l, char *r ) { + int res = strcoll(l,r); + return ( res ) ? (int)( res/Iabs(res) ) : 0; +} +#else +int toup(a) { return clower(a) ? a+'A'-'a' : a; } +int todn(a) { return cupper(a) ? a+'a'-'A' : a; } + +char *zcpy(d,s) +char *d,*s; { - char *os=s; + char *od=d; loop: - if(!s[0]) return s-os; - if(!s[1]) return s-os+1; - if(!s[2]) return s-os+2; - if(!s[3]) return s-os+3; - if(!s[4]) return s-os+4; - if(!s[5]) return s-os+5; - if(!s[6]) return s-os+6; - if(!s[7]) return s-os+7; - if(!s[8]) return s-os+8; - if(!s[9]) return s-os+9; - if(!s[10]) return s-os+10; - if(!s[11]) return s-os+11; - if(!s[12]) return s-os+12; - if(!s[13]) return s-os+13; - if(!s[14]) return s-os+14; - if(!s[15]) return s-os+15; - s+=15; goto loop; + if(!(d[0]=s[0])) return od; + if(!(d[1]=s[1])) return od; + if(!(d[2]=s[2])) return od; + if(!(d[3]=s[3])) return od; + if(!(d[4]=s[4])) return od; + if(!(d[5]=s[5])) return od; + if(!(d[6]=s[6])) return od; + if(!(d[7]=s[7])) return od; + if(!(d[8]=s[8])) return od; + if(!(d[9]=s[9])) return od; + if(!(d[10]=s[10])) return od; + if(!(d[11]=s[11])) return od; + if(!(d[12]=s[12])) return od; + if(!(d[13]=s[13])) return od; + if(!(d[14]=s[14])) return od; + if(!(d[15]=s[15])) return od; + s+=16; d+=16; goto loop; } char *zchr(s,c) @@ -108,30 +115,6 @@ return p; } -char *zcpy(d,s) -char *d,*s; - { - char *od=d; - loop: - if(!(d[0]=s[0])) return od; - if(!(d[1]=s[1])) return od; - if(!(d[2]=s[2])) return od; - if(!(d[3]=s[3])) return od; - if(!(d[4]=s[4])) return od; - if(!(d[5]=s[5])) return od; - if(!(d[6]=s[6])) return od; - if(!(d[7]=s[7])) return od; - if(!(d[8]=s[8])) return od; - if(!(d[9]=s[9])) return od; - if(!(d[10]=s[10])) return od; - if(!(d[11]=s[11])) return od; - if(!(d[12]=s[12])) return od; - if(!(d[13]=s[13])) return od; - if(!(d[14]=s[14])) return od; - if(!(d[15]=s[15])) return od; - s+=16; d+=16; goto loop; - } - char *zcat(d,s) char *d,*s; { @@ -146,6 +129,29 @@ return zcpy((char *)malloc(zlen(s)+1),s); } +int zlen(s) +char *s; + { + char *os=s; + loop: + if(!s[0]) return s-os; + if(!s[1]) return s-os+1; + if(!s[2]) return s-os+2; + if(!s[3]) return s-os+3; + if(!s[4]) return s-os+4; + if(!s[5]) return s-os+5; + if(!s[6]) return s-os+6; + if(!s[7]) return s-os+7; + if(!s[8]) return s-os+8; + if(!s[9]) return s-os+9; + if(!s[10]) return s-os+10; + if(!s[11]) return s-os+11; + if(!s[12]) return s-os+12; + if(!s[13]) return s-os+13; + if(!s[14]) return s-os+14; + if(!s[15]) return s-os+15; + s+=15; goto loop; + } int zcmp(l,r) char *l, *r; { @@ -201,6 +207,7 @@ if(toup(l[c]) + +#ifdef LOCALE + #include +#endif + #define _upp 1 #define _low 2 @@ -38,6 +44,30 @@ /* Character type test macros */ +#ifdef LOCALE +#define cupper(c) isupper(c) +#define clower(c) islower(c) +#define calpha(c) isalpha(c) +#ifdef NOISBLANK +#define cwhite(c) (_ctaA[(unsigned char)(c)]&(_whi)) +#else +#define cwhite(c) isblank(c) +#endif +#define cwhitel(c) isspace(c) +#define cwhitef(c) (isspace(c)||!c) +#define cdec(c) isdigit(c) +#define chex(c) isxdigit(c) +#define crest(c) (isalnum(c)||(char)c=='_') +#define toup(c) toupper(c) +#define todn(c) tolower(c) +#define zlen(s) strlen(s) +#define zchr(s,c) strchr(s,c) +#define zrchr(s,c) strrchr(s,c) +#define zcpy(d,s) strcpy(d,s) +#define zcat(d,s) strcat(d,s) +#define zdup(s) strdup(s) + +#else /* Upper case */ #define cupper(c) (_ctaB[(unsigned char)(c)]&_upp) @@ -47,27 +77,6 @@ /* Letter */ #define calpha(c) (_ctaB[(unsigned char)(c)]&(_low|_upp)) -/* First legal character of a C identifier */ -#define cfirst(c) (_ctaB[(unsigned char)(c)]&(_low|_upp|_und)) - -/* Remaining legal characters of a C identifier */ -#define crest(c) (_ctaB[(unsigned char)(c)]&(_low|_upp|_und|_bin|_oct|_dec)) - -/* Binary digit */ -#define cbin(c) (_ctaB[(unsigned char)(c)]&(_bin)) - -/* Octal digit */ -#define coct(c) (_ctaB[(unsigned char)(c)]&(_bin|_oct)) - -/* Decimal digit */ -#define cdec(c) (_ctaB[(unsigned char)(c)]&(_bin|_oct|_dec)) - -/* Hexadecimal digit */ -#define chex(c) (_ctaB[(unsigned char)(c)]&(_bin|_oct|_dec|_hex)) - -/* Floating-point digit */ -#define cfloat(c) (_ctaB[(unsigned char)(c)]&(_bin|_oct|_dec|_flo)) - /* Whitespace: tab or space */ #define cwhite(c) (_ctaA[(unsigned char)(c)]&(_whi)) @@ -77,11 +86,14 @@ /* Whitespace: tab, space, newline or nul */ #define cwhitef(c) (_ctaA[(unsigned char)(c)]&(_whi|_eol|_eos)) -/* int Iabs(int n); Return absolute value of given int */ -int Iabs(); +/* Decimal digit */ +#define cdec(c) (_ctaB[(unsigned char)(c)]&(_bin|_oct|_dec)) -/* long Labs(long n); Return absolute value of given long */ -long Labs(); +/* Hexadecimal digit */ +#define chex(c) (_ctaB[(unsigned char)(c)]&(_bin|_oct|_dec|_hex)) + +/* Remaining legal characters of a C identifier */ +#define crest(c) (_ctaB[(unsigned char)(c)]&(_low|_upp|_und|_bin|_oct|_dec)) /* int toup(int c); Convert character to uppercase if it was lowercase */ int toup(); @@ -89,23 +101,16 @@ /* int todn(int c); Convert character to lowercase if it was uppercase */ int todn(); -/* unsigned Umin(unsigned a,unsigned b); Return the smaller unsigned integer */ -unsigned Umin(); - -/* unsigned Umax(unsigned a,unsigned b); Return the larger unsigned integer */ -unsigned Umax(); - -/* int Imin(int a,int b); Return the lower integer */ -int Imin(); - -/* int Imax(int a,int b); Return the higher integer */ -int Imax(); - -/* long Lmax(long a,long b); Return the higher long */ -long Lmax(); +/* int zcmp(char *l,char *r); Compare the strings. Return -1 if l is + * less than r; return 0 if l equals r; and return 1 if l is greater than r. + */ +int zcmp(); -/* long Lmin(long a,long b); Return the smaller long */ -long Lmin(); +/* int zicmp(char *l,char *r); Compare the strings, case insensitive. Return + * -1 if l is less than r; return 0 if l equals r; and return 1 if l is greater + * than r. + */ +int zicmp(); /* int zlen(char *s); Return length of z-string */ int zlen(); @@ -128,16 +133,36 @@ /* char *zdup(char *s); Duplicate z-string into an malloc block */ char *zdup(); -/* int zcmp(char *l,char *r); Compare the strings. Return -1 if l is - * less than r; return 0 if l equals r; and return 1 if l is greater than r. - */ -int zcmp(); +#endif + + +/* int Iabs(int n); Return absolute value of given int */ +int Iabs(); + +/* long Labs(long n); Return absolute value of given long */ +long Labs(); + + +/* unsigned Umin(unsigned a,unsigned b); Return the smaller unsigned integer */ +unsigned Umin(); + +/* unsigned Umax(unsigned a,unsigned b); Return the larger unsigned integer */ +unsigned Umax(); + +/* int Imin(int a,int b); Return the lower integer */ +int Imin(); + +/* int Imax(int a,int b); Return the higher integer */ +int Imax(); + +/* long Lmax(long a,long b); Return the higher long */ +long Lmax(); + +/* long Lmin(long a,long b); Return the smaller long */ +long Lmin(); + + -/* int zicmp(char *l,char *r); Compare the strings, case insensitive. Return - * -1 if l is less than r; return 0 if l equals r; and return 1 if l is greater - * than r. - */ -int zicmp(); /* int fields(char *s,char **fields,char sep); Break up z-string containing * fields into its componant fields. This is done by setting the field @@ -154,5 +179,7 @@ * characters are in 's', the number of fields is 1. */ int nfields(); + +int zstrcmp(char * l, char * r); #endif