Re: [Patch] cygcheck: pretty_id misbehaving.

2004-10-17 Thread Christopher Faylor
On Sat, Oct 16, 2004 at 02:14:33AM +0200, Bas van Gompel wrote:
Op Fri, 15 Oct 2004 09:59:04 -0400 schreef Christopher Faylor
jj:  or to negate
:  sz repeatedly inside of a loop.

My plan was to not negate sz at all, use the printf format-flag ``-''.

Yes.  I get it.  This is a difference of opinion.

Also, space needs to be allocated for the trailing `\0` on uid and
gid, and notice there isn't a space at the end of the printf format.

I keep making this stupid mistake.  I have, again, checked in a variation
of your fix.  I think I got it right this time.

Thanks,
cgf


Re: [Patch] cygcheck: pretty_id misbehaving.

2004-10-17 Thread Buzz
Op Sun, 17 Oct 2004 19:34:23 -0400 schreef Christopher Faylor
in [EMAIL PROTECTED]:
:  On Sat, Oct 16, 2004 at 02:14:33AM +0200, Bas van Gompel wrote:
:  Op Fri, 15 Oct 2004 09:59:04 -0400 schreef Christopher Faylor
:  jj:  or to negate
:  :  sz repeatedly inside of a loop.
: 
:  My plan was to not negate sz at all, use the printf format-flag ``-''.
:
:   Yes.  I get it.  This is a difference of opinion.

Oh well, it works.

:  Also, space needs to be allocated for the trailing `\0` on uid and
:  gid, and notice there isn't a space at the end of the printf format.
:
:   I keep making this stupid mistake.  I have, again, checked in a variation
:  of your fix.  I think I got it right this time.

Well, almost. :)


ChangeLog-entry:

2004-10-18  Bas van Gompel  [EMAIL PROTECTED]

* Cygcheck.cc (pretty_id): Count ')' in ui_len and gui_len.


--- src/winsup/utils-3/cygcheck.cc  17 Oct 2004 23:31:23 -  1.51
+++ src/winsup/utils-3/cygcheck.cc  18 Oct 2004 01:20:27 -
@@ -814,8 +814,8 @@ pretty_id (const char *s, char *cygwin, 
 }
 
   char **ng = groups - 1;
-  size_t len_uid = strlen (UID: ) + strlen (uid);
-  size_t len_gid = strlen (GID: ) + strlen (gid);
+  size_t len_uid = strlen (UID: )) + strlen (uid);
+  size_t len_gid = strlen (GID: )) + strlen (gid);
   *++ng = groups[0] = (char *) alloca (len_uid + 1);
   *++ng = groups[1] = (char *) alloca (len_gid + 1);
   sprintf (groups[0], UID: %s), uid);


L8r,

Buzz.
-- 
  ) |  | ---/ ---/  Yes, this | This message consists of true | I do not
--  |  |   //   really is |   and false bits entirely.| mail for
  ) |  |  //a 72 by 4 +---+ any1 but
--  \--| /--- /---  .sigfile. |   |perl -pe s.u(z)\1.as.| me. 4^re


Re: [Patch] cygcheck: pretty_id misbehaving.

2004-10-17 Thread Christopher Faylor
On Mon, Oct 18, 2004 at 03:32:07AM +0200, Buzz wrote:
2004-10-18  Bas van Gompel  [EMAIL PROTECTED]

   * Cygcheck.cc (pretty_id): Count ')' in ui_len and gui_len.

Thanks.  Checked in without change.

cgf


Re: [Patch] cygcheck: pretty_id misbehaving.

2004-10-17 Thread Bas van Gompel
Op Sun, 17 Oct 2004 21:46:29 -0400 schreef Christopher Faylor
in [EMAIL PROTECTED]:
:  On Mon, Oct 18, 2004 at 03:32:07AM +0200, Buzz wrote:

[...]

:  * Cygcheck.cc (pretty_id): Count ')' in ui_len and gui_len.
:
:   Thanks.  Checked in without change.

Thank you (for writing a better ChangeLog-entry as well).

Remaining items... (I missed these last time around.)


ChangeLog-entry:

2004-10-18  Bas van Gompel  [EMAIL PROTECTED]

* cygcheck.cc (pretty_id): Don't let i become negative. Fix
printf-format.


