No more (v)long distinction. - 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 957cec77c667f233f07157cd7a7e6c2c66c2c6e2
(DIR) parent 258b74b67b0885d97c6ea71e5d8c231cb5a92ded
(HTM) Author: Rob King <jking@deadpixi.com>
Date: Tue, 27 Sep 2016 10:27:31 -0500
No more (v)long distinction.
This drastically improves 64-bit compatibility.
I believe this may have been the root issue with Mac OS X compatibility.
Note that this breaks compatibility with classic sam. There's no going
back from this.
Diffstat:
README.rst | 5 -----
sam/mesg.c | 47 +++++++------------------------
sam/mesg.h | 8 +-------
sam/moveto.c | 6 ++----
sam/sam.h | 1 -
samterm/main.c | 33 ++++++-------------------------
samterm/mesg.c | 75 ++++++-------------------------
samterm/samrc.c | 2 +-
samterm/samterm.h | 2 --
9 files changed, 34 insertions(+), 145 deletions(-)
---
(DIR) diff --git a/README.rst b/README.rst
@@ -86,11 +86,6 @@ in its default configuration,
a Deadpixi samterm won't work with a non-Deadpixi sam
nor will a Deadpixi sam work with a non-Deadpixi samterm.
-Defining `CLASSIC_SAM_COMPATIBILITY` in `config.h` will allow backwards-compatibility between Deadpixi and classic sam,
-but at the expense of some of the newer features.
-
-(And note that there may come a time where there is a hard break with the past!)
-
New Features
============
(DIR) diff --git a/sam/mesg.c b/sam/mesg.c
@@ -15,17 +15,10 @@ int noflush;
int tversion;
long inlong(void);
-long invlong(void);
int inshort(void);
int inmesg(Tmesg);
void setgenstr(File*, Posn, Posn);
-#ifdef CLASSIC_SAM_COMPATIBILITY
-int oldcompat = 1;
-#else
-int oldcompat = 0;
-#endif
-
#ifdef DEBUG
char *hname[] = {
[Hversion] "Hversion",
@@ -207,7 +200,7 @@ inmesg(Tmesg type)
break;
case Tstartcmdfile:
- l = invlong(); /* for 64-bit pointers */
+ l = inlong(); /* for 64-bit pointers */
journaln(0, l);
Strdupl(&genstr, samname);
cmd = newfile();
@@ -259,11 +252,8 @@ inmesg(Tmesg type)
l = inlong(); /* position */
l1 = inlong(); /* lines to seek past position */
journaln(0, l1);
- if (!oldcompat){
- l2 = inlong(); /* cookie to return (identifies layer) */
- journaln(0, l2);
- } else
- l2 = 0;
+ l2 = inlong(); /* cookie to return (identifies layer) */
+ journaln(0, l2);
lookorigin(whichfile(s), l, l1, l2);
break;
@@ -273,7 +263,7 @@ inmesg(Tmesg type)
if(!f->rasp) /* this might be a duplicate message */
f->rasp = emalloc(sizeof(List));
current(f);
- outTsv(Hbindname, f->tag, invlong()); /* for 64-bit pointers */
+ outTsv(Hbindname, f->tag, inlong()); /* for 64-bit pointers */
outTs(Hcurrent, f->tag);
journaln(0, f->tag);
if(f->state == Unread)
@@ -361,7 +351,7 @@ inmesg(Tmesg type)
break;
case Tstartnewfile:
- l = invlong();
+ l = inlong();
Strdupl(&genstr, empty);
f = newfile();
f->rasp = emalloc(sizeof(List));
@@ -537,16 +527,6 @@ long
inlong(void)
{
ulong n;
-
- n = inp[0] | (inp[1]<<8) | (inp[2]<<16) | (inp[3]<<24);
- inp += 4;
- return n;
-}
-
-long
-invlong(void)
-{
- ulong n;
n = (inp[7]<<24) | (inp[6]<<16) | (inp[5]<<8) | inp[4];
n = (n<<16) | (inp[3]<<8) | inp[2];
@@ -686,7 +666,7 @@ outTsv(Hmesg type, int s, Posn l)
{
outstart(type);
outshort(s);
- outvlong((void*)l);
+ outlong(l);
journaln(1, l);
outsend();
}
@@ -720,17 +700,10 @@ outlong(long l)
*outp++ = l>>8;
*outp++ = l>>16;
*outp++ = l>>24;
-}
-
-void
-outvlong(void *v)
-{
- int i;
- uintptr_t l;
-
- l = (uintptr_t)v;
- for(i = 0; i < 8; i++, l >>= 8)
- *outp++ = l;
+ *outp++ = l>>32;
+ *outp++ = l>>40;
+ *outp++ = l>>48;
+ *outp++ = l>>56;
}
void
(DIR) diff --git a/sam/mesg.h b/sam/mesg.h
@@ -1,11 +1,5 @@
/* Copyright (c) 1998 Lucent Technologies - All rights reserved. */
-#ifdef CLASSIC_SAM_COMPATIBILITY
-#define VERSION 0
-#else
-#define VERSION 16091
-#endif
-
-extern int oldcompat;
+#define VERSION 16092
#define TBLOCKSIZE 512 /* largest piece of text sent to terminal */
#define DATASIZE (UTFmax*TBLOCKSIZE+30) /* ... including protocol header stuff */
(DIR) diff --git a/sam/moveto.c b/sam/moveto.c
@@ -58,10 +58,8 @@ lookorigin(File *f, Posn p0, Posn ls, long rl)
p0 = 0;
}else
p0 = oldp0;
- if (oldcompat)
- outTsl(Horigin, f->tag, p0);
- else
- outTsll(Horigin, f->tag, p0, rl);
+
+ outTsll(Horigin, f->tag, p0, rl);
}
int
(DIR) diff --git a/sam/sam.h b/sam/sam.h
@@ -395,6 +395,5 @@ void outstart(Hmesg);
void outcopy(int, void*);
void outshort(int);
void outlong(long);
-void outvlong(void*);
void outsend(void);
void outflush(void);
(DIR) diff --git a/samterm/main.c b/samterm/main.c
@@ -31,12 +31,6 @@ int expandtabs = 0;
char *machine = "localhost";
int nofifo = 0;
-#ifdef CLASSIC_SAM_COMPATIBILITY
-int oldcompat = 1;
-#else
-int oldcompat = 0;
-#endif
-
int
main(int argc, char *argv[])
{
@@ -343,16 +337,10 @@ scrorigin(Flayer *l, int but, long p0)
switch(but){
case 1:
- if (oldcompat)
- outTsll(Torigin, t->tag, l->origin, p0);
- else
- outTslll(Torigin, t->tag, l->origin, p0, getlayer(l, t));
+ outTslll(Torigin, t->tag, l->origin, p0, getlayer(l, t));
break;
case 2:
- if (oldcompat)
- outTsll(Torigin, t->tag, p0, 1L);
- else
- outTslll(Torigin, t->tag, p0, 1L, getlayer(l, t));
+ outTslll(Torigin, t->tag, p0, 1L, getlayer(l, t));
break;
case 3:
horigin(t->tag, p0, NULL);
@@ -418,10 +406,7 @@ center(Flayer *l, long a)
if (!t->lock && (a < l->origin || l->origin + l->f.nchars < a)){
a = (a > t->rasp.nrunes) ? t->rasp.nrunes : a;
- if (oldcompat)
- outTsll(Torigin, t->tag, a, 2L);
- else
- outTslll(Torigin, t->tag, a, 2L, getlayer(l, t));
+ outTslll(Torigin, t->tag, a, 2L, getlayer(l, t));
return 1;
}
@@ -443,10 +428,7 @@ onethird(Flayer *l, long a)
lines = ((s.max.y-s.min.y)/l->f.fheight+1)/3;
if (lines < 2)
lines = 2;
- if (oldcompat)
- outTsll(Torigin, t->tag, a, lines);
- else
- outTslll(Torigin, t->tag, a, lines, getlayer(l, t));
+ outTslll(Torigin, t->tag, a, lines, getlayer(l, t));
return 1;
}
return 0;
@@ -497,10 +479,7 @@ static long
cmdscrollup(Flayer *l, long a, Text *t, const char *arg)
{
flushtyping(0);
- if (oldcompat)
- outTsll(Torigin, t->tag, l->origin, l->f.maxlines + 1);
- else
- outTslll(Torigin, t->tag, l->origin, l->f.maxlines + 1, getlayer(l, t));
+ outTslll(Torigin, t->tag, l->origin, l->f.maxlines + 1, getlayer(l, t));
return a;
}
@@ -990,7 +969,7 @@ type(Flayer *l) /* what a bloody mess this is -- but it's getting better! */
CommandEntry *e = &commands[k.c];
if (!e->unlocked || !lock){
- if (k.t == Tcurrent || oldcompat)
+ if (k.t == Tcurrent)
a = e->f(l, a, t, k.a);
else{
Flayer *lt = flwhich(k.p);
(DIR) diff --git a/samterm/mesg.c b/samterm/mesg.c
@@ -20,7 +20,6 @@ int hversion;
void inmesg(Hmesg, int);
int inshort(int);
long inlong(int);
-long invlong(int);
void hsetdot(int, long, long);
void hmoveto(int, long, Flayer *);
void hsetsnarf(int);
@@ -115,7 +114,7 @@ inmesg(Hmesg type, int count)
break;
case Hbindname:
- l = invlong(2); /* for 64-bit pointers */
+ l = inlong(2); /* for 64-bit pointers */
if((i=whichmenu(m)) < 0)
break;
/* in case of a race, a bindname may already have occurred */
@@ -170,7 +169,7 @@ inmesg(Hmesg type, int count)
case Hgrow:
if(whichmenu(m) >= 0)
- hgrow(m, l, inlong(6), 1);
+ hgrow(m, l, inlong(10), 1);
break;
case Hnewname:
@@ -203,7 +202,7 @@ inmesg(Hmesg type, int count)
case Hdata:
if(whichmenu(m) >= 0)
- l += hdata(m, l, indata+6, count-6);
+ l += hdata(m, l, indata+10, count-10);
Checkscroll:
if(m == cmd.tag){
for(i=0; i<NL; i++){
@@ -216,13 +215,9 @@ inmesg(Hmesg type, int count)
case Horigin:
if(whichmenu(m) >= 0){
- if (oldcompat)
- horigin(m, l, NULL);
- else{
- Text *t = whichtext(m);
- l2 = inlong(6);
- horigin(m, l, &t->l[l2]);
- }
+ Text *t = whichtext(m);
+ l2 = inlong(10);
+ horigin(m, l, &t->l[l2]);
}
break;
@@ -236,15 +231,15 @@ inmesg(Hmesg type, int count)
case Hsetdot:
if(whichmenu(m) >= 0)
- hsetdot(m, l, inlong(6));
+ hsetdot(m, l, inlong(10));
break;
case Hgrowdata:
if(whichmenu(m)<0)
break;
- hgrow(m, l, inlong(6), 0);
+ hgrow(m, l, inlong(10), 0);
whichtext(m)->lock++; /* fake the request */
- l += hdata(m, l, indata+10, count-10);
+ l += hdata(m, l, indata+18, count-18);
goto Checkscroll;
case Hmoveto:
@@ -269,7 +264,7 @@ inmesg(Hmesg type, int count)
case Hcut:
if(whichmenu(m) >= 0)
- hcut(m, l, inlong(6));
+ hcut(m, l, inlong(10));
break;
case Hclose:
@@ -340,7 +335,7 @@ clrlock(void)
void
startfile(Text *t)
{
- outTsv(Tstartfile, t->tag, t); /* for 64-bit pointers */
+ outTsl(Tstartfile, t->tag, (long)t); /* for 64-bit pointers */
setlock();
}
@@ -348,7 +343,7 @@ void
startnewfile(int type, Text *t)
{
t->tag = Untagged;
- outTv(type, t); /* for 64-bit pointers */
+ outTl(type, (long)t); /* for 64-bit pointers */
}
int
@@ -360,13 +355,6 @@ inshort(int n)
long
inlong(int n)
{
- return indata[n]|(indata[n+1]<<8)|
- ((long)indata[n+2]<<16)|((long)indata[n+3]<<24);
-}
-
-long
-invlong(int n)
-{
long l;
l = (indata[n+7]<<24) | (indata[n+6]<<16) | (indata[n+5]<<8) | indata[n+4];
@@ -438,23 +426,6 @@ outTsl(Tmesg type, int s1, long l1)
}
void
-outTsv(Tmesg type, int s1, void *l1)
-{
- outstart(type);
- outshort(s1);
- outvlong(l1);
- outsend();
-}
-
-void
-outTv(Tmesg type, void *l1)
-{
- outstart(type);
- outvlong(l1);
- outsend();
-}
-
-void
outTslS(Tmesg type, int s1, long l1, Rune *s)
{
char buf[DATASIZE*3+1];
@@ -508,23 +479,9 @@ outshort(int s)
void
outlong(long l)
{
- uchar buf[4];
-
- buf[0]=l;
- buf[1]=l>>8;
- buf[2]=l>>16;
- buf[3]=l>>24;
- outcopy(4, buf);
-}
-
-void
-outvlong(void *v)
-{
int i;
- uintptr_t l;
uchar buf[8];
- l = (uintptr_t)v;
for(i = 0; i < sizeof(buf); i++, l >>= 8)
buf[i] = l;
@@ -590,12 +547,8 @@ hmoveto(int m, long p0, Flayer *l)
Text *t = whichtext(m);
l = l ? l : &t->l[t->front];
- if (p0 < l->origin || p0 - l->origin > l->f.nchars * 9/10){
- if (oldcompat)
- outTsll(Torigin, m, p0, 2L);
- else
- outTslll(Torigin, m, p0, 2L, getlayer(l, t));
- }
+ if (p0 < l->origin || p0 - l->origin > l->f.nchars * 9/10)
+ outTslll(Torigin, m, p0, 2L, getlayer(l, t));
}
void
(DIR) diff --git a/samterm/samrc.c b/samterm/samrc.c
@@ -165,7 +165,7 @@ static Defaultbinding defaultbindings[] ={
/* Use Control-Tab to insert a literal tab when tab expansion is enabled. */
{ControlMask, XK_Tab, Kraw, '\t', NULL},
- {0, 0, Kend, 0}
+ {0, 0, Kend, 0, NULL}
};
void
(DIR) diff --git a/samterm/samterm.h b/samterm/samterm.h
@@ -176,13 +176,11 @@ void outTslS(Tmesg, int, long, Rune*);
void outTslll(Tmesg, int, long, long, long);
void outTsll(Tmesg, int, long, long);
void outTsl(Tmesg, int, long);
-void outTsv(Tmesg, int, void*);
void outTv(Tmesg, void*);
void outstart(Tmesg);
void outcopy(int, uchar*);
void outshort(int);
void outlong(long);
-void outvlong(void*);
void outsend(void);
int getlayer(const Flayer *l, const Text *t);
void loadrcfile(FILE *);