From:	SMTP%"bailey@GENETICS.UPENN.EDU"  7-JUN-1994 19:38:44.88
To:	EVERHART
CC:	
Subj:	Patch: Re: A couple of other bugs with V6.1b9

Date:         Tue, 7 Jun 1994 15:24:29 EDT
Reply-To:     Charles Bailey <bailey@GENETICS.UPENN.EDU>
Sender:       ANU-NEWS Discussion <ANU-NEWS@VM1.NoDak.EDU>
From:         Charles Bailey <bailey@GENETICS.UPENN.EDU>
Organization: HHMI/Human Genetics, Univ of Pa.
Subject:      Patch: Re: A couple of other bugs with V6.1b9
To:           Multiple recipients of list ANU-NEWS <ANU-NEWS@VM1.NoDak.EDU>

In article <1994Jun7.182822.4754@zippy.dct.ac.uk>, ccdarg@zippy.dct.ac.uk (Alan
Greig) writes:
> In article <1994Jun6.184123.4698@zippy.dct.ac.uk>, ccdarg@zippy.dct.ac.uk (Ala
n Greig) writes:
>> In article <1994Jun6.181716.4694@zippy.dct.ac.uk>, ccdarg@zippy.dct.ac.uk (Al
an Greig) writes:
>>>
>>> Could whoever made the changes in this area have a look please? If
>>> you're too busy let me know.
>>
>> Being more specific: In newsutility.c is the following [in map_items() ]
>>
>>         if (gap->grp_count) {
>>           if (gap->grp_ia[gap->grp_count-1].itm_num > gap->grp_topnum)
>>             gap->grp_topnum = gap->grp_ia[gap->grp_count-1].itm_num;
>>           }
>
> Ok, continuing the thread:
>
> This is indeed the problem area and I've exchanged a few messages
> back and forth with Charles Bailey and I've been running a patched
> version which handles display=unseen perfectly. I guess Charles
> will probably post an 'official' patch here fairly soon. If you really
> can't wait then try commenting out the above four lines *or* change
> the two "gap->grp_count-1" to "gap->grp_count" but best wait for
> the posted version.

Here's the patch.  It should fix this bug (seen only when using News with a
local database), and also make sure grp_topnum is set correctly when running as
an NNTP client.  Since I couldn't reproduce the problem here, I asked sites
which had seen the problem to test this patch before I posted it.  It appears to
work, but please let me know if you see any odd behavior you think may be a
consequence of this patch.

                    Regards,
                    Charles Bailey

