Subject: 9libs, new sam release, experimental wily release

From: "Mark H. Wilkinson" <[email-masked]>
Date: Thu, 10 Jun 1999 19:04:28 -0400

We would like to announce the release of the following bundles of code:

 * 9libs-1.0, a collection of libraries which emulate some parts of the
   Plan 9 programming environment under Unix and the X Window System.
 * sam-9libs, a new release of Rob Pike's editor, sam, which uses 9libs-1.0.
 * wily-9libs, an experimental release of Gary Capell's editor, wily, which
   emulates the functionality of Rob's editor "acme" from Plan 9. Again,
   wily-9libs uses 9libs.

9libs-1.0 is a repackaging of libXg, libframe and libregexp from the last
release of sam. It replaces the collection of Makefiles with a build
system which uses a GNU-style configure script and which will build
shared libraries using GNU libtool. The intention is to make it easier
to compile and install the libraries (and applications which use them)
on modern Unix systems. It also adds some new implementations of Plan 9
functions (notably the print() functions) which have been grouped with
libregexp into a new library called libplan9c.

sam-9libs is a new release of sam which links against the libraries
from 9libs-1.0. Other than changes in the build system there is only
one new feature: sam uses the value of the environment variable TABSTOP
to set the size of its tabstop. It is intended that this release of sam
become the "official" release: the version of samterm which Bell Labs
run on brazil uses a newer graphics model than that provided by libg
(and libXg). As such it is growing increasingly difficult for them to
support this older version.

wily-9libs is an experimental (as in "not official") release of
wily-0.13.43 which has been modified to build against 9libs. It also
adds an implementation of the Font builtin which more closely emulates
the same builtin in acme.

You can get the code from the following locations:

	ftp://netlib.bell-labs.com/netlib/research/9libs
	ftp://ftp.demon.co.uk/pub/unix/plan9

Why would you want to use this? Basically, it makes your life easier.
You can compile and install 9libs, sam and wily separately if you want.
You can also build the whole lot together: it's as simple as this:

	; gunzip -c 9libs-1.0.tar.gz | tar xf -
	; cd 9libs-1.0
	; gunzip -c ../sam-9libs.tar.gz | tar xf -
	; gunzip -c ../wily-9libs.tar.gz | tar xf -
	; ./configure
	; make

The build system also supports building for multiple architectures from
one directory tree.

Enjoy!

Mark Wilkinson <[email-masked]>
Bengt Kleberg <[email-masked]>

---

From: Scott Schwartz <[email-masked]>
Date: Mon, 14 Jun 1999 20:39:48 -0400

"Mark H. Wilkinson" <[email-masked]> writes:
| It looks like your patches hadn't made it into the Bell Labs source,
| although I do remember some of them being posted to sam-fans. If you
| forward them to Bengt and myself we'll get them integrated.

Here they are.  (Hopefully I haven't introduced any new problems
today; I did tweak some things.)

The program I use in my xinitrc to load the font property looks like this:

	#!/bin/rc
	F=``(){sed -e 's/$/ \\n\\/'}
	{
	echo -n '*p9font: ' 
	echo $F
	echo -n '*p9fixed: '
	echo $F
	} | xrdb -merge

I use it like:
	load9font <$home/lib/unicode.9.font

Wily users might want to do this slightly differently, since that
requires a proportional font for one case.

cd ./libXg
===================================================================
RCS file: rdfontfile.c,v
retrieving revision 1.1
diff -c -r1.1 rdfontfile.c
*** /tmp/T0s0Qol_	Mon Jun 14 20:25:00 1999
--- rdfontfile.c	Mon Jun 14 18:06:11 1999
***************
*** 13,27 ****
  	return s;
  }
  
! Font *
! rdfontfile(char *name, int ldepth)
  {
! 	Font *fnt;
! 	Cachesubf *c;
! 	int fd, i;
! 	char *buf, *s, *t;
  	struct stat sbuf;
! 	unsigned long min, max;
  
  	fd = open(name, O_RDONLY);
  	if (fd < 0)
--- 13,25 ----
  	return s;
  }
  
! char *
! file2string(char* name)
  {
! 	int fd;
  	struct stat sbuf;
! 	char *buf;
! 	int i;
  
  	fd = open(name, O_RDONLY);
  	if (fd < 0)
***************
*** 44,54 ****
  		free(buf);
  		return 0;
  	}
  
! 	s = buf;
  	fnt = (Font *)malloc(sizeof(Font));
! 	if (fnt == 0)
! 		goto Err1;
  	memset((void*)fnt, 0, sizeof(Font));
  	fnt->name = (char *)malloc(strlen(name)+1);
  	if (fnt->name==0)
--- 42,73 ----
  		free(buf);
  		return 0;
  	}
