home *** CD-ROM | disk | FTP | other *** search
- ==========================
- amiga.sw/programs #656, from langeveld, 3118 chars, Tue Jul 30 04:23:48 1991
- There is/are comment(s) on this message.
- --------------------------
- /* makevers.rexx
- **
- ** $VER: MakeVers version 1.0 (30.07.1991)
- ** =======================================
- **
- ** A quickie "bumprev" utility. Finds the first line with "$VER: " in it,
- ** parses it, and updates the version and/or revision number and the date,
- ** based on the significant number of digits specified on the command line.
- ** Since it leaves the rest of the line alone, this can be used with just
- ** about any file, even this one (since it only does the first line!)
- **
- ** Usage: makevers <filename> <digits> [<force-version>]
- **
- ** Examples: MakeVers MyHeader.h 1
- ** Makevers MyApp.c 2 1.0
- ** Makevers MyProg.asm 3
- **
- ** Willy Langeveld, July 1991
- **
- */
- parse arg filename ndigits forceversion .
-
- if filename = "" then do
- say "Usage: bumprev <filename> <# digits>"
- exit 20
- end
-
- if ndigits = "" then ndigits = 1
- /*
- * Read the file in
- */
- if ~open(fh, filename, "R") then do
- say "File " filename " does not exist"
- exit 20
- end
-
- do i = 1
- str.i = readln(fh)
- if eof(fh) then leave
- end
- call close(fh)
- nlines = i - 1
- /*
- * Now write the file back out
- */
- if ~open(fh, filename, "W") then do
- say "File " filename " can't be modified"
- exit 20
- end
- /*
- * linefound will be set to 0 if the line is found
- */
- linefound = 20
- do i = 1 to nlines
- string = str.i
- if (index(string, "$VER: ") ~= 0) & (linefound ~= 0) then do
- /*
- * This is a good candidate for the string.
- */
- parse var string first "$VER: " name "(" date ")" last
- n = words(name)
- if forceversion = "" then do
- fullversion = subword(name, n, 1)
- if datatype(fullversion, numeric) then do
- /*
- * This is it, update the revision number, truncate to right number of digits
- */
- fullversion = fullversion + 10**(-ndigits)
- parse var fullversion version "." revision
- revision = substr(revision, 1, ndigits, "0")
- fullversion = version || "." || revision
- end
- else do
- /*
- * Datatype seems to not be numeric! Maybe better write this one out as
- * is and continue looking.
- */
- call writeln(fh, string)
- iterate i
- end
- end
- else fullversion = forceversion
- /*
- * Get the date in standard format
- */
- thedate = date(o)
- parse var thedate year "/" month "/" day .
- if year > 77 then year = year + 1900
- else year = year + 2000
- /*
- * Assemble the string
- */
- newstr = first || "$VER: " || subword(name, 1, n - 1)
- newstr = newstr || " " || fullversion || " "
- newstr = newstr || "(" || day || "." || month || "." || year || ")"
- newstr = newstr || last
-
- linefound = 0
- /*
- * Confirm update
- */
- say newstr
- end
- else do
- newstr = string
- end
-
- call writeln(fh, newstr)
- end
- /*
- * All done. If no line found, say so.
- */
- call close(fh)
-
- if linefound ~= 0 then say "No version string found"
-
- exit linefound
-
-