From:	SMTP%"Mark.Martinec@ijs.si" 25-MAY-1994 10:50:10.34
To:	EVERHART
CC:	
Subj:	Patch to the ADD FILE loop

Message-Id: <9405250212.AA02384@uu7.psi.com>
Date:         Tue, 24 May 1994 11:20:31 GMT
Reply-To: Mark Martinec <Mark.Martinec@ijs.si>
Sender: ANU-NEWS Discussion <ANU-NEWS@VM1.NoDak.EDU>
From: Mark Martinec <Mark.Martinec@ijs.si>
Organization: J. Stefan Institute, Lj, Slovenia
Subject:      Patch to the ADD FILE loop
To: Multiple recipients of list ANU-NEWS <ANU-NEWS@VM1.NoDak.EDU>

In article <1994May23.220621@tntvax> spb@tntvax.ntrs.com (Steve Bonine) writes:
> I have just discovered a loop in ADD FILE in the new version of news.  Maybe
> it's just coincidence (yeah, right) but I have never had a loop before in ADD
> FILE.  This is the place in the file where it looped:

The following fix should solve an ADD FILE loop.
Somebody else may fix the NNTP side of the problem
(generating an empty article).  I noticed that the
original article header specified 21 lines, whereas
the actual text had 20 lines  +  '#! rnews 1'  line:

> Organization: Loughborough College of Art and Design
> Followup-To: comp.graphics
> Lines: 21
>
> THE FUTURE OF GRAPHIC DESIGN?
[ ... ]
> Hi  the names Alan Leavy and I teach Graphic Design at Loughborough
> College of Art & Design at one the last five independent colleges in
> Id really welcome anybodies views on this matter as Ive got to make  a
> decision about the direction that this new electronics graphics course will
> take.
> #! rnews 1
> #! rnews 1798


Add the following statement:
  if (infile_eom) abnormal_exit = 1;

just before the 'for' loop in NEWSADD.C routine scan_header() :
  if (infile_eom) abnormal_exit = 1;
  for (; (!infile_eof && !infile_eom); get_line()) {


Here is the same thing in VMS_SHARE-ed diff -c format:

$! ------------------ CUT HERE -----------------------
$ v='f$verify(f$trnlnm("SHARE_UNPACK_VERIFY"))'
$!
$! This archive created:
$!  Name : 0
$!  By   : mark@cathy.ijs.si
$!  Date : 24-MAY-1994 11:08:36.41
$!  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. NEWSADD_C.PATCH;1
$!
$ 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-EXISTS, File ''P1' exists. Skipped"
$ delete 'f'*
$ exit
$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;EDIT(s,"TRIM");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;[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'
X*** _$1$dia100:`5Banu-news.news_src`5Dnewsadd.c;1
X--- newsadd.c
X**************
X*** 236,241
X  **`09`09Also the initial size of itm_text and its increments is
X  **`09`09based on statistical measurements.
X  **
X  **--
X  **/
X  `0C
X--- 236,245 -----
X  **`09`09Also the initial size of itm_text and its increments is
X  **`09`09based on statistical measurements.
X  **
X+ **`09V6.1b9`0924-May-1994`09mark.martinec@ijs.si
X+ **`09      - avoid looping when an empty article is received like in:
X+ **`09`09  #! rnews 1
X+ **`09`09  #! rnews 1798
X  **--
X  **/
X  `0C
X**************
X*** 1614,1619
X    *header_size = 0;
X    news_assert(!itm_text_tmp_in_use);
X `20
X    for (; (!infile_eof `26`26 !infile_eom); get_line()) `7B
X      *header_size += add_inline_l;
X      if (itm_text`5Bitm_text_tmp_l-1`5D == '`5Cn') itm_text_tmp_l--;  /* chop
V off `5Cn */
X--- 1618,1624 -----
X    *header_size = 0;
X    news_assert(!itm_text_tmp_in_use);
X `20
X+   if (infile_eom) abnormal_exit = 1;
X    for (; (!infile_eof `26`26 !infile_eom); get_line()) `7B
X      *header_size += add_inline_l;
X      if (itm_text`5Bitm_text_tmp_l-1`5D == '`5Cn') itm_text_tmp_l--;  /* chop
V off `5Cn */
$ call unpack NEWSADD_C.PATCH;1 -
 1045771596 "FORMAT STREAM_LF;CARRIAGE_CONTROL CARRIAGE_RETURN" 3 1 1
$ v=f$verify(v)
$ exit
--
  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  !!  Mark Martinec (system manager)   tel +386 61 1259-199  !!
  !!  J. Stefan Institute, Jamova 39   fax +386 61  219-385  !!
  !!  61000 Ljubljana, Slovenia        mark.martinec@ijs.si  !!
  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! http://www.ijs.si/ !!!!!
