|
Thank you Barbara and Scott for pointing out the errors you found. The program using the regex structures has been running just fine for about 5 years.
-----Original Message-----
From: MIDRANGE-L [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Barbara Morris
Sent: Tuesday, October 14, 2014 4:32 PM
To: Midrange Systems Technical Discussion
Subject: Re: Syntax check a string as a valid email address
On 2014-10-14 15:07, Monnier, Gary wrote:
D regex_t DS qualified
D align based(prototype_only)
Unfortunately, RPG's ALIGN keyword doesn't make the data structure exactly the same as the C struct. The C data structure's length is a multiple of its alignment, which is 16 since it contains a pointer. The RPG data structure doesn't have the extra padding at the end, so it's smaller than the C struct. The regex functions expect the full length, and if the additional storage happens to be storage that your program is using, you can get unexpected results from the regex functions and/or from using your fields that happen to be where the regex functions think the end of the struct is.
You could explicitly set the length of the regex_t structure to 640.
Or if you don't want to hard-code the length ...
You could code DIM(1) to get the RPG compiler to define the size of regex_t as a multiple of its alignmen.
D reg DS likeds(regex_t) dim(1)
And then you'd pass reg(1) instead of reg when you do the call.
Or, since you're not actually using the subfields of regex_t, you could keep the calls simple by renaming your regex_t to regex_sub_t and then defining regex_t like this:
D regex_t DS qualified
D align based(prototype_only)
D reg likeds(regex_sub_t) dim(1)
--
Barbara
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list To post a message email: MIDRANGE-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx Before posting, please take a moment to review the archives at http://archive.midrange.com/midrange-l.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.