Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2003-01-24 06:53:46 +0300
committerChristopher Faylor <me@cgf.cx>2003-01-24 06:53:46 +0300
commitac4133746eeaad61b2bb2f71bd8861615b052427 (patch)
tree40d48ebf8a73cbd5ec8a206ab0a953033942d303 /winsup/cygwin/grp.cc
parent09a88426740b765a99759d29da0e2a5f98c7281b (diff)
* pwdrp.h (pwdgrp::refresh): Lock entire test prior to reading.
* grp.cc (pwdgrp::parse_group): Eliminate arg and use class member instead. Use next_str and next_int to parse arguments. * passwd.cc (pwdgrp::parse_passwd): Ditto. (grab_string): Eliminate. (grab_int): Ditto. * pwdgrp.h (pwdgrp::parse): Eliminate input arg. (pwdgrp::parse_passwd): Reflect above change. (pwdgrp::parse_group): Reflect above change. (pwdgrp::next_str): New function. (pwdgrp::next_int): Ditto. (pwdgrp::gets): Eliminate. * uinfo.cc (pwdgrp::next_str): New function. (pwdgrp::next_int): Ditto. (pwdgrp::add_line): Subsume gets. (pwdgrp::gets): Eliminate. (pwdgrp::load): Just call add_line to parse input buffer.
Diffstat (limited to 'winsup/cygwin/grp.cc')
-rw-r--r--winsup/cygwin/grp.cc64
1 files changed, 27 insertions, 37 deletions
diff --git a/winsup/cygwin/grp.cc b/winsup/cygwin/grp.cc
index 529fdbe26..9cce888a3 100644
--- a/winsup/cygwin/grp.cc
+++ b/winsup/cygwin/grp.cc
@@ -34,50 +34,40 @@ static pwdgrp gr (group_buf);
static char * NO_COPY null_ptr;
bool
-pwdgrp::parse_group (char *line)
+pwdgrp::parse_group ()
{
- char *dp = strchr (line, ':');
-
- if (!dp)
- return false;
+ char *dp;
# define grp (*group_buf)[curr_lines]
- *dp++ = '\0';
- grp.gr_name = line;
+ memset (&grp, 0, sizeof (grp));
+ grp.gr_name = next_str ();
+ if (!grp.gr_name)
+ return false;
- grp.gr_passwd = dp;
- dp = strchr (grp.gr_passwd, ':');
- if (dp)
+ grp.gr_passwd = next_str ();
+ int n = next_int ();
+ if (n >= 0)
{
- *dp++ = '\0';
- grp.gr_gid = strtoul (line = dp, &dp, 10);
- if (dp != line && *dp == ':')
+ grp.gr_gid = n;
+ dp = next_str ();
+ if (!dp)
{
- grp.gr_mem = &null_ptr;
- if (*++dp)
- {
- int i = 0;
- char *cp;
-
- for (cp = dp; (cp = strchr (cp, ',')) != NULL; ++cp)
- ++i;
- char **namearray = (char **) calloc (i + 2, sizeof (char *));
- if (namearray)
- {
- i = 0;
- for (cp = dp; (cp = strchr (dp, ',')) != NULL; dp = cp + 1)
- {
- *cp = '\0';
- namearray[i++] = dp;
- }
- namearray[i++] = dp;
- namearray[i] = NULL;
- grp.gr_mem = namearray;
- }
- }
- curr_lines++;
- return true;
+ 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 *));
+ if (namearray)
+ {
+ for (i = 0; (dp = next_str (',')); i++)
+ namearray[i] = dp;
+ namearray[i] = NULL;
+ grp.gr_mem = namearray;
}
+ curr_lines++;
+ return true;
}
return false;
# undef grp