Sign in Join

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

Mailing lists / fpc-devel / 2010-03

StrUtils unit (is poorly implemented)

14 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

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

Flávio Etrusco

Hello,
are StrUtils just for Delphi compatibility or are they meant for "real use"? In the first case, is there an alternative unit? In the second, would simple patches to implement "AnsiStartsStr" and "AnsiEndsStr" with CompareMem (for starters) be accepted?

Best regards,
Flávio

Reply by email

Michael Van Canneyt
to Flávio Etrusco
Flávio Etrusco wrote 5 lines
Hello, are StrUtils just for Delphi compatibility or are they meant for "real use"? In the first case, is there an alternative unit? In the second, would simple patches to implement "AnsiStartsStr" and "AnsiEndsStr" with CompareMem (for starters) be accepted?

They would be accepted.

Michael.

Reply by email

Jonas Maebe
to Michael Van Canneyt
Michael Van Canneyt wrote 9 lines
On Sun, 28 Mar 2010, Flávio Etrusco wrote: > are StrUtils just for Delphi compatibility or are they meant for > "real use"? > In the first case, is there an alternative unit? In the second, would > simple patches to implement "AnsiStartsStr" and "AnsiEndsStr" with > CompareMem (for starters) be accepted? They would be accepted.

If accompanied by tests :)

Jonas

Reply by email

Carsten Bager
to Jonas Maebe

I have a program that rune continuously. Now we have had a shift from winter to summer time. I could not get my program to adopt the right time before I stopped and restarted the program.
Is there a function I can call (every hour shift) so I am sure that my program always gets the right local time

Carsten

Reply by email

Alexander Bauer
to Carsten Bager

I've exact the same Problem.
It seems that the daylight saving offset is only calculated once on program start.
Is there a method to update that ?

Alex

Carsten Bager wrote 13 lines
I have a program that rune continuously. Now we have had a shift from winter to summer time. I could not get my program to adopt the right time before I stopped and restarted the program. Is there a function I can call (every hour shift) so I am sure that my program always gets the right local time Carsten _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply by email

Michael Van Canneyt
to Alexander Bauer
Alexander Bauer wrote
I've exact the same Problem. It seems that the daylight saving offset is only calculated once on program start. Is there a method to update that ?

No. The InitLocalTime procedure is private to the implementation of the unix unit. We can make it public, please post a bugreport for this.

Michael.

Reply by email

Carsten Bager
to Michael Van Canneyt
No. The InitLocalTime procedure is private to the implementation of the unix unit. We can make it public, please post a bugreport for this.

Do you know if it would be nessery to call DoneLocalTime before caling InitLocalTime.

Carsten
Med venlig hilsen
Carsten Bager

BEAS A/S
Brørupvænget 10
DK-7650 Bøvlingbjerg
Tlf. : +45 9788 5222 Fax : +45 9788 5434
www.beas.dk

Reply by email

Michael Van Canneyt
to Carsten Bager
Carsten Bager wrote 5 lines
> No. The InitLocalTime procedure is private to the implementation of the unix > unit. We can make it public, please post a bugreport for this. Do you know if it would be nessery to call DoneLocalTime before caling InitLocalTime.

As far as I can see not; the routines use reallocmem.

Michael.

Reply by email

Flávio Etrusco
to Jonas Maebe: If accompanied by tests :) Jonas

2010/3/29 Jonas Maebe :

Show quoted text 15 lines
On 29 Mar 2010, at 08:57, Michael Van Canneyt wrote: > On Sun, 28 Mar 2010, Flávio Etrusco wrote: > >> are StrUtils just for Delphi compatibility or are they meant for "real >> use"? >> In the first case, is there an alternative unit? In the second, would >> simple patches to implement "AnsiStartsStr" and "AnsiEndsStr" with >> CompareMem (for starters) be accepted? > > They would be accepted. If accompanied by tests :)

