summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-07-24 18:15:13 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-07-24 18:15:13 +0000
commit9d40bd2a7ce3100befc3054237b3cb3a8bc9777d (patch)
tree3da90ac84a9ba5f4aa9e551ab6e61969d88b7cd7
parent0db02e2364d93cad88a1df785984438635066e39 (diff)
downloadmandoc-9d40bd2a7ce3100befc3054237b3cb3a8bc9777d.tar.gz
Scary-looking but otherwise harmless changes allow me to build for Windows.
That is to say, with mingw32. This amounts to the following: (1) break compat.c into compat_strlcpy.c and compat_strlcat.c (2) add compat_getsubopt.c (from OpenBSD) and test-getsubopt.c (3) add test-strptime.c for HAVE_STRPTIME (4) add ifdef bits here and there, where necessary (5) remove some harmless unportable stuff (u_char, localtime_r) I've added the appropriate mdocml.zip target to the Makefile, too.
-rw-r--r--Makefile48
-rw-r--r--compat_getsubopt.c100
-rw-r--r--compat_strlcat.c (renamed from compat.c)46
-rw-r--r--compat_strlcpy.c59
-rw-r--r--config.h.post4
-rw-r--r--man_hash.c10
-rw-r--r--man_validate.c3
-rw-r--r--mandoc.c13
-rw-r--r--mdoc_hash.c14
-rw-r--r--mdoc_validate.c2
-rw-r--r--out.c2
-rw-r--r--preconv.c8
-rw-r--r--test-getsubopt.c12
-rw-r--r--test-strptime.c13
14 files changed, 264 insertions, 70 deletions
diff --git a/Makefile b/Makefile
index ceeaab60..93959a6d 100644
--- a/Makefile
+++ b/Makefile
@@ -18,7 +18,8 @@ VDATE = 24 July 2011
# UCS-4 value) should you define USE_WCHAR. If you define it and your
# system DOESN'T support this, -Tlocale will produce garbage.
# If you don't define it, -Tlocale is a synonym for -Tacsii.
-CFLAGS += -g -DUSE_WCHAR -DHAVE_CONFIG_H -DVERSION="\"$(VERSION)\""
+CFLAGS += -DUSE_WCHAR
+CFLAGS += -g -DHAVE_CONFIG_H -DVERSION="\"$(VERSION)\""
CFLAGS += -W -Wall -Wstrict-prototypes -Wno-unused-parameter -Wwrite-strings
PREFIX = /usr/local
BINDIR = $(PREFIX)/bin
@@ -45,7 +46,9 @@ SRCS = Makefile \
att.in \
chars.c \
chars.in \
- compat.c \
+ compat_getsubopt.c \
+ compat_strlcat.c \
+ compat_strlcpy.c \
config.h.post \
config.h.pre \
eqn.7 \
@@ -179,6 +182,13 @@ LIBMANDOC_LNS = $(LIBMAN_LNS) \
mandoc.ln \
read.ln
+COMPAT_OBJS = compat_getsubopt.o \
+ compat_strlcat.o \
+ compat_strlcpy.o
+COMPAT_LNS = compat_getsubopt.ln \
+ compat_strlcat.ln \
+ compat_strlcpy.ln
+
arch.o arch.ln: arch.in
att.o att.ln: att.in
chars.o chars.ln: chars.in
@@ -193,6 +203,8 @@ $(LIBMDOC_OBJS) $(LIBMDOC_LNS): libmdoc.h
$(LIBROFF_OBJS) $(LIBROFF_LNS): libroff.h
$(LIBMANDOC_OBJS) $(LIBMANDOC_LNS): mandoc.h mdoc.h man.h libmandoc.h config.h
+$(COMPAT_OBJS) $(COMPAT_LNS): config.h
+
MANDOC_HTML_OBJS = eqn_html.o \
html.o \
man_html.o \
@@ -234,8 +246,6 @@ $(MANDOC_HTML_OBJS) $(MANDOC_HTML_LNS): html.h
$(MANDOC_TERM_OBJS) $(MANDOC_TERM_LNS): term.h
$(MANDOC_OBJS) $(MANDOC_LNS): main.h mandoc.h mdoc.h man.h config.h out.h
-compat.o compat.ln: config.h
-
MANDOCDB_OBJS = mandocdb.o
MANDOCDB_LNS = mandocdb.ln
@@ -319,8 +329,8 @@ clean:
rm -f llib-lpreconv.ln $(PRECONV_LNS)
rm -f mandoc $(MANDOC_OBJS)
rm -f llib-lmandoc.ln $(MANDOC_LNS)
- rm -f config.h config.log compat.o compat.ln
- rm -f mdocml.tar.gz
+ rm -f config.h config.log $(COMPAT_OBJS) $(COMPAT_LNS)
+ rm -f mdocml.tar.gz mdocml.zip
rm -f index.html $(INDEX_OBJS)
install: all
@@ -350,11 +360,11 @@ installwww: www
$(INSTALL_DATA) mdocml.tar.gz $(PREFIX)/snapshots/mdocml-$(VERSION).tar.gz
$(INSTALL_DATA) mdocml.md5 $(PREFIX)/snapshots/mdocml-$(VERSION).md5
-libmandoc.a: compat.o $(LIBMANDOC_OBJS)
- $(AR) rs $@ compat.o $(LIBMANDOC_OBJS)
+libmandoc.a: $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
+ $(AR) rs $@ $(COMPAT_OBJS) $(LIBMANDOC_OBJS)
-llib-llibmandoc.ln: compat.ln $(LIBMANDOC_LNS)
- $(LINT) $(LINTFLAGS) -Clibmandoc compat.ln $(LIBMANDOC_LNS)
+llib-llibmandoc.ln: $(COMPAT_LNS) $(LIBMANDOC_LNS)
+ $(LINT) $(LINTFLAGS) -Clibmandoc $(COMPAT_LNS) $(LIBMANDOC_LNS)
mandoc: $(MANDOC_OBJS) libmandoc.a
$(CC) -o $@ $(MANDOC_OBJS) libmandoc.a
@@ -383,12 +393,30 @@ mdocml.tar.gz: $(SRCS)
( cd .dist/ && tar zcf ../$@ ./ )
rm -rf .dist/
+mdocml.zip: $(SRCS)
+ mkdir -p .win32/mdocml-$(VERSION)/
+ $(INSTALL_SOURCE) $(SRCS) .win32
+ cp .win32/Makefile .win32/Makefile.old
+ grep -v DUSE_WCHAR .win32/Makefile.old >.win32/Makefile
+ ( cd .win32; CC=i586-mingw32msvc-cc AR=i586-mingw32msvc-ar CFLAGS='-DOSNAME=\"Windows\"' make; \
+ make install PREFIX=mdocml-$(VERSION) ; \
+ zip -r ../$@ mdocml-$(VERSION) )
+ rm -rf .win32
+
index.html: $(INDEX_OBJS)
config.h: config.h.pre config.h.post
rm -f config.log
( cat config.h.pre; \
echo; \
+ if $(CC) $(CFLAGS) -Werror -o test-strptime test-strptime.c >> config.log 2>&1; then \
+ echo '#define HAVE_STRPTIME'; \
+ rm test-strptime; \
+ fi; \
+ if $(CC) $(CFLAGS) -Werror -o test-getsubopt test-getsubopt.c >> config.log 2>&1; then \
+ echo '#define HAVE_GETSUBOPT'; \
+ rm test-getsubopt; \
+ fi; \
if $(CC) $(CFLAGS) -Werror -o test-strlcat test-strlcat.c >> config.log 2>&1; then \
echo '#define HAVE_STRLCAT'; \
rm test-strlcat; \
diff --git a/compat_getsubopt.c b/compat_getsubopt.c
new file mode 100644
index 00000000..1a7ec6e8
--- /dev/null
+++ b/compat_getsubopt.c
@@ -0,0 +1,100 @@
+#ifdef HAVE_GETSUBOPT
+
+int dummy;
+
+#else
+
+/* $OpenBSD: getsubopt.c,v 1.4 2005/08/08 08:05:36 espie Exp $ */
+
+/*-
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+
+/*
+ * The SVID interface to getsubopt provides no way of figuring out which
+ * part of the suboptions list wasn't matched. This makes error messages
+ * tricky... The extern variable suboptarg is a pointer to the token
+ * which didn't match.
+ */
+char *suboptarg;
+
+int
+getsubopt(char **optionp, char * const *tokens, char **valuep)
+{
+ int cnt;
+ char *p;
+
+ suboptarg = *valuep = NULL;
+
+ if (!optionp || !*optionp)
+ return(-1);
+
+ /* skip leading white-space, commas */
+ for (p = *optionp; *p && (*p == ',' || *p == ' ' || *p == '\t'); ++p);
+
+ if (!*p) {
+ *optionp = p;
+ return(-1);
+ }
+
+ /* save the start of the token, and skip the rest of the token. */
+ for (suboptarg = p;
+ *++p && *p != ',' && *p != '=' && *p != ' ' && *p != '\t';);
+
+ if (*p) {
+ /*
+ * If there's an equals sign, set the value pointer, and
+ * skip over the value part of the token. Terminate the
+ * token.
+ */
+ if (*p == '=') {
+ *p = '\0';
+ for (*valuep = ++p;
+ *p && *p != ',' && *p != ' ' && *p != '\t'; ++p);
+ if (*p)
+ *p++ = '\0';
+ } else
+ *p++ = '\0';
+ /* Skip any whitespace or commas after this token. */
+ for (; *p && (*p == ',' || *p == ' ' || *p == '\t'); ++p);
+ }
+
+ /* set optionp for next round. */
+ *optionp = p;
+
+ for (cnt = 0; *tokens; ++tokens, ++cnt)
+ if (!strcmp(suboptarg, *tokens))
+ return(cnt);
+ return(-1);
+}
+
+#endif
diff --git a/compat.c b/compat_strlcat.c
index f00cc5c6..ba9196da 100644
--- a/compat.c
+++ b/compat_strlcat.c
@@ -1,3 +1,9 @@
+#ifdef HAVE_STRLCAT
+
+int dummy;
+
+#else
+
/* $OpenBSD: strlcat.c,v 1.13 2005/08/08 08:05:37 espie Exp $ */
/*
@@ -15,16 +21,10 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
#include <sys/types.h>
#include <string.h>
-int dummy; /* To prevent an empty object file */
-
-#ifndef HAVE_STRLCAT
/*
* Appends src to string dst of size siz (unlike strncat, siz is the
* full size of dst, not space left). At most siz-1 characters
@@ -59,37 +59,5 @@ strlcat(char *dst, const char *src, size_t siz)
return(dlen + (s - src)); /* count does not include NUL */
}
-#endif
-#ifndef HAVE_STRLCPY
-/*
- * Copy src to string dst of size siz. At most siz-1 characters
- * will be copied. Always NUL terminates (unless siz == 0).
- * Returns strlen(src); if retval >= siz, truncation occurred.
- */
-size_t
-strlcpy(char *dst, const char *src, size_t siz)
-{
- char *d = dst;
- const char *s = src;
- size_t n = siz;
-
- /* Copy as many bytes as will fit */
- if (n != 0) {
- while (--n != 0) {
- if ((*d++ = *s++) == '\0')
- break;
- }
- }
-
- /* Not enough room in dst, add NUL and traverse rest of src */
- if (n == 0) {
- if (siz != 0)
- *d = '\0'; /* NUL-terminate dst */
- while (*s++)
- ;
- }
-
- return(s - src - 1); /* count does not include NUL */
-}
-#endif
+#endif
diff --git a/compat_strlcpy.c b/compat_strlcpy.c
new file mode 100644
index 00000000..f56f2d85
--- /dev/null
+++ b/compat_strlcpy.c
@@ -0,0 +1,59 @@
+#ifdef HAVE_STRLCPY
+
+int dummy;
+
+#else
+
+/* $OpenBSD: strlcpy.c,v 1.11 2006/05/05 15:27:38 millert Exp $ */
+
+/*
+ * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/types.h>
+#include <string.h>
+
+/*
+ * Copy src to string dst of size siz. At most siz-1 characters
+ * will be copied. Always NUL terminates (unless siz == 0).
+ * Returns strlen(src); if retval >= siz, truncation occurred.
+ */
+size_t
+strlcpy(char *dst, const char *src, size_t siz)
+{
+ char *d = dst;
+ const char *s = src;
+ size_t n = siz;
+
+ /* Copy as many bytes as will fit */
+ if (n != 0) {
+ while (--n != 0) {
+ if ((*d++ = *s++) == '\0')
+ break;
+ }
+ }
+
+ /* Not enough room in dst, add NUL and traverse rest of src */
+ if (n == 0) {
+ if (siz != 0)
+ *d = '\0'; /* NUL-terminate dst */
+ while (*s++)
+ ;
+ }
+
+ return(s - src - 1); /* count does not include NUL */
+}
+
+#endif
diff --git a/config.h.post b/config.h.post
index 81c01b93..3cdf9a78 100644
--- a/config.h.post
+++ b/config.h.post
@@ -21,5 +21,9 @@ extern size_t strlcat(char *, const char *, size_t);
#ifndef HAVE_STRLCPY
extern size_t strlcpy(char *, const char *, size_t);
#endif
+#ifndef HAVE_GETSUBOPT
+extern int getsubopt(char **, char * const *, char **);
+extern char *suboptarg;
+#endif
#endif /* MANDOC_CONFIG_H */
diff --git a/man_hash.c b/man_hash.c
index 10fa18c2..95e7c790 100644
--- a/man_hash.c
+++ b/man_hash.c
@@ -33,7 +33,7 @@
#define HASH_DEPTH 6
#define HASH_ROW(x) do { \
- if (isupper((u_char)(x))) \
+ if (isupper((unsigned char)(x))) \
(x) -= 65; \
else \
(x) -= 97; \
@@ -47,7 +47,7 @@
* macro (the integer value of the enum stored as a char to save a bit
* of space).
*/
-static u_char table[26 * HASH_DEPTH];
+static unsigned char table[26 * HASH_DEPTH];
/*
* XXX - this hash has global scope, so if intended for use as a library
@@ -66,13 +66,13 @@ man_hash_init(void)
for (i = 0; i < (int)MAN_MAX; i++) {
x = man_macronames[i][0];
- assert(isalpha((u_char)x));
+ assert(isalpha((unsigned char)x));
HASH_ROW(x);
for (j = 0; j < HASH_DEPTH; j++)
if (UCHAR_MAX == table[x + j]) {
- table[x + j] = (u_char)i;
+ table[x + j] = (unsigned char)i;
break;
}
@@ -89,7 +89,7 @@ man_hash_find(const char *tmp)
if ('\0' == (x = tmp[0]))
return(MAN_MAX);
- if ( ! (isalpha((u_char)x)))
+ if ( ! (isalpha((unsigned char)x)))
return(MAN_MAX);
HASH_ROW(x);
diff --git a/man_validate.c b/man_validate.c
index 27381cf8..257bb6de 100644
--- a/man_validate.c
+++ b/man_validate.c
@@ -412,7 +412,8 @@ post_TH(CHKARGS)
if (n && n->string) {
for (p = n->string; '\0' != *p; p++) {
/* Only warn about this once... */
- if (isalpha((u_char)*p) && ! isupper((u_char)*p)) {
+ if (isalpha((unsigned char)*p) &&
+ ! isupper((unsigned char)*p)) {
man_nmsg(m, n, MANDOCERR_UPPERCASE);
break;
}
diff --git a/mandoc.c b/mandoc.c
index 0f8e5394..c08465ff 100644
--- a/mandoc.c
+++ b/mandoc.c
@@ -542,7 +542,10 @@ a2time(time_t *t, const char *fmt, const char *p)
memset(&tm, 0, sizeof(struct tm));
+ pp = NULL;
+#ifdef HAVE_STRPTIME
pp = strptime(p, fmt, &tm);
+#endif
if (NULL != pp && '\0' == *pp) {
*t = mktime(&tm);
return(1);
@@ -554,12 +557,12 @@ a2time(time_t *t, const char *fmt, const char *p)
static char *
time2a(time_t t)
{
- struct tm tm;
+ struct tm *tm;
char *buf, *p;
size_t ssz;
int isz;
- localtime_r(&t, &tm);
+ tm = localtime(&t);
/*
* Reserve space:
@@ -569,15 +572,15 @@ time2a(time_t t)
*/
p = buf = mandoc_malloc(10 + 4 + 4 + 1);
- if (0 == (ssz = strftime(p, 10 + 1, "%B ", &tm)))
+ if (0 == (ssz = strftime(p, 10 + 1, "%B ", tm)))
goto fail;
p += (int)ssz;
- if (-1 == (isz = snprintf(p, 4 + 1, "%d, ", tm.tm_mday)))
+ if (-1 == (isz = snprintf(p, 4 + 1, "%d, ", tm->tm_mday)))
goto fail;
p += isz;
- if (0 == strftime(p, 4 + 1, "%Y", &tm))
+ if (0 == strftime(p, 4 + 1, "%Y", tm))
goto fail;
return(buf);
diff --git a/mdoc_hash.c b/mdoc_hash.c
index 88c10331..9aad261a 100644
--- a/mdoc_hash.c
+++ b/mdoc_hash.c
@@ -31,7 +31,7 @@
#include "mandoc.h"
#include "libmdoc.h"
-static u_char table[27 * 12];
+static unsigned char table[27 * 12];
/*
* XXX - this hash has global scope, so if intended for use as a library
@@ -48,14 +48,14 @@ mdoc_hash_init(void)
for (i = 0; i < (int)MDOC_MAX; i++) {
p = mdoc_macronames[i];
- if (isalpha((u_char)p[1]))
- major = 12 * (tolower((u_char)p[1]) - 97);
+ if (isalpha((unsigned char)p[1]))
+ major = 12 * (tolower((unsigned char)p[1]) - 97);
else
major = 12 * 26;
for (j = 0; j < 12; j++)
if (UCHAR_MAX == table[major + j]) {
- table[major + j] = (u_char)i;
+ table[major + j] = (unsigned char)i;
break;
}
@@ -70,11 +70,11 @@ mdoc_hash_find(const char *p)
if (0 == p[0])
return(MDOC_MAX);
- if ( ! isalpha((u_char)p[0]) && '%' != p[0])
+ if ( ! isalpha((unsigned char)p[0]) && '%' != p[0])
return(MDOC_MAX);
- if (isalpha((u_char)p[1]))
- major = 12 * (tolower((u_char)p[1]) - 97);
+ if (isalpha((unsigned char)p[1]))
+ major = 12 * (tolower((unsigned char)p[1]) - 97);
else if ('1' == p[1])
major = 12 * 26;
else
diff --git a/mdoc_validate.c b/mdoc_validate.c
index c3198c0d..f8ea5b6a 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -2046,7 +2046,7 @@ post_dt(POST_ARGS)
if (NULL != (nn = n->child))
for (p = nn->string; *p; p++) {
- if (toupper((u_char)*p) == *p)
+ if (toupper((unsigned char)*p) == *p)
continue;
/*
diff --git a/out.c b/out.c
index ebd85c7d..ee4217c1 100644
--- a/out.c
+++ b/out.c
@@ -69,7 +69,7 @@ a2roffsu(const char *src, struct roffsu *dst, enum roffscale def)
return(0);
while (i < BUFSIZ) {
- if ( ! isdigit((u_char)*src)) {
+ if ( ! isdigit((unsigned char)*src)) {
if ('.' != *src)
break;
else if (hasd)
diff --git a/preconv.c b/preconv.c
index fcb50790..b2f031bc 100644
--- a/preconv.c
+++ b/preconv.c
@@ -18,8 +18,10 @@
#include "config.h"
#endif
+#ifdef HAVE_MMAP
#include <sys/stat.h>
#include <sys/mman.h>
+#endif
#include <assert.h>
#include <fcntl.h>
@@ -244,10 +246,11 @@ static int
read_whole_file(const char *f, int fd,
struct buf *fb, int *with_mmap)
{
- struct stat st;
size_t off;
ssize_t ssz;
+#ifdef HAVE_MMAP
+ struct stat st;
if (-1 == fstat(fd, &st)) {
perror(f);
return(0);
@@ -273,6 +276,7 @@ read_whole_file(const char *f, int fd,
if (fb->buf != MAP_FAILED)
return(1);
}
+#endif
/*
* If this isn't a regular file (like, say, stdin), then we must
@@ -510,9 +514,11 @@ main(int argc, char *argv[])
rc = EXIT_SUCCESS;
out:
+#ifdef HAVE_MMAP
if (map)
munmap(b.buf, b.sz);
else
+#endif
free(b.buf);
if (fd > STDIN_FILENO)
diff --git a/test-getsubopt.c b/test-getsubopt.c
new file mode 100644
index 00000000..25e11246
--- /dev/null
+++ b/test-getsubopt.c
@@ -0,0 +1,12 @@
+#if defined(__linux__) || defined(__MINT__)
+# define _GNU_SOURCE /* getsubopt() */
+#endif
+
+#include <stdlib.h>
+
+int
+main(int argc, char **argv)
+{
+ getsubopt(argv, argv, argv);
+ return 0;
+}
diff --git a/test-strptime.c b/test-strptime.c
new file mode 100644
index 00000000..976e9c80
--- /dev/null
+++ b/test-strptime.c
@@ -0,0 +1,13 @@
+#if defined(__linux__) || defined(__MINT__)
+# define _GNU_SOURCE /* strptime(), getsubopt() */
+#endif
+
+#include <time.h>
+
+int
+main(int argc, char **argv)
+{
+ struct tm tm;
+ strptime(*argv, "%D", &tm);
+ return 0;
+}