[fpc-pascal] A simple "exception handling" question

Michael Van Canneyt michael at freepascal.org
Sun Jan 29 11:34:36 CET 2006



On Sun, 29 Jan 2006, Michalis Kamburelis wrote:

> Bob Richards wrote:
> > Michalis Kamburelis wrote:
> > 
> > 
> > > There's a bug in Hex2Dec implementation -- it returns 0 instead of
> > > raising EConvertError. Here's a patch:
> > > 
> > > Index: strutils.pp
> > > ===================================================================
> > > --- strutils.pp    (wersja 2298)
> > > +++ strutils.pp    (kopia robocza)
> > > @@ -1156,7 +1156,7 @@
> > >  HexStr:='$'+ S
> > > else
> > >     HexStr:=S;
> > > -  Result:=StrTointDef(HexStr,0);
> > > +  Result:=StrToint(HexStr);
> > > end;
> > > 
> > > function Dec2Numb(N: Longint; Len, Base: Byte): string;
> > > _______________________________________________
> > 
> > 
> > First, thanks for the reply; I applied the patch, it applied without a
> > problem, verified
> > the new StrUtils.pp source, all OK as per the patch. Recompiled
> > strutils.ppu. The function
> > still returns a zero on error.
> > 
> > Is there another patch I need as well?
> 
> I'm quite sure that my patch is all you need. I tested it on my system with
> your test program hextest, and it fixed the situation. So my guess is that
> you're probably mistakenly using old compiled version of strutils unit instead
> of the patched one. Check it -- e.g. add some trivial
>   Writeln('i am the new version');
> inside Hex2Dec implementation and see if your hextest prints this message.
> 
> You can also just paste the corrected implementation of Hex2Dec inside your
> program, this will also fix the bug, without the need to recompile strutils
> unit.
> 
> Of course, ultimately the solution is to wait until this patch will be applied
> to FPC sources and then use updated FPC version from SVN.

Patch is applied.

Michael.



More information about the fpc-pascal mailing list