delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2004/07/27/16:00:06.1

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Trace-PostClient-IP: 68.147.131.211
From: Brian Inglis <Brian DOT Inglis AT SystematicSw DOT Invalid>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: strange error
Organization: Systematic Software
Message-ID: <t3adg0t3060ol07v7q8m9rr38h5ki144s1@4ax.com>
References: <AL1Nc.380$zS6 DOT 55822 AT news02 DOT tsnz DOT net> <20040726055220 DOT 22465 DOT 00000447 AT mb-m11 DOT aol DOT com> <Ca5Nc.440$zS6 DOT 63234 AT news02 DOT tsnz DOT net> <6U5Nc.449$zS6 DOT 65197 AT news02 DOT tsnz DOT net>
X-Newsreader: Forte Agent 1.93/32.576 English (American)
MIME-Version: 1.0
Lines: 48
Date: Tue, 27 Jul 2004 19:45:51 GMT
NNTP-Posting-Host: 24.71.223.147
X-Complaints-To: abuse AT shaw DOT ca
X-Trace: pd7tw2no 1090957551 24.71.223.147 (Tue, 27 Jul 2004 13:45:51 MDT)
NNTP-Posting-Date: Tue, 27 Jul 2004 13:45:51 MDT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

On Mon, 26 Jul 2004 23:26:47 +1200 in comp.os.msdos.djgpp, Paul
Wilkins <disk AT paradise DOT net DOT nz> wrote:

>Paul Wilkins wrote:
>
>Do not post when tired.
>
>> Let's head back to the line where the trouble occurs, which I presume 
>> you want to fix.
>> 
>> m55:r--;if(R[r]!=1)goto m55;
>> 
>> r gets decreased until R[r] = 1.
>> 
>> That needs to be fixed so that r doesn't go below 0
><snip>
>> Is that right?
>> 
>> In that case, let's count down to 0 and break out when we're successful.
>> 
>> for (r; r>=0; r--) if (R[r]==0) break;
>
>Make that
>   for (r; r>=0; r--) if (R[r]==1) break;
>
>> 
>> or
>> 
>> for (r; r>=0; r--)
>>   if (R[r]==1)
>>     break; // out of for loop
>
>If you don't want to check R[0] (ie. you use R[1] as your first entry) 
>then change r>=0 to r>0 or r>=1

The posted code reminds me of Fortran programs I'd be handed by
engineers, while a junior programmer, to turn into a program usable by
others, or library routines that would play well with others. 

The OP might be happier developing this type of (goto laden) code
under the g77 Fortran compiler, available from DJGPP mirrors, which
has the option -fbounds-check for subscript checking. 

-- 
Thanks. Take care, Brian Inglis 	Calgary, Alberta, Canada

Brian DOT Inglis AT CSi DOT com 	(Brian dot Inglis at SystematicSw dot ab dot ca)
    fake address		use address above to reply

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019