--- src/winsup/utils/cygcheck.cc18 Oct 2004 01:44:55 -  1.52
+++ src/winsup/utils/cygcheck.cc18 Oct 2004 04:47:24 -
@@ -836,11 +836,11 @@ pretty_id (const char *s, char *cygwin, 
 
   printf (\nOutput from %s (%s)\n, id, s);
   int n = 80 / (int) ++sz;
-  int i = n ? n - 2 : 0;
+  int i = n  2 ? n - 2 : 0;
   sz = -sz;
   for (char **g = groups; g = ng; g++)
 if ((g != ng)  (++i  n))
-  printf (%*s , sz, *g);
+  printf (%*s, sz, *g);
 else
   {
puts (*g);


L8r,

Buzz.
-- 
  ) |  | ---/ ---/  Yes, this | This message consists of true | I do not
--  |  |   //   really is |   and false bits entirely.| mail for
  ) |  |  //a 72 by 4 +---+ any1 but
--  \--| /--- /---  .sigfile. |   |perl -pe s.u(z)\1.as.| me. 4^re


Re: [Patch] cygcheck: pretty_id misbehaving.

2004-10-15 Thread Bas van Gompel
Op Thu, 14 Oct 2004 13:36:21 -0400 schreef Christopher Faylor
in [EMAIL PROTECTED]:
:  On Thu, Oct 14, 2004 at 05:31:16PM +0200, Bas van Gompel wrote:

[...]

:  * cygcheck.cc (pretty_id): Correct layout.
:
:   Thanks for the patch but I think it's possible to do this and make
:  things a little more robust wrt the column calculations.  See below.
:  This actually shrinks the number of lines slightly too.
:
:  I'm going to check this in.

Here are some corrections/changes to your patch:

*) Don't exit, return. (Allow other checks to run.)
*) Update len_gid, not len_uid.
*) Correct calculation of sz. (sizeof(x) == strlen(x) + 1)
*) Don't negate sz, update printf-format
*) Correct low values of n and i.
*) Change order in which final n and sz are set.


ChangeLog-entry:

2004-10-15  Bas van Gompel  [EMAIL PROTECTED]

* cygcheck.cc (pretty_id): Don't exit, return. Correct layout.


--- src/winsup/utils-3/cygcheck.cc  14 Oct 2004 17:35:46 -  1.49
+++ src/winsup/utils-3/cygcheck.cc  15 Oct 2004 10:56:44 -
@@ -802,7 +802,7 @@ pretty_id (const char *s, char *cygwin, 
   else
 {
   fprintf (stderr, garbled output from `id' command - no uid= found\n);
-  exit (1);
+  return;
 }
   char *gid = strtok (NULL, ));
   if (gid)
@@ -810,17 +810,17 @@ pretty_id (const char *s, char *cygwin, 
   else
 {
   fprintf (stderr, garbled output from `id' command - no gid= found\n);
-  exit (1);
+  return;
 }
 
   char **ng = groups - 1;
   size_t len_uid = strlen (uid);
   size_t len_gid = strlen (gid);
   *++ng = groups[0] = (char *) alloca (len_uid += sizeof (UID: )));
-  *++ng = groups[1] = (char *) alloca (len_uid += sizeof (GID: )));
+  *++ng = groups[1] = (char *) alloca (len_gid += sizeof (GID: )));
   sprintf (groups[0], UID: %s), uid);
   sprintf (groups[1], GID: %s), gid);
-  size_t sz = max (len_uid, len_gid);
+  size_t sz = max (len_uid, len_gid) - 1;
   while ((*++ng = strtok (NULL, ,)))
 {
   char *p = strchr (*ng, '\n');
@@ -834,12 +834,14 @@ pretty_id (const char *s, char *cygwin, 
 }
 
   printf (\nOutput from %s (%s)\n, id, s);
+  sz++;
   int n = 80 / (int) sz;
-  sz = -(sz + 1);
-  int i = n - 2;
+  if (!n)
+n = 1;
+  int i = (n  1) ? n - 2 : 0;
   for (char **g = groups; g  ng; g++)
 if ((g != ng - 1)  (++i  n))
-  printf (%*s , sz, *g);
+  printf (%-*s, sz, *g);
 else
   {
puts (*g);


L8r,

Buzz.
-- 
  ) |  | ---/ ---/  Yes, this | This message consists of true | I do not
--  |  |   //   really is |   and false bits entirely.| mail for
  ) |  |  //a 72 by 4 +---+ any1 but
--  \--| /--- /---  .sigfile. |   |perl -pe s.u(z)\1.as.| me. 4^re


Re: [Patch] cygcheck: pretty_id misbehaving.

2004-10-15 Thread Christopher Faylor
On Fri, Oct 15, 2004 at 02:03:24PM +0200, Bas van Gompel wrote:
ChangeLog-entry:

2004-10-15  Bas van Gompel  [EMAIL PROTECTED]

   * cygcheck.cc (pretty_id): Don't exit, return. Correct layout.

Thanks.  I've checked in a variation of this patch.

I don't see any reason to guard against n being zero or to negate
sz repeatedly inside of a loop.

cgf