Rev 255 | Blame | Compare with Previous | Last modification | View Log | RSS feed
#! perl######################################################################### Copyright ( C ) 2004 ERG Limited, All rights reserved## Module name : jats.sh# Module type : Makefile system# Compiler(s) : n/a# Environment(s): jats## Description : Provide varions utility functions to process version# package infrormation.##......................................................................#require 5.006_001;use strict;use warnings;package JatsVersionUtils;our (@ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS, $VERSION);use Exporter;$VERSION = 1.00;@ISA = qw(Exporter);# Symbols to autoexport (:DEFAULT tag)@EXPORT = qw( SplitPackageSplitVersion);#-------------------------------------------------------------------------------# Function : SplitVersion## Description : Extract the various fields from the version number## Inputs : $version - Version data - without project extension## Returns : A list of:# Major, Minor, Patch, Build, RawPatch#sub SplitVersion{my ($version) = @_;my ($major, $minor, $patch ) = split ('\.', $version);## Decode the patch number and extract the build number# Need to know the the length of the user string to decode# Those less than three digits are build 0#my $build = 0;$minor = 0 unless ( $minor );$patch = 0 unless ( $patch );my $raw_patch = $patch;if ( length( $patch) >= 4 ){$build = substr( $patch, -3 ,3);$patch = substr( $patch, 0 ,length($patch)-3);}return ( $major, $minor, $patch, $build, $raw_patch );}#-------------------------------------------------------------------------------# Function : SplitPackage## Description : Split a package name and version into 4 parts## Handle version of the form:# 1) text.suffix# 2) text<space>suffix# 3) text [No suffix]# Assumptions:# The project suffix is not numeric# Versions of the form (nnnnnn).prj are a WIP### Inputs : $1 - Package name# $2 - Package Version Input string## Returns : $0 - Package name# $1 - Version part# $2 - Suffix (project) part# $4 - Reformed Version string#sub SplitPackage{my ($package, $version) = @_;my $rel;my $suf;my $full;## Clean string(s)#$version =~ s~^\s+~~;$version =~ s~\s+$~~;$package =~ s~^\s+~~;$package =~ s~\s+$~~;if ( $version =~ m~^\((.*?)\)([\.]([^.0-9]+))$~ ){$rel = 'WIP';$suf = $3;$suf = '' unless ( $suf );}elsif ( $version =~ m~^(.*?)([\.\s]([^.0-9]+))$~ ){$rel = $1;$suf = $3;$suf = '' unless ( $suf );}else{$rel = $version;$suf = '';}## Generate a full version string# xx.xx.xxxx.prj#$full = $rel;$full .= '.' . $suf if ( $suf );return ( $package, $rel, $suf, $full );}1;