aboutsummaryrefslogtreecommitdiff
path: root/winsup/cygwin/grp.cc
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2003-01-26 05:38:38 +0000
committerChristopher Faylor <me@cgf.cx>2003-01-26 05:38:38 +0000
commit6503705696e9e778fb51b1be354bc879f18ba61c (patch)
treebac2a0b68cb962abf7424d905276e27353624508 /winsup/cygwin/grp.cc
parentc9b99d0d2a61c0307c25ce16e41f80b2e67d8806 (diff)
downloadnewlib-6503705696e9e778fb51b1be354bc879f18ba61c.zip
newlib-6503705696e9e778fb51b1be354bc879f18ba61c.tar.gz
newlib-6503705696e9e778fb51b1be354bc879f18ba61c.tar.bz2
* include/sys/strace.h (paranoid_printf): Define as not being part of "all"
output. * pwdgrp.h (pwdgrp::next_num): Rename from next_int. Returns true/false if parse operation succeeded. (pwdgrp::reparse): Remove. (pwdgrp::raw_ptr): New function. Returns pointer in line. (pwdgrp::next_num): New functions for parsing other than unsigned long. * grp.cc (pwdgrp::parse_group): Reinstate previous parsing behavior. Don't fill in fields with NULL and assign empty gr_mem to known pointer rather than doing a pointless calloc. Streamline gr_mem parsing. Don't increment curr_lines here. * passwd.cc (pwdgrp::parse_passwd): Use new behavior of next_num. Don't increment curr_lines here. * uinfo.cc (pwdgrp::next_str): Keep returning EOL if out of data. (pwdgrp::reparse): Remove. (pwdgrp::next_num): Rename from next_int. Return bool indicating success of parse, argument returns value parsed. (pwdgrp::add_line): Increment curr_lines here on successful parse. (pwdgrp::load): (from Pierre Humblet) Don't return status. Just report it here.
Diffstat (limited to 'winsup/cygwin/grp.cc')
-rw-r--r--winsup/cygwin/grp.cc45
1 files changed, 21 insertions, 24 deletions
diff --git a/winsup/cygwin/grp.cc b/winsup/cygwin/grp.cc
index b4b590b..c16d925 100644
--- a/winsup/cygwin/grp.cc
+++ b/winsup/cygwin/grp.cc
@@ -39,38 +39,36 @@ pwdgrp::parse_group ()
char *dp;
# define grp (*group_buf)[curr_lines]
+
memset (&grp, 0, sizeof (grp));
+
grp.gr_name = next_str ();
- if (!grp.gr_name)
+ if (!*grp.gr_name)
return false;
grp.gr_passwd = next_str ();
- int n = next_int ();
- if (n >= 0)
+
+ if (!next_num (grp.gr_gid))
+ return false;
+
+ int n;
+ dp = raw_ptr ();
+ for (n = 0; *next_str (','); n++)
+ continue;
+
+ grp.gr_mem = &null_ptr;
+ if (n)
{
- grp.gr_gid = n;
- dp = next_str ();
- if (!dp)
- {
- static char empty[] = "";
- dp = empty;
- }
- int i = 0;
- for (char *cp = dp; (cp = strchr (cp, ',')) != NULL; cp++)
- i++;
- char **namearray = (char **) calloc (i + 2, sizeof (char *));
+ char **namearray = (char **) calloc (n + 2, sizeof (char *));
if (namearray)
{
- reparse (dp);
- for (i = 0; (dp = next_str (',')); i++)
+ for (int i = 0; i < n; i++, dp = strchr (dp, '\0') + 1)
namearray[i] = dp;
- namearray[i] = NULL;
grp.gr_mem = namearray;
}
- curr_lines++;
- return true;
}
- return false;
+
+ return true;
# undef grp
}
@@ -85,8 +83,7 @@ pwdgrp::read_group ()
if ((*group_buf)[i].gr_mem != &null_ptr)
free ((*group_buf)[i].gr_mem);
- if (!gr.load ("/etc/group"))
- debug_printf ("gr.load failed");
+ load ("/etc/group");
/* Complete /etc/group in memory if needed */
if (!internal_getgrgid (myself->gid))
@@ -106,11 +103,11 @@ pwdgrp::read_group ()
snprintf (linebuf, sizeof (linebuf), "%s:%s:%lu:%s",
group_name, strbuf, myself->gid, cygheap->user.name ());
debug_printf ("Completing /etc/group: %s", linebuf);
- gr.add_line (linebuf);
+ add_line (linebuf);
}
static char NO_COPY pretty_ls[] = "????????::-1:";
if (wincap.has_security ())
- gr.add_line (pretty_ls);
+ add_line (pretty_ls);
return;
}