[1266] in testers

home help back first fref pref prev next nref lref last post

Re: 7.2 session_gate: patches

daemon@ATHENA.MIT.EDU (daemon@ATHENA.MIT.EDU)
Fri Nov 30 11:18:54 1990

From: brlewis@ATHENA.MIT.EDU
Date: Fri, 30 Nov 90 11:18:35 -0500
To: testers@ATHENA.MIT.EDU


The bug with powers[] was probably introduced as somebody tried to
allow for ps2-style pid's, which might be 6 digits long.  But itoa
assumes 5.  Whoever added the extra power probably overlooked that.
I'm including a patch that will allow for 6 digits, and will prevent
anyone from making the same mistake in the future by making powers[]
into a null-terminated array.

But then, why is all this pid file stuff still in there?  Is there
some reason for staying backward-compatible with 7.1 end_session?

*** session_gate.c	Fri Nov 30 10:33:05 1990
--- /tmp/foo.c	Fri Nov 30 11:10:36 1990
***************
*** 84,92 ****
        }
  }
  
  
- static powers[] = {10000,1000,100,10,1};
- 
  int itoa(x, buf)
  int x;
  char *buf;
--- 84,91 ----
        }
  }
  
+ static powers[] = {100000,10000,1000,100,10,1,0};
  
  int itoa(x, buf)
  int x;
  char *buf;
***************
*** 95,101 ****
      int pos=0;
      int digit;
  
!     for (i = 0; i < 5; i++)
        {
  	  digit = (x/powers[i]) % 10;
  	  if ((pos > 0) || (digit != 0) || (i == 4))
--- 94,100 ----
      int pos=0;
      int digit;
  
!     for (i = 0; powers[i]; i++)
        {
  	  digit = (x/powers[i]) % 10;
  	  if ((pos > 0) || (digit != 0) || (i == 4))

home help back first fref pref prev next nref lref last post