source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: Make character engine (-Tascii, -Tpdf, -Tps) ready for Unicode:
@ 2011-05-14 17:54 kristaps
  0 siblings, 0 replies; only message in thread
From: kristaps @ 2011-05-14 17:54 UTC (permalink / raw)
  To: source

Log Message:
-----------
Make character engine (-Tascii, -Tpdf, -Tps) ready for Unicode: make buffer
consist of type "int".  This will take more work (especially in encode and
friends), but this is a strong start.  This commit also consists of some 
harmless lint fixes.

Modified Files:
--------------
    mdocml:
        chars.c
        mandoc.c
        term.c
        term.h
        term_ascii.c
        term_ps.c

Revision Data
-------------
Index: term.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/term.c,v
retrieving revision 1.186
retrieving revision 1.187
diff -Lterm.c -Lterm.c -u -p -r1.186 -r1.187
--- term.c
+++ term.c
@@ -532,7 +532,7 @@ adjbuf(struct termp *p, size_t sz)
 	while (sz >= p->maxcols)
 		p->maxcols <<= 2;
 
-	p->buf = mandoc_realloc(p->buf, p->maxcols);
+	p->buf = mandoc_realloc(p->buf, sizeof(int) * p->maxcols);
 }
 
 
@@ -562,8 +562,8 @@ encode(struct termp *p, const char *word
 	if (TERMFONT_NONE == (f = term_fonttop(p))) {
 		if (p->col + sz >= p->maxcols) 
 			adjbuf(p, p->col + sz);
-		memcpy(&p->buf[(int)p->col], word, sz);
-		p->col += sz;
+		for (i = 0; i < (int)sz; i++)
+			p->buf[(int)p->col++] = word[i];
 		return;
 	}
 
Index: mandoc.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mandoc.c,v
retrieving revision 1.50
retrieving revision 1.51
diff -Lmandoc.c -Lmandoc.c -u -p -r1.50 -r1.51
--- mandoc.c
+++ mandoc.c
@@ -704,7 +704,7 @@ mandoc_strntou(const char *p, size_t sz,
 		return(-1);
 
 	memcpy(buf, p, sz);
-	buf[sz] = '\0';
+	buf[(int)sz] = '\0';
 
 	errno = 0;
 	v = strtol(buf, &ep, base);
Index: chars.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/chars.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -Lchars.c -Lchars.c -u -p -r1.40 -r1.41
--- chars.c
+++ chars.c
@@ -151,7 +151,8 @@ mchars_num2char(const char *p, size_t sz
 		return('\0');
 
 	i = atoi(p);
-	return(isprint(i) ? (char)i : '\0');
+	/* LINTED */
+	return(isprint(i) ? i : '\0');
 }
 
 /* 
Index: term.h
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/term.h,v
retrieving revision 1.80
retrieving revision 1.81
diff -Lterm.h -Lterm.h -u -p -r1.80 -r1.81
--- term.h
+++ term.h
@@ -103,7 +103,7 @@ struct	termp {
 #define	TERMP_ANPREC	 (1 << 13)	/* See termp_an_pre(). */
 #define	TERMP_KEEP	 (1 << 14)	/* Keep words together. */
 #define	TERMP_PREKEEP	 (1 << 15)	/* ...starting with the next one. */
-	char		 *buf;		/* Output buffer. */
+	int		 *buf;		/* Output buffer. */
 	enum termenc	  enc;		/* Type of encoding. */
 	struct mchars	 *symtab;	/* Encoded-symbol table. */
 	enum termfont	  fontl;	/* Last font set. */
@@ -111,12 +111,12 @@ struct	termp {
 	int		  fonti;	/* Index of font stack. */
 	term_margin	  headf;	/* invoked to print head */
 	term_margin	  footf;	/* invoked to print foot */
-	void		(*letter)(struct termp *, char);
+	void		(*letter)(struct termp *, int);
 	void		(*begin)(struct termp *);
 	void		(*end)(struct termp *);
 	void		(*endline)(struct termp *);
 	void		(*advance)(struct termp *, size_t);
-	size_t		(*width)(const struct termp *, char);
+	size_t		(*width)(const struct termp *, int);
 	double		(*hspan)(const struct termp *,
 				const struct roffsu *);
 	const void	 *argf;		/* arg for headf/footf */
Index: term_ascii.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/term_ascii.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -Lterm_ascii.c -Lterm_ascii.c -u -p -r1.12 -r1.13
--- term_ascii.c
+++ term_ascii.c
@@ -33,12 +33,12 @@
 
 static	double		  ascii_hspan(const struct termp *,
 				const struct roffsu *);
-static	size_t		  ascii_width(const struct termp *, char);
+static	size_t		  ascii_width(const struct termp *, int);
 static	void		  ascii_advance(struct termp *, size_t);
 static	void		  ascii_begin(struct termp *);
 static	void		  ascii_end(struct termp *);
 static	void		  ascii_endline(struct termp *);
-static	void		  ascii_letter(struct termp *, char);
+static	void		  ascii_letter(struct termp *, int);
 
 
 void *
@@ -84,7 +84,7 @@ ascii_alloc(char *outopts)
 
 /* ARGSUSED */
 static size_t
-ascii_width(const struct termp *p, char c)
+ascii_width(const struct termp *p, int c)
 {
 
 	return(1);
@@ -101,7 +101,7 @@ ascii_free(void *arg)
 
 /* ARGSUSED */
 static void
-ascii_letter(struct termp *p, char c)
+ascii_letter(struct termp *p, int c)
 {
 	
 	/* LINTED */
Index: term_ps.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/term_ps.c,v
retrieving revision 1.48
retrieving revision 1.49
diff -Lterm_ps.c -Lterm_ps.c -u -p -r1.48 -r1.49
--- term_ps.c
+++ term_ps.c
@@ -373,14 +373,14 @@ ps_growbuf(struct termp *p, size_t sz)
 
 static	double		  ps_hspan(const struct termp *,
 				const struct roffsu *);
-static	size_t		  ps_width(const struct termp *, char);
+static	size_t		  ps_width(const struct termp *, int);
 static	void		  ps_advance(struct termp *, size_t);
 static	void		  ps_begin(struct termp *);
 static	void		  ps_closepage(struct termp *);
 static	void		  ps_end(struct termp *);
 static	void		  ps_endline(struct termp *);
 static	void		  ps_fclose(struct termp *);
-static	void		  ps_letter(struct termp *, char);
+static	void		  ps_letter(struct termp *, int);
 static	void		  ps_pclose(struct termp *);
 static	void		  ps_pletter(struct termp *, int);
 static	void		  ps_printf(struct termp *, const char *, ...);
@@ -963,9 +963,12 @@ ps_fclose(struct termp *p)
 
 
 static void
-ps_letter(struct termp *p, char c)
+ps_letter(struct termp *p, int arg)
 {
-	char		cc;
+	char		cc, c;
+
+	/* LINTED */
+	c = arg >= 128 || arg <= 0 ? '?' : arg;
 
 	/*
 	 * State machine dictates whether to buffer the last character
@@ -1095,14 +1098,14 @@ ps_setfont(struct termp *p, enum termfon
 
 /* ARGSUSED */
 static size_t
-ps_width(const struct termp *p, char c)
+ps_width(const struct termp *p, int c)
 {
 
 	if (c <= 32 || c - 32 >= MAXCHAR)
 		return((size_t)fonts[(int)TERMFONT_NONE].gly[0].wx);
 
 	c -= 32;
-	return((size_t)fonts[(int)TERMFONT_NONE].gly[(int)c].wx);
+	return((size_t)fonts[(int)TERMFONT_NONE].gly[c].wx);
 }
 
 
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-05-14 17:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-14 17:54 mdocml: Make character engine (-Tascii, -Tpdf, -Tps) ready for Unicode: kristaps

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).