home *** CD-ROM | disk | FTP | other *** search
- /*
- Bump.rexx - by Larry Phillips, 1990
- Bump a source file by 1 revision or specify version and revsion
-
- Usage: Bump filename [version] [revision]
- If only filename specified, bump revision and perhaps version
- If filename and version specified, bump version, make revision 00
- If all three specified, set to given values
-
- If the revision is greater than 99, the revision will be set to 00, and
- the version will be bumped by 1.
-
- Source file must contain a lines with the strings 'VERSION' and 'REVISION',
- each on a separate line, and each line having a numeric value in the range
- 0-99 somewhere after the string. Additionally, the numeric value must be
- followed by at least one space. Use a comment if necessary.
-
- The lines must be within the first 1024 bytes of the beginning of the file.
-
- Examples of valid lines in source:
-
- #define VERSION 0 /**/
- #define REVISION 01 /**/
-
- VERSION EQU 5 ;
- REVISION EQU 10 ;
-
- */
-
- parse arg filename version revision
-
- if filename = '' | filename = '?' then call usage
-
- if version >= 0 then doversion = 1
- if version >= 0 & revision = '' then revision = 0
-
- if open(infile,filename,'a') >0 then do
- call seek(infile,0,'b')
- inline = readch(infile,1024)
-
- rev = pos('REVISION',inline)
- if rev > 0 then do
- revstring = substr(inline,rev,pos('0a'x,inline,rev)-rev)
- do i=2 to 3
- if word(revstring,i) < 100 & word(revstring,i) ~< 0 then do
- revoffset = rev + wordindex(revstring,i) - 2
- revstring = word(revstring,i)
- if revision = '' then revision = revstring + 1
- if revision > 99 then revision = 0
- if length(revision) = 1 then revision = '0' || revision
- call seek(infile,revoffset,'b')
- call writech(infile,strip(revision) || ' ')
- end
- end
- end
-
- if revision = 0 | doversion = 1 then do
- ver = pos('VERSION',inline)
- if ver > 0 then do
- verstring = substr(inline,ver,pos('0a'x,inline,ver)-ver)
- do i=2 to 3
- if word(verstring,i) < 100 & word(verstring,i) ~< 0 then do
- veroffset = ver + wordindex(verstring,i) - 2
- verstring = word(verstring,i)
- if version = '' then version = verstring + 1
- if version > 99 then version = 0
- call seek(infile,veroffset,'b')
- call writech(infile,strip(version) || ' ')
- end
- end
- end
- end
- end
-
- else
- say 'Cannot open' filename
- exit 0
-
- usage:
- do i = 5 to 9
- say sourceline(i)
- end
- call writech(stdout,'Want more help? (Y/N) ')
- temp = readch(stdin,10)
- if verify(temp,'yY','match') > 0 then
- do i = 9 to 25
- say sourceline(i)
- end
- exit 0
-