diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2014-08-17 20:53:50 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2014-08-17 20:53:50 +0000 |
commit | f845a3643bca2ca958e02d8fb6b9a018e8033b14 (patch) | |
tree | abbd6c8f5f919bfe2502fe984ef0f9566cb9681a /compat_getsubopt.c | |
parent | 8d82ccaaedf7599071b86e2805fed023f23e0145 (diff) | |
download | mandoc-f845a3643bca2ca958e02d8fb6b9a018e8033b14.tar.gz |
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 'compat_getsubopt.c')
-rw-r--r-- | compat_getsubopt.c | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/compat_getsubopt.c b/compat_getsubopt.c index 3a4a7d4a..7f675749 100644 --- a/compat_getsubopt.c +++ b/compat_getsubopt.c @@ -6,6 +6,7 @@ int dummy; #else +/* $Id$ */ /* $OpenBSD: getsubopt.c,v 1.4 2005/08/08 08:05:36 espie Exp $ */ /*- @@ -41,18 +42,11 @@ int dummy; #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 *suboptarg; char *p; suboptarg = *valuep = NULL; |