On Sat, Aug 11, 2007 at 11:53:06PM +0200, Jean-Marc Lasgouttes wrote:

> Enrico Forestieri <[EMAIL PROTECTED]> writes:
> 
> > Please find attached a revised patch. This time I checked that dist
> > actually works.
> 
> Could you please streamline the code below? 
> 
> +[lyx_major=`echo $PACKAGE_VERSION | sed -e 's/[[.]].*//'`
> + lyx_minor=`echo $PACKAGE_VERSION | sed -e "s/^$lyx_major//" -e 's/^.//'`
> + lyx_release=$lyx_minor
> + lyx_minor=`echo $lyx_release | sed -e 's/[[.]].*//'`
> + lyx_release=`echo $lyx_release | sed -e "s/^$lyx_minor//" -e 's/^.//'`
> + lyx_patch=$lyx_release
> + lyx_release=`echo $lyx_patch | sed -e 's/[[^0-9]].*//'`
> + lyx_patch=`echo $lyx_patch | sed -e "s/^$lyx_release//" -e 's/^[[.]]//' -e 
> 's/[[^0-9]].*//'`
> 
> At least lines 2 and 3 do not look right.

Please, explain what doesn't look right. Every line looks Ok to me.
It is stripping the first digit from a string of type x.whatever,
so I carry along "whatever" assigning it to a temp var, but instead
of a really temp var I use another one that will be overwritten later.
In the last steps I account for the fact that "whatever" could be
"0svn", or "0pre", or something like that.

> But what is it doing,
> exactly?

Given PACKAGE_VERSION=1.4.5.2
After line 1: lyx_major=1
After line 2: lyx_minor=4.5.2
After line 3: lyx_release=4.5.2
After line 4: lyx_minor=4
After line 5: lyx_release=5.2
After line 6: lyx_patch=5.2
After line 7: lyx_release=5
After line 8: lyx_patch=2

Example 1:
Given PACKAGE_VERSION=1.6.0 or PACKAGE_VERSION=1.6.0svn we get
lyx_major=1
lyx_minor=6
lyx_release=0
lyx_patch=0

Example 2:
Given PACKAGE_VERSION=1.4.5.2 or PACKAGE_VERSION=1.4.5.2svn we get
lyx_major=1
lyx_minor=4
lyx_release=5
lyx_patch=2

I don't know what else I could explain, and anyway the code looks
quite strightforward to me. Please find attached a shell script
doing exactly that. You can experiment by calling it as
$ setversion.sh <version_string_here>
Take into account the fact that version string should have at least
three fields, i.e. it should be something like x.y.z

-- 
Enrico

Attachment: setversion.sh
Description: Bourne shell script

Reply via email to