+ 	return buf;
+ }
  
! Font *
! rdfontfile(char *name, int ldepth)
! {
! 	return rdfontstring(name, file2string(name), ldepth);
! }
! 
! Font*
! rdfontstring(char *name, char *s, int ldepth)
! {
! 	Font *fnt;
! 	Cachesubf *c;
! 	int i;
! 	char *t;
! 	struct stat sbuf;
! 	unsigned long min, max;
! 
! 	if (s == 0)
! 		return 0;
  	fnt = (Font *)malloc(sizeof(Font));
! 	if (fnt == 0) {
!     Err1:
! 		return 0;
! 	}
  	memset((void*)fnt, 0, sizeof(Font));
  	fnt->name = (char *)malloc(strlen(name)+1);
  	if (fnt->name==0)
***************
*** 97,117 ****
  		c->min = min;
  		c->max = max;
  		t = s;
! 		while (*s && *s!='\n' && *s!='\t')
  			s++;
! 		*s++ = 0;
  		c->f = (Subfont *)0;
! 		c->name = (char *)malloc(strlen(t)+1);
  		if (c->name == 0)
  		{
  			free(c);
  			goto Err3;
  		}
! 		strcpy(c->name, t);
  		s = skip(s);
  		fnt->nsubf++;
  	} while(*s);
- 	free(buf);
  	return fnt;
  }
  
--- 116,139 ----
  		c->min = min;
  		c->max = max;
  		t = s;
! 		while (*s && *s!='\n' && *s!='\t' && *s!=' ')
  			s++;
! 		/* *s++ = 0; */
  		c->f = (Subfont *)0;
! 		c->name = (char *)malloc(s-t+1);
  		if (c->name == 0)
  		{
  			free(c);
  			goto Err3;
  		}
! 		{ int i;
! 		  for (i = 0; i < s-t; ++i) c->name[i] = t[i];
! 		  c->name[i] = 0;
! 		}
! 		/* strcpy(c->name, t); */
  		s = skip(s);
  		fnt->nsubf++;
  	} while(*s);
  	return fnt;
  }
  
***************
*** 127,132 ****
--- 149,155 ----
  		if (c->f)
  			subffree(c->f);
  		free(c->name);
+ 		free(c);
  	}
  	free(f->subf);
  	free(f);
