summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-10-13 10:21:24 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-10-13 10:21:24 +0000
commit5cf7b56146264fe9cc6ca3f7594e29a1da4df624 (patch)
tree1428bfe69ba7414af6b3c9677aad93cfab428e14
parentf06be045fa23029451ed1ae110eb8e27f016042c (diff)
downloadmandoc-5cf7b56146264fe9cc6ca3f7594e29a1da4df624.tar.gz
mandoc-5cf7b56146264fe9cc6ca3f7594e29a1da4df624.tar.zst
mandoc-5cf7b56146264fe9cc6ca3f7594e29a1da4df624.zip
Clean up consts (noted by Joerg Sonnenberger and Ulrich Sporlein).
-rw-r--r--Makefile2
-rw-r--r--html.c14
-rw-r--r--html.h4
-rw-r--r--main.c13
4 files changed, 20 insertions, 13 deletions
diff --git a/Makefile b/Makefile
index ff259098..5815bb28 100644
--- a/Makefile
+++ b/Makefile
@@ -13,7 +13,7 @@ VERSION = 1.9.8
VDATE = 10 October 2009
VFLAGS = -DVERSION=\"$(VERSION)\"
-CFLAGS += -W -Wall -Wstrict-prototypes -Wno-unused-parameter -g
+CFLAGS += -W -Wall -Wstrict-prototypes -Wno-unused-parameter -Wwrite-strings -g
CFLAGS += $(VFLAGS)
LINTFLAGS += $(VFLAGS)
diff --git a/html.c b/html.c
index 5ab4c877..8001cf6c 100644
--- a/html.c
+++ b/html.c
@@ -1,4 +1,4 @@
-/* $Id: html.c,v 1.62 2009/10/09 06:54:11 kristaps Exp $ */
+/* $Id: html.c,v 1.63 2009/10/13 10:21:24 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -21,6 +21,7 @@
#include <err.h>
#include <stdio.h>
#include <stdarg.h>
+#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@@ -29,11 +30,13 @@
#include "chars.h"
#include "html.h"
+#define UNCONST(a) ((void *)(uintptr_t)(const void *)(a))
+
#define DOCTYPE "-//W3C//DTD HTML 4.01//EN"
#define DTD "http://www.w3.org/TR/html4/strict.dtd"
struct htmldata {
- char *name;
+ const char *name;
int flags;
#define HTML_CLRLINE (1 << 0)
#define HTML_NOSTACK (1 << 1)
@@ -87,7 +90,8 @@ void *
html_alloc(char *outopts)
{
struct html *h;
- char *toks[4], *v;
+ const char *toks[4];
+ char *v;
toks[0] = "style";
toks[1] = "man";
@@ -106,7 +110,7 @@ html_alloc(char *outopts)
}
while (outopts && *outopts)
- switch (getsubopt(&outopts, toks, &v)) {
+ switch (getsubopt(&outopts, UNCONST(toks), &v)) {
case (0):
h->style = v;
break;
@@ -600,7 +604,7 @@ void
bufcat_su(struct html *h, const char *p, const struct roffsu *su)
{
double v;
- char *u;
+ const char *u;
v = su->scale;
diff --git a/html.h b/html.h
index adfc1a24..1bb688e1 100644
--- a/html.h
+++ b/html.h
@@ -1,4 +1,4 @@
-/* $Id: html.h,v 1.12 2009/10/07 12:35:23 kristaps Exp $ */
+/* $Id: html.h,v 1.13 2009/10/13 10:21:24 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -77,7 +77,7 @@ SLIST_HEAD(ordq, ord);
struct htmlpair {
enum htmlattr key;
- char *val;
+ const char *val;
};
#define PAIR_CLASS_INIT(p, v) \
diff --git a/main.c b/main.c
index 523be512..79c5f1f3 100644
--- a/main.c
+++ b/main.c
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.44 2009/09/21 13:06:13 kristaps Exp $ */
+/* $Id: main.c,v 1.45 2009/10/13 10:21:24 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -20,6 +20,7 @@
#include <err.h>
#include <fcntl.h>
#include <stdio.h>
+#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@@ -27,6 +28,8 @@
#include "mdoc.h"
#include "man.h"
+#define UNCONST(a) ((void *)(uintptr_t)(const void *)(a))
+
/* Account for FreeBSD and Linux in our declarations. */
#ifdef __linux__
@@ -576,7 +579,7 @@ static int
foptions(int *fflags, char *arg)
{
char *v, *o;
- char *toks[7];
+ const char *toks[7];
toks[0] = "ign-scope";
toks[1] = "no-ign-escape";
@@ -588,7 +591,7 @@ foptions(int *fflags, char *arg)
while (*arg) {
o = arg;
- switch (getsubopt(&arg, toks, &v)) {
+ switch (getsubopt(&arg, UNCONST(toks), &v)) {
case (0):
*fflags |= IGN_SCOPE;
break;
@@ -622,7 +625,7 @@ static int
woptions(int *wflags, char *arg)
{
char *v, *o;
- char *toks[3];
+ const char *toks[3];
toks[0] = "all";
toks[1] = "error";
@@ -630,7 +633,7 @@ woptions(int *wflags, char *arg)
while (*arg) {
o = arg;
- switch (getsubopt(&arg, toks, &v)) {
+ switch (getsubopt(&arg, UNCONST(toks), &v)) {
case (0):
*wflags |= WARN_WALL;
break;