Sign in Join

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

Mailing lists / fpc-pascal / 2016-04

FCL maskutils incompatible with Delphi

9 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

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

silvioprog

Hello,

Last week, a member of Lazarus Brazillian group reported a problem related to the MaskUtils unit. His message (adapted from pt-BR to en-US) was:

*"Good afternoon.*

*I need help with FormatMaskText, because it doesn't work properly with the same code that works fine on Delphi".*

His refactored example was:

=== code ===

uses maskutils;
const MY_UNMASKED_VALUE = 'H1H357K808K44616YK8720';
begin
  WriteLn(FormatMaskText('!>cccccc\-ccccc\-ccccc-cccccc;0;*',
MY_UNMASKED_VALUE));
  // uncomment the like below and enjoy the crash
  //WriteLn(FormatMaskText('!>CCCCCC\-CCCCC\-CCCCC-CCCCCC;0;_',
MY_UNMASKED_VALUE));
end.

=== /code ===

The expected value: H1H357-K808K-44616-YK8720.

The returned value: H1H357-K808K-44616-******.

If you uncomment the code in the last writeln, it will raise the generic "FormatMaskText function failed!" error.

However, this attached patch was sent from another member and it seems fix the problem.

Can I open an issue at bugtracker related to this problem?

Thank you!

Silvio Clécio

Reply by email

Bart
to silvioprog
silvioprog wrote 7 lines
The expected value: H1H357-K808K-44616-YK8720. The returned value: H1H357-K808K-44616-******. If you uncomment the code in the last writeln, it will raise the generic "FormatMaskText function failed!" error.

The issue you describe looks like http://bugs.freepascal.org/view.php?id=30020

There is also a bugreport about crashes in FormatMaskText. http://bugs.freepascal.org/view.php?id=28201

And there is also a thread in this ML about a new implementation of the MaskUtils unit.

Bart

Reply by email

silvioprog
to Bart
Bart wrote 19 lines
On 4/19/16, silvioprog wrote: > The expected value: H1H357-K808K-44616-YK8720. > > The returned value: H1H357-K808K-44616-******. > > If you uncomment the code in the last writeln, it will raise the generic > "FormatMaskText function failed!" error. > The issue you describe looks like http://bugs.freepascal.org/view.php?id=30020 There is also a bugreport about crashes in FormatMaskText. http://bugs.freepascal.org/view.php?id=28201 And there is also a thread in this ML about a new implementation of the MaskUtils unit.

Yes, he (Handlei) reported it at Brazillian group, but he didn't tell us that had already reported patch was sent from another member, and he told us that it fix the current maskutils.pp unit, I just sent it here as they asked me.

Can I send this patch to #30020 or just wait for new MaskUtils implementation?

Silvio Clécio

Reply by email

Bart
to silvioprog
silvioprog wrote 8 lines
Yes, he (Handlei) reported it at Brazillian group, but he didn't tell us that had already reported that at bugtracker. The patch was sent from another member, and he told us that it fix the current maskutils.pp unit, I just sent it here as they asked me. Can I send this patch to #30020 or just wait for new MaskUtils implementation?

Send it to the bugreport anyway.
The new implementation I wrote is ot going to be implemented soon (see related thread for reasons why).

Bart

Reply by email

Andreas Klausmann
to Bart

Hi,
how can I resolve hostnames in a local (private) network under linux? Both gethostbyname() and THostResolver work fine for google.com etc, but not for local hostnames like testhost.local.
Testhost is reachable from console by hostname: ping testhost.local -> success (resolved in background by avahi)

gethostbyname() works fine under Windows even for LAN resolution (resolved in background by Netbios name service).

Currently I'm working on Ubuntu 15.10 on a raspberry, fpc 3.0.

Best regards!
Andreas

Reply by email

Michael Van Canneyt
to Andreas Klausmann
Andreas Klausmann wrote 11 lines
Hi, how can I resolve hostnames in a local (private) network under linux? Both gethostbyname() and THostResolver work fine for google.com etc, but not for local hostnames like testhost.local. Testhost is reachable from console by hostname: ping testhost.local -> success (resolved in background by avahi) gethostbyname() works fine under Windows even for LAN resolution (resolved in background by Netbios name service). Currently I'm working on Ubuntu 15.10 on a raspberry, fpc 3.0.

You will need to use the C library routines for this. The FPC native implementation does not work with avahi or local DNS caches.

Michael.

Reply by email

Graeme Geldenhuys
to Andreas Klausmann: how can I resolve hostnames in a local (private) network under linux? Both…
Andreas Klausmann wrote
Testhost is reachable from console by hostname: ping testhost.local -> success (resolved in background by avahi)

Not sure, but you could always create a wrapper function or class around the OS 'ping' command, or nslookup. Read the program results and let your wrapper function or class return that as the resolved name.

Regards,
Graeme

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp

Reply by email

Andreas Klausmann
to Marco van de Voort: In our previous episode, Michael Van Canneyt said: (which is in unit cnetdb in somewhat…

Thanks, cnetdb.gethostbyname() works fine (at least on my raspberry). :) Creating a wrapper function is recently my work-around for an actual ping component (since linux doesn't seem to have a corresponding component like ping.dll and I want to ping as non-root)

Marco van de Voort wrote 9 lines
In our previous episode, Michael Van Canneyt said: > You will need to use the C library routines for this. (which is in unit cnetdb in somewhat recent FPC's) _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply by email