Use wchar_t's for Runes. - sam - An updated version of the sam text editor.
(HTM) git clone git://vernunftzentrum.de/sam.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) LICENSE
---
(DIR) commit dde296185e1a9e5da394deae1e61aa883c1b5d84
(DIR) parent 2832a9cdfbb306f063f6456bf7c9c743556111ec
(HTM) Author: Rob King <jking@deadpixi.com>
Date: Tue, 27 Sep 2016 17:02:43 -0500
Use wchar_t's for Runes.
Diffstat:
include/frame.h | 2 +-
include/libc.h | 4 ++--
include/libg.h | 2 +-
include/regexp.h | 14 +++++++-------
include/u.h | 2 --
libXg/font.c | 2 +-
libXg/rune.c | 12 ++++++------
libframe/frbox.c | 2 +-
libframe/frinsert.c | 4 ++--
libframe/frptofchar.c | 4 ++--
libframe/frutil.c | 2 +-
sam/buffer.c | 2 +-
sam/cmd.c | 12 ++++++------
sam/disc.c | 20 ++++++++++----------
sam/file.c | 22 +++++++++++-----------
sam/io.c | 4 ++--
sam/mesg.c | 6 +++---
sam/moveto.c | 8 ++++----
sam/rasp.c | 6 +++---
sam/regexp.c | 20 ++++++++++----------
sam/sam.c | 10 +++++-----
sam/sam.h | 32 ++++++++++++++++----------------
sam/string.c | 14 +++++++-------
sam/unix.c | 22 +++++++++++-----------
samterm/flayer.c | 6 +++---
samterm/flayer.h | 6 +++---
samterm/io.c | 2 +-
samterm/main.c | 10 +++++-----
samterm/menu.c | 2 +-
samterm/mesg.c | 12 ++++++------
samterm/rasp.c | 8 ++++----
samterm/samterm.h | 22 +++++++++++-----------
32 files changed, 147 insertions(+), 149 deletions(-)
---
(DIR) diff --git a/include/frame.h b/include/frame.h
@@ -42,7 +42,7 @@ struct Frame
uint64_t frcharofpt(Frame*, Point);
Point frptofchar(Frame*, uint64_t);
int frdelete(Frame*, uint64_t, uint64_t);
-void frinsert(Frame*, Rune*, Rune*, uint64_t);
+void frinsert(Frame*, wchar_t*, wchar_t*, uint64_t);
void frselect(Frame*, Mouse*);
void frselectp(Frame*, Fcode);
void frselectf(Frame*, Point, Point, Fcode);
(DIR) diff --git a/include/libc.h b/include/libc.h
@@ -32,8 +32,8 @@ enum
/*
* new rune routines
*/
-extern int runetochar(char*, Rune*);
-extern int chartorune(Rune*, char*);
+extern int runetochar(char*, wchar_t*);
+extern int chartorune(wchar_t*, char*);
extern int runelen(int64_t);
extern int fullrune(char*, int);
(DIR) diff --git a/include/libg.h b/include/libg.h
@@ -181,7 +181,7 @@ extern void bitblt(Bitmap*, Point, Bitmap*, Rectangle, Fcode);
extern Point string(Bitmap*, Point, XftFont*, char*, Fcode);
extern int64_t strwidth(XftFont*, char*);
extern Point strsize(XftFont*, char*);
-extern int64_t charwidth(XftFont*, Rune);
+extern int64_t charwidth(XftFont*, wchar_t);
extern void texture(Bitmap*, Rectangle, Bitmap*, Fcode);
extern void wrbitmap(Bitmap*, int, int, unsigned char*);
extern void rdbitmap(Bitmap*, int, int, unsigned char*);
(DIR) diff --git a/include/regexp.h b/include/regexp.h
@@ -12,12 +12,12 @@ struct Resub{
union
{
char *sp;
- Rune *rsp;
+ wchar_t *rsp;
}s;
union
{
char *ep;
- Rune *rep;
+ wchar_t *rep;
}e;
};
@@ -25,8 +25,8 @@ struct Resub{
* character class, each pair of rune's defines a range
*/
struct Reclass{
- Rune *end;
- Rune spans[64];
+ wchar_t *end;
+ wchar_t spans[64];
};
/*
@@ -36,7 +36,7 @@ struct Reinst{
int type;
union {
Reclass *cp; /* class pointer */
- Rune r; /* character */
+ wchar_t r; /* character */
int subid; /* sub-expression id for RBRA and LBRA */
Reinst *right; /* right child of OR */
}u1;
@@ -61,5 +61,5 @@ extern Reprog *regcompnl(char*);
extern void regerror(char*);
extern int regexec(Reprog*, char*, Resub*, int);
extern void regsub(char*, char*, Resub*, int);
-extern int rregexec(Reprog*, Rune*, Resub*, int);
-extern void rregsub(Rune*, Rune*, Resub*, int);
+extern int rregexec(Reprog*, wchar_t*, Resub*, int);
+extern void rregsub(wchar_t*, wchar_t*, Resub*, int);
(DIR) diff --git a/include/u.h b/include/u.h
@@ -8,5 +8,3 @@
#include <sys/types.h>
#include <unistd.h>
#include <wchar.h>
-
-typedef uint16_t Rune;
(DIR) diff --git a/libXg/font.c b/libXg/font.c
@@ -7,7 +7,7 @@
#define PJW 0 /* use NUL==pjw for invisible characters */
long
-charwidth(XftFont *f, Rune r)
+charwidth(XftFont *f, wchar_t r)
{
char chars[UTFmax + 1] = {0};
(DIR) diff --git a/libXg/rune.c b/libXg/rune.c
@@ -28,7 +28,7 @@ enum
};
int
-chartorune(Rune *rune, char *str)
+chartorune(wchar_t *rune, char *str)
{
int c, c1, c2;
int64_t l;
@@ -84,7 +84,7 @@ bad:
}
int
-runetochar(char *str, Rune *rune)
+runetochar(char *str, wchar_t *rune)
{
int64_t c;
@@ -121,7 +121,7 @@ runetochar(char *str, Rune *rune)
int
runelen(int64_t c)
{
- Rune rune;
+ wchar_t rune;
char str[10];
rune = c;
@@ -129,7 +129,7 @@ runelen(int64_t c)
}
int
-runenlen(Rune *r, int nrune)
+runenlen(wchar_t *r, int nrune)
{
int nb, c;
@@ -167,7 +167,7 @@ char*
utfrune(char *s, int64_t c)
{
int64_t c1;
- Rune r;
+ wchar_t r;
int n;
if(c < Runesync) /* not part of utf sequence */
@@ -196,7 +196,7 @@ utflen(char *s)
{
int c;
int64_t n;
- Rune rune;
+ wchar_t rune;
n = 0;
for(;;) {
(DIR) diff --git a/libframe/frbox.c b/libframe/frbox.c
@@ -88,7 +88,7 @@ uint8_t*
runeindex(uint8_t *p, int n)
{
int i, w;
- Rune rune;
+ wchar_t rune;
for(i=0; i<n; i++,p+=w)
if(*p < Runeself)
(DIR) diff --git a/libframe/frinsert.c b/libframe/frinsert.c
@@ -10,7 +10,7 @@ static Frame frame;
static
Point
-bxscan(Frame *f, Rune *sp, Rune *ep, Point *ppt)
+bxscan(Frame *f, wchar_t *sp, wchar_t *ep, Point *ppt)
{
int w, c, nb, delta, nl, nr, rw;
Frbox *b;
@@ -96,7 +96,7 @@ chopframe(Frame *f, Point pt, uint64_t p, int bn)
}
void
-frinsert(Frame *f, Rune *sp, Rune *ep, uint64_t p0)
+frinsert(Frame *f, wchar_t *sp, wchar_t *ep, uint64_t p0)
{
Point pt0, pt1, ppt0, ppt1, pt;
Frbox *b;
(DIR) diff --git a/libframe/frptofchar.c b/libframe/frptofchar.c
@@ -10,7 +10,7 @@ _frptofcharptb(Frame *f, uint64_t p, Point pt, int bn)
uint8_t *s;
Frbox *b;
int w, l;
- Rune r;
+ wchar_t r;
for(b = &f->box[bn]; bn<f->nbox; bn++,b++){
_frcklinewrap(f, &pt, b);
@@ -72,7 +72,7 @@ frcharofpt(Frame *f, Point pt)
uint8_t *s;
Frbox *b;
uint64_t p;
- Rune r;
+ wchar_t r;
pt = _frgrid(f, pt);
qt.x = f->left;
(DIR) diff --git a/libframe/frutil.c b/libframe/frutil.c
@@ -9,7 +9,7 @@ _frcanfit(Frame *f, Point pt, Frbox *b)
{
int left, w, nr;
uint8_t *p;
- Rune r;
+ wchar_t r;
left = f->r.max.x-pt.x;
if(b->nrune < 0)
(DIR) diff --git a/sam/buffer.c b/sam/buffer.c
@@ -23,7 +23,7 @@ Bterm(Buffer *b)
}
int
-Bread(Buffer *b, Rune *addr, int n, Posn p0)
+Bread(Buffer *b, wchar_t *addr, int n, Posn p0)
{
int m;
(DIR) diff --git a/sam/cmd.c b/sam/cmd.c
@@ -46,11 +46,11 @@ Addr *simpleaddr(void);
void freecmd(void);
void okdelim(int);
-Rune line[BLOCKSIZE];
-Rune termline[BLOCKSIZE];
-Rune *linep = line;
-Rune *terminp = termline;
-Rune *termoutp = termline;
+wchar_t line[BLOCKSIZE];
+wchar_t termline[BLOCKSIZE];
+wchar_t *linep = line;
+wchar_t *terminp = termline;
+wchar_t *termoutp = termline;
List cmdlist;
List addrlist;
List relist;
@@ -71,7 +71,7 @@ inputc(void)
{
int n, nbuf;
char buf[3];
- Rune r;
+ wchar_t r;
Again:
nbuf = 0;
(DIR) diff --git a/sam/disc.c b/sam/disc.c
@@ -7,8 +7,8 @@ static Discdesc desc[NBUFFILES];
void bkalloc(Disc*, int);
void bkfree(Disc*, int);
-void bkwrite(Disc*, Rune*, int, int, int);
-void bkread(Disc*, Rune*, int, int, int);
+void bkwrite(Disc*, wchar_t*, int, int, int);
+void bkread(Disc*, wchar_t*, int, int, int);
Discdesc *
@@ -49,7 +49,7 @@ Dclose(Disc *d)
}
int
-Dread(Disc *d, Rune *addr, int n, Posn p1)
+Dread(Disc *d, wchar_t *addr, int n, Posn p1)
{
int i, nb, nr;
Posn p = 0, p2 = p1+n;
@@ -102,11 +102,11 @@ Dread(Disc *d, Rune *addr, int n, Posn p1)
}
void
-Dinsert(Disc *d, Rune *addr, int n, Posn p0) /* if addr null, just make space */
+Dinsert(Disc *d, wchar_t *addr, int n, Posn p0) /* if addr null, just make space */
{
int i, nb, ni;
Posn p = 0;
- Rune hold[BLOCKSIZE];
+ wchar_t hold[BLOCKSIZE];
int nhold;
for(i=0; i<d->block.nused; i++){
@@ -177,7 +177,7 @@ Ddelete(Disc *d, Posn p1, Posn p2)
{
int i, nb, nd;
Posn p = 0;
- Rune buf[BLOCKSIZE];
+ wchar_t buf[BLOCKSIZE];
for(i = 0; i<d->block.nused; i++){
if((p+=d->block.blkptr[i].nrunes) > p1){
@@ -233,11 +233,11 @@ Ddelete(Disc *d, Posn p1, Posn p2)
}
void
-Dreplace(Disc *d, Posn p1, Posn p2, Rune *addr, int n)
+Dreplace(Disc *d, Posn p1, Posn p2, wchar_t *addr, int n)
{
int i, nb, nr;
Posn p = 0;
- Rune buf[BLOCKSIZE];
+ wchar_t buf[BLOCKSIZE];
if(p2-p1 > n)
Ddelete(d, p1+n, p2);
@@ -290,14 +290,14 @@ Dreplace(Disc *d, Posn p1, Posn p2, Rune *addr, int n)
}
void
-bkread(Disc *d, Rune *loc, int n, int bk, int off)
+bkread(Disc *d, wchar_t *loc, int n, int bk, int off)
{
Seek(d->desc->fd, RUNESIZE*(BLOCKSIZE*d->block.blkptr[bk].bnum+off), 0);
Read(d->desc->fd, loc, n*RUNESIZE);
}
void
-bkwrite(Disc *d, Rune *loc, int n, int bk, int off)
+bkwrite(Disc *d, wchar_t *loc, int n, int bk, int off)
{
Seek(d->desc->fd, RUNESIZE*(BLOCKSIZE*d->block.blkptr[bk].bnum+off), 0);
Write(d->desc->fd, loc, n*RUNESIZE);
(DIR) diff --git a/sam/file.c b/sam/file.c
@@ -6,7 +6,7 @@
Discdesc *files[NDISC];
Discdesc *transcripts[NDISC];
Buffer *undobuf;
-static String *ftempstr(Rune*, int);
+static String *ftempstr(wchar_t*, int);
int fcount;
File *lastfile;
@@ -119,7 +119,7 @@ Finsert(File *f, String *str, Posn p1)
f->cp1 = f->cp2 = p1;
}
if(f->cp2 != p1){ /* grab the piece in between */
- Rune buf[SKIP];
+ wchar_t buf[SKIP];
String s;
Fchars(f, buf, f->cp2, p1);
s.s = buf;
@@ -157,7 +157,7 @@ Fdelete(File *f, Posn p1, Posn p2)
Fflush(f);
f->cp1 = f->cp2 = p1;
}else{
- Rune buf[SKIP];
+ wchar_t buf[SKIP];
String s;
Fchars(f, buf, f->cp2, p1);
s.s = buf;
@@ -228,7 +228,7 @@ Fupdate(File *f, int mktrans, int toterm)
Posn p0, p1, p2, p, deltadot = 0, deltamark = 0, delta = 0;
int changes = FALSE;
union Hdr buf;
- Rune tmp[BLOCKSIZE+1]; /* +1 for NUL in 'f' case */
+ wchar_t tmp[BLOCKSIZE+1]; /* +1 for NUL in 'f' case */
if(f->state == Readerr)
return FALSE;
@@ -241,7 +241,7 @@ Fupdate(File *f, int mktrans, int toterm)
else
p0 = 0;
f->dot = f->ndot;
- while((n=Bread(t, (Rune*)&buf, sizeof buf/RUNESIZE, p0)) > 0){
+ while((n=Bread(t, (wchar_t*)&buf, sizeof buf/RUNESIZE, p0)) > 0){
switch(buf.cs.c){
default:
panic("unknown in Fupdate");
@@ -360,7 +360,7 @@ puthdr_csl(Buffer *b, char c, int16_t s, Posn p)
buf.c = c;
buf.s = s;
buf.l = p;
- Binsert(b, ftempstr((Rune*)&buf, sizeof buf/RUNESIZE), b->nrunes);
+ Binsert(b, ftempstr((wchar_t*)&buf, sizeof buf/RUNESIZE), b->nrunes);
}
void
@@ -370,7 +370,7 @@ puthdr_cs(Buffer *b, char c, int16_t s)
buf.c = c;
buf.s = s;
- Binsert(b, ftempstr((Rune*)&buf, sizeof buf/RUNESIZE), b->nrunes);
+ Binsert(b, ftempstr((wchar_t*)&buf, sizeof buf/RUNESIZE), b->nrunes);
}
void
@@ -386,7 +386,7 @@ puthdr_M(Buffer *b, Posn p, Range dot, Range mk, Mod m, int16_t s1)
mark.mark = mk;
mark.m = m;
mark.s1 = s1;
- Binsert(b, ftempstr((Rune *)&mark, sizeof mark/RUNESIZE), b->nrunes);
+ Binsert(b, ftempstr((wchar_t *)&mark, sizeof mark/RUNESIZE), b->nrunes);
}
void
@@ -399,11 +399,11 @@ puthdr_cll(Buffer *b, char c, Posn p1, Posn p2)
buf.c = c;
buf.l = p1;
buf.l1 = p2;
- Binsert(b, ftempstr((Rune*)&buf, sizeof buf/RUNESIZE), b->nrunes);
+ Binsert(b, ftempstr((wchar_t*)&buf, sizeof buf/RUNESIZE), b->nrunes);
}
int64_t
-Fchars(File *f, Rune *addr, Posn p1, Posn p2)
+Fchars(File *f, wchar_t *addr, Posn p1, Posn p2)
{
return Bread(f->buf, addr, p2-p1, p1);
}
@@ -454,7 +454,7 @@ Fbgetcload(File *f, Posn p)
}
static String*
-ftempstr(Rune *s, int n)
+ftempstr(wchar_t *s, int n)
{
static String p;
(DIR) diff --git a/sam/io.c b/sam/io.c
@@ -23,7 +23,7 @@ checkqid(File *f)
void
writef(File *f)
{
- Rune c;
+ wchar_t c;
Posn n;
char *name;
int i, samename, newfile;
@@ -74,7 +74,7 @@ Posn
readio(File *f, int *nulls, int setdate)
{
int n, b, w;
- Rune *r;
+ wchar_t *r;
Posn nt;
Posn p = addr.r.p2;
uint64_t dev, qid;
(DIR) diff --git a/sam/mesg.c b/sam/mesg.c
@@ -169,7 +169,7 @@ whichfile(int tag)
int
inmesg(Tmesg type)
{
- Rune buf[1025];
+ wchar_t buf[1025];
int i, m;
int16_t s;
int64_t l, l1, l2;
@@ -178,7 +178,7 @@ inmesg(Tmesg type)
Range r;
String *str;
char *c;
- Rune *rp;
+ wchar_t *rp;
if(type > TMAX)
panic("inmesg");
@@ -453,7 +453,7 @@ inmesg(Tmesg type)
m = 32000;
dprint("?warning: snarf buffer truncated\n");
}
- rp = malloc(m*sizeof(Rune));
+ rp = malloc(m*sizeof(wchar_t));
if(rp){
Bread(snarfbuf, rp, m, 0);
c = Strtoc(tmprstr(rp, m));
(DIR) diff --git a/sam/moveto.c b/sam/moveto.c
@@ -94,10 +94,10 @@ clickmatch(File *f, int cl, int cr, int dir)
return cl=='\n' && nest==1;
}
-Rune*
-strrune(Rune *s, Rune c)
+wchar_t*
+strrune(wchar_t *s, wchar_t c)
{
- Rune c1;
+ wchar_t c1;
if(c == 0) {
while(*s++)
@@ -115,7 +115,7 @@ void
doubleclick(File *f, Posn p1)
{
int c, i;
- Rune *r, *l;
+ wchar_t *r, *l;
if(p1 > f->nrunes)
return;
(DIR) diff --git a/sam/rasp.c b/sam/rasp.c
@@ -18,7 +18,7 @@ toterminal(File *f, int toterm)
Range r;
union{
union Hdr g;
- Rune buf[8+GROWDATASIZE];
+ wchar_t buf[8+GROWDATASIZE];
}hdr;
Posn growpos, grown;
@@ -32,7 +32,7 @@ toterminal(File *f, int toterm)
grown = 0;
noflush = 1;
SET(growpos);
- while(Bread(t, (Rune*)&hdr, sizeof(hdr)/RUNESIZE, p0) > 0){
+ while(Bread(t, (wchar_t*)&hdr, sizeof(hdr)/RUNESIZE, p0) > 0){
switch(hdr.g.cs.c){
default:
fprintf(stderr, "char %c %.2x\n", hdr.g.cs.c, hdr.g.cs.c);
@@ -94,7 +94,7 @@ toterminal(File *f, int toterm)
grown = n;
}
}else{
- Rune *rp;
+ wchar_t *rp;
if(grown){
outTsll(Hgrow, f->tag, growpos, grown);
grown = 0;
(DIR) diff --git a/sam/regexp.c b/sam/regexp.c
@@ -98,11 +98,11 @@ int subidstack[NSTACK];
int *subidp;
bool backwards;
int nbra;
-Rune *exprp; /* pointer to next character in source expression */
+wchar_t *exprp; /* pointer to next character in source expression */
#define DCLASS 10 /* allocation increment */
int nclass; /* number active */
int Nclass; /* high water mark */
-Rune **class;
+wchar_t **class;
int negateclass;
void addinst(Ilist *l, Inst *inst, Rangeset *sep);
@@ -112,7 +112,7 @@ void pushand(Inst*, Inst*);
void pushator(int);
Node *popand(int);
int popator(void);
-void startlex(Rune*);
+void startlex(wchar_t*);
int lex(void);
void operator(int);
void operand(int);
@@ -146,7 +146,7 @@ newinst(int t)
}
Inst *
-realcompile(Rune *s)
+realcompile(wchar_t *s)
{
int token;
@@ -391,7 +391,7 @@ dump(void){
#endif
void
-startlex(Rune *s)
+startlex(wchar_t *s)
{
exprp = s;
nbra = 0;
@@ -466,7 +466,7 @@ void
bldcclass(void)
{
int64_t c1, c2, n, na;
- Rune *classp;
+ wchar_t *classp;
classp = emalloc(DCLASS*RUNESIZE);
n = 0;
@@ -502,7 +502,7 @@ bldcclass(void)
classp[n] = 0;
if(nclass == Nclass){
Nclass += DCLASS;
- class = erealloc(class, Nclass*sizeof(Rune*));
+ class = erealloc(class, Nclass*sizeof(wchar_t*));
}
class[nclass++] = classp;
}
@@ -510,7 +510,7 @@ bldcclass(void)
int
classmatch(int classno, int c, int negate)
{
- Rune *p;
+ wchar_t *p;
p = class[classno];
while(*p){
@@ -634,7 +634,7 @@ execute(File *f, Posn startp, Posn eof)
if(f->getcbuf[f->getci-2]=='\n')
goto Step;
}else{
- Rune c;
+ wchar_t c;
if(Fchars(f, &c, p-1, p)==1 && c=='\n')
goto Step;
}
@@ -772,7 +772,7 @@ bexecute(File *f, Posn startp)
if(f->getcbuf[f->getci+1]=='\n')
goto Step;
}else if(p<f->nrunes-1){
- Rune c;
+ wchar_t c;
if(Fchars(f, &c, p, p+1)==1 && c=='\n')
goto Step;
}
(DIR) diff --git a/sam/sam.c b/sam/sam.c
@@ -5,7 +5,7 @@
#include <stdbool.h>
#include <unistd.h>
-Rune genbuf[BLOCKSIZE];
+wchar_t genbuf[BLOCKSIZE];
int io;
int panicking;
int rescuing;
@@ -14,7 +14,7 @@ String genstr;
String rhs;
String wd;
String cmdstr;
-Rune empty[] = { 0 };
+wchar_t empty[] = { 0 };
char *genc;
File *curfile;
File *flist;
@@ -35,7 +35,7 @@ char *rsamname = "rsam";
char *sh = "sh";
char *shpath = "/bin/sh";
-Rune baddir[] = { '<', 'b', 'a', 'd', 'd', 'i', 'r', '>', '\n'};
+wchar_t baddir[] = { '<', 'b', 'a', 'd', 'd', 'i', 'r', '>', '\n'};
void usage(void);
@@ -425,7 +425,7 @@ undostep(File *f)
t = f->transcript;
changes = Fupdate(f, TRUE, TRUE);
- Bread(t, (Rune*)&mark, (sizeof mark)/RUNESIZE, f->markp);
+ Bread(t, (wchar_t*)&mark, (sizeof mark)/RUNESIZE, f->markp);
Bdelete(t, f->markp, t->nrunes);
f->markp = mark.p;
f->dot.r = mark.dot;
@@ -494,7 +494,7 @@ cd(String *str)
flist = 0;
}
if (readcmd(t) != 0) {
- Strduplstr(&genstr, tmprstr(baddir, sizeof(baddir)/sizeof(Rune)));
+ Strduplstr(&genstr, tmprstr(baddir, sizeof(baddir)/sizeof(wchar_t)));
Straddc(&genstr, '\0');
}
freetmpstr(t);
(DIR) diff --git a/sam/sam.h b/sam/sam.h
@@ -8,7 +8,7 @@
*/
#define BLOCKSIZE 2048
-#define RUNESIZE sizeof(Rune)
+#define RUNESIZE sizeof(wchar_t)
#define NDISC 5
#define NBUFFILES 3+2*NDISC /* plan 9+undo+snarf+NDISC*(transcript+buf) */
#define NSUBEXP 10
@@ -127,7 +127,7 @@ struct String
{
int16_t n;
int16_t size;
- Rune *s;
+ wchar_t *s;
};
struct Buffer
@@ -168,7 +168,7 @@ struct File
int64_t date; /* time stamp of plan9 file */
Posn cp1, cp2; /* Write-behind cache positions and */
String cache; /* string */
- Rune getcbuf[NGETC];
+ wchar_t getcbuf[NGETC];
int ngetc;
int getci;
Posn getcp;
@@ -219,16 +219,16 @@ void Bdelete(Buffer*, Posn, Posn);
void Bflush(Buffer*);
void Binsert(Buffer*, String*, Posn);
Buffer *Bopen(Discdesc*);
-int Bread(Buffer*, Rune*, int, Posn);
+int Bread(Buffer*, wchar_t*, int, Posn);
void Dclose(Disc*);
void Ddelete(Disc*, Posn, Posn);
-void Dinsert(Disc*, Rune*, int, Posn);
+void Dinsert(Disc*, wchar_t*, int, Posn);
Disc *Dopen(Discdesc*);
-int Dread(Disc*, Rune*, int, Posn);
-void Dreplace(Disc*, Posn, Posn, Rune*, int);
+int Dread(Disc*, wchar_t*, int, Posn);
+void Dreplace(Disc*, Posn, Posn, wchar_t*, int);
int Fbgetcload(File*, Posn);
int Fbgetcset(File*, Posn);
-int64_t Fchars(File*, Rune*, Posn, Posn);
+int64_t Fchars(File*, wchar_t*, Posn, Posn);
void Fclose(File*);
void Fdelete(File*, Posn, Posn);
int Fgetcload(File*, Posn);
@@ -307,20 +307,20 @@ void Straddc(String*, int);
void Strclose(String*);
int Strcmp(String*, String*);
void Strdelete(String*, Posn, Posn);
-void Strdupl(String*, Rune*);
+void Strdupl(String*, wchar_t*);
void Strduplstr(String*, String*);
void Strinit(String*);
void Strinit0(String*);
void Strinsert(String*, String*, Posn);
void Strinsure(String*, uint64_t);
void Strzero(String*);
-int Strlen(Rune*);
+int Strlen(wchar_t*);
char *Strtoc(String*);
void syserror(char*);
void telldot(File*);
void tellpat(void);
String *tmpcstr(char*);
-String *tmprstr(Rune*, int);
+String *tmprstr(wchar_t*, int);
void freetmpstr(String*);
void termcommand(void);
void termwrite(char*);
@@ -340,15 +340,15 @@ void writef(File*);
Posn writeio(File*);
Discdesc *Dstart(void);
-extern Rune samname[]; /* compiler dependent */
-extern Rune *left[];
-extern Rune *right[];
+extern wchar_t samname[]; /* compiler dependent */
+extern wchar_t *left[];
+extern wchar_t *right[];
extern char *rsamname; /* globals */
extern char *samterm;
extern char *sh;
extern char *shpath;
-extern Rune genbuf[];
+extern wchar_t genbuf[];
extern char *genc;
extern int io;
extern int patset;
@@ -375,7 +375,7 @@ extern int downloaded;
extern int eof;
extern int bpipeok;
extern int panicking;
-extern Rune empty[];
+extern wchar_t empty[];
extern int termlocked;
extern int noflush;
(DIR) diff --git a/sam/string.c b/sam/string.c
@@ -39,9 +39,9 @@ Strzero(String *p)
}
int
-Strlen(Rune *r)
+Strlen(wchar_t *r)
{
- Rune *s;
+ wchar_t *s;
for(s=r; *s; s++)
;
@@ -49,7 +49,7 @@ Strlen(Rune *r)
}
void
-Strdupl(String *p, Rune *s) /* copies the null */
+Strdupl(String *p, wchar_t *s) /* copies the null */
{
p->n = Strlen(s)+1;
Strinsure(p, p->n);
@@ -124,7 +124,7 @@ Strtoc(String *s)
{
int i;
char *c, *d;
- Rune *r;
+ wchar_t *r;
c = emalloc(s->n*UTFmax + 1); /* worst case UTFmax bytes per rune, plus NUL */
d = c;
r = s->s;
@@ -137,10 +137,10 @@ Strtoc(String *s)
}
/*
- * Build very temporary String from Rune*
+ * Build very temporary String from wchar_t*
*/
String*
-tmprstr(Rune *r, int n)
+tmprstr(wchar_t *r, int n)
{
static String p;
@@ -157,7 +157,7 @@ String*
tmpcstr(char *s)
{
String *p;
- Rune *r;
+ wchar_t *r;
int i, n;
n = utflen(s); /* don't include NUL */
(DIR) diff --git a/sam/unix.c b/sam/unix.c
@@ -11,23 +11,23 @@
#include <stdarg.h>
#endif
-Rune samname[] = { '~', '~', 's', 'a', 'm', '~', '~', 0 };
+wchar_t samname[] = { '~', '~', 's', 'a', 'm', '~', '~', 0 };
-static Rune l1[] = { '{', '[', '(', '<', 0253, 0};
-static Rune l2[] = { '\n', 0};
-static Rune l3[] = { '\'', '"', '`', 0};
-Rune *left[]= { l1, l2, l3, 0};
+static wchar_t l1[] = { '{', '[', '(', '<', 0253, 0};
+static wchar_t l2[] = { '\n', 0};
+static wchar_t l3[] = { '\'', '"', '`', 0};
+wchar_t *left[]= { l1, l2, l3, 0};
-static Rune r1[] = {'}', ']', ')', '>', 0273, 0};
-static Rune r2[] = {'\n', 0};
-static Rune r3[] = {'\'', '"', '`', 0};
-Rune *right[]= { r1, r2, r3, 0};
+static wchar_t r1[] = {'}', ']', ')', '>', 0273, 0};
+static wchar_t r2[] = {'\n', 0};
+static wchar_t r3[] = {'\'', '"', '`', 0};
+wchar_t *right[]= { r1, r2, r3, 0};
void
print_ss(char *s, String *a, String *b)
{
char *ap, *bp, *cp;
- Rune *rp;
+ wchar_t *rp;
ap = emalloc(a->n+1);
for (cp = ap, rp = a->s; *rp; rp++)
@@ -46,7 +46,7 @@ void
print_s(char *s, String *a)
{
char *ap, *cp;
- Rune *rp;
+ wchar_t *rp;
ap = emalloc(a->n+1);
for (cp = ap, rp = a->s; *rp; rp++)
(DIR) diff --git a/samterm/flayer.c b/samterm/flayer.c
@@ -30,7 +30,7 @@ flstart(Rectangle r)
}
void
-flnew(Flayer *l, Rune *(*fn)(Flayer*, int64_t, uint64_t*), int u0, void *u1)
+flnew(Flayer *l, wchar_t *(*fn)(Flayer*, int64_t, uint64_t*), int u0, void *u1)
{
if(nllist == nlalloc){
nlalloc += DELTA;
@@ -207,7 +207,7 @@ lldelete(Flayer *l)
}
void
-flinsert(Flayer *l, Rune *sp, Rune *ep, int64_t p0)
+flinsert(Flayer *l, wchar_t *sp, wchar_t *ep, int64_t p0)
{
if(flprepare(l)){
frinsert(&l->f, sp, ep, p0-l->origin);
@@ -362,7 +362,7 @@ flprepare(Flayer *l)
{
Frame *f;
uint64_t n;
- Rune *r;
+ wchar_t *r;
if(l->visible == None)
return 0;
(DIR) diff --git a/samterm/flayer.h b/samterm/flayer.h
@@ -22,7 +22,7 @@ struct Flayer
int64_t origin; /* offset of first char in flayer */
int64_t p0, p1;
int64_t click; /* time at which selection click occurred, in HZ */
- Rune *(*textfn)(Flayer*, int64_t, uint64_t*);
+ wchar_t *(*textfn)(Flayer*, int64_t, uint64_t*);
int user0;
void *user1;
Rectangle entire;
@@ -35,8 +35,8 @@ void flclose(Flayer*);
void fldelete(Flayer*, int64_t, int64_t);
void flfp0p1(Flayer*, uint64_t*, uint64_t*);
void flinit(Flayer*, Rectangle, XftFont*, uint64_t bg);
-void flinsert(Flayer*, Rune*, Rune*, int64_t);
-void flnew(Flayer*, Rune *(*fn)(Flayer*, int64_t, uint64_t*), int, void*);
+void flinsert(Flayer*, wchar_t*, wchar_t*, int64_t);
+void flnew(Flayer*, wchar_t *(*fn)(Flayer*, int64_t, uint64_t*), int, void*);
int flprepare(Flayer*);
Rectangle flrect(Flayer*, Rectangle);
void flrefresh(Flayer*, Rectangle, int);
(DIR) diff --git a/samterm/io.c b/samterm/io.c
@@ -129,7 +129,7 @@ getch(void)
int
externchar(void)
{
- Rune r;
+ wchar_t r;
loop:
if(got & (Eextern & ~block)){
(DIR) diff --git a/samterm/main.c b/samterm/main.c
@@ -12,7 +12,7 @@ extern uint64_t _bgpixel;
extern void hmoveto(int, int64_t, Flayer *);
Text cmd;
-Rune *scratch;
+wchar_t *scratch;
int64_t nscralloc;
extern Bitmap screen;
unsigned int cursor;
@@ -231,7 +231,7 @@ duplicate(Flayer *l, Rectangle r, XftFont *f, int close)
{
Text *t=(Text *)l->user1;
Flayer *nl = findl(t);
- Rune *rp;
+ wchar_t *rp;
uint64_t n;
if(nl){
@@ -935,9 +935,9 @@ void
type(Flayer *l) /* what a bloody mess this is -- but it's getting better! */
{
Text *t = (Text *)l->user1;
- Rune buf[100];
+ wchar_t buf[100];
Keystroke k = {0};
- Rune *p = buf;
+ wchar_t *p = buf;
int64_t a;
if(lock || t->lock){
@@ -1028,7 +1028,7 @@ panic(char *s)
abort();
}
-Rune*
+wchar_t*
stgettext(Flayer *l, int64_t n, uint64_t *np)
{
Text *t;
(DIR) diff --git a/samterm/menu.c b/samterm/menu.c
@@ -317,7 +317,7 @@ genmenu3(int n)
{
Text *t;
int c, i, k, l, w;
- Rune r;
+ wchar_t r;
char *p;
if(n >= NMENU3+nname)
(DIR) diff --git a/samterm/mesg.c b/samterm/mesg.c
@@ -426,7 +426,7 @@ outTsl(Tmesg type, int s1, int64_t l1)
}
void
-outTslS(Tmesg type, int s1, int64_t l1, Rune *s)
+outTslS(Tmesg type, int s1, int64_t l1, wchar_t *s)
{
char buf[DATASIZE*3+1];
char *c;
@@ -517,7 +517,7 @@ horigin(int m, int64_t p0, Flayer *l)
l = l ? l : &t->l[t->front];
int64_t a;
uint64_t n;
- Rune *r;
+ wchar_t *r;
if (getlayer(l, t) < 0)
return; /* the user managed to close the layer during the round trip with the host */
@@ -558,7 +558,7 @@ hcheck(int m)
Text *t;
int reqd = 0, i;
int64_t n, nl, a;
- Rune *r;
+ wchar_t *r;
if(m == Untagged)
return;
@@ -685,7 +685,7 @@ hgrow(int m, int64_t a, int64_t new, int req)
}
int
-hdata1(Text *t, int64_t a, Rune *r, int len)
+hdata1(Text *t, int64_t a, wchar_t *r, int len)
{
int i;
Flayer *l;
@@ -711,7 +711,7 @@ hdata(int m, int64_t a, uint8_t *s, int len)
{
int i, w;
Text *t = whichtext(m);
- Rune buf[DATASIZE], *r;
+ wchar_t buf[DATASIZE], *r;
if(t->lock)
--t->lock;
@@ -724,7 +724,7 @@ hdata(int m, int64_t a, uint8_t *s, int len)
}
int
-hdatarune(int m, int64_t a, Rune *r, int len)
+hdatarune(int m, int64_t a, wchar_t *r, int len)
{
Text *t = whichtext(m);
(DIR) diff --git a/samterm/rasp.c b/samterm/rasp.c
@@ -129,7 +129,7 @@ rresize(Rasp *r, int64_t a, int64_t old, int64_t new)
}
void
-rdata(Rasp *r, int64_t p0, int64_t p1, Rune *cp)
+rdata(Rasp *r, int64_t p0, int64_t p1, wchar_t *cp)
{
Section *s, *t, *ns;
@@ -167,12 +167,12 @@ rclean(Rasp *r)
}
void
-Strcpy(Rune *to, Rune *from)
+Strcpy(wchar_t *to, wchar_t *from)
{
do; while((*to++ = *from++));
}
-Rune*
+wchar_t*
rload(Rasp *r, uint64_t p0, uint64_t p1, uint64_t *nrp)
{
Section *s;
@@ -253,7 +253,7 @@ rcontig(Rasp *r, uint64_t p0, uint64_t p1, int text)
}
void
-Strgrow(Rune **s, int64_t *n, int want) /* can always toss the old data when called */
+Strgrow(wchar_t **s, int64_t *n, int want) /* can always toss the old data when called */
{
if(*n >= want)
return;
(DIR) diff --git a/samterm/samterm.h b/samterm/samterm.h
@@ -1,7 +1,7 @@
/* Copyright (c) 1998 Lucent Technologies - All rights reserved. */
#define SAMTERM
-#define RUNESIZE sizeof(Rune)
+#define RUNESIZE sizeof(wchar_t)
#define MAXFILES 256
#define NL 5
@@ -46,7 +46,7 @@ typedef struct Rasp Rasp;
struct Section
{
int64_t nrunes;
- Rune *text; /* if null, we haven't got it */
+ wchar_t *text; /* if null, we haven't got it */
Section *next;
};
@@ -86,7 +86,7 @@ extern unsigned int cursor;
extern Flayer *which;
extern Flayer *work;
extern Text cmd;
-extern Rune *scratch;
+extern wchar_t *scratch;
extern int64_t nscralloc;
extern char lock;
extern char hasunlocked;
@@ -94,7 +94,7 @@ extern int64_t snarflen;
extern Mouse mouse;
extern int64_t modified;
-Rune *stgettext(Flayer*, int64_t, uint64_t*);
+wchar_t *stgettext(Flayer*, int64_t, uint64_t*);
void *alloc(uint64_t n);
void iconinit(void);
@@ -129,7 +129,7 @@ void duplicate(Flayer*, Rectangle, XftFont*, int);
void startfile(Text*);
void panic(char*);
void closeup(Flayer*);
-void Strgrow(Rune**, int64_t*, int);
+void Strgrow(wchar_t**, int64_t*, int);
int RESHAPED(void);
void reshape(void);
void rcv(void);
@@ -144,8 +144,8 @@ void hcut(int, int64_t, int64_t);
void horigin(int, int64_t, Flayer *);
void hgrow(int, int64_t, int64_t, int);
int hdata(int, int64_t, uint8_t*, int);
-int hdatarune(int, int64_t, Rune*, int);
-Rune *rload(Rasp*, uint64_t, uint64_t, uint64_t*);
+int hdatarune(int, int64_t, wchar_t*, int);
+wchar_t *rload(Rasp*, uint64_t, uint64_t, uint64_t*);
void menuins(int, uint8_t*, Text*, int, int);
void menudel(int);
Text *sweeptext(int, int);
@@ -155,14 +155,14 @@ void scrdraw(Flayer*, int64_t tot);
int rcontig(Rasp*, uint64_t, uint64_t, int);
int rmissing(Rasp*, uint64_t, uint64_t);
void rresize(Rasp *, int64_t, int64_t, int64_t);
-void rdata(Rasp*, int64_t, int64_t, Rune*);
+void rdata(Rasp*, int64_t, int64_t, wchar_t*);
void rclean(Rasp*);
void scrorigin(Flayer*, int, int64_t);
int64_t scrtotal(Flayer*);
void flnewlyvisible(Flayer*);
char *rcvstring(void);
-void Strcpy(Rune*, Rune*);
-void Strncpy(Rune*, Rune*, int64_t);
+void Strcpy(wchar_t*, wchar_t*);
+void Strncpy(wchar_t*, wchar_t*, int64_t);
void flushtyping(int);
void dumperrmsg(int, int, int, int);
int screensize(int*,int*);
@@ -172,7 +172,7 @@ int screensize(int*,int*);
void outTs(Tmesg, int);
void outT0(Tmesg);
void outTl(Tmesg, int64_t);
-void outTslS(Tmesg, int, int64_t, Rune*);
+void outTslS(Tmesg, int, int64_t, wchar_t*);
void outTslll(Tmesg, int, int64_t, int64_t, int64_t);
void outTsll(Tmesg, int, int64_t, int64_t);
void outTsl(Tmesg, int, int64_t);