From 08bf2e54388d51780db85567252d4a31b8ea8573 Mon Sep 17 00:00:00 2001 From: Robb Matzke Date: Fri, 21 Apr 2000 14:27:14 -0500 Subject: [svn-r2177] ./bin/h5vers Version numbers include an annotation string consisting of a sequence of letters and digits and is printed by this script as either: 1.2.3-pre4 version 1.2 release 3 (pre4) Other tools should print version numbers similarly. A `-i annot' switch was added to increment the annotation (the first subsequence of digits is what is incremented, e.g., `pre9' becomes `pre10'). The `-i' switch (with no argument) was changed to increment the annotation string if present, or the release number otherwise. (By the way, it actually took about 30 minutes ;-) --- bin/h5vers | 112 ++++++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 74 insertions(+), 38 deletions(-) diff --git a/bin/h5vers b/bin/h5vers index eefca78..02b7045 100755 --- a/bin/h5vers +++ b/bin/h5vers @@ -22,8 +22,14 @@ use strict; # Without options this program only displays the current version and # doesn't modify any files or create backups. The default is to print -# the version number as a dotted triple like `1.0.24' but with the -# `-v' option the version will be printed as `version 1.0 release 24'. +# the version number like X.Y.Z-A where X is the major version number, +# Y is the minor version number, Z is the release number, and A is +# a short annotation string (the `-' is printed only if A is not empty). +# If the `-v' switch is given the version will be printed like: +# +# version X.Y release Z (A) +# +# The space and parentheses around A are only printed if A is not empty. # # The `-s VERSION' switch will set the version as specified. If the # string contains a dotted triple then it will be used as the version @@ -32,12 +38,19 @@ use strict; # number. If any numbers are missing then zero is assumed. This # allows versions to be specified like `-s "version 2.1 release 8"' or # `-s hdf5-2.1.8.tar.bz2'. If the new version is less than the old -# version then a warning message is generated on standard error. +# version then a warning message is generated on standard error. The +# annotation string, A, is set only if it appears immediately after the +# third number, separated by a dash (e.g., `1.2.3-pre1') or in parentheses +# (e.g., `version 1.2 release 3 (pre1)'). # -# The `-i [major|minor|release]' option increments the major, minor, -# or release (the default) number. If the minor number is incremented -# then the release number is set to zero; if the major number is -# incremented then the minor and release numbers are set to zero. +# The `-i [major|minor|release|annot|last]' option increments the major +# number, minor number, release number, or annotation string. The `last' +# switch increments the annotation string if present, otherwise the +# release number. If the release number is incremented then the annotation +# string is cleared. If the minor number is incremented then the release +# number is set to zero and the annotation string is cleared; if the major +# number is incremented then the minor and release numbers are set to zero +# and the annotation string is cleared. # # If a file is specified then that file is used instead of # ./H5public.h or ./src/H5public.h. @@ -45,7 +58,7 @@ use strict; # If the version number is changed (either `-s' or `-i' was used on # the command line) then the first line of the README file one # directory above the H5public.h file is also modified so it looks -# something like: This is hdf5-1.2.3 currently under development. +# something like: This is hdf5-1.2.3-pre1 currently under development. ############################################################################## sub getvers { @@ -55,6 +68,7 @@ sub getvers { ($vers[0]) = /^\#\s*define\s+H5_VERS_MAJOR\s+(\d+)/m; ($vers[1]) = /^\#\s*define\s+H5_VERS_MINOR\s+(\d+)/m; ($vers[2]) = /^\#\s*define\s+H5_VERS_RELEASE\s+(\d+)/m; + ($vers[3]) = /^\#\s*define\s+H5_VERS_SUBRELEASE\s+\"([^\"]*)\"/m; return @vers; } @@ -63,22 +77,23 @@ sub setvers { $_[0] =~ s/^(\#\s*define\s+H5_VERS_MAJOR\s+)\d+/$1$vers[0]/m; $_[0] =~ s/^(\#\s*define\s+H5_VERS_MINOR\s+)\d+/$1$vers[1]/m; $_[0] =~ s/^(\#\s*define\s+H5_VERS_RELEASE\s+)\d+/$1$vers[2]/m; + $_[0] =~ s/^(\#\s*define\s+H5_VERS_SUBRELEASE\s+\")[^\"]*/$1$vers[3]/m; } sub usage { my ($prog) = $0 =~ /([^\/]+)$/; print STDERR <$file" or die "unable to open $file but backup saved!\n"; @@ -192,8 +217,10 @@ if ($README) { open FILE, $README or die "$README: $!\n"; my @contents = ; close FILE; - $contents[0] = sprintf("This is hdf5-%d.%d.%d currently under development\n", - @newver); + $contents[0] = sprintf("This is hdf5-%d.%d.%d%s %s", + @newver[0,1,2], + $newver[3] eq "" ? "" : "-".$newver[3], + "currently under development\n"); open FILE, ">$README" or die "$README: $!\n"; print FILE @contents; close FILE; @@ -201,9 +228,18 @@ if ($README) { # Print the new version number if ($verbose) { - printf "version %d.%d release %d\n", @newver; + printf("version %d.%d release %d%s\n", @newver[0,1,2], + $newver[3] eq "" ? "" : " (".$newver[3].")"); } else { - printf "%d.%d.%d\n", @newver; + printf("%d.%d.%d%s\n", @newver[0,1,2], + $newver[3] eq "" ? "" : "-".$newver[3]); } exit 0; + +# Because the first line of this file looks like a Bourne shell script, we +# must tell XEmacs explicitly that this is really a perl script. +# +# Local Variables: +# mode:perl +# End: -- cgit v0.12