ref: 0ec1cfd78b495e9be40e4aa24e35b2aa5d5e5704
parent: d916a4c3823f55227ffae35738c2497256e307b5
author: henesy <devnull@localhost>
date: Mon Mar 11 10:13:12 EDT 2019
fix wording in Windows build instructions ;; add support for $font and $Font checks in acme (thanks aeggy) ;; fix missing disk.b and disk.m
--- a/INSTALL
+++ b/INSTALL
@@ -91,7 +91,7 @@
1 Edit mkconfig
-2 Add $INFERNO/Nt/bin to Path
+2 Add $INFERNO/Nt/386/bin to Path
3 Start Developer Command Prompt
--- a/appl/acme/acme.b
+++ b/appl/acme/acme.b
@@ -207,9 +207,19 @@
f := utils->getenv("acme-font");
if (f != nil)
fontnames[0] = f;
+ else {
+ f = utils->getenv("font");
+ if (f != nil)
+ fontnames[0] = f;
+ }
f = utils->getenv("acme-Font");
if (f != nil)
fontnames[1] = f;
+ else {
+ f = utils->getenv("Font");
+ if (f != nil)
+ fontnames[0] = f;
+ }
arg = arginit(argl);
while(ac = argopt(arg)) case(ac){
'b' =>
--- /dev/null
+++ b/appl/acme/disk.b
@@ -1,0 +1,136 @@
+implement Diskm;
+
+include "common.m";
+
+sys : Sys;
+acme : Acme;
+utils : Utils;
+
+SZSHORT, Block, Blockincr, Astring : import Dat;
+error : import utils;
+
+init(mods : ref Dat->Mods)
+{
+ sys = mods.sys;
+ acme = mods.acme;
+ utils = mods.utils;
+}
+
+blist : ref Block;
+
+tempfile() : ref Sys->FD
+{
+ buf := sys->sprint("/tmp/X%d.%.4sacme", sys->pctl(0, nil), utils->getuser());
+ for(i:='A'; i<='Z'; i++){
+ buf[5] = i;
+ (ok, nil) := sys->stat(buf);
+ if(ok == 0)
+ continue;
+ fd := sys->create(buf, Sys->ORDWR|Sys->ORCLOSE, 8r600);
+ if(fd != nil)
+ return fd;
+ }
+ return nil;
+}
+
+Disk.init() : ref Disk
+{
+ d : ref Disk;
+
+ d = ref Disk;
+ d.free = array[Dat->Maxblock/Dat->Blockincr+1] of ref Block;
+ d.addr = 0;
+ d.fd = tempfile();
+ if(d.fd == nil){
+ error(sys->sprint("can't create temp file %r"));
+ acme->acmeexit("temp create");
+ }
+ return d;
+}
+
+ntosize(n : int) : (int, int)
+{
+ size : int;
+
+ if (n > Dat->Maxblock)
+ error("bad assert in ntosize");
+ size = n;
+ if(size & (Blockincr-1))
+ size += Blockincr - (size & (Blockincr-1));
+ # last bucket holds blocks of exactly Maxblock
+ return (size * SZSHORT, size/Blockincr);
+}
+
+Disk.new(d : self ref Disk, n : int) : ref Block
+{
+ i, j, size : int;
+ b, bl : ref Block;
+
+ (size, i) = ntosize(n);
+ b = d.free[i];
+ if(b != nil)
+ d.free[i] = b.next;
+ else{
+ # allocate in chunks to reduce malloc overhead
+ if(blist == nil){
+ blist = ref Block;
+ bl = blist;
+ for(j=0; j<100-1; j++) {
+ bl.next = ref Block;
+ bl = bl.next;
+ }
+ }
+ b = blist;
+ blist = b.next;
+ b.addr = d.addr;
+ d.addr += size;
+ }
+ b.n = n;
+ return b;
+}
+
+Disk.release(d : self ref Disk, b : ref Block)
+{
+ (nil, i) := ntosize(b.n);
+ b.next = d.free[i];
+ d.free[i] = b;
+}
+
+Disk.write(d : self ref Disk, bp : ref Block, r : string, n : int) : ref Block
+{
+ size, nsize, i : int;
+ b : ref Block;
+ ab : array of byte;
+
+ b = bp;
+ (size, i) = ntosize(b.n);
+ (nsize, i) = ntosize(n);
+ if(size != nsize){
+ d.release(b);
+ b = d.new(n);
+ }
+ if(sys->seek(d.fd, big b.addr, 0) < big 0)
+ error("seek error in temp file");
+ ab = utils->stob(r, n);
+ if(sys->write(d.fd, ab, len ab) != len ab)
+ error("write error to temp file");
+ ab = nil;
+ b.n = n;
+ return b;
+}
+
+Disk.read(d : self ref Disk, b : ref Block, r : ref Astring, n : int)
+{
+ ab : array of byte;
+
+ if (n > b.n)
+ error("bad assert in Disk.read");
+ (nil, nil) := ntosize(b.n);
+ if(sys->seek(d.fd, big b.addr, 0) < big 0)
+ error("seek error in temp file");
+ ab = array[n*SZSHORT] of byte;
+ if(sys->read(d.fd, ab, len ab) != len ab)
+ error("read error from temp file");
+ utils->btos(ab, r);
+ ab = nil;
+}
--- /dev/null
+++ b/appl/acme/disk.m
@@ -1,0 +1,19 @@
+Diskm : module {
+ PATH : con "/dis/acme/disk.dis";
+
+ init : fn(mods : ref Dat->Mods);
+
+ Disk : adt {
+ fd : ref Sys->FD;
+ addr : int; # length of temp file
+ free : array of ref Dat->Block;
+
+ init : fn() : ref Disk;
+ new : fn(d : self ref Disk, n : int) : ref Dat->Block;
+ release : fn(d : self ref Disk, b : ref Dat->Block);
+ read : fn(d : self ref Disk, b : ref Dat->Block, s : ref Dat->Astring, n : int);
+ write : fn(d : self ref Disk, b : ref Dat->Block, s : string, n : int) : ref Dat->Block;
+ };
+
+ tempfile: fn() : ref Sys->FD;
+};
binary files a/dis/acme.dis b/dis/acme.dis differ
binary files a/dis/acme/acme.dis b/dis/acme/acme.dis differ