!-------------------------------------------------------------------------------
!              Computational Biology and Informatics Laboratory
!         Dept. of Genetics, Univ. of Pennsylvania School of Medicine
!              Philadelphia, PA USA 19104     Tel. (215) 573-3112
!          Internet: bailey@genetics.upenn.edu  (IN 128.91.200.37)
!-------------------------------------------------------------------------------
$! ------------------ CUT HERE -----------------------
$ v='f$verify(f$trnlnm("SHARE_UNPACK_VERIFY"))'
$!
$! This archive created:
$!  Name : 940607_NEWSUTILITY.PATCH
$!  By   : bailey@genetics.upenn.edu
$!  Date :  7-JUN-1994 15:22:12.90
$!  Using: VMS_SHARE 8.4, (C) 1993 Andy Harper, Kings College London UK
$!
$! Credit is due to these people for their original ideas:
$!    James Gray, Michael Bednarek
$!
$! TO UNPACK THIS SHARE FILE, CONCATENATE ALL PARTS IN ORDER
$! AND EXECUTE AS A COMMAND PROCEDURE  (  @name  )
$!
$! THE FOLLOWING FILE(S) WILL BE CREATED AFTER UNPACKING:
$!       1. 940607_NEWSUTILITY.PATCH
$!
$ set="set"
$ set symbol/scope=(nolocal,noglobal)
$ f=f$parse("SHARE_UNPACK_TEMP","SYS$SCRATCH:."+f$getjpi("","PID"))
$ e="write sys$error  ""%UNPACK"", "
$ w="write sys$output ""%UNPACK"", "
$ if .not. f$trnlnm("SHARE_UNPACK_LOG") then $ w = "!"
$ if f$getsyi("CPU") .gt. 127 then $ goto start
$ ve=f$getsyi("version")
$ if ve-f$extract(0,1,ve) .ges. "4.4" then $ goto start
$ e "-E-OLDVER, Must run at least VMS 4.4"
$ v=f$verify(v)
$ exit 44
$unpack: subroutine ! P1=filename, P2=checksum, P3=attributes,P4=size
$ if f$parse(P1) .nes. "" then $ goto dirok
$ dn=f$parse(P1,,,"DIRECTORY")
$ w "-I-CREDIR, Creating directory ''dn'"
$ create/dir 'dn'
$ if $status then $ goto dirok
$ e "-E-CREDIRFAIL, Unable to create ''dn' File skipped"
$ delete 'f'*
$ exit
$dirok:
$ x=f$search(P1)
$ if x .eqs. "" then $ goto file_absent
$ e "-W-HIGHVERS, Creating higher version of ", P1
$file_absent:
$ w "-I-UNPACK, Unpacking ", P5, " of ", P6, " - ", P1, " - ", P4, " Blocks"
$ n=P1
$ if P3 .nes. "" then $ n=f
$ if .not. f$verify() then $ define/user sys$output nl:
$ EDIT/TPU/NOSEC/NODIS/COM=SYS$INPUT/NOJOURNAL 'f'/OUT='n'
PROCEDURE GetHex(s,p)LOCAL x1,x2;x1:=INDEX(t,SUBSTR(s,p,1))-1;x2:=INDEX(t,
SUBSTR(s,p+1,1))-1;RETURN 16*x1+x2;ENDPROCEDURE;PROCEDURE SkipPartsep LOCAL m;
LOOP m:=MARK(NONE);EXITIF m=END_OF(b);DELETE(m);EXITIF INDEX(ERASE_LINE,
"-+-+-+-+-+-+-+-+")=1;ENDLOOP;ENDPROCEDURE;PROCEDURE ProcessLine LOCAL c,s,l,b,
n,p;c := ERASE_CHARACTER(1);s := ERASE_LINE;IF c = "X" THEN SPLIT_LINE; ENDIF;
MOVE_HORIZONTAL(-1);l := LENGTH(s);p := 1;LOOP EXITIF p > l;c := SUBSTR(s,p,1);
p := p+1;CASE c FROM ' ' TO '`' ['`']: COPY_TEXT(ASCII(GetHex(s,p))); p:=p+2;[
' ']: p:=p+1;[INRANGE,OUTRANGE]: COPY_TEXT(c);ENDCASE;ENDLOOP;ENDPROCEDURE;
PROCEDURE Decode LOCAL m;POSITION(BEGINNING_OF(b));LOOP m:=MARK(NONE);EXITIF m=
END_OF(b);DELETE(m);IF INDEX(CURRENT_LINE,"+-+-+-+-+-+-+-+-")=
1 THEN SkipPartSep;ELSE ProcessLine;MOVE_HORIZONTAL(1);ENDIF;ENDLOOP;
ENDPROCEDURE;SET(FACILITY_NAME,"UNPACK");SET(SUCCESS,OFF);SET(INFORMATIONAL,
OFF);t:="0123456789ABCDEF";f:=GET_INFO(COMMAND_LINE,"file_name");b:=
CREATE_BUFFER(f,f);Decode;WRITE_FILE(b,GET_INFO(COMMAND_LINE,"output_file"));
QUIT;
$ if p3 .eqs. "" then $ goto dl
$ open/write fdl &f
$ write fdl "RECORD"
$ write fdl P3
$ close fdl
$ w "-I-CONVRFM, Converting record format to ", P3
$ convert/fdl=&f &f-1 &P1
$dl: delete 'f'*
$ checksum 'P1'
$ if checksum$checksum .nes. P2 then $ -
  e "-E-CHKSMFAIL, Checksum of ''P1' failed."
