xref: /illumos-gate/usr/src/cmd/tbl/t9.c (revision 2a8bcb4e)
17c478bd9Sstevel@tonic-gate /*
2*b5514887Smuffin  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
37c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
47c478bd9Sstevel@tonic-gate  */
57c478bd9Sstevel@tonic-gate 
67c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
77c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
87c478bd9Sstevel@tonic-gate 
97c478bd9Sstevel@tonic-gate 
107c478bd9Sstevel@tonic-gate /*
117c478bd9Sstevel@tonic-gate  * Copyright (c) 1980 Regents of the University of California.
127c478bd9Sstevel@tonic-gate  * All rights reserved. The Berkeley software License Agreement
137c478bd9Sstevel@tonic-gate  * specifies the terms and conditions for redistribution.
147c478bd9Sstevel@tonic-gate  */
157c478bd9Sstevel@tonic-gate 
167c478bd9Sstevel@tonic-gate  /* t9.c: write lines for tables over 200 lines */
177c478bd9Sstevel@tonic-gate # include "t..c"
18*b5514887Smuffin 
19*b5514887Smuffin static int useln;
20*b5514887Smuffin 
21*b5514887Smuffin void
yetmore(void)22*b5514887Smuffin yetmore(void)
237c478bd9Sstevel@tonic-gate {
247c478bd9Sstevel@tonic-gate for(useln=0; useln<MAXLIN && table[useln]==0; useln++);
257c478bd9Sstevel@tonic-gate if (useln>=MAXLIN)
267c478bd9Sstevel@tonic-gate 	error(gettext("Weird.  No data in table."));
277c478bd9Sstevel@tonic-gate table[0]=table[useln];
287c478bd9Sstevel@tonic-gate for(useln=nlin-1; useln>=0 && (fullbot[useln] || instead[useln]); useln--);
297c478bd9Sstevel@tonic-gate if (useln<0)
307c478bd9Sstevel@tonic-gate 	error(gettext("Weird.  No real lines in table."));
317c478bd9Sstevel@tonic-gate domore(leftover);
327c478bd9Sstevel@tonic-gate while (gets1(cstore=cspace, MAXSTR) && domore(cstore))
337c478bd9Sstevel@tonic-gate 	;
347c478bd9Sstevel@tonic-gate last =cstore;
357c478bd9Sstevel@tonic-gate return;
367c478bd9Sstevel@tonic-gate }
37*b5514887Smuffin 
38*b5514887Smuffin int
domore(char * dataln)39*b5514887Smuffin domore(char *dataln)
407c478bd9Sstevel@tonic-gate {
417c478bd9Sstevel@tonic-gate 	int icol, ch;
427c478bd9Sstevel@tonic-gate if (prefix(".TE", dataln))
437c478bd9Sstevel@tonic-gate 	return(0);
447c478bd9Sstevel@tonic-gate if (dataln[0] == '.' && !isdigit((unsigned char)dataln[1]))
457c478bd9Sstevel@tonic-gate 	{
467c478bd9Sstevel@tonic-gate 	puts(dataln);
477c478bd9Sstevel@tonic-gate 	return(1);
487c478bd9Sstevel@tonic-gate 	}
497c478bd9Sstevel@tonic-gate instead[0]=0;
507c478bd9Sstevel@tonic-gate fullbot[0]=0;
517c478bd9Sstevel@tonic-gate if (dataln[1]==0)
527c478bd9Sstevel@tonic-gate switch(dataln[0])
537c478bd9Sstevel@tonic-gate 	{
547c478bd9Sstevel@tonic-gate 	case '_': fullbot[0]= '-'; putline(useln,0);  return(1);
557c478bd9Sstevel@tonic-gate 	case '=': fullbot[0]= '='; putline(useln, 0); return(1);
567c478bd9Sstevel@tonic-gate 	}
577c478bd9Sstevel@tonic-gate for (icol = 0; icol <ncol; icol++)
587c478bd9Sstevel@tonic-gate 	{
597c478bd9Sstevel@tonic-gate 	table[0][icol].col = dataln;
607c478bd9Sstevel@tonic-gate 	table[0][icol].rcol=0;
617c478bd9Sstevel@tonic-gate 	for(; (ch= *dataln) != '\0' && ch != tab; dataln++)
627c478bd9Sstevel@tonic-gate 			;
637c478bd9Sstevel@tonic-gate 	*dataln++ = '\0';
647c478bd9Sstevel@tonic-gate 	switch(ctype(useln,icol))
657c478bd9Sstevel@tonic-gate 		{
667c478bd9Sstevel@tonic-gate 		case 'n':
677c478bd9Sstevel@tonic-gate 			table[0][icol].rcol = maknew(table[0][icol].col);
687c478bd9Sstevel@tonic-gate 			break;
697c478bd9Sstevel@tonic-gate 		case 'a':
707c478bd9Sstevel@tonic-gate 			table[0][icol].rcol = table[0][icol].col;
717c478bd9Sstevel@tonic-gate 			table[0][icol].col= "";
727c478bd9Sstevel@tonic-gate 			break;
737c478bd9Sstevel@tonic-gate 		}
747c478bd9Sstevel@tonic-gate 	while (ctype(useln,icol+1)== 's') /* spanning */
757c478bd9Sstevel@tonic-gate 		table[0][++icol].col = "";
767c478bd9Sstevel@tonic-gate 	if (ch == '\0') break;
777c478bd9Sstevel@tonic-gate 	}
787c478bd9Sstevel@tonic-gate while (++icol <ncol)
797c478bd9Sstevel@tonic-gate 	table[0][icol].col = "";
807c478bd9Sstevel@tonic-gate putline(useln,0);
817c478bd9Sstevel@tonic-gate return(1);
827c478bd9Sstevel@tonic-gate }
83