Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2009-03

[patch] regex.pp with out parameters

4 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Graeme Geldenhuys

Hi,

Please find attached a minor patch that removes the following compiler hints when TRegexEngine.Parse(...) is used.

================
iterator_impl.pas(306,46) Hint: Local variable "LErrorCode" does not seem to be initialized
iterator_impl.pas(306,34) Hint: Local variable "LErrorPos" does not seem to be initialized
================

The patch simply changes the 'var' parameters to 'out' parameters.

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Reply by email

Joost van der Sluis
to Graeme Geldenhuys

Op vrijdag 27-03-2009 om 12:55 uur [tijdzone +0200], schreef Graeme Geldenhuys:

Show quoted text 13 lines
Hi, Please find attached a minor patch that removes the following compiler hints when TRegexEngine.Parse(...) is used. ================ iterator_impl.pas(306,46) Hint: Local variable "LErrorCode" does not seem to be initialized iterator_impl.pas(306,34) Hint: Local variable "LErrorPos" does not seem to be initialized ================ The patch simply changes the 'var' parameters to 'out' parameters.

It surely fixes the warning, but not the problem? Doesn't 'out' generate faster code in this case? And shoudn't the error be always set? To 0 if no error occured or something else if there really is an error?

(I didn't look at the code yet)

Joost.

Reply by email

Graeme Geldenhuys
to Joost van der Sluis
Joost van der Sluis wrote 6 lines
> > The patch simply changes the 'var' parameters to 'out' parameters. It surely fixes the warning, but not the problem? Doesn't 'out' generate faster code in this case? And shoudn't the error be always set? To 0 if no error occured or something else if there really is an error?

Well, I was simply working on the warning issue. I hate compiler warnings or hints in my code. :-) Looking at the Parse() method, it never reads the parameters, it only ever sets them. Hence the idea of using the 'out' parameters.

If the Parse() was successful, it does the following:

    Result := true;
    aErrorPos := 0;
    aErrorCode := recNone;

On any errors, other values are set.

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Reply by email

Joost van der Sluis
to Graeme Geldenhuys

Op vrijdag 27-03-2009 om 14:07 uur [tijdzone +0200], schreef Graeme Geldenhuys:

Show quoted text 13 lines
On Fri, Mar 27, 2009 at 1:57 PM, Joost van der Sluis wrote: >> >> The patch simply changes the 'var' parameters to 'out' parameters. > > It surely fixes the warning, but not the problem? Doesn't 'out' generate > faster code in this case? And shoudn't the error be always set? To 0 if > no error occured or something else if there really is an error? Well, I was simply working on the warning issue. I hate compiler warnings or hints in my code. :-) Looking at the Parse() method, it never reads the parameters, it only ever sets them. Hence the idea of using the 'out' parameters.

Ok, thanks. Comitted in revision 12969.

Joost

Reply by email