[comp.bugs.sys5] Obscure bug in ci,co,rcs

news@jpusa1.UUCP (usenet) (08/27/87)

An obscure bug surfaced when trying to co a bunch of
files.  The variable 'linecorr' is not initialized to
0 for each file.  This will cause editstring to break
if linecorr happened to be < 0 at the end of doing the
last file.  Following are diffs to rcs.c and rcsgen.c

*** /tmp/,RCSt1a11512	Wed Aug 26 19:06:54 1987
--- rcs.c	Wed Aug 26 18:45:44 1987
***************
*** 504,509
                  /* no revision deleted */
                  fastcopy(finptr,frewrite);
              } else {
                  if ( cuttail )
                      buildeltatext(gendeltas);
                  else

--- 504,510 -----
                  /* no revision deleted */
                  fastcopy(finptr,frewrite);
              } else {
+ 		extern int linecorr; linecorr = 0;
                  if ( cuttail )
                      buildeltatext(gendeltas);
                  else
*** /tmp/,RCSt1a11526	Wed Aug 26 19:08:47 1987
--- rcsgen.c	Wed Aug 26 18:47:37 1987
***************
*** 94,99
   */
  {
          int i;
  
          if (deltas[0]==target) {
                  /* only latest revision to generate */

--- 94,100 -----
   */
  {
          int i;
+ 	extern int linecorr; linecorr = 0;
  
          if (deltas[0]==target) {
                  /* only latest revision to generate */
--
Stu Heiss {gargoyle,ihnp4}!jpusa1!stu

roy@felix.UUCP (Roy Morris) (09/03/87)

In article <317@jpusa1.UUCP> stu@jpusa1.UUCP (Stu Heiss) writes:
>An obscure bug surfaced when trying to co a bunch of
>files.  The variable 'linecorr' is not initialized to
>0 for each file.  This will cause editstring to break
>if linecorr happened to be < 0 at the end of doing the
>last file.  Following are diffs to rcs.c and rcsgen.c

A cleaner fix to the problem is to add the following line to the
routine initeditfiles() in rcsedit.c.  We weren't bitten by the
variable 'editline' not being initialized, but it's not worth
waiting to see if it happens.

88a89
> 	editline = linecorr = 0;

Roy Morris   FileNet Corp   ...!felix!roy