Plan 9 from Bell Labs’s /usr/web/sources/contrib/steve/root/sys/src/cmd/refer/refer4.c

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


# include "refer.h"
static gate = 0;
static char	buff[LLINE];

void output(char *s)
{
	if (gate)
		fputs(buff, ftemp);
	else
		gate = 1;
	strcpy(buff, s);
	if (strlen(buff) > LLINE)
		err("one buff too big (%d)!", LLINE);
}

void append(char *s)
{
	char	*p, *r; 
	int	lch;

	trimnl(buff);
	for (p = buff; *p; p++)
		;
	lch = *--p;
	switch (lch) {
	case '.': 
	case ',': 
	case ';': 
	case ':':
		*p = 0;
		r = "\\*(<";
		while (*r) 
			*p++ = *r++;
		*p++ = lch;
		*p = 0;
	}
	strcat(buff, s);
	switch (lch) {
	case '.': 
	case ',': 
	case ';': 
	case ':':
		for (p = buff; *p; p++)
			;
		if (*--p == '\n')
			*p = 0;
		r = "\\*(>";
		while (*r) 
			*p++ = *r++;
		*p++ = lch;
		*p++ = '\n';
		*p = 0;
	}
	if (strlen(buff) > LLINE)
		err("output buff too long (%d)", LLINE);
}

void flout(void)
{
	if (gate)
		fputs(buff, ftemp);
	gate = 0;
}

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.