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-26 08:38:38 +0300
committerChristopher Faylor <me@cgf.cx>2003-01-26 08:38:38 +0300
commit6503705696e9e778fb51b1be354bc879f18ba61c (patch)
treebac2a0b68cb962abf7424d905276e27353624508 /winsup/cygwin/uinfo.cc
parentc9b99d0d2a61c0307c25ce16e41f80b2e67d8806 (diff)
* 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/uinfo.cc')
-rw-r--r--winsup/cygwin/uinfo.cc49
1 files changed, 24 insertions, 25 deletions
diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc
index dcc9376ee..bc1680374 100644
--- a/winsup/cygwin/uinfo.cc
+++ b/winsup/cygwin/uinfo.cc
@@ -400,33 +400,23 @@ pwdgrp::next_str (char c)
search[2] = c;
char *res = lptr;
char *p = strpbrk (lptr, search);
- if (!p)
- lptr = NULL;
- else
+ if (p)
{
- lptr = (*p == '\n') ? NULL : p + 1;
+ lptr = (*p == '\n') ? p : p + 1;
*p = '\0';
}
return res;
}
-void
-pwdgrp::reparse (char *in_lptr)
-{
- lptr = in_lptr;
-}
-
-int
-pwdgrp::next_int (char c)
+bool
+pwdgrp::next_num (unsigned long& n)
{
- char *p = next_str (c);
+ char *p = next_str ();
if (!p)
return -1;
char *cp;
- unsigned n = strtoul (p, &cp, 10);
- if (p == cp)
- return -1;
- return n;
+ n = strtoul (p, &cp, 10);
+ return p != cp && !*cp;
}
char *
@@ -447,14 +437,19 @@ pwdgrp::add_line (char *eptr)
max_lines += 10;
*pwdgrp_buf = realloc (*pwdgrp_buf, max_lines * pwdgrp_buf_elem_size);
}
- (void) (this->*parse) ();
+ if ((this->*parse) ())
+ curr_lines++;
}
return eptr;
}
-bool
+void
pwdgrp::load (const char *posix_fname)
{
+ const char *res;
+ static const char failed[] = "failed";
+ static const char succeeded[] = "succeeded";
+
if (buf)
free (buf);
buf = NULL;
@@ -464,26 +459,29 @@ pwdgrp::load (const char *posix_fname)
paranoid_printf ("%s", posix_fname);
- bool res;
if (pc.error || !pc.exists () || !pc.isdisk () || pc.isdir ())
- res = false;
+ {
+ paranoid_printf ("strange path_conv problem");
+ res = failed;
+ }
else
{
HANDLE fh = CreateFile (pc, GENERIC_READ, wincap.shared (), NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
if (fh == INVALID_HANDLE_VALUE)
- res = false;
+ res = failed;
else
{
DWORD size = GetFileSize (fh, NULL), read_bytes;
buf = (char *) malloc (size + 1);
if (!ReadFile (fh, buf, size, &read_bytes, NULL))
{
+ paranoid_printf ("ReadFile failed, %E");
CloseHandle (fh);
if (buf)
free (buf);
buf = NULL;
- res = false;
+ res = failed;
}
else
{
@@ -494,11 +492,12 @@ pwdgrp::load (const char *posix_fname)
while ((eptr = add_line (eptr)))
continue;
debug_printf ("%s curr_lines %d", posix_fname, curr_lines);
- res = true;
+ res = succeeded;
}
}
}
+ debug_printf ("load of %s %s", posix_fname, res);
initialized = true;
- return res;
+ return;
}