Enclosed you find the latest version of "updateEntityValues.rex" that should go into the tools
directory.
Ad revisions for the documentation: there is a little catch here. When updating
"${book}/en-US/${book}.ent" and then checking in the changed docs the latest revision will be of the
just checked-in version, although the documentation itself has not changed, just the file with the
entity values.
To become able to still fetch a meaningful revision value, the program now does
two things:
* it has a new switch "-r revision": this revision number should be the one
received when creating
"branches/5.0.0" for preparing the release,
* it will ignore the revision information of the "${book}/en-US/${book}.ent"
file
Running a test on the current books in branches/5.0.0 yields (12537 is the revision number when we
created branches/5.0.0):
F:\work\svn\oorexx\docs\branches\5.0.0\tools>*updateEntityValues.rex -r 12537 -y
"2022" -e "2022.12.24" ..*
ooconsole........ YEAR: 2014-2022 EDITION: 2022.12.20
oodguide......... YEAR: 2012-2022 EDITION: 2022.12.20
oodialog......... YEAR: 2005-2022 EDITION: 2022.12.20
oorexxbuild...... YEAR: 2005-2022 EDITION: 2022.12.20
oosqlite......... YEAR: 2005-2022 EDITION: 2022.12.20
ootest........... YEAR: 2005-2022 EDITION: 2022.12.20
orxncurses....... YEAR: 2005-2022 EDITION: 2022.12.20
readme........... YEAR: 2005-2022 EDITION: 2022.12.20
rexxapi.......... YEAR: 2005-2022 EDITION: 2022.12.20
rexxextensions... YEAR: 2005-2022 EDITION: 2022.12.20
rexxgtk.......... YEAR: 2005-2017 EDITION: 1
rexxpg........... YEAR: 2005-2022 EDITION: 2022.12.20
rexxref.......... YEAR: 2005-2022 EDITION: 2022.12.20
rxftp............ YEAR: 2005-2022 EDITION: 2022.12.20
rxmath........... YEAR: 2005-2022 EDITION: 2022.12.20
rxsock........... YEAR: 2005-2022 EDITION: 2022.12.20
unixextensions... YEAR: 2005-2022 EDITION: 2022.12.20
winextensions.... YEAR: 2005-2022 EDITION: 2022.12.20
F:\work\svn\oorexx\docs\branches\5.0.0\tools>*updateEntityValues.rex ..*
ooconsole........ YEAR: "2014-2022" VERSION: "1.0.0" EDITION: "2022.12.24 (last
revised on 20140610 with r10162)"
oodguide......... YEAR: "2012-2022" VERSION: "4.2.4" EDITION: "2022.12.24 (last
revised on 20140728 with r10338)"
oodialog......... YEAR: "2005-2022" VERSION: "4.2.4" EDITION: "2022.12.24 (last
revised on 20220402 with r12362)"
F:\work\svn\oorexx\docs\branches\5.0.0\oorexx\en-US\oorexx.ent: does not
exist, skipping ...
oorexxbuild...... YEAR: "2005-2022" VERSION: "5.0.0" EDITION: "2022.12.24 (last
revised on 20220701 with r12463)"
oosqlite......... YEAR: "2005-2022" VERSION: "1.0.0" EDITION: "2022.12.24 (last
revised on 20140313 with r9954)"
ootest........... YEAR: "2005-2022" VERSION: "5.0.0" EDITION: "2022.12.24 (last
revised on 20181122 with r11523)"
orxncurses....... YEAR: "2005-2022" VERSION: "5.0.0" EDITION: "2022.12.24 (last
revised on 20220704 with r12464)"
readme........... YEAR: "2005-2022" VERSION: "5.0.0" EDITION: "2022.12.24 (last
revised on 20200712 with r12097)"
rexxapi.......... YEAR: "2005-2022" VERSION: "5.0.0" EDITION: "2022.12.24 (last
revised on 20220903 with r12507)"
rexxextensions... YEAR: "2005-2022" VERSION: "5.0.0" EDITION: "2022.12.24 (last
revised on 20220619 with r12444)"
rexxgtk.......... YEAR: "2005-2022" VERSION: "5.0.0" EDITION: "2022.12.24 (last
revised on 20220704 with r12464)"
rexxpg........... YEAR: "2005-2022" VERSION: "5.0.0" EDITION: "2022.12.24 (last
revised on 20220624 with r12454)"
rexxref.......... YEAR: "2005-2022" VERSION: "5.0.0" EDITION: "2022.12.24 (last
revised on 20221024 with r12526)"
rxftp............ YEAR: "2005-2022" VERSION: "5.0.0" EDITION: "2022.12.24 (last
revised on 20210319 with r12205)"
rxmath........... YEAR: "2005-2022" VERSION: "5.0.0" EDITION: "2022.12.24 (last
revised on 20170214 with r11204)"
rxsock........... YEAR: "2005-2022" VERSION: "5.0.0" EDITION: "2022.12.24 (last
revised on 20220722 with r12485)"
F:\work\svn\oorexx\docs\branches\5.0.0\tools\en-US\tools.ent: does not
exist, skipping ...
unixextensions... YEAR: "2005-2022" VERSION: "5.0.0" EDITION: "2022.12.24 (last
revised on 20210319 with r12205)"
winextensions.... YEAR: "2005-2022" VERSION: "5.0.0" EDITION: "2022.12.24 (last
revised on 20220524 with r12416)"
Did not create a pdf book, as I urgently need to leave for today unfortunately. The revision string
gets only created and appended, if the "-r" switch is supplied. To change the revision string just
change the return value from the routine getRevInfo() at the very end.
---rony
/* purpose: - allow updating the entity values for YEAR, VERSION and EDITION
in the appropriate books (${book}/en-US/${book].ent)
usage: - no argument: show the current values of the entites YEAR, VERSION
and EDITION for each book
- arguments: [-r revisionNumber] [-y "year string"] [-v "version string"] [-e "edition string"] [directory]
... revisionNumber: do not honor revisionNumber or higher;
use revisionNumber of branches-creation, e.g. 12537 for branches/5.0.0 on 2022-12-14
date: 2022-12-21
version: 0.02
*/
-- using .sysCargs as this supplies the arguments like the shell:
-- updateEntityValues.rex -y "2022" ..
-- updateEntityValues.rex -v "5.0.0 -> 5.1.0" ..
-- updateEntityValues.rex -e "2022.12.24" ..
-- updateEntityValues.rex -r 12537 -e "2022.12.24" ..
call analyzeArgs
if .argYear | .argVersion | .argEdition then -- update any of the entity values?
do
call updateEntityValues
end
exit
analyzeArgs: procedure
pkgLocal=.context~package~local
pkgLocal~dirSep=.rexxInfo~directorySeparator
argNum=.sysCargs~items
if argNum<2 then -- show values: either no argument (currDir) or directory argument
do
if argNum=0 then pkgLocal~dir="."
else pkgLocal~dir=.sysCArgs[1]
if \sysFileExists(.dir) then
do
.error~say("directory" pp(.dir) "does not exist, aborting ...")
exit -1
end
call showEntityValues
exit 0
end
if argNum//2=1 then -- uneven, last argument is the directory argument
do
pkgLocal~dir=.sysCargs[argNum] -- assign directory argument
if \sysFileExists(.dir) then
do
.error~say("directory" pp(.dir) "does not exist, aborting ...")
exit -2
end
argNum-=1 -- now only switch/value pairs if any
end
pkgLocal~argYear =.false -- default values
pkgLocal~argVersion=.false
pkgLocal~argEdition=.false
pkgLocal~argRelease=.false
do i=1 to argNum by 2
select case .sysCargs[i]
when "-r" then -- latest year value: if alreay a year range, then change the upper year to the supplied one
do
pkgLocal~releaseValue =.sysCargs[i+1]~strip
pkgLocal~argRelease =.true
end
when "-y" then -- latest year value: if alreay a year range, then change the upper year to the supplied one
do
pkgLocal~yearValue =.sysCargs[i+1]~strip
pkgLocal~argYear =.true
end
when "-v" then -- replace for all
do
parse value .sysCargs[i+1] with currValue "->" newValue
if newValue<>"" then
do
pkgLocal~versionCurrValue=currValue~strip
pkgLocal~versionNewValue =newValue~strip
pkgLocal~argVersion =.true
end
end
when "-e" then
do
pkgLocal~editionValue=.sysCargs[i+1] -- replace for all plus add book's revision information
pkgLocal~argEdition =.true
end
otherwise
say "unknown switch" pp(.sysCargs[i]) "with value" pp(.sysCargs[i+1])", aborting ..."
exit -3
end
end
return
::routine showEntityValues -- show the entity values YEAR, VERSION and EDITION of all books
tgtDir=.dir || .dirSep
call sysFileTree tgtDir"*", "dirs.", "DO"
do i=1 to dirs.0
bookPath=dirs.i
book=FileSpec('name',dirs.i) -- get directory assume it is a book
-- say "... book:" pp(book) "bookPath="pp(bookPath)
entFile=bookPath || .dirSep || "en-US" || .dirSep || book".ent"
-- say "... book:" pp(book) "entFile:" pp(entFile)
if SysFileExists(entFile) then
do
res=analyzeEntFile(entFile) -- returns the values
say (book~left(17,'.')) res
end
else
say entFile": does not exist, skipping ..."
end
::routine analyzeEntFile
parse arg entFile
s=.stream~new(entFile)~~open("read")
str=s~arrayin~makeString -- get file's content
s~close
res=""
do ent over "YEAR", "VERSION", "EDITION"
needle1='<!ENTITY' ent
needle2='>'
res=res ent":"
pos=1 -- start out
do forever
-- say "... a) pos:" pp(pos) "needle1:" pp(needle1)
pos=pos(needle1,str,pos) -- look for the needle
-- say "... b) pos:" pp(pos) "needle1:" pp(needle1)
if pos=0 then
do
res=res pp("n/a") -- not available (maybe commented out)
-- say "... cannot find" pp(needle1) "..."
leave
end
posCommEnd=lastPos('-->',str,pos) -- in an XML comment?
if posCommEnd>0 then
do
posCommStart=lastPos('<!--',str,pos)
if posCommEnd<posCommStart then -- we are in a comment
do
pos=pos("-->",str,posCommStart) -- position on end of comment
if pos=0 then
do
res=res pp("problem: XML end comment '-->' missing!")
leave
end
iterate
end
end
-- o.k. outside of a comment
-- parse var str =(pos) (needle1) val (needle2)
parse var str 1 preStr +(pos-1) =(pos) (needle1) val (needle2)
-- say "... pos="pp(pos) "needle1="pp(needle1) "val="pp(val) "| str~substr(pos,10):" pp(str~substr(pos,10))
res = res val~strip
leave
end
end
return strip(res)
::routine updateEntityValues -- show the entity values YEAR, VERSION and EDITION of all books
tgtDir=.dir || .dirSep
call sysFileTree tgtDir"*", "dirs.", "DO"
do i=1 to dirs.0 -- for 1 -- NIXI
bookPath=dirs.i
book=FileSpec('name',dirs.i) -- get directory assume it is a book
-- say "... book:" pp(book) "bookPath="pp(bookPath)
entFile=bookPath || .dirSep || "en-US" || .dirSep || book".ent"
-- say "... book:" pp(book) "entFile:" pp(entFile)
if SysFileExists(entFile) then
do
res=updateEntFile(entFile, bookPath, book) -- returns the values
say (book~left(17,'.')) res
end
end
::routine updateEntFile
parse arg entFile, bookPath, book
s=.stream~new(entFile)~~open("read")
str=s~charIn(1,s~chars)
s~close
res=""
mb=.MutableBuffer~new
do ent over "YEAR", "VERSION", "EDITION"
select case ent -- skip entity ?
when 'YEAR' then if .argYear =.false then iterate
when 'VERSION' then if .argVersion=.false then iterate
when 'EDITION' then if .argEdition=.false then iterate
otherwise nop
end
needle1='<!ENTITY' ent
needle2='>'
res=res ent":"
pos=1 -- start out
do forever
-- say "... a) pos:" pp(pos) "needle1:" pp(needle1)
pos=pos(needle1,str,pos) -- look for the needle
-- say "... b) pos:" pp(pos) "needle1:" pp(needle1)
if pos=0 then
do
res=res pp("n/a") -- not available (maybe commented out)
-- say "... cannot find" pp(needle1) "..."
leave
end
posCommEnd=lastPos('-->',str,pos) -- in an XML comment?
if posCommEnd>0 then
do
posCommStart=lastPos('<!--',str,pos)
if posCommEnd<posCommStart then -- we are in a comment
do
pos=pos("-->",str,posCommStart) -- position on end of comment
if pos=0 then
do
res=res pp("problem: XML end comment '-->' missing!")
leave
end
iterate
end
end
-- o.k. outside of a comment
parse var str 1 preStr +(pos-1) =(pos) (needle1) '"' val '"' (needle2) str
-- say "... pos="pp(pos) "needle1="pp(needle1) "val="pp(val) "| str~substr(pos,10):" pp(str~substr(pos,10))
mb~append(preStr,needle1,' "')
select case ent -- process entity
when 'YEAR' then -- replace or change upper year
do
if val~pos("-")>0 then -- already a range, replace upper year
do
parse var val oldYear '-' currYear
mb~append(oldYear,'-',.yearValue)
end
else
do
if val<.yearValue then
mb~append(val~strip,"-",.yearValue) -- turn into range
else
mb~append(.yearValue)
end
end
when 'VERSION' then mb~append(val~changeStr(.versionCurrValue,.versionNewValue))
when 'EDITION' then
do
mb~append(.editionValue)
if .argRelease then -- if release supplied: ignore release or newer
do
mb~append(" ",getRevInfo(bookPath, book))
end
end
otherwise nop
end
mb~append('"',needle2)
res = res val~strip
leave
end
end
mb~append(str) -- append any left over
newContent=mb~string
-- replace file
.stream~new(entFile)~~open("replace")~~charout(newContent)~~close
return strip(res)
::requires "svnListRevisions.rex" -- get revision utility
::routine pp
return "["arg(1)"]"
::routine getRevInfo
use arg bookPath, book
-- look into the files in "en-US", ignore ${book}.ent file
tgtDir=bookPath || .dirSep || "en-US"
ignoreFiles=book".ent" -- add additional file names, if sensible
arr=getRevisionInfos(tgtDir)
maxRelease=.releaseValue-1 -- anything higher (= newer) gets ignored
tmpRelease=.nil
do revItem over arr
if revItem~revision>maxRelease then iterate
if wordPos(revItem~name,ignoreFiles)>0 then iterate
if tmpRelease=.nil then
tmpRelease=revItem
else if tmpRelease~date<revItem~date then
tmpRelease=revItem
end
parse value tmpRelease~date with date "T" time
return "(last revised on" date~changeStr("-","") "with r"tmpRelease~revision")"
_______________________________________________
Oorexx-devel mailing list
Oorexx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-devel