First question: is there a rule for test project names? Is tstrutils1.pp ok? Do I have to register the file somewhere? (couldn't find anything about it on the wiki)

Second question: In current code, when ASubText is '', AnsiStartStr returns False and
AnsiEndsStr returns True. Is this correct?

Best regards,
Flávio

Reply by email

Alexander Bauer
to Michael Van Canneyt: No. The InitLocalTime procedure is private to the implementation of the unix unit. We can…
GetLocalTimezone(fptime);

This method is pulic and is enough to calculate the new daylight saving offset.
Thanks for the hint.

Alex

Michael Van Canneyt wrote 18 lines
On Mon, 29 Mar 2010, Alexander Bauer wrote: > I've exact the same Problem. > It seems that the daylight saving offset is only calculated once on > program start. > Is there a method to update that ? No. The InitLocalTime procedure is private to the implementation of the unix unit. We can make it public, please post a bugreport for this. Michael. _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply by email

Jonas Maebe
to Flávio Etrusco: 2010/3/29 Jonas Maebe : First question: is there a rule for test project names? Is…
Flávio Etrusco wrote 7 lines
2010/3/29 Jonas Maebe : > > If accompanied by tests :) First question: is there a rule for test project names? Is tstrutils1.pp ok? Do I have to register the file somewhere? (couldn't find anything about it on the wiki)

The name doesn't matter, since renaming a file is easy (it will be renamed by us to "tw<mantis bug nr>.pp"). The only requirement for the test is that it is a plain console app that returns a 0 exit code if successful, and a non-zero exit code if it fails.

Second question: In current code, when ASubText is '', AnsiStartStr returns False and AnsiEndsStr returns True. Is this correct?

I don't know.

Jonas

Reply by email

Marco van de Voort
to Flávio Etrusco: 2010/3/29 Jonas Maebe : First question: is there a rule for test project names? Is…

In our previous episode, Fl?vio Etrusco said:

Second question: In current code, when ASubText is '', AnsiStartStr returns False and AnsiEndsStr returns True. Is this correct?

If the string='' then ansistartsstr returns true and endstr false

if they string'' then both return false.

I'm using the Dutch locale in windows 7.

Warning: one of the reasons I never bothered with the ansi* routines is:
- they are supposed to be locale dependant in their comparisons.
- they have support for mbcs versions of eastern locale codepages, where chars are not one byte.

For these reasons, I left them high and dry till we have a bit more direction on unicode. (which might skip them all together)

Reply by email

Flávio Etrusco
to Marco van de Voort
Marco van de Voort wrote 9 lines
In our previous episode, Fl?vio Etrusco said: > > Second question: In current code, when ASubText is '', AnsiStartStr > returns False and > AnsiEndsStr returns True. Is this correct? If the string='' then ansistartsstr returns true and endstr false if they string'' then both return false.

I don't quite follow. This is what I get:

AnsiStartsStr('', '') = FALSE
AnsiStartsStr('', 'aaa') = FALSE
AnsiEndsStr('', '') = TRUE
AnsiEndsStr('', 'ab') = TRUE

Should I retain this behavior or what?

Show quoted text 6 lines
I'm using the Dutch locale in windows 7. Warning: one of the reasons I never bothered with the ansi* routines is: - they are supposed to be locale dependant in their comparisons. - they have support for mbcs versions of eastern locale codepages, where   chars are not one byte.

Sure. I know this would be relevant for sorting, but are there a locale were different byte sequences should be considered equal? Actually I guess that there are (like ae vs æ?), but anyway using CompareMem is better than the current implementation.

For these reasons, I left them high and dry till we have a bit more direction on unicode. (which might skip them all together)

I imagined that.

Best regards,
Flávio

Reply by email

Flávio Etrusco
to Flávio Etrusco

Issue tracker:
http://bugs.freepascal.org/view.php?id=16153

2010/3/30 Flávio Etrusco :

Show quoted text 42 lines
On Tue, Mar 30, 2010 at 6:04 AM, Marco van de Voort wrote: > In our previous episode, Fl?vio Etrusco said: >> >> Second question: In current code, when ASubText is '', AnsiStartStr >> returns False and >> AnsiEndsStr returns True. Is this correct? > > If the string='' then ansistartsstr returns true and endstr false > > if they string'' then both return false. I don't quite follow. This is what I get: AnsiStartsStr('', '')      = FALSE AnsiStartsStr('', 'aaa') = FALSE AnsiEndsStr('', '')       = TRUE AnsiEndsStr('', 'ab')    = TRUE Should I retain this behavior or what? > I'm using the Dutch locale in windows 7. > > Warning: one of the reasons I never bothered with the ansi* routines is: > - they are supposed to be locale dependant in their comparisons. > - they have support for mbcs versions of eastern locale codepages, where >   chars are not one byte. Sure. I know this would be relevant for sorting, but are there a locale were different byte sequences should be considered equal? Actually I guess that there are (like ae vs æ?), but anyway using CompareMem is better than the current implementation. > For these reasons, I left them high and dry till we have a bit more > direction on unicode. (which might skip them all together) I imagined that. Best regards, Flávio

Reply by email