code: purgatorio

Download patch

ref: 8164505a0df98c04b04ae40eb0780bbadf710e1d
parent: efd1615c5741a6898853fefc24b1cbcb734e5477
author: henesy <devnull@localhost>
date: Wed Oct 2 21:02:17 EDT 2019

add ind and unind for use in acme from petes a+.b and a-.b

--- a/.hgignore
+++ b/.hgignore
@@ -59,6 +59,7 @@
 ^dis/*/.*.dis
 ^appl/.*.dis
 ^appl/.*.sbl
+^acme/dis/.*.dis
 ^tmp/.*
 ^contrib/.*
 ^usr/\.*
--- /dev/null
+++ b/appl/acme/acme/bin/src/ind.b
@@ -1,0 +1,49 @@
+implement APlus;
+
+include "sys.m"; sys: Sys;
+include "draw.m";
+include "bufio.m"; bufio: Bufio;
+	Iobuf: import bufio;
+
+APlus: module {
+	init: fn(nil: ref Draw->Context, args: list of string);
+};
+
+pname: string;
+
+init(nil: ref Draw->Context, args: list of string)
+{
+	sys = load Sys Sys->PATH;
+	bufio = load Bufio Bufio->PATH;
+
+	indents := "\t";
+
+	if(args != nil) {
+		pname = hd args;
+		args = tl args;
+	} else {
+		pname = "a+";
+	}
+
+	if(args != nil)
+		indents = hd args;
+
+	indent(indents);
+}
+
+indent(s: string)
+{
+	stdin := bufio->fopen(sys->fildes(0), bufio->OREAD);
+	if(stdin == nil) {
+		sys->fprint(sys->fildes(2), "%s: Couldn't create a bufio:  %r\n", pname);
+		raise "fail:errors";
+	}
+
+	while((line := stdin.gets('\n')) != nil) {
+		if(line == "\n") {
+			sys->print("\n");
+		} else {
+			sys->print("%s%s", s, line);
+		}
+	}
+}
--- a/appl/acme/acme/bin/src/mkfile
+++ b/appl/acme/acme/bin/src/mkfile
@@ -9,6 +9,8 @@
 	spout.dis\
 	awd.dis\
 	cd.dis\
+	ind.dis\
+	unind.dis\
 
 MODULES=\
 	
--- /dev/null
+++ b/appl/acme/acme/bin/src/unind.b
@@ -1,0 +1,47 @@
+implement AMinus;
+
+include "sys.m"; sys: Sys;
+include "draw.m";
+include "bufio.m"; bufio: Bufio;
+	Iobuf: import bufio;
+
+AMinus: module {
+	init: fn(nil: ref Draw->Context, args: list of string);
+};
+
+pname: string;
+
+init(nil: ref Draw->Context, args: list of string)
+{
+	sys = load Sys Sys->PATH;
+	bufio = load Bufio Bufio->PATH;
+
+	indents := "\t";
+
+	if(args != nil) {
+		pname = hd args;
+		args = tl args;
+	} else {
+		pname = "a-";
+	}
+
+	if(args != nil)
+		indents = hd args;
+
+	unindent(indents);
+}
+
+unindent(s: string)
+{
+	stdin := bufio->fopen(sys->fildes(0), bufio->OREAD);
+	if(stdin == nil) {
+		sys->fprint(sys->fildes(2), "%s: Couldn't create a bufio:  %r\n", pname);
+		raise "fail:errors";
+	}
+
+	while((line := stdin.gets('\n')) != nil) {
+		if(len line >= len s && line[0:len s] == s)
+			line = line[len s:];
+		sys->print("%s", line);
+	}
+}