diff options
author | Christopher Faylor <me@cgf.cx> | 2003-01-27 00:16:01 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2003-01-27 00:16:01 +0000 |
commit | fea48988ea866e6ef4f29247a13a8b28eb9be7ce (patch) | |
tree | 40e1433368cfe58c000284730c207907c298c633 /winsup/cygwin/uinfo.cc | |
parent | 285d6b97b11d0516ba82b0deb59afe746ef8fb93 (diff) | |
download | newlib-fea48988ea866e6ef4f29247a13a8b28eb9be7ce.zip newlib-fea48988ea866e6ef4f29247a13a8b28eb9be7ce.tar.gz newlib-fea48988ea866e6ef4f29247a13a8b28eb9be7ce.tar.bz2 |
* strings.h (strechr): New function.
* uinfo.cc (pwdgrp::next_str): Search only for input char in string. Return
EOS on failure. Don't check for NULL since it shouldn't be possible.
(pwdgrp::add_line): Revert to replacing '\n' in input line with '\0'.
(pwdgrp::next_num): Pass explicit separator character to next_str.
* grp.cc (pwdgrp::parse_group): Ditto.
* passwd.cc (pwdgrp::parse_passwd): Ditto. Revamp test for garbage input.
* pwdgrp.h (pwdgrp::next_str): Don't use default parameter.
Diffstat (limited to 'winsup/cygwin/uinfo.cc')
-rw-r--r-- | winsup/cygwin/uinfo.cc | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc index 82712d9..a6831e2 100644 --- a/winsup/cygwin/uinfo.cc +++ b/winsup/cygwin/uinfo.cc @@ -394,24 +394,17 @@ cygheap_user::env_name (const char *name, size_t namelen) char * pwdgrp::next_str (char c) { - if (!lptr) - return NULL; - char search[] = ":\n\0\0"; - search[2] = c; char *res = lptr; - char *p = strpbrk (lptr, search); - if (p) - { - lptr = (*p == '\n') ? p : p + 1; - *p = '\0'; - } + lptr = strechr (lptr, c); + if (*lptr) + *lptr++ = '\0'; return res; } bool pwdgrp::next_num (unsigned long& n) { - char *p = next_str (); + char *p = next_str (':'); if (!p) return -1; char *cp; @@ -425,11 +418,13 @@ pwdgrp::add_line (char *eptr) if (eptr) { lptr = eptr; - eptr = strchr (lptr, '\n'); - if (eptr) + eptr = strechr (lptr, '\n'); + if (*eptr) { if (eptr > lptr && eptr[-1] == '\r') - eptr[-1] = '\n'; + eptr[-1] = '\0'; + else + *eptr = '\0'; eptr++; } if (curr_lines >= max_lines) |