$ exit
$ endsubroutine
$start:
$!
$ create 'f'
XANU`20News`20Patch
XPatch`20ID:`20940607_newsutility.c!bailey@genetics.upenn.edu
XDate:`2007-Jun-1994
XAuthor:`20Charles`20Bailey`20`20bailey@genetics.upenn.edu
XNews`20Version:`206.1beta9
XNews`20Files:`20NewsUtility.C
XDescription:`20Fixes`20bug`20in`20map_items()`20which`20caused`20grp_topnum`20
Vto`20be`20set
Xincorrectly`20when`20operating`20as`20a`20local`20reader.`20`20This`20bug`20wa
Vs`20particularly`20likely
Xto`20be`20apparent`20in`20groups`20containing`20only`20one`20item.`20`20Also
V`20adds`20code`20to`20update
Xgrp_topnum`20when`20operating`20as`20a`20NNTP`20client.
X***`20newsutility.c
X---`20newsutility_new.c
X**************
X***`20101,103
X`20`20**--
X`20`20**/
X`20`20`0C
X---`20101,106`20-----
X+`20**`09V6.1b9`20`20`207-Jun-1994`20`20Charles`20Bailey`20`20bailey@genetics.
Vupenn.edu
X+`20**`09`20-`20fix`20bug`20in`20map_items()`20which`20caused`20grp_topnum`20t
Vo`20be`20set`20incorrectly
X+`20**`09`20`20`20under`20some`20circumstances`20(particularly`20when`20group
V`20has`20only`20one`20item)
X`20`20**--
X`20`20**/
X`20`20`0C
X**************
X***`202671,2676
X`20`20`20`20`20`20`20`20`20`20`20`20`7D
X`20`20`20`20`20`20`20`20`20`20`7D
X`20`20`20`20`20`20`20`20if`20(gap->grp_unread`20>`20gap->grp_count)`20gap->grp
V_unread`20=`20gap->grp_count;
X`20`20`20`20`20`20`20`20`7D
X`20`20`20`20`20`20`7D
X`20`20`20`20else`20`7B
X---`202674,2682`20-----
X`20`20`20`20`20`20`20`20`20`20`20`20`7D
X`20`20`20`20`20`20`20`20`20`20`7D
X`20`20`20`20`20`20`20`20if`20(gap->grp_unread`20>`20gap->grp_count)`20gap->grp
V_unread`20=`20gap->grp_count;
X+`20`20`20`20`20`20`20if`20(gap->grp_count)
X+`20`20`20`20`20`20`20`20`20gap->grp_topnum`20=`20gap->grp_ia`5Bgap->grp_count
V`5D.itm_num;
X+`20`20`20`20`20`20`20else`20gap->grp_topnum`20=`20last;
X`20`20`20`20`20`20`20`20`7D
X`20`20`20`20`20`20`7D
X`20`20`20`20else`20`7B
X**************
X***`202701,2708
X`20`20`20`20`20`20while`20(sys_get_nornf(`26itmrab))`20`7B
X`20`20`20`20`20`20`20`20if`20(newsitm.itm_grp`20!=`20key`5B1`5D)`20`7B
X`20`20`09if`20(gap->grp_count)`20`7B
X!`20`09`20`20if`20(gap->grp_ia`5Bgap->grp_count-1`5D.itm_num`20>`20gap->grp_to
Vpnum)
X!`20`09`20`20`20`20gap->grp_topnum`20=`20gap->grp_ia`5Bgap->grp_count-1`5D.itm
V_num;
X`20`20`09`20`20`7D
X`20`20`09break;
X`20`20`09`7D
X---`202707,2714`20-----
X`20`20`20`20`20`20while`20(sys_get_nornf(`26itmrab))`20`7B
X`20`20`20`20`20`20`20`20if`20(newsitm.itm_grp`20!=`20key`5B1`5D)`20`7B
X`20`20`09if`20(gap->grp_count)`20`7B
X!`20`09`20`20if`20(gap->grp_ia`5Bgap->grp_count`5D.itm_num`20>`20gap->grp_topn
Vum)
X!`20`09`20`20`20`20gap->grp_topnum`20=`20gap->grp_ia`5Bgap->grp_count`5D.itm_n
Vum;
X`20`20`09`20`20`7D
X`20`20`09break;
X`20`20`09`7D
X***`20patchlist.h;-1
X---`20patchlist.h
X**************
X***`201,1
X`20`20=+=+=`20End`20=+=+=
X---`201,2`20-----
X+`20940607_newsutility.c!bailey@genetics.upenn.edu
X`20`20=+=+=`20End`20=+=+=
$ call unpack 940607_NEWSUTILITY.PATCH -
 1316649334 "FORMAT STREAM_LF;CARRIAGE_CONTROL CARRIAGE_RETURN" 4 1 1
$ v=f$verify(v)
$ exit
