[git commit future 1/1] parse_config: rename macro to config_read6
Khem Raj
raj.khem at gmail.com
Sat Mar 19 18:51:25 UTC 2011
commit: http://git.uclibc.org/uClibc/commit/?id=466257ae568ed99fb287d7287874533dbabfd913
branch: http://git.uclibc.org/uClibc/commit/?id=refs/heads/future
Might fix the problems reported to list.
Reported-by: Tony Wu <tung7970 at gmail.com>
Signed-off-by: Peter S. Mazinger <ps.m at gmx.net>
---
include/internal/parse_config.h | 2 +-
libc/inet/getnet.c | 2 +-
libc/inet/getproto.c | 2 +-
libc/inet/getservice.c | 2 +-
libc/inet/resolv.c | 2 +-
libc/misc/internals/parse_config.c | 7 +++----
libc/unistd/sysconf.c | 8 ++++----
libc/unistd/usershell.c | 2 +-
8 files changed, 13 insertions(+), 14 deletions(-)
diff --git a/include/internal/parse_config.h b/include/internal/parse_config.h
index 69be0cb..ad2dae5 100644
--- a/include/internal/parse_config.h
+++ b/include/internal/parse_config.h
@@ -47,7 +47,7 @@ typedef struct parser_t {
parser_t* config_open(const char *filename) FAST_FUNC attribute_hidden;
int config_read(parser_t *parser, char ***tokens, unsigned flags, const char *delims) FAST_FUNC attribute_hidden;
-#define config_read(parser, tokens, max, min, str, flags) \
+#define config_read6(parser, tokens, max, min, str, flags) \
config_read(parser, tokens, ((flags) | (((min) & 0xFF) << 8) | ((max) & 0xFF)), str)
void config_close(parser_t *parser) FAST_FUNC attribute_hidden;
diff --git a/libc/inet/getnet.c b/libc/inet/getnet.c
index 9049f97..3e840fe 100644
--- a/libc/inet/getnet.c
+++ b/libc/inet/getnet.c
@@ -86,7 +86,7 @@ int getnetent_r(struct netent *result_buf,
netp->data_len = aliaslen;
netp->line_len = buflen - aliaslen;
/* <name>[[:space:]]<netnumber>[[:space:]][<aliases>] */
- if (!config_read(netp, &tok, MAXTOKENS-1, MINTOKENS, "# \t/", PARSE_NORMAL)) {
+ if (!config_read6(netp, &tok, MAXTOKENS-1, MINTOKENS, "# \t/", PARSE_NORMAL)) {
goto DONE;
}
result_buf->n_name = *(tok++);
diff --git a/libc/inet/getproto.c b/libc/inet/getproto.c
index c59da7e..449ad8d 100644
--- a/libc/inet/getproto.c
+++ b/libc/inet/getproto.c
@@ -85,7 +85,7 @@ int getprotoent_r(struct protoent *result_buf,
protop->data_len = aliaslen;
protop->line_len = buflen - aliaslen;
/* <name>[[:space:]]<protonumber>[[:space:]][<aliases>] */
- if (!config_read(protop, &tok, MAXTOKENS - 1, MINTOKENS, "# \t/", PARSE_NORMAL)) {
+ if (!config_read6(protop, &tok, MAXTOKENS - 1, MINTOKENS, "# \t/", PARSE_NORMAL)) {
goto DONE;
}
result_buf->p_name = *(tok++);
diff --git a/libc/inet/getservice.c b/libc/inet/getservice.c
index 183099f..7d1e04c 100644
--- a/libc/inet/getservice.c
+++ b/libc/inet/getservice.c
@@ -87,7 +87,7 @@ int getservent_r(struct servent *result_buf,
servp->data_len = aliaslen;
servp->line_len = buflen - aliaslen;
/* <name>[[:space:]]<port>/<proto>[[:space:]][<aliases>] */
- if (!config_read(servp, &tok, MAXTOKENS - 1, MINTOKENS, "# \t/", PARSE_NORMAL)) {
+ if (!config_read6(servp, &tok, MAXTOKENS - 1, MINTOKENS, "# \t/", PARSE_NORMAL)) {
goto DONE;
}
result_buf->s_name = *(tok++);
diff --git a/libc/inet/resolv.c b/libc/inet/resolv.c
index c03f03a..ad3ec16 100644
--- a/libc/inet/resolv.c
+++ b/libc/inet/resolv.c
@@ -1635,7 +1635,7 @@ int __read_etc_hosts_r(
parser->line_len = buflen - aliaslen;
*h_errnop = HOST_NOT_FOUND;
/* <ip>[[:space:]][<aliases>] */
- while (config_read(parser, &tok, MAXTOKENS, MINTOKENS, "# \t", PARSE_NORMAL)) {
+ while (config_read6(parser, &tok, MAXTOKENS, MINTOKENS, "# \t", PARSE_NORMAL)) {
result_buf->h_aliases = alias = host_aliases = tok+1;
if (action == GETHOSTENT) {
/* Return whatever the next entry happens to be. */
diff --git a/libc/misc/internals/parse_config.c b/libc/misc/internals/parse_config.c
index 73c10aa..369d28f 100644
--- a/libc/misc/internals/parse_config.c
+++ b/libc/misc/internals/parse_config.c
@@ -28,7 +28,7 @@ int parse_main(int argc UNUSED_PARAM, char **argv)
if (p) {
int n;
char **t = xmalloc(sizeof(char *) * ntokens);
- while ((n = config_read(p, t, ntokens, mintokens, delims, flags)) != 0) {
+ while ((n = config_read6(p, t, ntokens, mintokens, delims, flags)) != 0) {
for (int i = 0; i < n; ++i)
printf("[%s]", t[i]);
puts("");
@@ -101,7 +101,7 @@ Typical usage:
parser_t *p = config_open(filename);
if (p) {
// parse line-by-line
- while (config_read(p, t, 3, 0, delimiters, flags)) { // 1..3 tokens
+ while (config_read6(p, t, 3, 0, delimiters, flags)) { // 1..3 tokens
// use tokens
bb_error_msg("TOKENS: [%s][%s][%s]", t[0], t[1], t[2]);
}
@@ -175,9 +175,8 @@ void FAST_FUNC config_close(parser_t *parser)
mintokens > 0 make config_read() print error message if less than mintokens
(but more than 0) are found. Empty lines are always skipped (not warned about).
*/
-#undef config_read
int FAST_FUNC config_read(parser_t *parser, char ***tokens,
- unsigned flags, const char *delims)
+ unsigned flags, const char *delims)
{
char *line;
int ntokens, mintokens;
diff --git a/libc/unistd/sysconf.c b/libc/unistd/sysconf.c
index b9aacff..95eb95d 100644
--- a/libc/unistd/sysconf.c
+++ b/libc/unistd/sysconf.c
@@ -51,7 +51,7 @@ static int nprocessors_onln(void)
int ret = 0;
if (p) {
- while (config_read(p, &l, 2, 1, " ", 0))
+ while (config_read6(p, &l, 2, 1, " ", 0))
if (l[0][0] == 'c'
&& l[0][1] == 'p'
&& l[0][2] == 'u'
@@ -59,13 +59,13 @@ static int nprocessors_onln(void)
++ret;
} else if ((p = config_open("/proc/cpuinfo"))) {
#if defined __sparc__
- while (config_read(p, &l, 2, 2, "\0:", PARSE_NORMAL))
+ while (config_read6(p, &l, 2, 2, "\0:", PARSE_NORMAL))
if (strncmp("ncpus active", l[0], 12) == 0) {
ret = atoi(l[1]);
break;
}
#else
- while (config_read(p, &l, 2, 2, "\0:\t", PARSE_NORMAL))
+ while (config_read6(p, &l, 2, 2, "\0:\t", PARSE_NORMAL))
if (strcmp("processor", l[0]) == 0)
++ret;
#endif
@@ -100,7 +100,7 @@ static int nprocessors_conf(void)
#if defined __sparc__
char **l = NULL;
parser_t *p = config_open("/proc/stat");
- while (config_read(p, &l, 2, 2, "\0:", PARSE_NORMAL))
+ while (config_read6(p, &l, 2, 2, "\0:", PARSE_NORMAL))
if (strncmp("ncpus probed", l[0], 13) == 0) {
ret = atoi(l[1]);
break;
diff --git a/libc/unistd/usershell.c b/libc/unistd/usershell.c
index f8f7582..58261c8 100644
--- a/libc/unistd/usershell.c
+++ b/libc/unistd/usershell.c
@@ -52,7 +52,7 @@ static void __setusershell(void)
char **shell = NULL;
int pos = 0;
- while (config_read(shellp, &shell, 1, 1, "# \t", PARSE_NORMAL))
+ while (config_read6(shellp, &shell, 1, 1, "# \t", PARSE_NORMAL))
{
shellb = realloc(shellb, (pos + 2) * sizeof(char*));
shells = (char**) shellb + pos++;
--
1.7.3.4
More information about the uClibc-cvs
mailing list