Nathan,

I'm no Perl programmer AT ALL, so take this for what it it worth ($0).

This RE correctly parses a version no. either at the beginning of the string or preceded by a white-space character.

$ echo "10.4.2" | perl -E 'while (<STDIN>) { if ( m/(^|\s)((\d+\.)+\d+)/ ) { $version = $2 ; print $version, "\n" ; last } }'
10.4.2

I modified the RE from the last one I saw you post ($version =~ m/\s([\d\.]+\w?)/m;) to allow for multiple digit fields, to remove the "m" modifier ($ is gone now), and to only allow digits in the last field of the version number.

I don't know all the contortions of version strings you are trying to match, i.e., why you allowed any alphanumeric (including _) for the last field.  This one will match all digits with an optional single letter suffix at the end (i.e., must be at a word boundary).

$ echo "10.4.2A" | perl -E 'while (<STDIN>) { if ( m/(^|\s)((\d+\.)+\d+([a-zA-Z]\b)?)/ ) { $version = $2 ; print $version, "\n" ; last } }'
10.4.2A

Larry Baker
US Geological Survey
650-329-5608
baker@usgs.gov



On 15 Nov 2012, at 8:42 AM, Hjelm, Nathan T wrote:

Committed as r27615. Let me know if there are any more issues.

-Nathan

________________________________________
From: devel-bounces@open-mpi.org [devel-bounces@open-mpi.org] on behalf of Ralph Castain [rhc@open-mpi.org]
Sent: Thursday, November 15, 2012 8:53 AM
To: Open MPI Developers
Subject: Re: [OMPI devel] [OMPI svn] svn:open-mpi r27601 - trunk

Looks fine to me. I would only add one further refinement - I think we should check m4, but add a check in autogen.pl so that if we get nothing useful back from -v (or whatever), then output a warning that we couldn't validate the version and assume it is okay.

I believe the tool will return a non-zero status if the option isn't supported, so we should be able to do this - yes?


On Nov 15, 2012, at 7:48 AM, "Hjelm, Nathan T" <hjelmn@lanl.gov> wrote:

Since the version of m4 that comes with Solaris likely works with all our .m4 files and there is no way to check the version (no --version, -v, -V, or anything from what I can tell) I guess we have no choice but to not check the m4 version.

flex on the other hand we can check. How about this for the new regex (for reference the old one is $version =~ m/\s([\d\w\.]+)$/m; -- matching a version at the end of the line):

$version =~ m/\s([\d\.]+\w?)/m;

It works with Apple's flex and still works with glibtoolize, autoconf, and automake.

 Searching for autoconf
   Found autoconf version 2.69; checking version...
     Found version component 2 -- need 2
     Found version component 69 -- need 65
   ==> ACCEPTED
 Searching for libtoolize
libtoolize not found
 Searching for glibtoolize
   Found glibtoolize version 2.4.2; checking version...
     Found version component 2 -- need 2
     Found version component 4 -- need 2
   ==> ACCEPTED
 Searching for automake
   Found automake version 1.12.2; checking version...
     Found version component 1 -- need 1
     Found version component 12 -- need 11
   ==> ACCEPTED
 Searching for flex
   Found flex version 2.5.35; checking version...
     Found version component 2 -- need 2
     Found version component 5 -- need 5
     Found version component 35 -- need 35
   ==> ACCEPTED
 Searching for m4
   Found m4 version 1.4.6; checking version...
     Found version component 1 -- need 1
     Found version component 4 -- need 4
     Found version component 6 -- need 16
   ==> Too low!  Skipping this version
 Searching for gm4
   Found gm4 version 1.4.16; checking version...
     Found version component 1 -- need 1
     Found version component 4 -- need 4
     Found version component 16 -- need 16
   ==> ACCEPTED


-Nathan

________________________________________
From: devel-bounces@open-mpi.org [devel-bounces@open-mpi.org] on behalf of Paul Hargrove [phhargrove@lbl.gov]
Sent: Wednesday, November 14, 2012 7:37 PM
To: Larry Baker
Cc: Open MPI Developers
Subject: Re: [OMPI devel] [OMPI svn] svn:open-mpi r27601 - trunk

