Plan 9 from Bell Labs’s /usr/web/sources/contrib/uriel/changes/2005/1119/4

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


64-bit fixes.
 [jmk] --rw-rw-r-- M 107020 glenda sys 14280 Nov 19 20:27 sys/src/cmd/troff2html/troff2html.c
	/n/sourcesdump/2005/1119/plan9/sys/src/cmd/troff2html/troff2html.c:7,19 - 
	/n/sourcesdump/2005/1120/plan9/sys/src/cmd/troff2html/troff2html.c:7,22
	  	Wid = 20,	/* tmac.anhtml sets page width to 20" so we can recognize .nf text */
	  };
	  
	- typedef ulong Char;
	+ typedef uintptr Char;
	  typedef struct Troffchar Troffchar;
	  typedef struct Htmlchar Htmlchar;
	  typedef struct Font Font;
	  typedef struct HTMLfont HTMLfont;
	  
	- /* a Char is 32 bits. low 16 bits are the rune. higher are attributes */
	+ /*
	+  * a Char is >= 32 bits. low 16 bits are the rune. higher are attributes.
	+  * must be able to hold a pointer.
	+  */
	  enum
	  {
	  	Italic	=	16,
	/n/sourcesdump/2005/1119/plan9/sys/src/cmd/troff2html/troff2html.c:66,77 - 
	/n/sourcesdump/2005/1120/plan9/sys/src/cmd/troff2html/troff2html.c:69,80
	  /* R must be first; it's the default representation for fonts we don't recognize */
	  HTMLfont htmlfonts[] =
	  {
	- 	"R",			nil,		0,
	- 	"LucidaSans",	nil,		0,
	- 	"I",			"i",	Italic,
	+ 	"R",		nil,	0,
	+ 	"LucidaSans",	nil,	0,
	+ 	"I",		"i",	Italic,
	  	"LucidaSansI",	"i",	Italic,
	- 	"CW",		"tt",		CW,
	- 	"LucidaCW",	"tt",		CW,
	+ 	"CW",		"tt",	CW,
	+ 	"LucidaCW",	"tt",	CW,
	  	nil,	nil,
	  };
	  
	/n/sourcesdump/2005/1119/plan9/sys/src/cmd/troff2html/troff2html.c:78,121 - 
	/n/sourcesdump/2005/1120/plan9/sys/src/cmd/troff2html/troff2html.c:81,124
	  #define TABLE "<table border=0 cellpadding=0 cellspacing=0>"
	  
	  char*
	- onattr[8*sizeof(ulong)] =
	+ onattr[8*sizeof(int)] =
	  {
	  	0, 0, 0, 0, 0, 0, 0, 0,
	  	0, 0, 0, 0, 0, 0, 0, 0,
	- 	"<i>",	/* italic */
	- 	"<b>",	/* bold */
	+ 	"<i>",			/* italic */
	+ 	"<b>",			/* bold */
	  	"<tt><font size=+1>",	/* cw */
	- 	"<+table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>\n",	/* indent1 */
	- 	"<+table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>\n",	/* indent2 */
	- 	"<+table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>\n",	/* indent3 */
	+ 	"<+table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>\n",		/* indent1 */
	+ 	"<+table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>\n",		/* indent2 */
	+ 	"<+table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>\n",		/* indent3 */
	  	0,
	  	0,
	  	0,
	  	"<p><font size=+1><b>",	/* heading 25 */
	- 	"<unused>",	/* anchor 26 */
	+ 	"<unused>",		/* anchor 26 */
	  };
	  
	  char*
	- offattr[8*sizeof(ulong)] =
	+ offattr[8*sizeof(int)] =
	  {
	  	0, 0, 0, 0, 0, 0, 0, 0,
	  	0, 0, 0, 0, 0, 0, 0, 0,
	- 	"</i>",	/* italic */
	- 	"</b>",	/* bold */
	- 	"</font></tt>",	/* cw */
	- 	"<-/table>",	/* indent1 */
	- 	"<-/table>",	/* indent2 */
	- 	"<-/table>",	/* indent3 */
	+ 	"</i>",			/* italic */
	+ 	"</b>",			/* bold */
	+ 	"</font></tt>",		/* cw */
	+ 	"<-/table>",		/* indent1 */
	+ 	"<-/table>",		/* indent2 */
	+ 	"<-/table>",		/* indent3 */
	  	0,
	  	0,
	  	0,
	- 	"</b></font>",	/* heading 25 */
	- 	"</a>",	/* anchor 26 */
	+ 	"</b></font>",		/* heading 25 */
	+ 	"</a>",			/* anchor 26 */
	  };
	  
	- Font *font[Nfont];
	+ Font	*font[Nfont];
	  
	- Biobuf bout;
	+ Biobuf	bout;
	  int	debug = 0;
	  
	  /* troff state */
	/n/sourcesdump/2005/1119/plan9/sys/src/cmd/troff2html/troff2html.c:126,141 - 
	/n/sourcesdump/2005/1120/plan9/sys/src/cmd/troff2html/troff2html.c:129,144
	  int	ps = 1;
	  int	res = 720;
	  
	- int		didP = 0;
	- int		atnewline = 1;
	- int		prevlineH = 0;
	- ulong	attr = 0;	/* or'ed into each Char */
	+ int	didP = 0;
	+ int	atnewline = 1;
	+ int	prevlineH = 0;
	+ Char	attr = 0;	/* or'ed into each Char */
	  
	- Char		*chars;
	- int		nchars;
	- int		nalloc;
	+ Char	*chars;
	+ int	nchars;
	+ int	nalloc;
	  char**	anchors;	/* allocated in order */
	- int		nanchors;
	+ int	nanchors;
	  
	  char	*filename;
	  int	cno;
	/n/sourcesdump/2005/1119/plan9/sys/src/cmd/troff2html/troff2html.c:245,251 - 
	/n/sourcesdump/2005/1120/plan9/sys/src/cmd/troff2html/troff2html.c:248,254
	  }
	  
	  void
	- emitul(ulong ul)
	+ emitchar(Char c)
	  {
	  	if(nalloc == nchars){
	  		nalloc += 10000;
	/n/sourcesdump/2005/1119/plan9/sys/src/cmd/troff2html/troff2html.c:253,265 - 
	/n/sourcesdump/2005/1120/plan9/sys/src/cmd/troff2html/troff2html.c:256,268
	  		if(chars == nil)
	  			sysfatal("malloc failed: %r");
	  	}
	- 	chars[nchars++] = ul;
	+ 	chars[nchars++] = c;
	  }
	  
	  void
	  emit(Rune r)
	  {
	- 	emitul(r | attr);
	+ 	emitchar(r | attr);
	  	/*
	  	 * Close man page references early, so that 
	  	 * .IR proof (1),
	/n/sourcesdump/2005/1119/plan9/sys/src/cmd/troff2html/troff2html.c:272,279 - 
	/n/sourcesdump/2005/1120/plan9/sys/src/cmd/troff2html/troff2html.c:275,282
	  void
	  emitstr(char *s)
	  {
	- 	emitul(Estring);
	- 	emitul((ulong)s);
	+ 	emitchar(Estring);
	+ 	emitchar((Char)s);
	  }
	  
	  int indentlevel;
	/n/sourcesdump/2005/1119/plan9/sys/src/cmd/troff2html/troff2html.c:312,320 - 
	/n/sourcesdump/2005/1120/plan9/sys/src/cmd/troff2html/troff2html.c:315,324
	  }
	  
	  void
	- setattr(ulong a)
	+ setattr(Char a)
	  {
	- 	int on, off, i, j;
	+ 	Char on, off;
	+ 	int i, j;
	  
	  	on = a & ~attr;
	  	off = attr & ~a;
	/n/sourcesdump/2005/1119/plan9/sys/src/cmd/troff2html/troff2html.c:348,353 - 
	/n/sourcesdump/2005/1120/plan9/sys/src/cmd/troff2html/troff2html.c:352,359
	  			if(j == Anchor)
	  				onattr[j] = anchors[nanchors++];
	  			iputs(&bout, onattr[j]);
	+ 			if(nnest >= nelem(nest))
	+ 				sysfatal("nesting too deep");
	  			nest[nnest++] = j;
	  		}
	  	}
	/n/sourcesdump/2005/1119/plan9/sys/src/cmd/troff2html/troff2html.c:358,364 - 
	/n/sourcesdump/2005/1120/plan9/sys/src/cmd/troff2html/troff2html.c:364,370
	  flush(void)
	  {
	  	int i;
	- 	ulong c, a;
	+ 	Char c, a;
	  
	  	nanchors = 0;
	  	for(i=0; i<nchars; i++){
	/n/sourcesdump/2005/1119/plan9/sys/src/cmd/troff2html/troff2html.c:561,572 - 
	/n/sourcesdump/2005/1120/plan9/sys/src/cmd/troff2html/troff2html.c:567,578
	  			}
	  		}else if(strcmp(fld[2], "manPP") == 0){
	  			didP = 1;
	- 			emitul(Epp);
	+ 			emitchar(Epp);
	  		}else if(nfld<4 || strcmp(fld[2], "manref")!=0){
	  			if(nfld>2 && strcmp(fld[2], "<P>")==0){	/* avoid triggering extra <br> */
	  				didP = 1;
	  				/* clear all font attributes before paragraph */
	- 				emitul(' ' | (attr & ~(0xFFFF|((1<<Italic)|(1<<Bold)|(1<<CW)))));
	+ 				emitchar(' ' | (attr & ~(0xFFFF|((1<<Italic)|(1<<Bold)|(1<<CW)))));
	  				emitstr("<P>");
	  				/* next emittec char will turn font attributes back on */
	  			}else if(nfld>2 && strcmp(fld[2], "<H4>")==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.