]> git.pld-linux.org Git - packages/dietlibc.git/blame - dietlibc-getsubopt.patch
always pass MYARCH explicitly
[packages/dietlibc.git] / dietlibc-getsubopt.patch
CommitLineData
43892f17
JR
1--- dietlibc-0.31/include/stdlib.h~ 2009-03-19 14:33:16.000000000 +0100
2+++ dietlibc-0.31/include/stdlib.h 2009-03-19 14:46:17.000000000 +0100
3@@ -81,6 +81,16 @@
4 long int labs(long int i) __THROW __attribute__((__const__));
5 __extension__ long long int llabs(long long int i) __THROW __attribute__((__const__));
6
7+#ifdef __USE_XOPEN_EXTENDED
8+/* Parse comma separated suboption from *OPTIONP and match against
9+ strings in TOKENS. If found return index and set *VALUEP to
10+ optional value introduced by an equal sign. If the suboption is
11+ not part of TOKENS return in *VALUEP beginning of unknown
12+ suboption. On exit *OPTIONP is set to the beginning of the next
13+ token or at the terminating NUL character. */
14+extern int getsubopt (char **optionp, char *const *tokens, char **valuep) __THROW;
15+#endif
16+
17 #ifdef _XOPEN_SOURCE
18 int grantpt (int fd) __THROW;
19 int unlockpt (int fd) __THROW;
20--- /dev/null 2009-03-05 20:33:59.000000000 +0100
21+++ dietlibc-0.31/lib/getsubopt.c 2009-03-19 14:55:18.000000000 +0100
22@@ -0,0 +1,73 @@
23+/* Parse comma separate list into words.
24+ Copyright (C) 1996, 1997, 1999, 2004 Free Software Foundation, Inc.
25+ This file is part of the GNU C Library.
26+ Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
27+
28+ The GNU C Library is free software; you can redistribute it and/or
29+ modify it under the terms of the GNU Lesser General Public
30+ License as published by the Free Software Foundation; either
31+ version 2.1 of the License, or (at your option) any later version.
32+
33+ The GNU C Library is distributed in the hope that it will be useful,
34+ but WITHOUT ANY WARRANTY; without even the implied warranty of
35+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
36+ Lesser General Public License for more details.
37+
38+ You should have received a copy of the GNU Lesser General Public
39+ License along with the GNU C Library; if not, write to the Free
40+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
41+ 02111-1307 USA. */
42+
43+#include <stdlib.h>
44+#include <string.h>
45+
46+/* Parse comma separated suboption from *OPTIONP and match against
47+ strings in TOKENS. If found return index and set *VALUEP to
48+ optional value introduced by an equal sign. If the suboption is
49+ not part of TOKENS return in *VALUEP beginning of unknown
50+ suboption. On exit *OPTIONP is set to the beginning of the next
51+ token or at the terminating NUL character. */
52+int
53+getsubopt (char **optionp, char *const *tokens, char **valuep)
54+{
55+ char *endp, *vstart;
56+ int cnt;
57+
58+ if (**optionp == '\0')
59+ return -1;
60+
61+ /* Find end of next token. */
62+ endp = strchr (*optionp, ',');
63+ if (endp == NULL)
64+ endp = strchr (*optionp, '\0');
65+
66+ /* Find start of value. */
67+ vstart = memchr (*optionp, '=', endp - *optionp);
68+ if (vstart == NULL)
69+ vstart = endp;
70+
71+ /* Try to match the characters between *OPTIONP and VSTART against
72+ one of the TOKENS. */
73+ for (cnt = 0; tokens[cnt] != NULL; ++cnt)
74+ if (strncmp (*optionp, tokens[cnt], vstart - *optionp) == 0
75+ && tokens[cnt][vstart - *optionp] == '\0')
76+ {
77+ /* We found the current option in TOKENS. */
78+ *valuep = vstart != endp ? vstart + 1 : NULL;
79+
80+ if (*endp != '\0')
81+ *endp++ = '\0';
82+ *optionp = endp;
83+
84+ return cnt;
85+ }
86+
87+ /* The current suboption does not match any option. */
88+ *valuep = *optionp;
89+
90+ if (*endp != '\0')
91+ *endp++ = '\0';
92+ *optionp = endp;
93+
94+ return -1;
95+}
This page took 0.06776 seconds and 4 git commands to generate.