aboutsummaryrefslogtreecommitdiffstats
path: root/troff/troff.d
diff options
context:
space:
mode:
authorBaptiste Daroussin <bapt@FreeBSD.org>2016-10-23 00:24:25 +0000
committerBaptiste Daroussin <bapt@FreeBSD.org>2016-10-23 00:24:25 +0000
commitab1717bb35d85041e0184f79daa1313a1306dc01 (patch)
treefa0739f76b49b902269f8f7c1e1c7c5ea30c0556 /troff/troff.d
parentaa7798c94fa57f6c00fab4393c9fe91334864371 (diff)
downloadsrc-ab1717bb35d85041e0184f79daa1313a1306dc01.tar.gz
src-ab1717bb35d85041e0184f79daa1313a1306dc01.zip
Import heirloom doctools snapshot 20161016vendor/heirloom-doctools/20161016
Notes
Notes: svn path=/vendor/heirloom-doctools/dist/; revision=307809 svn path=/vendor/heirloom-doctools/20161016/; revision=307810; tag=vendor/heirloom-doctools/20161016
Diffstat (limited to 'troff/troff.d')
-rw-r--r--troff/troff.d/Makefile.mk2
-rw-r--r--troff/troff.d/afm.c40
-rw-r--r--troff/troff.d/afm.h2
-rw-r--r--troff/troff.d/devaps/Makefile.mk2
-rw-r--r--troff/troff.d/devaps/getopt.c222
-rw-r--r--troff/troff.d/dpost.d/Makefile.mk2
-rw-r--r--troff/troff.d/dpost.d/color.c2
-rw-r--r--troff/troff.d/dpost.d/dpost.c322
-rw-r--r--troff/troff.d/dpost.d/dpost.h4
-rw-r--r--troff/troff.d/dpost.d/draw.c8
-rw-r--r--troff/troff.d/dpost.d/gen.h27
-rw-r--r--troff/troff.d/dpost.d/getopt.c222
-rw-r--r--troff/troff.d/dpost.d/misc.c27
-rw-r--r--troff/troff.d/dpost.d/ps_include.c21
-rw-r--r--troff/troff.d/dpost.d/request.c8
-rw-r--r--troff/troff.d/dpost.d/request.h2
-rw-r--r--troff/troff.d/draw.c11
-rw-r--r--troff/troff.d/fontmap.c6
-rw-r--r--troff/troff.d/fontmap.h2
-rw-r--r--troff/troff.d/otf.c109
-rw-r--r--troff/troff.d/otfdump.c7
-rw-r--r--troff/troff.d/pt.h4
-rw-r--r--troff/troff.d/t10.c129
-rw-r--r--troff/troff.d/t6.c150
24 files changed, 428 insertions, 903 deletions
diff --git a/troff/troff.d/Makefile.mk b/troff/troff.d/Makefile.mk
index c5064cde9e3c..630646cd7917 100644
--- a/troff/troff.d/Makefile.mk
+++ b/troff/troff.d/Makefile.mk
@@ -62,5 +62,5 @@ version.o: ../version.c
otfdump_vs.o: ../version.c
afm.o: dev.h afm.h
otf.o: dev.h afm.h unimap.h
-otfdump.o: afm.h afm.c otf.c otfdump.c dpost.d/getopt.c dev.h
+otfdump.o: afm.h afm.c otf.c otfdump.c dev.h
fontmap.o: fontmap.h
diff --git a/troff/troff.d/afm.c b/troff/troff.d/afm.c
index f87dcefaaf58..b5bea1c35e6f 100644
--- a/troff/troff.d/afm.c
+++ b/troff/troff.d/afm.c
@@ -31,6 +31,10 @@
#include "dev.h"
#include "afm.h"
+#ifndef __unused
+#define __unused __attribute__((unused))
+#endif
+
extern char *chname;
extern short *chtab;
extern int nchtab;
@@ -44,9 +48,9 @@ static void addkernpair(struct afmtab *, char *_line);
/*
* This table maps troff special characters to PostScript names.
*/
-const struct names {
- char *trname;
- char *psname;
+static const struct names {
+ const char *trname;
+ const char *psname;
} names[] = {
{ "hy", "hyphen" },
{ "ct", "cent" },
@@ -81,7 +85,7 @@ const struct names {
/*
* Names for Symbol fonts only.
*/
-const struct names greeknames[] = {
+static const struct names greeknames[] = {
{ "*A", "Alpha" },
{ "*B", "Beta" },
{ "*C", "Xi" },
@@ -133,7 +137,7 @@ const struct names greeknames[] = {
{ 0, 0 }
};
-const struct names mathnames[] = {
+static const struct names mathnames[] = {
{ "!=", "notequal" },
{ "**", "asteriskmath" },
{ "+-", "plusminus" },
@@ -187,7 +191,7 @@ const struct names mathnames[] = {
{ 0, 0 },
};
-const struct names largenames[] = {
+static const struct names largenames[] = {
{ "bv", "braceex" },
{ "lb", "braceleftbt" },
{ "lc", "bracketlefttp" },
@@ -203,7 +207,7 @@ const struct names largenames[] = {
{ 0, 0 }
};
-const struct names punctnames[] = {
+static const struct names punctnames[] = {
{ "or", "bar" },
{ "\\-","endash" },
{ "aa","acute" },
@@ -216,7 +220,7 @@ const struct names punctnames[] = {
/*
* These names are only used with the S font.
*/
-const struct names Snames[] = {
+static const struct names Snames[] = {
{ "br", "parenleftex" },
{ "ul", "underscore" },
{ "vr", "bracketleftex" },
@@ -226,7 +230,7 @@ const struct names Snames[] = {
/*
* These names are only used with the S1 font.
*/
-const struct names S1names[] = {
+static const struct names S1names[] = {
{ "ru", "underscore" },
{ 0, 0 }
};
@@ -499,7 +503,7 @@ nextprime(int n)
268435399, 536870909, 1073741789, 2147483647
};
int mprime = 7;
- int i;
+ size_t i;
for (i = 0; i < sizeof primes / sizeof *primes; i++)
if ((mprime = primes[i]) >= (n < 65536 ? n*4 :
@@ -530,7 +534,7 @@ struct namecache *
afmnamelook(struct afmtab *a, const char *name)
{
struct namecache *np;
- unsigned h, c, n = 0;
+ int h, c, n = 0;
h = pjw(name) % a->nameprime;
np = &a->namecache[c = h];
@@ -632,7 +636,7 @@ afmremap(struct afmtab *a)
#ifndef DUMP
static int
-asciiequiv(int code, const char *psc, enum spec s)
+asciiequiv(int code __unused, const char *psc, enum spec s)
{
int i;
@@ -655,7 +659,7 @@ asciiequiv(int code, const char *psc, enum spec s)
}
static char *
-thisword(const char *text, const char *wrd)
+thisword(char *text, const char *wrd)
{
while (*text == *wrd)
text++, wrd++;
@@ -665,7 +669,7 @@ thisword(const char *text, const char *wrd)
*text == '\r') {
while (*text != 0 && (*text == ' ' || *text == '\t'))
text++;
- return (char *)text;
+ return text;
}
return NULL;
}
@@ -890,9 +894,7 @@ afmget(struct afmtab *a, char *contents, size_t size)
cp = a->file;
else
cp++;
- l = strlen(cp) + 1;
- a->base = malloc(l);
- n_strcpy(a->base, cp, l);
+ a->base = strdup(cp);
if ((cp = strrchr(a->base, '.')) != NULL)
*cp = '\0';
if (dev.allpunct)
@@ -988,8 +990,8 @@ afmget(struct afmtab *a, char *contents, size_t size)
* troff and dpost need it in combination with AFM support.
*/
void
-makefont(int nf, char *devfontab, char *devkerntab, char *devcodetab,
- char *devfitab, int nw)
+makefont(int nf, const char *devfontab, const char *devkerntab,
+ const char *devcodetab, const char *devfitab, int nw)
{
int i;
diff --git a/troff/troff.d/afm.h b/troff/troff.d/afm.h
index 5c18a38f99f7..59c601905917 100644
--- a/troff/troff.d/afm.h
+++ b/troff/troff.d/afm.h
@@ -123,7 +123,7 @@ extern int afmget(struct afmtab *, char *, size_t);
extern int otfget(struct afmtab *, char *, size_t);
extern struct namecache *afmnamelook(struct afmtab *, const char *);
extern int afmgetkern(struct afmtab *, int, int);
-extern void makefont(int, char *, char *, char *, char *, int);
+extern void makefont(int, const char *, const char *, const char *, const char *, int);
extern int unitconv(int);
extern void afmalloc(struct afmtab *, int);
extern void afmremap(struct afmtab *);
diff --git a/troff/troff.d/devaps/Makefile.mk b/troff/troff.d/devaps/Makefile.mk
index 92e3d7f1c3fd..e38fffbdd64b 100644
--- a/troff/troff.d/devaps/Makefile.mk
+++ b/troff/troff.d/devaps/Makefile.mk
@@ -1,4 +1,4 @@
-OBJ = daps.o build.o draw.o getopt.o version.o
+OBJ = daps.o build.o draw.o version.o
FONTS = B I R S CT CW CX GB GI GR GS HI HK HX PO PX S1 SC SM TX DESC \
C G H BI CE CI HB HL MB MI MR MX PA PB PI TB
diff --git a/troff/troff.d/devaps/getopt.c b/troff/troff.d/devaps/getopt.c
deleted file mode 100644
index bb8c53d072cb..000000000000
--- a/troff/troff.d/devaps/getopt.c
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany
- *
- * Sccsid @(#)getopt.c 1.10 (gritter) 12/16/07
- */
-/* from OpenSolaris "getopt.c 1.23 05/06/08 SMI" */
-
-/* Copyright (c) 1988 AT&T */
-/* All Rights Reserved */
-
-
-/*
- * See getopt(3C) and SUS/XPG getopt() for function definition and
- * requirements.
- *
- * This actual implementation is a bit looser than the specification
- * as it allows any character other than ':' to be used as an option
- * character - The specification only guarantees the alnum characters
- * ([a-z][A-Z][0-9]).
- */
-
-#include <sys/types.h>
-#include <string.h>
-#include <stdio.h>
-
-extern ssize_t write(int, const void *, size_t);
-
-char *optarg = NULL;
-int optind = 1;
-int opterr = 1;
-int optopt = 0;
-
-#define ERR(s, c) err(s, c, optstring, argv[0])
-static void
-err(const char *s, int c, const char *optstring, const char *argv0)
-{
- char errbuf[256], *ep = errbuf;
- const char *cp;
-
- if (opterr && optstring[0] != ':') {
- for (cp = argv0; *cp && ep<&errbuf[sizeof errbuf]; cp++, ep++)
- *ep = *cp;
- for (cp = ": "; *cp && ep<&errbuf[sizeof errbuf]; cp++, ep++)
- *ep = *cp;
- for (cp = s; *cp && ep<&errbuf[sizeof errbuf]; cp++, ep++)
- *ep = *cp;
- for (cp = " -- "; *cp && ep<&errbuf[sizeof errbuf]; cp++, ep++)
- *ep = *cp;
- if (ep<&errbuf[sizeof errbuf])
- *ep++ = c;
- if (ep<&errbuf[sizeof errbuf])
- *ep++ = '\n';
- write(2, errbuf, ep - errbuf);
- }
-}
-
-/*
- * getopt_sp is required to keep state between successive calls to getopt()
- * while extracting aggregated options (ie: -abcd). Hence, getopt() is not
- * thread safe or reentrant, but it really doesn't matter.
- *
- * So, why isn't this "static" you ask? Because the historical Bourne
- * shell has actually latched on to this little piece of private data.
- */
-int getopt_sp = 1;
-
-/*
- * Determine if the specified character (c) is present in the string
- * (optstring) as a regular, single character option. If the option is found,
- * return a pointer into optstring pointing at the option character,
- * otherwise return null. The character ':' is not allowed.
- */
-static char *
-parse(const char *optstring, const char c)
-{
- char *cp = (char *)optstring;
-
- if (c == ':')
- return (NULL);
- do {
- if (*cp == c)
- return (cp);
- } while (*cp++ != '\0');
- return (NULL);
-}
-
-/*
- * External function entry point.
- */
-int
-getopt(int argc, char *const *argv, const char *optstring)
-{
- char c;
- char *cp;
-
- /*
- * Has the end of the options been encountered? The following
- * implements the SUS requirements:
- *
- * If, when getopt() is called:
- * argv[optind] is a null pointer
- * *argv[optind] is not the character '-'
- * argv[optind] points to the string "-"
- * getopt() returns -1 without changing optind. If
- * argv[optind] points to the string "--"
- * getopt() returns -1 after incrementing optind.
- */
- if (getopt_sp == 1) {
- if (optind >= argc || argv[optind][0] != '-' ||
- argv[optind] == NULL || argv[optind][1] == '\0')
- return (EOF);
- else if (strcmp(argv[optind], "--") == 0) {
- optind++;
- return (EOF);
- }
- }
-
- /*
- * Getting this far indicates that an option has been encountered.
- * Note that the syntax of optstring applies special meanings to
- * the characters ':' and '(', so they are not permissible as
- * option letters. A special meaning is also applied to the ')'
- * character, but its meaning can be determined from context.
- * Note that the specification only requires that the alnum
- * characters be accepted.
- */
- optopt = c = (unsigned char)argv[optind][getopt_sp];
- optarg = NULL;
- if ((cp = parse(optstring, c)) == NULL) {
- /* LINTED: variable format specifier */
- ERR("illegal option", c);
- if (argv[optind][++getopt_sp] == '\0') {
- optind++;
- getopt_sp = 1;
- }
- return ('?');
- }
- optopt = c = *cp;
-
- /*
- * A valid option has been identified. If it should have an
- * option-argument, process that now. SUS defines the setting
- * of optarg as follows:
- *
- * 1. If the option was the last character in the string pointed to
- * by an element of argv, then optarg contains the next element
- * of argv, and optind is incremented by 2. If the resulting
- * value of optind is not less than argc, this indicates a
- * missing option-argument, and getopt() returns an error
- * indication.
- *
- * 2. Otherwise, optarg points to the string following the option
- * character in that element of argv, and optind is incremented
- * by 1.
- *
- * The second clause allows -abcd (where b requires an option-argument)
- * to be interpreted as "-a -b cd".
- */
- if (*(cp + 1) == ':') {
- /* The option takes an argument */
- if (argv[optind][getopt_sp+1] != '\0') {
- optarg = &argv[optind++][getopt_sp+1];
- } else if (++optind >= argc) {
- /* LINTED: variable format specifier */
- ERR("option requires an argument", c);
- getopt_sp = 1;
- optarg = NULL;
- return (optstring[0] == ':' ? ':' : '?');
- } else
- optarg = argv[optind++];
- getopt_sp = 1;
- } else {
- /* The option does NOT take an argument */
- if (argv[optind][++getopt_sp] == '\0') {
- getopt_sp = 1;
- optind++;
- }
- optarg = NULL;
- }
- return (c);
-} /* getopt() */
-
-#ifdef __APPLE__
-/*
- * Starting with Mac OS 10.5 Leopard, <unistd.h> turns getopt()
- * into getopt$UNIX2003() by default. Consequently, this function
- * is called instead of the one defined above. However, optind is
- * still taken from this file, so in effect, options are not
- * properly handled. Defining an own getopt$UNIX2003() function
- * works around this issue.
- */
-int
-getopt$UNIX2003(int argc, char *const argv[], const char *optstring)
-{
- return getopt(argc, argv, optstring);
-}
-#endif /* __APPLE__ */
diff --git a/troff/troff.d/dpost.d/Makefile.mk b/troff/troff.d/dpost.d/Makefile.mk
index 36847f46d999..d3d161638b4c 100644
--- a/troff/troff.d/dpost.d/Makefile.mk
+++ b/troff/troff.d/dpost.d/Makefile.mk
@@ -1,7 +1,7 @@
BST = ../../../stuff/bst
OBJ = dpost.o draw.o color.o pictures.o ps_include.o afm.o \
- makedev.o glob.o misc.o request.o version.o getopt.o \
+ makedev.o glob.o misc.o request.o version.o \
asciitype.o otf.o ../fontmap.o $(BST)/bst.o
FLAGS = -I. -I.. -DFNTDIR='"$(FNTDIR)"' -DPSTDIR='"$(PSTDIR)"' $(EUC) \
diff --git a/troff/troff.d/dpost.d/color.c b/troff/troff.d/dpost.d/color.c
index 4568aec09177..95e30d15fa04 100644
--- a/troff/troff.d/dpost.d/color.c
+++ b/troff/troff.d/dpost.d/color.c
@@ -181,7 +181,7 @@ newcolor (
char *p; /* next character in *name */
- int i; /* goes in color[i] */
+ size_t i; /* goes in color[i] */
/*
diff --git a/troff/troff.d/dpost.d/dpost.c b/troff/troff.d/dpost.d/dpost.c
index f27d33cbd4f8..dd5c5465721b 100644
--- a/troff/troff.d/dpost.d/dpost.c
+++ b/troff/troff.d/dpost.d/dpost.c
@@ -281,31 +281,20 @@
#include "afm.h"
#include "fontmap.h"
+char *progname;
+static const char *prologue = DPOST; /* the basic PostScript prologue */
+const char *colorfile = COLOR; /* things needed for color support */
+const char *drawfile = DRAW; /* and drawing */
+static const char *cutmarksfile = CUTMARKS;
+static const char *formfile = FORMFILE; /* stuff for multiple pages per sheet */
+const char *baselinefile = BASELINE;
-#if defined (__GLIBC__) && defined (_IO_getc_unlocked)
-#undef getc
-#define getc(f) _IO_getc_unlocked(f)
-#endif
-#if defined (__GLIBC__) && defined (_IO_putc_unlocked)
-#undef putc
-#define putc(c, f) _IO_putc_unlocked(c, f)
-#endif
-
-
-char *progname;
-char *prologue = DPOST; /* the basic PostScript prologue */
-char *colorfile = COLOR; /* things needed for color support */
-char *drawfile = DRAW; /* and drawing */
-char *cutmarksfile = CUTMARKS;
-char *formfile = FORMFILE; /* stuff for multiple pages per sheet */
-char *baselinefile = BASELINE;
+static const char *fontdir = FONTDIR; /* binary device directories found here */
+static char *hostfontdir = NULL; /* host resident font directory */
-char *fontdir = FONTDIR; /* binary device directories found here */
-char *hostfontdir = NULL; /* host resident font directory */
-
-int formsperpage = 1; /* page images on each piece of paper */
-int copies = 1; /* and this many copies of each sheet */
-int picflag = ON; /* enable/disable picture inclusion */
+static int formsperpage = 1; /* page images on each piece of paper */
+static int copies = 1; /* and this many copies of each sheet */
+int picflag = ON; /* enable/disable picture inclusion */
/*
@@ -325,7 +314,7 @@ int picflag = ON; /* enable/disable picture inclusion */
int encoding = DFLTENCODING;
int realencoding = DFLTENCODING;
int maxencoding = MAXENCODING;
-int eflag;
+static int eflag;
int LanguageLevel; /* PostScript output language level */
static int Binary; /* PostScript output contains binary data */
@@ -341,10 +330,10 @@ static int Binary; /* PostScript output contains binary data */
*/
-char seenfonts[MAXINTERNAL+1];
-int docfonts = 0;
-struct afmtab **afmfonts;
-int afmcount = 0;
+static char seenfonts[MAXINTERNAL+1];
+static int docfonts = 0;
+static struct afmtab **afmfonts;
+static int afmcount = 0;
/*
*
@@ -359,8 +348,8 @@ int afmcount = 0;
#define devname troff_devname
-char devname[20] = ""; /* job is formatted for this printer */
-char *realdev = DEVNAME; /* a good description of target printer */
+static char devname[20] = ""; /* job is formatted for this printer */
+static const char *realdev = DEVNAME; /* a good description of target printer */
/*
@@ -373,12 +362,12 @@ char *realdev = DEVNAME; /* a good description of target printer */
struct dev dev; /* DESC starts this way */
struct Font **fontbase; /* FONT files begin this way */
-int *pstab; /* list of available sizes */
-int nsizes = 1; /* and the number of sizes in that list */
-int smnt; /* index of first special font */
+static int *pstab; /* list of available sizes */
+static int nsizes = 1; /* and the number of sizes in that list */
+static int smnt; /* index of first special font */
int nchtab; /* number of special character names */
-int fsize; /* max size of a font files in bytes */
-int unitwidth; /* set to dev.unitwidth */
+static int fsize; /* max size of a font files in bytes */
+static int unitwidth; /* set to dev.unitwidth */
char *chname; /* special character strings */
short *chtab; /* used to locate character names */
unsigned short **fitab; /* locates char info on each font */
@@ -402,7 +391,7 @@ char **kerntab; /* for makefont() */
*/
-char *downloaded; /* nonzero means it's been downloaded */
+static char *downloaded; /* nonzero means it's been downloaded */
/*
@@ -416,22 +405,22 @@ char *downloaded; /* nonzero means it's been downloaded */
int nfonts = 0; /* number of font positions */
int size = 1; /* current size - internal value */
#define FRACTSIZE -23 /* if size == FRACTSIZE then ... */
-float fractsize = 0; /* fractional point size */
-int font = 0; /* font position we're using now */
-int subfont = 0; /* extra encoding vector */
+static float fractsize = 0; /* fractional point size */
+static int font = 0; /* font position we're using now */
+static int subfont = 0; /* extra encoding vector */
int hpos = 0; /* where troff wants to be - horizontally */
int vpos = 0; /* same but vertically */
-float lastw = 0; /* width of the last input character */
-int track = 0; /* tracking hint from troff */
-int lasttrack = 0; /* previous tracking hint */
-int tracked; /* records need to flush track */
-int lastc = 0; /* and its name (or index) */
+static float lastw = 0; /* width of the last input character */
+static int track = 0; /* tracking hint from troff */
+static int lasttrack = 0; /* previous tracking hint */
+static int tracked; /* records need to flush track */
+static int lastc = 0; /* and its name (or index) */
int res; /* resolution assumed in input file */
-float widthfac = 1.0; /* for emulation = res/dev.res */
-float horscale = 1.0; /* horizontal font scaling */
-float lasthorscale = 1.0; /* last horizontal font scaling */
-int wordspace = 0; /* w command was last */
+static float widthfac = 1.0; /* for emulation = res/dev.res */
+static float horscale = 1.0; /* horizontal font scaling */
+static float lasthorscale = 1.0; /* last horizontal font scaling */
+static int wordspace = 0; /* w command was last */
/*
@@ -443,13 +432,13 @@ int wordspace = 0; /* w command was last */
*/
-int lastsize = -1; /* last internal size we used */
-float lastfractsize = -1; /* last fractional size */
-int lastfont = -1; /* last font we told printer about */
-int lastsubfont = -1; /* last extra encoding vector */
-float lastx = -1; /* printer's current position */
-int lasty = -1;
-int savey = -1;
+static int lastsize = -1; /* last internal size we used */
+static float lastfractsize = -1; /* last fractional size */
+static int lastfont = -1; /* last font we told printer about */
+static int lastsubfont = -1; /* last extra encoding vector */
+static float lastx = -1; /* printer's current position */
+static int lasty = -1;
+static int savey = -1;
int lastend; /* where last character on this line was */
@@ -466,7 +455,7 @@ int lastend; /* where last character on this line was */
*/
-struct {
+static struct {
struct afmtab *afm; /* AFM data, if any */
char *name; /* name of the font loaded here */
@@ -493,9 +482,9 @@ struct {
*/
-int gotspecial = FALSE;
-int gotregular = FALSE;
-int seenpage = FALSE;
+static int gotspecial = FALSE;
+static int gotregular = FALSE;
+static int seenpage = FALSE;
/*
@@ -511,10 +500,10 @@ int seenpage = FALSE;
*/
-float pointslop = SLOP; /* horizontal error in points */
-int Sflag; /* unless -S gives explicit slop */
-int slop; /* and machine units */
-int rvslop; /* to extend box in reverse video mode */
+static float pointslop = SLOP; /* horizontal error in points */
+static int Sflag; /* unless -S gives explicit slop */
+static int slop; /* and machine units */
+static int rvslop; /* to extend box in reverse video mode */
/*
@@ -530,11 +519,11 @@ int rvslop; /* to extend box in reverse video mode */
*/
-int textcount = 0; /* strings accumulated so far */
-int stringstart = 0; /* where the next one starts */
-int laststrstart = INT_MIN; /* save for optimization */
-int spacecount = 0; /* spaces seen so far on current line */
-int charcount = 0; /* characters on current line */
+static int textcount = 0; /* strings accumulated so far */
+static int stringstart = 0; /* where the next one starts */
+static int laststrstart = INT_MIN; /* save for optimization */
+static int spacecount = 0; /* spaces seen so far on current line */
+static int charcount = 0; /* characters on current line */
/*
@@ -547,9 +536,9 @@ int charcount = 0; /* characters on current line */
*/
-char strings[STRINGSPACE];
-char *strptr;
-Line line[MAXSTACK+3];
+static char strings[STRINGSPACE];
+static char *strptr;
+static Line line[MAXSTACK+3];
/*
@@ -572,8 +561,8 @@ Line line[MAXSTACK+3];
*/
-Devfontmap *devfontmap = NULL; /* device level */
-Fontmap fontmap[] = FONTMAP; /* and general mapping tables - emulation */
+static Devfontmap *devfontmap = NULL; /* device level */
+static Fontmap fontmap[] = FONTMAP; /* and general mapping tables - emulation */
/*
@@ -642,16 +631,16 @@ int printed = 0; /* charge for this many pages */
*/
-FILE *tf = NULL; /* PostScript output goes here */
-FILE *gf = NULL; /* global data goes here */
-FILE *rf = NULL; /* resource data goes here */
-FILE *sf = NULL; /* supplied resource comments go here */
-FILE *nf = NULL; /* needed resource comments go here */
-FILE *pf = NULL; /* elements of _custompagesetup */
-int sfcount; /* count of supplied resources */
-int nfcount; /* count of needed resources */
-int ostdout; /* old standard output */
-FILE *fp_acct = NULL; /* accounting stuff written here */
+FILE *tf = NULL; /* PostScript output goes here */
+FILE *gf = NULL; /* global data goes here */
+FILE *rf = NULL; /* resource data goes here */
+FILE *sf = NULL; /* supplied resource comments go here */
+FILE *nf = NULL; /* needed resource comments go here */
+FILE *pf = NULL; /* elements of _custompagesetup */
+static int sfcount; /* count of supplied resources */
+static int nfcount; /* count of needed resources */
+static int ostdout; /* old standard output */
+static FILE *fp_acct = NULL; /* accounting stuff written here */
/*
@@ -664,7 +653,7 @@ FILE *fp_acct = NULL; /* accounting stuff written here */
*/
-char temp[4096];
+static char temp[4096];
/*****************************************************************************/
@@ -771,7 +760,7 @@ main(int agc, char *agv[])
} /* End of main */
/*****************************************************************************/
-int
+static int
putint(int n, FILE *fp)
{
char buf[20];
@@ -801,7 +790,7 @@ putint(int n, FILE *fp)
return c;
}
-int
+static int
putstring1(const char *sp, int n, FILE *fp)
{
/*
@@ -815,7 +804,7 @@ putstring1(const char *sp, int n, FILE *fp)
return n + 2;
}
-int
+static int
putstring(const char *sp, int n, FILE *fp)
{
int c = 0, m;
@@ -865,7 +854,7 @@ init_signals(void)
/*****************************************************************************/
static char *
-pdfdate(time_t *tp, char *buf, size_t size)
+pdfdate(time_t *tp, char *buf, size_t sz)
{
struct tm *tmptr;
int tzdiff, tzdiff_hour, tzdiff_min;
@@ -877,7 +866,7 @@ pdfdate(time_t *tp, char *buf, size_t size)
tmptr = localtime(tp);
if (tmptr->tm_isdst > 0)
tzdiff_hour++;
- snprintf(buf, size, "(D:%04d%02d%02d%02d%02d%02d%+03d'%02d')",
+ snprintf(buf, sz, "(D:%04d%02d%02d%02d%02d%02d%+03d'%02d')",
tmptr->tm_year + 1900,
tmptr->tm_mon + 1, tmptr->tm_mday,
tmptr->tm_hour, tmptr->tm_min, tmptr->tm_sec,
@@ -1257,14 +1246,6 @@ setpaths (
/*****************************************************************************/
-static int
-prefix(const char *str, const char *pfx)
-{
- while (*pfx && *str == *pfx)
- str++, pfx++;
- return *str == 0;
-}
-
static void
setmarks(char *str)
{
@@ -1651,7 +1632,7 @@ devcntrl(
char str[4096], *buf, str1[4096];
- int c, n, size;
+ int c, n, sz;
/*
@@ -1665,7 +1646,7 @@ devcntrl(
*/
- buf = malloc(size = 4096);
+ buf = malloc(sz = 4096);
sget(str, sizeof str, fp); /* get the control function name */
switch ( str[0] ) { /* only the first character counts */
@@ -1707,7 +1688,7 @@ devcntrl(
case 'f': /* load font in a position */
fscanf(fp, "%d", &n);
sget(str, sizeof str, fp);
- fgets(buf, size, fp); /* in case there's a filename */
+ fgets(buf, sz, fp); /* in case there's a filename */
ungetc('\n', fp); /* fgets() goes too far */
str1[0] = '\0'; /* in case there's nothing to come in */
c = 0;
@@ -1747,15 +1728,15 @@ devcntrl(
ungetc(c, fp);
n = 0;
for (;;) {
- fgets(&buf[n], size - n, fp);
+ fgets(&buf[n], sz - n, fp);
if ((c = getc(fp)) != '+') {
ungetc(c, fp);
break;
}
while (buf[n])
n++;
- if (size - n < 4096)
- buf = realloc(buf, size += 4096);
+ if (sz - n < 4096)
+ buf = realloc(buf, sz += 4096);
lineno++;
}
if ( strcmp(str, "PI") == 0 || strcmp(str, "PictureInclusion") == 0 )
@@ -1913,7 +1894,7 @@ fontinit(void)
void
loadfont (
int n, /* load this font position */
- char *s, /* with the file for this font */
+ const char *s, /* with the file for this font */
char *s1, /* taken from here - possibly */
int forcespecial, /* this is definitively a special font */
int spec /* map specification */
@@ -1926,7 +1907,7 @@ loadfont (
char *fpout = NULL; /* for reading *s file */
int fin; /* for reading *s.afm file */
int nw; /* number of width table entries */
- char *p;
+ const char *p;
char *path;
size_t l;
@@ -1991,9 +1972,7 @@ loadfont (
goto fail;
}
close(fin);
- l = strlen(path) + 1;
- a->path = malloc(l);
- n_strcpy(a->path, path, l);
+ a->path = strdup(path);
if (path != temp)
free(path);
a->file = s;
@@ -2098,7 +2077,7 @@ loadspecial(void)
/*****************************************************************************/
-char *defaultFonts[] =
+static const char *defaultFonts[] =
{ "R", "I", "B", "BI", "CW", "H", "HB", "HX", "S1", "S", NULL };
void
@@ -2165,9 +2144,9 @@ fontprint (
/*****************************************************************************/
-char *
+const char *
mapfont (
- char *name /* troff wanted this font */
+ const char *name /* troff wanted this font */
)
@@ -2390,7 +2369,7 @@ t_init(void)
if (eflag == 0)
realencoding = encoding = dev.encoding;
if (encoding == 5) {
- LanguageLevel = MAX(LanguageLevel, 2);
+ LanguageLevel = max(LanguageLevel, 2);
Binary++;
}
slop = pointslop * res / POINTS + .5;
@@ -2433,13 +2412,13 @@ static struct supplylist {
} *supplylist;
void
-t_supply(char *font) /* supply a font */
+t_supply(char *fnt) /* supply a font */
{
struct supplylist *sp;
char *np, *file, *type = NULL, c;
- while (*font == ' ' || *font == '\t')
- font++;
+ while (*fnt == ' ' || *fnt == '\t')
+ fnt++;
for (np = font; *np && *np != ' ' && *np != '\t' && *np != '\n'; np++);
if (*np == '\0' || *np == '\n')
return;
@@ -2459,10 +2438,10 @@ t_supply(char *font) /* supply a font */
*np = '\0';
}
for (sp = supplylist; sp; sp = sp->next)
- if (strcmp(sp->font, font) == 0)
+ if (strcmp(sp->font, fnt) == 0)
return;
sp = calloc(1, sizeof *sp);
- sp->font = strdup(font);
+ sp->font = strdup(fnt);
sp->file = afmdecodepath(file);
sp->type = type && *type ? strdup(type) : NULL;
sp->next = supplylist;
@@ -2483,11 +2462,11 @@ static const char ps_truetypefont[] = "%!PS-TrueTypeFont";
static const char hex[] = "0123456789abcdef";
static void
-supplypfb(char *font, char *path, FILE *fp)
+supplypfb(char *fnt, char *path, FILE *fp)
{
char buf[30];
- long length;
- int i, c = EOF, n, type = 0, lastc = EOF;
+ size_t i, n, length;
+ int c = EOF, type = 0, lastch = EOF;
if (fread(buf, 1, 6, fp) != 6)
error(FATAL, "no data in %s", path);
@@ -2508,10 +2487,10 @@ supplypfb(char *font, char *path, FILE *fp)
length--;
}
if (sfcount++ == 0)
- fprintf(sf, "%%%%DocumentSuppliedResources: font %s\n", font);
+ fprintf(sf, "%%%%DocumentSuppliedResources: font %s\n", fnt);
else
- fprintf(sf, "%%%%+ font %s\n", font);
- fprintf(rf, "%%%%BeginResource: font %s\n", font);
+ fprintf(sf, "%%%%+ font %s\n", fnt);
+ fprintf(rf, "%%%%BeginResource: font %s\n", fnt);
for (;;) {
switch (type) {
case 1:
@@ -2524,13 +2503,13 @@ supplypfb(char *font, char *path, FILE *fp)
else
length--;
putc('\n', rf);
- lastc = '\n';
+ lastch = '\n';
break;
case 0:
continue;
default:
putc(c, rf);
- lastc = c;
+ lastch = c;
}
}
if (c == EOF)
@@ -2546,12 +2525,12 @@ supplypfb(char *font, char *path, FILE *fp)
putc(hex[buf[i]&017], rf);
}
putc('\n', rf);
- lastc = '\n';
+ lastch = '\n';
length -= n;
}
break;
case 3:
- if (lastc != '\n')
+ if (lastch != '\n')
putc('\n', rf);
fprintf(rf, "%%%%EndResource\n");
fclose(fp);
@@ -2569,24 +2548,23 @@ supplypfb(char *font, char *path, FILE *fp)
}
static void
-supplyotf(char *font, char *path, FILE *fp)
+supplyotf(char *fnt, char *path, FILE *fp)
{
static int cffcount;
struct stat st;
char *contents;
- size_t size, offset, length;
- int i;
+ size_t sz, offset, length, i;
int fsType;
const char StartData[] = " StartData ";
if (fstat(fileno(fp), &st) < 0)
error(FATAL, "cannot stat %s", path);
- size = st.st_size;
- contents = malloc(size);
- if (fread(contents, 1, size, fp) != size)
+ sz = st.st_size;
+ contents = malloc(sz);
+ if (fread(contents, 1, sz, fp) != sz)
error(FATAL, "cannot read %s", path);
fclose(fp);
- if ((fsType = otfcff(path, contents, size, &offset, &length)) < 0) {
+ if ((fsType = otfcff(path, contents, sz, &offset, &length)) < 0) {
free(contents);
return;
}
@@ -2602,19 +2580,19 @@ supplyotf(char *font, char *path, FILE *fp)
needresource("procset FontSetInit 0 0");
}
if (sfcount++ == 0)
- fprintf(sf, "%%%%DocumentSuppliedResources: font %s\n", font);
+ fprintf(sf, "%%%%DocumentSuppliedResources: font %s\n", fnt);
else
- fprintf(sf, "%%%%+ font %s\n", font);
- fprintf(rf, "%%%%BeginResource: font %s\n", font);
+ fprintf(sf, "%%%%+ font %s\n", fnt);
+ fprintf(rf, "%%%%BeginResource: font %s\n", fnt);
fprintf(rf, "/FontSetInit /ProcSet findresource begin\n");
if (encoding == 5) {
fprintf(rf, "%%%%BeginData: %ld Binary Bytes\n",
- (long)(length + 13 + strlen(font) + 12));
- fprintf(rf, "/%s %12ld StartData ", font, (long)length);
+ (long)(length + 13 + strlen(fnt) + 12));
+ fprintf(rf, "/%s %12ld StartData ", fnt, (long)length);
fwrite(&contents[offset], 1, length, rf);
fprintf(rf, "\n%%%%EndData\n");
} else {
- fprintf(rf, "/%s %ld ", font, (long)length);
+ fprintf(rf, "/%s %ld ", fnt, (long)length);
fprintf(rf, "currentfile /ASCIIHexDecode filter cvx exec\n");
for (i = 0; StartData[i]; i++) {
putc(hex[(StartData[i]&0360)>>4], rf);
@@ -2631,39 +2609,39 @@ supplyotf(char *font, char *path, FILE *fp)
}
fprintf(rf, "%%%%EndResource\n");
free(contents);
- LanguageLevel = MAX(LanguageLevel, 3);
+ LanguageLevel = max(LanguageLevel, 3);
}
static void
-supplyttf(char *font, char *path, FILE *fp)
+supplyttf(char *fnt, char *path, FILE *fp)
{
struct stat st;
char *contents;
- size_t size;
+ size_t sz;
if (fstat(fileno(fp), &st) < 0)
error(FATAL, "cannot stat %s", path);
- size = st.st_size;
- contents = malloc(size);
- if (fread(contents, 1, size, fp) != size)
+ sz = st.st_size;
+ contents = malloc(sz);
+ if (fread(contents, 1, sz, fp) != sz)
error(FATAL, "cannot read %s", path);
fclose(fp);
if (sfcount++ == 0)
- fprintf(sf, "%%%%DocumentSuppliedResources: font %s\n", font);
+ fprintf(sf, "%%%%DocumentSuppliedResources: font %s\n", fnt);
else
- fprintf(sf, "%%%%+ font %s\n", font);
- fprintf(rf, "%%%%BeginResource: font %s\n", font);
- otft42(font, path, contents, size, rf);
+ fprintf(sf, "%%%%+ font %s\n", fnt);
+ fprintf(rf, "%%%%BeginResource: font %s\n", fnt);
+ otft42(fnt, path, contents, sz, rf);
fprintf(rf, "%%%%EndResource\n");
free(contents);
- LanguageLevel = MAX(LanguageLevel, 2);
+ LanguageLevel = max(LanguageLevel, 2);
}
static void
-supply1(char *font, char *file, char *type)
+supply1(char *fnt, char *file, char *type)
{
FILE *fp;
- char line[4096], c;
+ char linebuf[4096], c;
if (strchr(file, '/') == 0) {
snprintf(temp, sizeof temp, "%s/dev%s/%s.%s",
@@ -2679,48 +2657,48 @@ supply1(char *font, char *file, char *type)
c == 0 || c == 't' ? "ttf" : "anything";
}
if (strcmp(type, "pfb") == 0) {
- supplypfb(font, file, fp);
+ supplypfb(fnt, file, fp);
return;
}
if (strcmp(type, "otf") == 0) {
- supplyotf(font, file, fp);
+ supplyotf(fnt, file, fp);
return;
}
if (strcmp(type, "ttf") == 0) {
- supplyttf(font, file, fp);
+ supplyttf(fnt, file, fp);
return;
}
- if (fgets(line, sizeof line, fp) == NULL)
+ if (fgets(linebuf, sizeof linebuf, fp) == NULL)
error(FATAL, "missing data in %s", file);
- if (strncmp(line, ps_adobe_font_, strlen(ps_adobe_font_)) &&
- strncmp(line, ps_truetypefont, strlen(ps_truetypefont)))
+ if (strncmp(linebuf, ps_adobe_font_, strlen(ps_adobe_font_)) &&
+ strncmp(linebuf, ps_truetypefont, strlen(ps_truetypefont)))
error(FATAL, "file %s does not start with \"%s\" or \"%s\"",
file, ps_adobe_font_, ps_truetypefont);
if (sfcount++ == 0)
- fprintf(sf, "%%%%DocumentSuppliedResources: font %s\n", font);
+ fprintf(sf, "%%%%DocumentSuppliedResources: font %s\n", fnt);
else
- fprintf(sf, "%%%%+ font %s\n", font);
- fprintf(rf, "%%%%BeginResource: font %s\n", font);
- while (fgets(line, sizeof line, fp) != NULL)
- fputs(line, rf);
+ fprintf(sf, "%%%%+ font %s\n", fnt);
+ fprintf(rf, "%%%%BeginResource: font %s\n", fnt);
+ while (fgets(linebuf, sizeof linebuf, fp) != NULL)
+ fputs(linebuf, rf);
fclose(fp);
fprintf(rf, "%%%%EndResource\n");
}
static void
-t_dosupply(const char *font)
+t_dosupply(const char *fnt)
{
struct supplylist *sp;
for (sp = supplylist; sp; sp = sp->next)
- if (strcmp(sp->font, font) == 0) {
+ if (strcmp(sp->font, fnt) == 0) {
if (sp->done == 0) {
supply1(sp->font, sp->file, sp->type);
sp->done = 1;
}
return;
}
- needresource("font %s", font);
+ needresource("font %s", fnt);
}
/*****************************************************************************/
@@ -3388,7 +3366,7 @@ t_slant (
void
t_reset (
- int c /* pause or restart */
+ int c __unused /* pause or restart */
)
@@ -3722,7 +3700,7 @@ oprep(int stext)
if (stext) {
starttext();
- if ( ABS(hpos - lastx) > slop )
+ if ( fabsf(hpos - lastx) > slop )
endstring();
}
wordspace = 0;
@@ -4251,7 +4229,7 @@ charlib (
char *name; /* name of the character */
char tname[10]; /* in case it's a single ASCII character */
- char *filename; /* real file name */
+ const char *filename; /* real file name */
/*
@@ -4321,7 +4299,7 @@ charlib (
int
doglobal (
- char *name /* copy this to the output - globally */
+ const char *name /* copy this to the output - globally */
)
@@ -4599,7 +4577,7 @@ orderbookmarks(void)
int counts[MAXBOOKMARKLEVEL+1];
int refs[MAXBOOKMARKLEVEL+1];
- int i, j, k, t;
+ size_t i, j, k, t;
int lvl = 0;
/*
diff --git a/troff/troff.d/dpost.d/dpost.h b/troff/troff.d/dpost.d/dpost.h
index ca96c570f1e7..9ec006ea32b6 100644
--- a/troff/troff.d/dpost.d/dpost.h
+++ b/troff/troff.d/dpost.d/dpost.h
@@ -148,8 +148,8 @@ typedef struct {
typedef struct {
- char *name; /* font name we're looking for */
- char *use; /* and this is what we should use */
+ const char *name; /* font name we're looking for */
+ const char *use; /* and this is what we should use */
} Fontmap;
diff --git a/troff/troff.d/dpost.d/draw.c b/troff/troff.d/dpost.d/draw.c
index 68d3215b4418..11e91f5d24e8 100644
--- a/troff/troff.d/dpost.d/draw.c
+++ b/troff/troff.d/dpost.d/draw.c
@@ -139,9 +139,9 @@
#include "ext.h" /* external variable definitions */
-int gotdraw = FALSE; /* TRUE when *drawfile has been added */
-int gotbaseline = FALSE; /* TRUE after *baselinefile is added */
-int inpath = FALSE; /* TRUE if we're putting pieces together */
+static int gotdraw = FALSE; /* TRUE when *drawfile has been added */
+static int gotbaseline = FALSE; /* TRUE after *baselinefile is added */
+static int inpath = FALSE; /* TRUE if we're putting pieces together */
/*
@@ -349,7 +349,7 @@ drawspline(
int x[100], y[100];
- int i, N;
+ size_t i, N;
/*
diff --git a/troff/troff.d/dpost.d/gen.h b/troff/troff.d/dpost.d/gen.h
index 6e0a2bb1ef86..e0d02d4b2ab2 100644
--- a/troff/troff.d/dpost.d/gen.h
+++ b/troff/troff.d/dpost.d/gen.h
@@ -61,20 +61,6 @@ extern const char creator[];
#define PI 3.141592654
#endif
-
-/*
- *
- * A few simple macros.
- *
- */
-
-
-#define ABS(A) ((A) >= 0 ? (A) : -(A))
-#undef MIN
-#define MIN(A, B) ((A) < (B) ? (A) : (B))
-#undef MAX
-#define MAX(A, B) ((A) > (B) ? (A) : (B))
-
/* color.c */
void getcolor(void);
void newcolor(char *);
@@ -91,11 +77,11 @@ void account(void);
void conv(register FILE *);
void devcntrl(FILE *);
void fontinit(void);
-void loadfont(int, char *, char *, int, int);
+void loadfont(int, const char *, char *, int, int);
void loadspecial(void);
void loaddefault(void);
void fontprint(int);
-char *mapfont(char *);
+const char *mapfont(const char *);
void getdevmap(void);
char *mapdevfont(char *);
void reset(void);
@@ -130,7 +116,7 @@ void endline(void);
void addchar(int);
void addoctal(int);
void charlib(int);
-int doglobal(char *);
+int doglobal(const char *);
void documentfont(const char *);
void documentfonts(void);
void redirect(int);
@@ -150,10 +136,11 @@ void drawtext(char *);
void settext(char *);
/* glob.c */
/* misc.c */
-void error(int, char *, ...);
+void interrupt(int);
+void error(int, const char *, ...);
void out_list(char *);
int in_olist(int);
-int cat(char *, FILE *);
+int cat(const char *, FILE *);
int str_convert(char **, int);
char *tempname(const char *);
int psskip(size_t, FILE *);
@@ -170,5 +157,5 @@ void ps_include(const char *, FILE *, FILE *, int, int, int, int,
/* request.c */
void saverequest(char *);
void writerequest(int, FILE *);
-void dumprequest(char *, char *, FILE *);
+void dumprequest(char *, const char *, FILE *);
/* tempnam.c */
diff --git a/troff/troff.d/dpost.d/getopt.c b/troff/troff.d/dpost.d/getopt.c
deleted file mode 100644
index bb8c53d072cb..000000000000
--- a/troff/troff.d/dpost.d/getopt.c
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * Portions Copyright (c) 2005 Gunnar Ritter, Freiburg i. Br., Germany
- *
- * Sccsid @(#)getopt.c 1.10 (gritter) 12/16/07
- */
-/* from OpenSolaris "getopt.c 1.23 05/06/08 SMI" */
-
-/* Copyright (c) 1988 AT&T */
-/* All Rights Reserved */
-
-
-/*
- * See getopt(3C) and SUS/XPG getopt() for function definition and
- * requirements.
- *
- * This actual implementation is a bit looser than the specification
- * as it allows any character other than ':' to be used as an option
- * character - The specification only guarantees the alnum characters
- * ([a-z][A-Z][0-9]).
- */
-
-#include <sys/types.h>
-#include <string.h>
-#include <stdio.h>
-
-extern ssize_t write(int, const void *, size_t);
-
-char *optarg = NULL;
-int optind = 1;
-int opterr = 1;
-int optopt = 0;
-
-#define ERR(s, c) err(s, c, optstring, argv[0])
-static void
-err(const char *s, int c, const char *optstring, const char *argv0)
-{
- char errbuf[256], *ep = errbuf;
- const char *cp;
-
- if (opterr && optstring[0] != ':') {
- for (cp = argv0; *cp && ep<&errbuf[sizeof errbuf]; cp++, ep++)
- *ep = *cp;
- for (cp = ": "; *cp && ep<&errbuf[sizeof errbuf]; cp++, ep++)
- *ep = *cp;
- for (cp = s; *cp && ep<&errbuf[sizeof errbuf]; cp++, ep++)
- *ep = *cp;
- for (cp = " -- "; *cp && ep<&errbuf[sizeof errbuf]; cp++, ep++)
- *ep = *cp;
- if (ep<&errbuf[sizeof errbuf])
- *ep++ = c;
- if (ep<&errbuf[sizeof errbuf])
- *ep++ = '\n';
- write(2, errbuf, ep - errbuf);
- }
-}
-
-/*
- * getopt_sp is required to keep state between successive calls to getopt()
- * while extracting aggregated options (ie: -abcd). Hence, getopt() is not
- * thread safe or reentrant, but it really doesn't matter.
- *
- * So, why isn't this "static" you ask? Because the historical Bourne
- * shell has actually latched on to this little piece of private data.
- */
-int getopt_sp = 1;
-
-/*
- * Determine if the specified character (c) is present in the string
- * (optstring) as a regular, single character option. If the option is found,
- * return a pointer into optstring pointing at the option character,
- * otherwise return null. The character ':' is not allowed.
- */
-static char *
-parse(const char *optstring, const char c)
-{
- char *cp = (char *)optstring;
-
- if (c == ':')
- return (NULL);
- do {
- if (*cp == c)
- return (cp);
- } while (*cp++ != '\0');
- return (NULL);
-}
-
-/*
- * External function entry point.
- */
-int
-getopt(int argc, char *const *argv, const char *optstring)
-{
- char c;
- char *cp;
-
- /*
- * Has the end of the options been encountered? The following
- * implements the SUS requirements:
- *
- * If, when getopt() is called:
- * argv[optind] is a null pointer
- * *argv[optind] is not the character '-'
- * argv[optind] points to the string "-"
- * getopt() returns -1 without changing optind. If
- * argv[optind] points to the string "--"
- * getopt() returns -1 after incrementing optind.
- */
- if (getopt_sp == 1) {
- if (optind >= argc || argv[optind][0] != '-' ||
- argv[optind] == NULL || argv[optind][1] == '\0')
- return (EOF);
- else if (strcmp(argv[optind], "--") == 0) {
- optind++;
- return (EOF);
- }
- }
-
- /*
- * Getting this far indicates that an option has been encountered.
- * Note that the syntax of optstring applies special meanings to
- * the characters ':' and '(', so they are not permissible as
- * option letters. A special meaning is also applied to the ')'
- * character, but its meaning can be determined from context.
- * Note that the specification only requires that the alnum
- * characters be accepted.
- */
- optopt = c = (unsigned char)argv[optind][getopt_sp];
- optarg = NULL;
- if ((cp = parse(optstring, c)) == NULL) {
- /* LINTED: variable format specifier */
- ERR("illegal option", c);
- if (argv[optind][++getopt_sp] == '\0') {
- optind++;
- getopt_sp = 1;
- }
- return ('?');
- }
- optopt = c = *cp;
-
- /*
- * A valid option has been identified. If it should have an
- * option-argument, process that now. SUS defines the setting
- * of optarg as follows:
- *
- * 1. If the option was the last character in the string pointed to
- * by an element of argv, then optarg contains the next element
- * of argv, and optind is incremented by 2. If the resulting
- * value of optind is not less than argc, this indicates a
- * missing option-argument, and getopt() returns an error
- * indication.
- *
- * 2. Otherwise, optarg points to the string following the option
- * character in that element of argv, and optind is incremented
- * by 1.
- *
- * The second clause allows -abcd (where b requires an option-argument)
- * to be interpreted as "-a -b cd".
- */
- if (*(cp + 1) == ':') {
- /* The option takes an argument */
- if (argv[optind][getopt_sp+1] != '\0') {
- optarg = &argv[optind++][getopt_sp+1];
- } else if (++optind >= argc) {
- /* LINTED: variable format specifier */
- ERR("option requires an argument", c);
- getopt_sp = 1;
- optarg = NULL;
- return (optstring[0] == ':' ? ':' : '?');
- } else
- optarg = argv[optind++];
- getopt_sp = 1;
- } else {
- /* The option does NOT take an argument */
- if (argv[optind][++getopt_sp] == '\0') {
- getopt_sp = 1;
- optind++;
- }
- optarg = NULL;
- }
- return (c);
-} /* getopt() */
-
-#ifdef __APPLE__
-/*
- * Starting with Mac OS 10.5 Leopard, <unistd.h> turns getopt()
- * into getopt$UNIX2003() by default. Consequently, this function
- * is called instead of the one defined above. However, optind is
- * still taken from this file, so in effect, options are not
- * properly handled. Defining an own getopt$UNIX2003() function
- * works around this issue.
- */
-int
-getopt$UNIX2003(int argc, char *const argv[], const char *optstring)
-{
- return getopt(argc, argv, optstring);
-}
-#endif /* __APPLE__ */
diff --git a/troff/troff.d/dpost.d/misc.c b/troff/troff.d/dpost.d/misc.c
index 3d6692b72021..b5dc8a4e4858 100644
--- a/troff/troff.d/dpost.d/misc.c
+++ b/troff/troff.d/dpost.d/misc.c
@@ -51,18 +51,19 @@
#include <string.h>
#include <fcntl.h>
+#include "global.h"
#include "gen.h" /* a few general purpose definitions */
#include "ext.h" /* external variable declarations */
#include "path.h"
#include "asciitype.h"
-static int nolist = 0; /* number of specified ranges */
+static size_t nolist = 0; /* number of specified ranges */
static int olist[512]; /* processing range pairs */
void
-error(int kind, char *mesg, ...)
+error(int kind, const char *mesg, ...)
{
@@ -102,7 +103,7 @@ error(int kind, char *mesg, ...)
/*****************************************************************************/
/* for the AFM handling functions from troff */
-void
+static void
verrprint(char *fmt, va_list ap)
{
fprintf(stderr, "%s: ", prog_name);
@@ -176,7 +177,7 @@ in_olist (
{
- int i; /* just a loop index */
+ size_t i; /* just a loop index */
/*
@@ -202,9 +203,9 @@ in_olist (
/*****************************************************************************/
-int
+int
cat (
- char *file, /* copy this file to out */
+ const char *file, /* copy this file to out */
FILE *out
)
@@ -284,11 +285,7 @@ str_convert (
void interrupt(
-
-
- int sig) /* signal that we caught */
-
-
+ int sig __unused) /* signal that we caught */
{
@@ -325,11 +322,6 @@ tempname(const char *sfx)
/*****************************************************************************/
-#if defined (__GLIBC__) && defined (_IO_getc_unlocked)
-#undef getc
-#define getc(f) _IO_getc_unlocked(f)
-#endif
-
#define LSIZE 512
int psskip(size_t n, FILE *fp)
@@ -379,7 +371,8 @@ char *psgetline(char **line, size_t *linesize, size_t *llen, FILE *fp)
int
sget(char *buf, size_t size, FILE *fp)
{
- int c, n = 0;
+ int c;
+ size_t n = 0;
do
c = getc(fp);
diff --git a/troff/troff.d/dpost.d/ps_include.c b/troff/troff.d/dpost.d/ps_include.c
index 758bde956243..3b463daf29d9 100644
--- a/troff/troff.d/dpost.d/ps_include.c
+++ b/troff/troff.d/dpost.d/ps_include.c
@@ -46,6 +46,7 @@
#include "ext.h"
#include "path.h"
#include "asciitype.h"
+#include "global.h"
#define var(x) fprintf(fout, "/%s %g def\n", #x, x)
@@ -60,7 +61,7 @@ static size_t bufsize;
typedef struct {long start, end;} Section;
static void copy(FILE *, FILE *, Section *);
-static char *_has(const char *, const char *);
+static char *_has(char *, const char *);
static void addfonts(char *);
/*****************************************************************************/
@@ -98,7 +99,7 @@ ps_include(
double o = outline != 0;
double s = scaleboth != 0;
int i; /* loop index */
- int lineno = 0;
+ int lno = 0;
int epsf = 0;
int hires = 0;
int state = 0;
@@ -142,7 +143,7 @@ ps_include(
fseek(fin, 0L, SEEK_SET);
while ( psgetline(&buf, &bufsize, NULL, fin) != NULL ) {
- if (++lineno == 1 && strncmp(buf, "%!PS-", 5) == 0) {
+ if (++lno == 1 && strncmp(buf, "%!PS-", 5) == 0) {
for (bp = buf; !spacechar(*bp&0377); bp++);
while (*bp && *bp != '\n' && *bp != '\r' &&
spacechar(*bp&0377))
@@ -199,7 +200,7 @@ ps_include(
} else if (has("%%LanguageLevel:")) {
int n;
sscanf(buf, "%%%%LanguageLevel: %d", &n);
- LanguageLevel = MAX(LanguageLevel, n);
+ LanguageLevel = max(LanguageLevel, n);
} else if ((bp = has("%%DocumentNeededFonts:")) != NULL ||
(bp = has("%%DocumentFonts:")) != NULL) {
cont = DOCUMENTFONTS;
@@ -324,18 +325,18 @@ copy(FILE *fin, FILE *fout, Section *s)
}
static char *
-_has(const char *buf, const char *word)
+_has(char *buffer, const char *word)
{
int n;
n = strlen(word);
- if (strncmp(buf, word, n) != 0)
+ if (strncmp(buffer, word, n) != 0)
return NULL;
- if (buf[n] == ' ' || buf[n] == '\t' || buf[n] == '\r' ||
- buf[n] == '\n' || buf[n] == 0) {
- while (buf[n] == ' ' || buf[n] == '\t')
+ if (buffer[n] == ' ' || buffer[n] == '\t' || buffer[n] == '\r' ||
+ buffer[n] == '\n' || buffer[n] == 0) {
+ while (buffer[n] == ' ' || buffer[n] == '\t')
n++;
- return (char *)&buf[n];
+ return &buffer[n];
}
return NULL;
}
diff --git a/troff/troff.d/dpost.d/request.c b/troff/troff.d/dpost.d/request.c
index 3cf447b42741..5e87b2ed740b 100644
--- a/troff/troff.d/dpost.d/request.c
+++ b/troff/troff.d/dpost.d/request.c
@@ -53,9 +53,9 @@
#include "path.h" /* for the default request file */
-Request request[MAXREQUEST]; /* next page or global request */
-int nextreq = 0; /* goes in request[nextreq] */
-char *requestfile = REQUESTFILE; /* default lookup file */
+static Request request[MAXREQUEST]; /* next page or global request */
+static int nextreq = 0; /* goes in request[nextreq] */
+static const char *requestfile = REQUESTFILE; /* default lookup file */
/*****************************************************************************/
@@ -138,7 +138,7 @@ dumprequest(
char *want, /* look for this string */
- char *file, /* in this file */
+ const char *file, /* in this file */
FILE *fp_out /* and write the value out here */
)
diff --git a/troff/troff.d/dpost.d/request.h b/troff/troff.d/dpost.d/request.h
index 829c7020d636..348f0f951c10 100644
--- a/troff/troff.d/dpost.d/request.h
+++ b/troff/troff.d/dpost.d/request.h
@@ -51,7 +51,7 @@ typedef struct {
char *want;
int page;
- char *file;
+ const char *file;
} Request;
diff --git a/troff/troff.d/draw.c b/troff/troff.d/draw.c
index d05e5a747667..e513bd08b61c 100644
--- a/troff/troff.d/draw.c
+++ b/troff/troff.d/draw.c
@@ -63,7 +63,7 @@ extern int DY; /* step size in y */
extern int drawdot; /* character to use when drawing */
extern int drawsize; /* shrink point size by this facter */
-int maxdots = 32000; /* maximum number of dots in an object */
+static int maxdots = 32000; /* maximum number of dots in an object */
#define sgn(n) ((n > 0) ? 1 : ((n < 0) ? -1 : 0))
#define abs(n) ((n) >= 0 ? (n) : -(n))
@@ -76,7 +76,7 @@ extern void vgoto(int);
extern int t_size(int);
extern void put1(int);
-void drawline(int, int, char *);
+void drawline(int, int, const char *);
void drawwig(char *);
char *getstr(char *, char *);
void drawcirc(int);
@@ -87,7 +87,7 @@ void conicarc(int, int, int, int, int, int, int, int);
void putdot(int, int);
void
-drawline(int dx, int dy, char *s) /* draw line from here to dx, dy using s */
+drawline(int dx, int dy, const char *s __unused) /* draw line from here to dx, dy using s */
{
int xd, yd;
float val, slope;
@@ -171,8 +171,9 @@ drawwig(char *s) /* draw wiggly line */
{
int x[50], y[50], xp, yp, pxp, pyp;
float t1, t2, t3, w;
- int i, j, numdots, N;
- int osize;
+ int j, numdots;
+ size_t i, N;
+ size_t osize;
char temp[50], *p;
osize = size;
diff --git a/troff/troff.d/fontmap.c b/troff/troff.d/fontmap.c
index afe8b44afdb8..0ba21280b5d7 100644
--- a/troff/troff.d/fontmap.c
+++ b/troff/troff.d/fontmap.c
@@ -46,7 +46,7 @@ static char *filepath;
static char *bufp;
static char *bufe;
-struct bst map = {
+static struct bst map = {
NULL,
mapcmp
};
@@ -94,8 +94,8 @@ rdftmap(char *path) {
free(buf);
}
-char *
-mapft(char *name) {
+const char *
+mapft(const char *name) {
struct bst_node *n;
if (map.root && !bst_srch(&map, (union bst_val)(void *)name, &n))
name = n->data.p;
diff --git a/troff/troff.d/fontmap.h b/troff/troff.d/fontmap.h
index 1b01d565ed13..da753c616ad7 100644
--- a/troff/troff.d/fontmap.h
+++ b/troff/troff.d/fontmap.h
@@ -1,2 +1,2 @@
void rdftmap(char *);
-char *mapft(char *);
+const char *mapft(const char *);
diff --git a/troff/troff.d/otf.c b/troff/troff.d/otf.c
index 1f3643030cf9..abaec6f55c8f 100644
--- a/troff/troff.d/otf.c
+++ b/troff/troff.d/otf.c
@@ -41,6 +41,10 @@
#include "dev.h"
#include "afm.h"
+#ifndef __unused
+#define __unused __attribute__((unused))
+#endif
+
extern struct dev dev;
extern char *chname;
extern short *chtab;
@@ -56,8 +60,8 @@ static unsigned short numTables;
static int ttf;
static const char *filename;
unsigned short unitsPerEm;
-short xMin, yMin, xMax, yMax;
-short indexToLocFormat;
+static short xMin, yMin, xMax, yMax;
+static short indexToLocFormat;
static struct afmtab *a;
static int nc;
static int fsType;
@@ -103,26 +107,26 @@ static struct table {
int in_sfnts;
uint32_t checksum;
} tables[] = {
- { "CFF ", &pos_CFF, 0 },
- { "cmap", &pos_cmap, 0 },
- { "cvt ", &pos_cvt, 1 },
- { "fpgm", &pos_fpgm, 1 },
- { "GPOS", &pos_GPOS, 0 },
- { "GSUB", &pos_GSUB, 0 },
- { "head", &pos_head, 2 },
- { "hhea", &pos_hhea, 1 },
- { "hmtx", &pos_hmtx, 1 },
- { "kern", &pos_kern, 0 },
- { "loca", &pos_loca, 1 },
- { "maxp", &pos_maxp, 1 },
- { "name", &pos_name, 0 },
- { "OS/2", &pos_OS_2, 0 },
- { "post", &pos_post, 0 },
- { "prep", &pos_prep, 1 },
- { "vhea", &pos_vhea, 1 },
- { "vmtx", &pos_vmtx, 1 },
- { "glyf", &pos_glyf, 3 }, /* holds glyph data */
- { NULL, NULL, 0 }
+ { "CFF ", &pos_CFF, 0, 0 },
+ { "cmap", &pos_cmap, 0, 0 },
+ { "cvt ", &pos_cvt, 1, 0 },
+ { "fpgm", &pos_fpgm, 1, 0 },
+ { "GPOS", &pos_GPOS, 0, 0 },
+ { "GSUB", &pos_GSUB, 0, 0 },
+ { "head", &pos_head, 2, 0 },
+ { "hhea", &pos_hhea, 1, 0 },
+ { "hmtx", &pos_hmtx, 1, 0 },
+ { "kern", &pos_kern, 0, 0 },
+ { "loca", &pos_loca, 1, 0 },
+ { "maxp", &pos_maxp, 1, 0 },
+ { "name", &pos_name, 0, 0 },
+ { "OS/2", &pos_OS_2, 0, 0 },
+ { "post", &pos_post, 0, 0 },
+ { "prep", &pos_prep, 1, 0 },
+ { "vhea", &pos_vhea, 1, 0 },
+ { "vmtx", &pos_vmtx, 1, 0 },
+ { "glyf", &pos_glyf, 3, 0 }, /* holds glyph data */
+ { NULL, NULL, 0, 0 }
};
static unsigned short *gid2sid;
@@ -1699,7 +1703,7 @@ free_INDEX(struct INDEX *ip)
}
static struct INDEX *
-get_INDEX(long *op)
+get_INDEX(unsigned long *op)
{
struct INDEX *ip;
int i;
@@ -1898,7 +1902,7 @@ otfalloc(int _nc)
static void
get_CFF(void)
{
- long o;
+ size_t o;
char buf[4];
if (pos_CFF < 0)
@@ -1936,7 +1940,7 @@ get_CFF(void)
/*ARGSUSED*/
static void
-get_ttf_post_1_0(int o)
+get_ttf_post_1_0(int o __unused)
{
int i;
@@ -1948,9 +1952,9 @@ get_ttf_post_1_0(int o)
static void
get_ttf_post_2_0(int o)
{
- int numberOfGlyphs;
- int numberNewGlyphs;
- int i, j, n;
+ size_t numberOfGlyphs;
+ size_t numberNewGlyphs;
+ size_t i, j, n;
char *cp, *sp;
numberOfGlyphs = pbe16(&contents[o+32]);
@@ -1991,8 +1995,8 @@ get_ttf_post_2_0(int o)
static void
get_ttf_post_2_5(int o)
{
- int numberOfGlyphs;
- int i, offset;
+ size_t numberOfGlyphs, i;
+ int offset;
numberOfGlyphs = pbe16(&contents[o+32]);
if (34+numberOfGlyphs > table_directories[pos_post].length)
@@ -2055,8 +2059,14 @@ addunimap(int gid, int c)
}
#endif /* !DPOST && !DUMP */
+#if defined(DPOST) || defined(DUMP)
+#define __actual_use __unused
+#else
+#define __actual_use
+#endif
+
static void
-addunitab(int c, int u)
+addunitab(int c __actual_use, int u __actual_use)
{
#if !defined (DPOST) && !defined (DUMP)
if (c >= a->nunitab) {
@@ -2099,7 +2109,8 @@ get_ms_unicode_cmap4(int o, int addchar)
int idDelta;
int idRangeOffset;
/* int glyphIdArray; */
- int c, e, i, d, r, s, gid, x;
+ int c, e, i, d, r, s, gid;
+ size_t x;
/* length = */ pbe16(&contents[o+2]);
segCount = pbe16(&contents[o+6]) / 2;
@@ -2176,11 +2187,11 @@ get_ms_unicode_cmap(int o, int addchar)
static int
get_cmap(int addchar)
{
- int numTables;
+ size_t nTables, i;
int platformID;
int encodingID;
int offset;
- int i, o;
+ int o;
int want_tbl;
int gotit = 0;
@@ -2195,8 +2206,8 @@ get_cmap(int addchar)
error("can only handle version 0 cmap tables");
return gotit;
}
- numTables = pbe16(&contents[o+2]);
- if (4 + 8*numTables > table_directories[pos_cmap].length) {
+ nTables = pbe16(&contents[o+2]);
+ if (4 + 8*nTables > table_directories[pos_cmap].length) {
if (addchar)
error("cmap table too small for values inside");
return gotit;
@@ -2204,7 +2215,7 @@ get_cmap(int addchar)
if (addchar)
otfalloc(numGlyphs);
want_tbl = -1;
- for (i = 0; i < numTables; i++) {
+ for (i = 0; i < nTables; i++) {
platformID = pbe16(&contents[o+4+8*i]);
encodingID = pbe16(&contents[o+4+8*i+2]);
if ((platformID == 3 && encodingID == 10) ||
@@ -2221,7 +2232,7 @@ get_cmap(int addchar)
}
static void
-get_ttf_post_3_0(int o)
+get_ttf_post_3_0(int o __unused)
{
int i, n;
int gotit;
@@ -3294,7 +3305,7 @@ CalcTableChecksum(uint32_t sum, const char *cp, int length)
}
static void
-sfnts1(struct table *tp, int *offset, uint32_t *ccs, FILE *fp)
+sfnts1(struct table *tp, int *offset, uint32_t *ccs, FILE *fp __unused)
{
int o, length;
@@ -3396,30 +3407,30 @@ static void
build_sfnts(FILE *fp)
{
int i, o, n;
- unsigned short numTables;
+ unsigned short nTables;
unsigned short searchRange;
unsigned short entrySelector;
unsigned short rangeShift;
uint32_t ccs;
- numTables = 0;
+ nTables = 0;
for (i = 0; tables[i].name; i++)
if (tables[i].in_sfnts && *tables[i].pos >= 0)
- numTables++;
+ nTables++;
entrySelector = 0;
- for (searchRange = 1; searchRange*2 < numTables; searchRange *= 2)
+ for (searchRange = 1; searchRange*2 < nTables; searchRange *= 2)
entrySelector++;
searchRange *= 16;
- rangeShift = numTables * 16 - searchRange;
+ rangeShift = nTables * 16 - searchRange;
fprintf(fp, "<%08X%04hX%04hX%04hX%04hX\n", 0x00010000,
- numTables, searchRange, entrySelector, rangeShift);
- ccs = 0x00010000 + (numTables<<16) + searchRange +
+ nTables, searchRange, entrySelector, rangeShift);
+ ccs = 0x00010000 + (nTables<<16) + searchRange +
(entrySelector<<16) + rangeShift;
- o = 12 + numTables * 16;
+ o = 12 + nTables * 16;
for (i = 0; tables[i].name; i++)
if (tables[i].in_sfnts && *tables[i].pos >= 0)
sfnts1(&tables[i], &o, &ccs, fp);
- o = 12 + numTables * 16;
+ o = 12 + nTables * 16;
n = 0;
for (i = 0; tables[i].name; i++) {
if (tables[i].in_sfnts && *tables[i].pos >= 0) {
@@ -3437,7 +3448,7 @@ build_sfnts(FILE *fp)
int
otft42(char *font, char *path, char *_contents, size_t _size, FILE *fp)
{
- char *cp;
+ const char *cp;
int ok = 0;
int i;
diff --git a/troff/troff.d/otfdump.c b/troff/troff.d/otfdump.c
index cb6b7f940b76..283e6ae07d1d 100644
--- a/troff/troff.d/otfdump.c
+++ b/troff/troff.d/otfdump.c
@@ -39,9 +39,9 @@ static void print(enum show, const char *, ...);
#define DUMP
#include <stdio.h>
+#include <unistd.h>
#include "otf.c"
#include "afm.c"
-#include "dpost.d/getopt.c"
#include <libgen.h>
@@ -109,7 +109,6 @@ dump(const char *name)
struct stat st;
FILE *fp;
char *cp;
- size_t l;
if ((fp = fopen(filename = name, "r")) == NULL) {
errprint("%s: cannot open", filename);
@@ -118,9 +117,7 @@ dump(const char *name)
memset(&A, 0, sizeof A);
a = &A;
a->file = a->path = (char *)filename;
- l = strlen(filename) + 1;
- a->base = malloc(l);
- n_strcpy(a->base, filename, l);
+ a->base = strdup(filename);
a->base = basename(a->base);
if ((cp = strrchr(a->base, '.')) != NULL)
*cp = '\0';
diff --git a/troff/troff.d/pt.h b/troff/troff.d/pt.h
index e047255d0194..fcd6c7b5b927 100644
--- a/troff/troff.d/pt.h
+++ b/troff/troff.d/pt.h
@@ -80,12 +80,12 @@ extern double u2pts(int);
/* t10.c */
extern void ptinit(void);
extern void specnames(void);
-extern int findch(register char *);
+extern int findch(register const char *);
extern void ptout(register tchar);
extern tchar *ptout0(tchar *, tchar *);
extern void ptps(void);
extern void ptfont(void);
-extern void ptfpcmd(int, char *, char *, int);
+extern void ptfpcmd(int, const char *, char *, int);
extern void ptlead(void);
extern void ptesc(void);
extern void newpage(int);
diff --git a/troff/troff.d/t10.c b/troff/troff.d/t10.c
index 52cfc40c0751..f858225de80e 100644
--- a/troff/troff.d/t10.c
+++ b/troff/troff.d/t10.c
@@ -50,6 +50,7 @@
* contributors.
*/
+#include <stdio.h>
#include <stdlib.h>
#include "tdef.h"
#include <ctype.h>
@@ -89,7 +90,7 @@ int Hor;
int Vert;
int Unitwidth;
int nfonts;
-int nsizes;
+static int nsizes;
int nchtab;
int lettrack;
float horscale;
@@ -289,22 +290,22 @@ ptinit(void)
kern = xflag;
if (ascii)
return;
- fdprintf(ptid, "x T %s\n", devname);
- fdprintf(ptid, "x res %d %d %d\n", Inch, Hor, Vert);
- fdprintf(ptid, "x init\n"); /* do initialization for particular device */
+ dprintf(ptid, "x T %s\n", devname);
+ dprintf(ptid, "x res %d %d %d\n", Inch, Hor, Vert);
+ dprintf(ptid, "x init\n"); /* do initialization for particular device */
/*
for (i = 1; i <= nfonts; i++)
- fdprintf(ptid, "x font %d %s\n", i, fontbase[i]->namefont);
- fdprintf(ptid, "x xxx fonts=%d sizes=%d unit=%d\n", nfonts, nsizes, Unitwidth);
- fdprintf(ptid, "x xxx nchtab=%d lchname=%d nfitab=%d\n",
+ dprintf(ptid, "x font %d %s\n", i, fontbase[i]->namefont);
+ dprintf(ptid, "x xxx fonts=%d sizes=%d unit=%d\n", nfonts, nsizes, Unitwidth);
+ dprintf(ptid, "x xxx nchtab=%d lchname=%d nfitab=%d\n",
dev.nchtab, dev.lchname, dev.nchtab+128-32);
- fdprintf(ptid, "x xxx sizes:\nx xxx ");
+ dprintf(ptid, "x xxx sizes:\nx xxx ");
for (i = 0; i < nsizes; i++)
- fdprintf(ptid, " %d", pstab[i]);
- fdprintf(ptid, "\nx xxx chars:\nx xxx ");
+ dprintf(ptid, " %d", pstab[i]);
+ dprintf(ptid, "\nx xxx chars:\nx xxx ");
for (i = 0; i < dev.nchtab; i++)
- fdprintf(ptid, " %s", &chname[chtab[i]]);
- fdprintf(ptid, "\nx xxx\n");
+ dprintf(ptid, " %s", &chname[chtab[i]]);
+ dprintf(ptid, "\nx xxx\n");
*/
#ifdef EUC
ptlocale(setlocale(LC_CTYPE, NULL));
@@ -317,7 +318,7 @@ specnames(void)
{
static struct {
int *n;
- char *v;
+ const char *v;
} spnames[] = {
{ &c_hyphen , "hy" },
{ &c_emdash , "em" },
@@ -348,7 +349,7 @@ specnames(void)
}
int
-findch(register char *s) /* find char s in chname */
+findch(register const char *s) /* find char s in chname */
{
register int i;
@@ -414,9 +415,9 @@ ptout(register tchar i)
if (linkout)
ptlink(linkout);
/*
- fdprintf(ptid, "x xxx end of line: hpos=%d, vpos=%d\n", hpos, vpos);
+ dprintf(ptid, "x xxx end of line: hpos=%d, vpos=%d\n", hpos, vpos);
*/
- fdprintf(ptid, "n%d %d\n", b, a); /* be nice to chuck */
+ dprintf(ptid, "n%d %d\n", b, a); /* be nice to chuck */
}
tchar *
@@ -455,7 +456,7 @@ ptout0(tchar *pi, tchar *pend)
ptlead();
if (esc)
ptesc();
- fdprintf(ptid, "x X ");
+ dprintf(ptid, "x X ");
/*
* not guaranteed of finding a XOFF if a word overflow
* error occured, so also bound this loop by olinep
@@ -479,9 +480,9 @@ ptout0(tchar *pi, tchar *pend)
ptps();
j = f = u2pts(sbits(i));
if (j != f && xflag && dev.anysize)
- fdprintf(ptid, "x H -23 %g\n", f);
+ dprintf(ptid, "x H -23 %g\n", f);
else
- fdprintf(ptid, "x H %d\n", j);
+ dprintf(ptid, "x H %d\n", j);
return(pi+outsize);
}
if (k == SLANT) {
@@ -490,7 +491,7 @@ ptout0(tchar *pi, tchar *pend)
if (xfont != mfont)
ptfont();
}
- fdprintf(ptid, "x S %d\n", (int)sbits(i)-180);
+ dprintf(ptid, "x S %d\n", (int)sbits(i)-180);
return(pi+outsize);
}
if (k == WORDSP) {
@@ -626,23 +627,23 @@ ptout0(tchar *pi, tchar *pend)
switch ((c=cbits(pi[1]))) {
case DRAWCIRCLE: /* circle */
case DRAWCIRCLEFI:
- fdprintf(ptid, "D%c %d\n", c, dx); /* dx is diameter */
+ dprintf(ptid, "D%c %d\n", c, dx); /* dx is diameter */
w = 0;
hpos += dx;
break;
case DRAWELLIPSE:
case DRAWELLIPSEFI:
- fdprintf(ptid, "D%c %d %d\n", c, dx, dy);
+ dprintf(ptid, "D%c %d %d\n", c, dx, dy);
w = 0;
hpos += dx;
break;
case DRAWLINE: /* line */
k = cbits(pi[2]);
- fdprintf(ptid, "D%c %d %d ", DRAWLINE, dx, dy);
+ dprintf(ptid, "D%c %d %d ", DRAWLINE, dx, dy);
if (k < 128)
- fdprintf(ptid, "%c\n", k);
+ dprintf(ptid, "%c\n", k);
else
- fdprintf(ptid, "%s\n", &chname[chtab[k - 128]]);
+ dprintf(ptid, "%s\n", &chname[chtab[k - 128]]);
w = 0;
hpos += dx;
vpos += dy;
@@ -654,7 +655,7 @@ ptout0(tchar *pi, tchar *pend)
dy2 = absmot(pi[6]);
if (isnmot(pi[6]))
dy2 = -dy2;
- fdprintf(ptid, "D%c %d %d %d %d\n", DRAWARC,
+ dprintf(ptid, "D%c %d %d %d %d\n", DRAWARC,
dx, dy, dx2, dy2);
w = 0;
hpos += dx + dx2;
@@ -662,13 +663,13 @@ ptout0(tchar *pi, tchar *pend)
break;
case DRAWSPLINE: /* spline */
default: /* something else; copy it like spline */
- fdprintf(ptid, "D%c %d %d", (int)cbits(pi[1]), dx, dy);
+ dprintf(ptid, "D%c %d %d", (int)cbits(pi[1]), dx, dy);
w = 0;
hpos += dx;
vpos += dy;
if (cbits(pi[3]) == DRAWFCN || cbits(pi[4]) == DRAWFCN) {
/* it was somehow defective */
- fdprintf(ptid, "\n");
+ dprintf(ptid, "\n");
break;
}
for (n = 5; cbits(pi[n]) != DRAWFCN; n += 2) {
@@ -678,11 +679,11 @@ ptout0(tchar *pi, tchar *pend)
dy = absmot(pi[n+1]);
if (isnmot(pi[n+1]))
dy = -dy;
- fdprintf(ptid, " %d %d", dx, dy);
+ dprintf(ptid, " %d %d", dx, dy);
hpos += dx;
vpos += dy;
}
- fdprintf(ptid, "\n");
+ dprintf(ptid, "\n");
break;
}
for (n = 3; cbits(pi[n]) != DRAWFCN; n++)
@@ -715,7 +716,7 @@ ptout0(tchar *pi, tchar *pend)
if (esc += bd)
ptesc();
if (k < 128) {
- fdprintf(ptid, "c%c\n", k);
+ dprintf(ptid, "c%c\n", k);
} else
pnc(k, a);
if (z)
@@ -734,13 +735,13 @@ pnc(int k, struct afmtab *a) {
if (k >= nchtab + 128) {
if (a && (j = a->fitab[k-nchtab-128-32]) < a->nchars &&
a->nametab[j] != NULL) {
- fdprintf(ptid, "CPS%s\n", a->nametab[j]);
+ dprintf(ptid, "CPS%s\n", a->nametab[j]);
} else {
- fdprintf(ptid, "N%d\n",
+ dprintf(ptid, "N%d\n",
k - (html ? 0 : (nchtab + 128)) );
}
} else {
- fdprintf(ptid, "C%s\n", &chname[chtab[k - 128]]);
+ dprintf(ptid, "C%s\n", &chname[chtab[k - 128]]);
}
}
@@ -766,7 +767,7 @@ pthorscale(int always)
{
if (horscale || mhorscale) {
if (always || mhorscale != horscale)
- fdprintf(ptid, "x X HorScale %g\n",
+ dprintf(ptid, "x X HorScale %g\n",
horscale ? horscale : 1.0);
mhorscale = horscale;
} else
@@ -778,7 +779,7 @@ pttrack(int always)
{
if (xflag && (lasttrack || lettrack || mtrack)) {
if (always || mtrack != (lasttrack + lettrack))
- fdprintf(ptid, "x X Track %d\n", lasttrack + lettrack);
+ dprintf(ptid, "x X Track %d\n", lasttrack + lettrack);
mtrack = lasttrack + lettrack;
} else
mtrack = 0;
@@ -804,9 +805,9 @@ ptps(void)
if ((z = zoomtab[xfont]) != 0 && dev.anysize && xflag)
s *= z;
if (dev.anysize && xflag && (!found || (z != 0 && z != 1)))
- fdprintf(ptid, "s-23 %g\n", s);
+ dprintf(ptid, "s-23 %g\n", s);
else
- fdprintf(ptid, "s%d\n", (int)s); /* really should put out string rep of size */
+ dprintf(ptid, "s%d\n", (int)s); /* really should put out string rep of size */
mpts = i;
mzoom = z;
pttrack(0);
@@ -817,24 +818,24 @@ void
ptfont(void)
{
mfont = xfont;
- fdprintf(ptid, "f%d\n", xfont);
+ dprintf(ptid, "f%d\n", xfont);
mtrack = 0;
pttrack(1);
pthorscale(1);
}
void
-ptfpcmd(int f, char *s, char *path, int flags)
+ptfpcmd(int f, const char *s, char *path, int flags)
{
if (ascii)
return;
- fdprintf(ptid, "x font %d %s", f, s);
+ dprintf(ptid, "x font %d %s", f, s);
if (path) {
- fdprintf(ptid, " %s", path);
+ dprintf(ptid, " %s", path);
if (flags)
- fdprintf(ptid, " %d", flags);
+ dprintf(ptid, " %d", flags);
}
- fdprintf(ptid, "\n");
+ dprintf(ptid, "\n");
ptfont(); /* make sure that it gets noticed */
}
@@ -843,7 +844,7 @@ ptlead(void)
{
vpos += lead;
if (!ascii)
- fdprintf(ptid, "V%d\n", vpos);
+ dprintf(ptid, "V%d\n", vpos);
lead = 0;
}
@@ -857,9 +858,9 @@ ptesc(void)
oput(esc/10 + '0');
oput(esc%10 + '0');
} else
- fdprintf(ptid, "%d", esc);
+ dprintf(ptid, "%d", esc);
} else
- fdprintf(ptid, "H%d\n", hpos);
+ dprintf(ptid, "H%d\n", hpos);
esc = 0;
}
@@ -868,7 +869,7 @@ ptsupplyfont(char *fontname, char *file)
{
if (ascii)
return;
- fdprintf(ptid, "x X SupplyFont %s %s\n", fontname, file);
+ dprintf(ptid, "x X SupplyFont %s %s\n", fontname, file);
}
void
@@ -876,7 +877,7 @@ ptpapersize(void)
{
if (ascii || mediasize.flag == 0)
return;
- fdprintf(ptid, "x X PaperSize %d %d %d\n",
+ dprintf(ptid, "x X PaperSize %d %d %d\n",
mediasize.val[2], mediasize.val[3],
mediasize.flag&2?1:0);
}
@@ -885,7 +886,7 @@ static void
cut1(const char *name, struct box *bp)
{
if (bp->flag)
- fdprintf(ptid, "x X %s %d %d %d %d\n", name,
+ dprintf(ptid, "x X %s %d %d %d %d\n", name,
bp->val[0], bp->val[1], bp->val[2], bp->val[3]);
}
@@ -913,7 +914,7 @@ ptlocale(const char *cp)
}
if (ascii || realpage == 0 || lp == NULL || dev.lc_ctype == 0)
return;
- fdprintf(ptid, "x X LC_CTYPE %s\n", lp);
+ dprintf(ptid, "x X LC_CTYPE %s\n", lp);
}
static void
@@ -926,9 +927,9 @@ ptanchor(int n)
for (rp = anchors; rp; rp = rp->next)
if (rp->cnt == n) {
if (html) {
- fdprintf(ptid, "x X Anchor %s\n", rp->name);
+ dprintf(ptid, "x X Anchor %s\n", rp->name);
} else {
- fdprintf(ptid, "x X Anchor %d,%d %s\n",
+ dprintf(ptid, "x X Anchor %d,%d %s\n",
vpos + lead - lss, hpos + esc, rp->name);
}
break;
@@ -943,15 +944,15 @@ _ptlink(int n, struct ref *rstart, const char *type)
if (ascii)
return;
if (html && !n) {
- fdprintf(ptid, "x X %s\n", type);
+ dprintf(ptid, "x X %s\n", type);
return;
}
for (rp = rstart; rp; rp = rp->next)
if (rp->cnt == n) {
if (html)
- fdprintf(ptid, "x X %s %s\n", type, rp->name);
+ dprintf(ptid, "x X %s %s\n", type, rp->name);
else
- fdprintf(ptid, "x X %s %d,%d,%d,%d %s\n",
+ dprintf(ptid, "x X %s %d,%d,%d,%d %s\n",
type,
linkhp, vpos + pts2u(1),
hpos + esc, vpos - pts * 8 / 10,
@@ -992,7 +993,7 @@ ptyon(int i)
ptlead();
if (esc)
ptesc();
- fdprintf(ptid, "x X ");
+ dprintf(ptid, "x X ");
savip = ip;
ip = (filep)cp->mx;
app = 1;
@@ -1084,7 +1085,7 @@ newpage(int n) /* called at end of each output page (we hope) */
vpos = 0;
if (ascii)
return;
- fdprintf(ptid, "p%d\n", n); /* new page */
+ dprintf(ptid, "p%d\n", n); /* new page */
for (i = 0; i <= nfonts; i++) {
if (fontbase[i] == NULL)
continue;
@@ -1092,13 +1093,13 @@ newpage(int n) /* called at end of each output page (we hope) */
struct afmtab *a = afmtab[(fontbase[i]->afmpos)-1];
if (a->encpath == NULL)
a->encpath = afmencodepath(a->path);
- fdprintf(ptid, "x font %d %s %s %d\n", i,
+ dprintf(ptid, "x font %d %s %s %d\n", i,
macname(fontlab[i]),
a->encpath, (int)a->spec);
if (a->supply)
ptsupplyfont(a->fontname, a->supply);
} else if (fontbase[i]->namefont[0])
- fdprintf(ptid, "x font %d %s\n", i, macname(fontlab[i]));
+ dprintf(ptid, "x font %d %s\n", i, macname(fontlab[i]));
}
ptps();
ptfont();
@@ -1110,13 +1111,13 @@ newpage(int n) /* called at end of each output page (we hope) */
void
pttrailer(void)
{
- fdprintf(ptid, "x trailer\n");
+ dprintf(ptid, "x trailer\n");
}
void
ptstop(void)
{
- fdprintf(ptid, "x stop\n");
+ dprintf(ptid, "x stop\n");
}
void
@@ -1126,11 +1127,11 @@ dostop(void)
return;
ptlead();
vpos = 0;
- /* fdprintf(ptid, "x xxx end of page\n");*/
+ /* dprintf(ptid, "x xxx end of page\n");*/
if (!nofeed)
pttrailer();
ptlead();
- fdprintf(ptid, "x pause\n");
+ dprintf(ptid, "x pause\n");
flusho();
mpts = mfont = 0;
ptesc();
diff --git a/troff/troff.d/t6.c b/troff/troff.d/t6.c
index bf7909cfd7b3..b1ae66504c63 100644
--- a/troff/troff.d/t6.c
+++ b/troff/troff.d/t6.c
@@ -92,7 +92,7 @@ int **ftrtab;
struct lgtab **lgtab;
int ***lgrevtab;
struct tracktab *tracktab;
-int sbold = 0;
+static int sbold = 0;
int kern = 0;
struct box mediasize, bleedat, trimat, cropat;
int psmaxcode;
@@ -100,7 +100,7 @@ struct ref *anchors, *links, *ulinks;
static int _minflg;
int lastrst;
int lastrsb;
-int spacewidth;
+static int spacewidth;
static void kernsingle(int **);
static int _ps2cc(const char *name, int create);
@@ -248,7 +248,7 @@ getcw(register int i)
goto g1;
}
if ((j = fitab[xfont][i]) == 0) { /* it's not on current font */
- int ii, jj, t;
+ int ii, jj, _t;
/* search through search list of xfont
* to see what font it ought to be on.
* first searches explicit fallbacks, then
@@ -259,8 +259,8 @@ getcw(register int i)
for (jj = 0; fallbacktab[xfont][jj] != 0; jj++) {
if ((ii = findft(fallbacktab[xfont][jj],0)) < 0)
continue;
- t = ftrans(ii, i + 32) - 32;
- j = fitab[ii][t];
+ _t = ftrans(ii, i + 32) - 32;
+ j = fitab[ii][_t];
if (j != 0) {
xfont = ii;
goto found;
@@ -271,8 +271,8 @@ getcw(register int i)
for (ii=smnt, jj=0; jj < nfonts; jj++, ii=ii % nfonts + 1) {
if (fontbase[ii] == NULL)
continue;
- t = ftrans(ii, i + 32) - 32;
- j = fitab[ii][t];
+ _t = ftrans(ii, i + 32) - 32;
+ j = fitab[ii][_t];
if (j != 0) {
/*
* troff traditionally relies on the
@@ -288,8 +288,8 @@ getcw(register int i)
found: p = fontab[ii];
k = *(p + j);
if (afmtab &&
- (t=fontbase[ii]->afmpos-1)>=0) {
- a = afmtab[t];
+ (_t=fontbase[ii]->afmpos-1)>=0) {
+ a = afmtab[_t];
if (a->bbtab[j]) {
lastrst = a->bbtab[j][3];
lastrsb = a->bbtab[j][1];
@@ -459,20 +459,20 @@ getdescender(void)
}
int
-kernadjust(tchar c, tchar d)
+kernadjust(tchar c, tchar e)
{
lastkern = 0;
- if (!kern || ismot(c) || ismot(d) || html)
+ if (!kern || ismot(c) || ismot(e) || html)
return 0;
if (!isdi(c)) {
c = trtab[cbits(c)] | (c & SFMASK);
c = ftrans(fbits(c), cbits(c)) | (c & SFMASK);
}
- if (!isdi(d)) {
- d = trtab[cbits(d)] | (d & SFMASK);
- d = ftrans(fbits(d), cbits(d)) | (d & SFMASK);
+ if (!isdi(e)) {
+ e = trtab[cbits(e)] | (e & SFMASK);
+ e = ftrans(fbits(e), cbits(e)) | (e & SFMASK);
}
- return getkw(c, d);
+ return getkw(c, e);
}
#define kprime 1021
@@ -486,17 +486,17 @@ static struct knode {
} **ktable;
static void
-kadd(tchar c, tchar d, int n)
+kadd(tchar c, tchar e, int n)
{
struct knode *kn;
int h;
if (ktable == NULL)
ktable = calloc(kprime, sizeof *ktable);
- h = khash(c, d);
+ h = khash(c, e);
kn = calloc(1, sizeof *kn);
kn->c = c;
- kn->d = d;
+ kn->d = e;
kn->n = n;
kn->next = ktable[h];
ktable[h] = kn;
@@ -554,22 +554,22 @@ found:
}
static struct knode *
-klook(tchar c, tchar d)
+klook(tchar c, tchar e)
{
struct knode *kp;
int h;
c = findchar(c);
- d = findchar(d);
- h = khash(c, d);
+ e = findchar(e);
+ h = khash(c, e);
for (kp = ktable[h]; kp; kp = kp->next)
- if (kp->c == c && kp->d == d)
+ if (kp->c == c && kp->d == e)
break;
return kp && kp->n != INT_MAX ? kp : NULL;
}
int
-getkw(tchar c, tchar d)
+getkw(tchar c, tchar e)
{
struct knode *kp;
struct afmtab *a;
@@ -578,27 +578,27 @@ getkw(tchar c, tchar d)
if (isxfunc(c, CHAR))
c = charout[sbits(c)].ch;
- if (isxfunc(d, CHAR))
- d = charout[sbits(d)].ch;
+ if (isxfunc(e, CHAR))
+ e = charout[sbits(e)].ch;
lastkern = 0;
- if (!kern || iszbit(c) || iszbit(d) || ismot(c) || ismot(d))
+ if (!kern || iszbit(c) || iszbit(e) || ismot(c) || ismot(e))
return 0;
- if (sbits(c) != sbits(d))
+ if (sbits(c) != sbits(e))
return 0;
f = fbits(c);
- g = fbits(d);
+ g = fbits(e);
if ((s = sbits(c)) == 0) {
s = xpts;
if (f == 0)
f = xfont;
}
i = cbits(c);
- j = cbits(d);
+ j = cbits(e);
if (i == SLANT || j == SLANT || i == XFUNC || j == XFUNC || cstab[f])
return 0;
k = 0;
if (i >= 32 && j >= 32) {
- if (ktable != NULL && (kp = klook(c, d)) != NULL)
+ if (ktable != NULL && (kp = klook(c, e)) != NULL)
k = kp->n;
else if ((n = (fontbase[f]->afmpos)-1) >= 0 &&
n == (fontbase[g]->afmpos)-1 &&
@@ -616,8 +616,8 @@ getkw(tchar c, tchar d)
}
if (j>32 && kernafter != NULL && kernafter[fbits(c)] != NULL)
k += kernafter[fbits(c)][i];
- if (i>32 && kernbefore != NULL && kernbefore[fbits(d)] != NULL)
- k += kernbefore[fbits(d)][j];
+ if (i>32 && kernbefore != NULL && kernbefore[fbits(e)] != NULL)
+ k += kernbefore[fbits(e)][j];
}
if (k != 0) {
k = (k * u2pts(s) + (Unitwidth / 2)) / Unitwidth;
@@ -713,9 +713,9 @@ postchar(const char *temp, int *fp)
return 0;
}
-const struct amap {
- char *alias;
- char *trname;
+static const struct amap {
+ const char *alias;
+ const char *trname;
} amap[] = {
{ "lq", "``" },
{ "rq", "''" },
@@ -726,13 +726,14 @@ tchar
setch(int delim) {
register int j;
char temp[NC];
- tchar c, d[2] = {0, 0};
- int f, n;
+ tchar c, e[2] = {0, 0};
+ int f;
+ size_t n;
const struct amap *ap;
n = 0;
if (delim == 'C')
- d[0] = getach();
+ e[0] = getach();
do {
c = getach();
if (c == 0 && n < 2)
@@ -741,7 +742,7 @@ setch(int delim) {
temp[n-1] = 0;
break;
}
- if ((delim == '[' && c == ']') || (delim == 'C' && c == d[0])) {
+ if ((delim == '[' && c == ']') || (delim == 'C' && c == e[0])) {
temp[n] = 0;
break;
}
@@ -754,7 +755,7 @@ setch(int delim) {
for (ap = amap; ap->alias; ap++)
if (!strcmp(ap->alias, temp)) {
size_t l;
- char *s = ap->trname;
+ const char *s = ap->trname;
if ((l = strlen(s) + 1) > NC) {
fprintf(stderr, "%s %i: strlen(%s)+1 > %d\n",
__FILE__, __LINE__, s, NC);
@@ -767,8 +768,8 @@ setch(int delim) {
nodelim(']');
return ' ';
}
- if (delim == 'C' && c != d[0]) {
- nodelim(d[0]);
+ if (delim == 'C' && c != e[0]) {
+ nodelim(e[0]);
return ' ';
}
c = 0;
@@ -780,7 +781,6 @@ setch(int delim) {
&& isxdigit((unsigned)temp[2])
&& isxdigit((unsigned)temp[3])
&& isxdigit((unsigned)temp[4])) {
- int n;
n = strtol(temp + 1, NULL, 16);
if (n)
c = setuc0(n);
@@ -816,7 +816,7 @@ setch(int delim) {
c = 0;
}
if (c == 0 && warn & WARN_CHAR)
- errprint("missing glyph \\%c%s%s%s%s", delim, d, temp, d,
+ errprint("missing glyph \\%c%s%s%s%s", delim, e, temp, e,
delim == '[' ? "]" : "");
if (c == 0 && !tryglf)
c = ' ';
@@ -843,7 +843,8 @@ findft(register int i, int required)
{
register int k;
int nk;
- char *mn, *mp;
+ const char *mn;
+ char *mp;
if ((k = i - '0') >= 0 && k <= nfonts && k < smnt && fontbase[k])
return(k);
@@ -1270,7 +1271,8 @@ tchar getlg(tchar i)
{
tchar j, k, pb[NC];
struct lgtab *lp;
- int c, f, n, lgn;
+ int c, f;
+ size_t n, lgn;
f = fbits(i);
if (lgtab[f] == NULL) /* font lacks ligatures */
@@ -1504,7 +1506,8 @@ getflig(int f, int mode)
{
int delete, allnum;
tchar from[NC], to;
- int c, i, j;
+ int c;
+ size_t i, j;
char number[NC];
if (skip(0))
@@ -1597,14 +1600,9 @@ casefp(int spec)
goto bad;
setfp(i, j, 0);
} else { /* 3rd argument = filename */
- size_t l;
- l = strlen(nextf) + 1;
- file = malloc(l);
- n_strcpy(file, nextf, l);
+ file = strdup(nextf);
if (!skip(0) && getname()) {
- l = strlen(nextf) + 1;
- supply = malloc(l);
- n_strcpy(supply, nextf, l);
+ supply = strdup(nextf);
} else
supply = NULL;
if (loadafm(i?i:-1, j, file, supply, 0, spec) == 0) {
@@ -1637,7 +1635,8 @@ casefps(void)
{ SPEC_NONE, NULL }
};
char name[NC];
- int c = 0, i;
+ int c = 0;
+ size_t i;
enum spec s = SPEC_NONE;
if (skip(1))
@@ -1663,7 +1662,8 @@ casefps(void)
int
setfp(int pos, int f, char *truename) /* mount font f at position pos[0...nfonts] */
{
- char longname[4096], *shortname, *ap;
+ char longname[4096], *ap;
+ const char *shortname;
char *fpout;
int i, nw;
@@ -1974,7 +1974,7 @@ tchar xlss(void)
struct afmtab **afmtab;
int nafm;
-char *
+static char *
onefont(char *prefix, char *file, char *type)
{
char *path, *fp, *tp;
@@ -2009,9 +2009,7 @@ getfontpath(char *file, char *type)
size_t l;
if ((troffonts = getenv("TROFFONTS")) != NULL) {
- l = strlen(troffonts) + 1;
- tp = malloc(l);
- n_strcpy(tp, troffonts, l);
+ tp = strdup(troffonts);
troffonts = tp;
do {
for (tq = tp; *tq && *tq != ':'; tq++);
@@ -2091,9 +2089,7 @@ loadafm(int nf, int rq, char *file, char *supply, int required, enum spec spec)
break;
}
a->path = path;
- l = strlen(file) + 1;
- a->file = malloc(l);
- n_strcpy(a->file, file, l);
+ a->file = strdup(file);
a->spec = spec;
a->rq = rq;
a->Font.namefont[0] = rq&0377;
@@ -2193,7 +2189,7 @@ done: afmtab = realloc(afmtab, (nafm+1) * sizeof *afmtab);
return 1;
}
-int
+static int
tracknum(void)
{
skip(1);
@@ -2337,7 +2333,7 @@ static void
setpapersize(int setmedia)
{
const struct {
- char *name;
+ const char *name;
int width;
int heigth;
} papersizes[] = {
@@ -2380,7 +2376,8 @@ setpapersize(int setmedia)
{ NULL, 0, 0 }
};
int c;
- int x = 0, y = 0, n;
+ int x = 0, y = 0;
+ size_t n;
char buf[NC];
lgf++;
@@ -2499,7 +2496,7 @@ casekernpair(void)
{
int savfont = font, savfont1 = font1;
int f, g, i, j, n;
- tchar c, d, *cp = NULL, *dp = NULL;
+ tchar c, e, *cp = NULL, *dp = NULL;
int a = 0, b = 0;
lgf++;
@@ -2555,12 +2552,12 @@ casekernpair(void)
if (c == UNPAD)
c = ' ';
setfbits(c, f);
- if ((d = cbits(dp[j])) == 0)
+ if ((e = cbits(dp[j])) == 0)
continue;
- if (d == UNPAD)
- d = ' ';
- setfbits(d, g);
- kadd(c, d, n);
+ if (e == UNPAD)
+ e = ' ';
+ setfbits(e, g);
+ kadd(c, e, n);
}
done:
free(cp);
@@ -2666,7 +2663,8 @@ static int
getfeature(struct afmtab *a, int f)
{
char name[NC];
- int ch1, ch2, c, i, j, minus;
+ int ch1, ch2, c, j, minus;
+ size_t i;
struct feature *fp;
if (skip(0))
@@ -2948,9 +2946,9 @@ _setlink(struct ref **rstart, int oncode, int offcode, int *cnt)
{
struct ref *rp;
char *np;
- int sv;
+ int _sv;
- sv = linkin;
+ _sv = linkin;
if ((linkin = !linkin)) {
if ((np = getref()) != NULL) {
rp = calloc(1, sizeof *rp);
@@ -2965,7 +2963,7 @@ _setlink(struct ref **rstart, int oncode, int offcode, int *cnt)
return mkxfunc(oncode, 0);
}
} else
- return mkxfunc(offcode, sv > 0 ? sv : 0);
+ return mkxfunc(offcode, _sv > 0 ? _sv : 0);
}
tchar