Larry,

I just wanted to speak up quickly to be sure nobody used your example to "fix" the Mac OS problem and thereby break Solaris instead.  No personal attack/affront was intended.

-Paulhttps://mymail.lanl.gov/owa/?ae=PreFormAction&t=IPM.Note&a=ReplyAll&id=RgAAAAD3GfjXt9HDTI902%2b63W1IcBwCuRfL1X%2babT5m7NFXoIdcVAAAAxVZxAACuRfL1X%2babT5m7NFXoIdcVAAAa4RQFAAAJ#

On Wed, Nov 14, 2012 at 7:10 PM, Larry Baker <baker@usgs.gov<mailto:baker@usgs.gov>> wrote:
Paul,

1) I wasn't trying to solve the --version issue, only the parsing of the response.
2) I assumed from the initial e-mail that the broken parser was in a Perl script.  I'm not a Perl person, so I wrote the example regular expression parser in sed.

These commands were done on my Mac OS X 10.6 system.  I have no idea where the apps came from.  I know the sed, at least, does not recognize regular expressions documented for GNU sed (such as \< \> for begin/end word).  Maybe it is a BSD sed?

I was just trying to illustrate how to fix the broken parsing of Ralph's "flex --version".  Assuming the RE parser I wrote is satisfactory, it would have to be adapted to fit in the framework, i.e., it has to be portable.

Larry Baker
US Geological Survey
650-329-5608<tel:650-329-5608>
baker@usgs.gov<mailto:baker@usgs.gov>



On 14 Nov 2012, at 5:41 PM, Paul Hargrove wrote:

On Wed, Nov 14, 2012 at 6:26 PM, Larry Baker <baker@usgs.gov<mailto:baker@usgs.gov>> wrote:
m4 --version | sed -n -E -e '1s/^.*[^A-Za-z0-9_-]?([0-9]+[.][0-9]+[.][0-9]+)[^A-Za-z0-9_-]?.*$/\1/p'


There are STILL problems with this approach as it is TWICE specific to GNU software:

1) M4 on OpenBSD (maybe others) doesn't support a "--version" flag:
$ m4 --version | sed -n -E -e '1s/^.*[^A-Za-z0-9_-]?([0-9]+[.][0-9]+[.][0-9]+)[^A-Za-z0-9_-]?.*$/\1/p'
m4: unknown option -- -
usage: m4 [-gPs] [-Dname[=value]] [-d flags] [-I dirname] [-o filename]
      [-t macro] [-Uname] [file ...]

2) sed on Solaris (maybe others) doesn't support a "-E" flag:
$ m4 --version | sed -n -E -e '1s/^.*[^A-Za-z0-9_-]?([0-9]+[.][0-9]+[.][0-9]+)[^A-Za-z0-9_-]?.*$/\1/p'
/bin/sed: illegal option -- E

-Paul

--
Paul H. Hargrove                          PHHargrove@lbl.gov<mailto:PHHargrove@lbl.gov>
Future Technologies Group
Computer and Data Sciences Department     Tel: +1-510-495-2352<tel:%2B1-510-495-2352>
Lawrence Berkeley National Laboratory     Fax: +1-510-486-6900<tel:%2B1-510-486-6900>

_______________________________________________
devel mailing list
devel@open-mpi.org<mailto:devel@open-mpi.org>
http://www.open-mpi.org/mailman/listinfo.cgi/devel




--
Paul H. Hargrove                          PHHargrove@lbl.gov<mailto:PHHargrove@lbl.gov>
Future Technologies Group
Computer and Data Sciences Department     Tel: +1-510-495-2352
Lawrence Berkeley National Laboratory     Fax: +1-510-486-6900

_______________________________________________
devel mailing list
devel@open-mpi.org
http://www.open-mpi.org/mailman/listinfo.cgi/devel


_______________________________________________
devel mailing list
devel@open-mpi.org
http://www.open-mpi.org/mailman/listinfo.cgi/devel

_______________________________________________
devel mailing list
devel@open-mpi.org
http://www.open-mpi.org/mailman/listinfo.cgi/devel