* cygcheck.cc (pretty_id): Don't exit on id error. Fix size calculations.
This commit is contained in:
parent
12a638f990
commit
167f0d8513
|
@ -1,3 +1,9 @@
|
||||||
|
2004-10-15 Bas van Gompel <cygwin-patch.buzz@bavag.tmfweb.nl>
|
||||||
|
Christopher Faylor <cgf@timesys.com>
|
||||||
|
|
||||||
|
* cygcheck.cc (pretty_id): Don't exit on id error. Fix size
|
||||||
|
calculations.
|
||||||
|
|
||||||
2004-10-14 Christopher Faylor <cgf@timesys.com>
|
2004-10-14 Christopher Faylor <cgf@timesys.com>
|
||||||
Bas van Gompel <cygwin-patch.buzz@bavag.tmfweb.nl>
|
Bas van Gompel <cygwin-patch.buzz@bavag.tmfweb.nl>
|
||||||
|
|
||||||
|
|
|
@ -802,7 +802,7 @@ pretty_id (const char *s, char *cygwin, size_t cyglen)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf (stderr, "garbled output from `id' command - no uid= found\n");
|
fprintf (stderr, "garbled output from `id' command - no uid= found\n");
|
||||||
exit (1);
|
return;
|
||||||
}
|
}
|
||||||
char *gid = strtok (NULL, ")");
|
char *gid = strtok (NULL, ")");
|
||||||
if (gid)
|
if (gid)
|
||||||
|
@ -810,14 +810,14 @@ pretty_id (const char *s, char *cygwin, size_t cyglen)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf (stderr, "garbled output from `id' command - no gid= found\n");
|
fprintf (stderr, "garbled output from `id' command - no gid= found\n");
|
||||||
exit (1);
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
char **ng = groups - 1;
|
char **ng = groups - 1;
|
||||||
size_t len_uid = strlen (uid);
|
size_t len_uid = strlen (uid);
|
||||||
size_t len_gid = strlen (gid);
|
size_t len_gid = strlen (gid);
|
||||||
*++ng = groups[0] = (char *) alloca (len_uid += sizeof ("UID: )"));
|
*++ng = groups[0] = (char *) alloca (len_uid += sizeof ("UID: )") - 1);
|
||||||
*++ng = groups[1] = (char *) alloca (len_uid += sizeof ("GID: )"));
|
*++ng = groups[1] = (char *) alloca (len_gid += sizeof ("GID: )") - 1);
|
||||||
sprintf (groups[0], "UID: %s)", uid);
|
sprintf (groups[0], "UID: %s)", uid);
|
||||||
sprintf (groups[1], "GID: %s)", gid);
|
sprintf (groups[1], "GID: %s)", gid);
|
||||||
size_t sz = max (len_uid, len_gid);
|
size_t sz = max (len_uid, len_gid);
|
||||||
|
@ -832,13 +832,14 @@ pretty_id (const char *s, char *cygwin, size_t cyglen)
|
||||||
if (sz < len)
|
if (sz < len)
|
||||||
sz = len;
|
sz = len;
|
||||||
}
|
}
|
||||||
|
ng--;
|
||||||
|
|
||||||
printf ("\nOutput from %s (%s)\n", id, s);
|
printf ("\nOutput from %s (%s)\n", id, s);
|
||||||
int n = 80 / (int) sz;
|
int n = 80 / (int) ++sz;
|
||||||
sz = -(sz + 1);
|
int i = n ? n - 2 : 0;
|
||||||
int i = n - 2;
|
sz = -sz;
|
||||||
for (char **g = groups; g < ng; g++)
|
for (char **g = groups; g <= ng; g++)
|
||||||
if ((g != ng - 1) && (++i < n))
|
if ((g != ng) && (++i < n))
|
||||||
printf ("%*s ", sz, *g);
|
printf ("%*s ", sz, *g);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue