aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/test-getsubopt.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2014-08-17 20:53:50 +0000
committerIngo Schwarze <schwarze@openbsd.org>2014-08-17 20:53:50 +0000
commit6bc581d1a26667c00bfa4397c833b05ca718ee9a (patch)
tree74339035f630d5731c5b26bf1632e1e90c75b60e /test-getsubopt.c
parent6dae70845e149f75383a1bbb4b745deffd14632e (diff)
downloadmandoc-6bc581d1a26667c00bfa4397c833b05ca718ee9a.tar.gz
mandoc-6bc581d1a26667c00bfa4397c833b05ca718ee9a.tar.zst
mandoc-6bc581d1a26667c00bfa4397c833b05ca718ee9a.zip
Do not require getsubopt() to provide extern char *suboptarg.
We don't use it anyway in mandoc. Like this, fewer systems need the compat implementation. In particular, we can now use the stock getsubopt() on glibc and musl. Besides, the comment in the BSD getsubopt.c that error messages are tricky without *suboptarg is massively overblown. If you simply save a copy of the pointer you pass into getsubopt(), that's quite usable for an error message. People start campaigning for the addition of *suboptarg to C libraries on the grounds that mandoc wants it, but actually, i consider library functions manipulating global data quite ugly, so stop pushing people into that questionable direction. While here, add an explicit Copyright header to the test file. While it's obviously to me what Kristaps intended, others might consider this file copyrightable and wonder what's up.
Diffstat (limited to 'test-getsubopt.c')
-rw-r--r--test-getsubopt.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/test-getsubopt.c b/test-getsubopt.c
index 2da98238..b0835697 100644
--- a/test-getsubopt.c
+++ b/test-getsubopt.c
@@ -1,11 +1,26 @@
+/* $Id: test-getsubopt.c,v 1.3 2014/08/17 20:53:50 schwarze Exp $ */
+/*
+ * Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
+ *
+ * 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.
+ */
+
#if defined(__linux__) || defined(__MINT__)
-# define _GNU_SOURCE /* getsubopt() */
+#define _GNU_SOURCE /* getsubopt() */
#endif
#include <stdlib.h>
-extern char *suboptarg;
-
int
main(void)
{
@@ -15,5 +30,5 @@ main(void)
char *const tokens[] = { token0, NULL };
char *value = NULL;
return( ! (0 == getsubopt(&options, tokens, &value)
- && suboptarg == buf && value == buf+2 && options == buf+3));
+ && value == buf+2 && options == buf+3));
}