===================================================================
RCS file: xtbinit.c,v
retrieving revision 1.1
diff -c -r1.1 xtbinit.c
*** /tmp/T0s0Qol_	Mon Jun 14 20:25:00 1999
--- xtbinit.c	Mon Jun 14 17:24:10 1999
***************
*** 185,191 ****
  	font = 0;
  	subfont = 0;
  	if (fontname) {
! 		font = rdfontfile(fontname, screen.ldepth);
  		if (!font || charwidth(font, (Rune) ' ') == 0) {
  			subfont = getsubfont(fontname);
  			if (!subfont)
--- 185,193 ----
  	font = 0;
  	subfont = 0;
  	if (fontname) {
! 		font = (fontname[0] == '.' || fontname[0] == '/')
! 		     ? rdfontfile(fontname, screen.ldepth)
! 		     : rdfontstring("p9font", fontname, screen.ldepth);
  		if (!font || charwidth(font, (Rune) ' ') == 0) {
  			subfont = getsubfont(fontname);
  			if (!subfont)
cd ./include
===================================================================
RCS file: libg.h,v
retrieving revision 1.1
diff -c -r1.1 libg.h
*** /tmp/T0gdJVh_	Mon Jun 14 20:25:01 1999
--- libg.h	Mon Jun 14 02:15:54 1999
***************
*** 201,206 ****
--- 201,207 ----
  extern int	 bitbltclip(void*);
  extern Subfont*	 getsubfont(char*);
  extern Font	*rdfontfile(char*, int);
+ extern Font	*rdfontstring(char*, char*, int);
  extern void	 ffree(Font*);
  extern Font	*mkfont(Subfont*);
  extern void	 subffree(Subfont*);
cd ./sam-9libs/sam
===================================================================
RCS file: sam.c,v
retrieving revision 1.1
diff -c -r1.1 sam.c
*** /tmp/T002r2br	Mon Jun 14 20:25:01 1999
--- sam.c	Mon Jun 14 02:27:09 1999
***************
*** 151,157 ****
  			continue;
  		if(io == -1){
  			sprint(buf, "%s/sam.save", home);
! 			io = create(buf, 1, 0777);
  			if(io<0)
  				return;
  		}
--- 151,157 ----
  			continue;
  		if(io == -1){
  			sprint(buf, "%s/sam.save", home);
! 			io = create(buf, 1, 0700);
  			if(io<0)
  				return;
  		}
===================================================================
RCS file: shell.c,v
retrieving revision 1.1
diff -c -r1.1 shell.c
*** /tmp/T002r2br	Mon Jun 14 20:25:01 1999
--- shell.c	Mon Jun 14 02:28:37 1999
***************
*** 34,40 ****
  		remove(errfile);
  	if((pid=fork()) == 0){
  		if(downloaded){	/* also put nasty fd's into errfile */
! 			fd = create(errfile, 1, 0666L);
  			if(fd < 0)
  				fd = create("/dev/null", 1, 0666L);
  			dup(fd, 2);
--- 34,40 ----
  		remove(errfile);
  	if((pid=fork()) == 0){
  		if(downloaded){	/* also put nasty fd's into errfile */
! 			fd = create(errfile, 1, 0600L);
  			if(fd < 0)
  				fd = create("/dev/null", 1, 0666L);
  			dup(fd, 2);
cd ./sam-9libs/samterm
===================================================================
RCS file: samterm.h,v
retrieving revision 1.1
diff -c -r1.1 samterm.h
*** /tmp/T00P2og_	Mon Jun 14 20:25:01 1999
--- samterm.h	Mon Jun 14 17:51:13 1999
***************
*** 2,8 ****
  #define	SAMTERM
  
  #define	RUNESIZE	sizeof(Rune)
! #define	MAXFILES	256
  #define	NL	5
  
  enum{
--- 2,8 ----
  #define	SAMTERM
  
  #define	RUNESIZE	sizeof(Rune)
! #define	MAXFILES	(4*1024)
  #define	NL	5
  
  enum{

---

From: Scott Schwartz <[email-masked]>
Date: Mon, 14 Jun 1999 20:10:04 -0400

"Mark H. Wilkinson" <[email-masked]> writes: 
| >   * In libXg, "fontfile" is specified by the X client app.  In general
| >     that cannot work: unlike in Plan 9, the X terminal usually won't
| >     share any filesystem with the machine on which the X app is
| >     running, so *no* filename can be valid for "-p9font".  The fix is
| >     to store the unicode font map in an X property which is set by your
| >     xinitrc.
| 
| By this, do you mean the case where you're logging into remote machines
| and running sam & samterm on the remote machine?

Yes.

| ... but I guess you're after a
| solution which is easier to manage, using the X server as shared storage.

Yup.

| That sounds reasonable, but I'd like to retain the existing mechanism
| too: it works well in networks where the file system is common to all
| machines to some degree. 

Of course.  The patch does that.  It checks to see if the fontfile
starts with '.' or '/', and if so, reads that file.  Otherwise it
treats it as the literal contents of the font file. In either case, as
before, it falls back to using a literal X font name if the previous
steps don't resolve to a font file. 

| That would be great!

I'll have them ready soon.  I got diverted hacking on 9term today.

---

From: "Mark H. Wilkinson" <[email-masked]>
Date: Mon, 14 Jun 1999 15:46:50 -0400

> | 9libs-1.0, sam-9libs, wily-9libs

> Thanks.  I have a couple of complaints, though.  Several of my
> favorite bugs (patches posted ages ago) have been resurrected
> in this new release.

It looks like your patches hadn't made it into the Bell Labs source,
although I do remember some of them being posted to sam-fans. If you
forward them to Bengt and myself we'll get them integrated.

> They are:
>   * In samterm, MAXFILES is too small.  (I've been using 4K.)

Sounds reasonable. The "sam" program uses a variable length list to
hold open files whilst the "samterm" program uses a fixed size array.
A better solution might be to replace the fixed size array with a variable
sized list, but upping the limit looks fine for the time being.

>   * In sam, private temp files are world readable/writable.

Yup, I remember this one too. Again, sounds Ok to me.

>   * In libXg, "fontfile" is specified by the X client app.  In general
>     that cannot work: unlike in Plan 9, the X terminal usually won't
>     share any filesystem with the machine on which the X app is
>     running, so *no* filename can be valid for "-p9font".  The fix is
>     to store the unicode font map in an X property which is set by your
>     xinitrc.

By this, do you mean the case where you're logging into remote machines
and running sam & samterm on the remote machine? You can always get round
the problem by making sure the font file you want to use is available
on each of the machines you connect to, but I guess you're after a
solution which is easier to manage, using the X server as shared storage.
That sounds reasonable, but I'd like to retain the existing mechanism
too: it works well in networks where the file system is common to all
machines to some degree.  It also has utility in wily where the Font
builtin can be used to switch between font files dynamically.

> I'll dig the diffs out of my RCS files tomorrow and sent them along.

That would be great!

Cheers,

-Mark.

---

From: Scott Schwartz <[email-masked]>
Date: Mon, 14 Jun 1999 02:44:32 -0400

They are: