Rosetta Code/Fix code tags: Difference between revisions

→‎{{header|REXX}}: changed comments and indentation, added a comment. -- ~~~~
m (→‎{{header|REXX}}: re-aligned first comment, added whitespace. -- ~~~~)
(→‎{{header|REXX}}: changed comments and indentation, added a comment. -- ~~~~)
Line 347:
 
=={{header|REXX}}==
 
Some older REXXes don't have the '''changestr''' bif, so one is include here.
<lang rexx>/*REXX program fixes (changes) depreciated code tags with newer tags.*/
ofid@ = 'converted.txt<' /*output " " /*ensure RC won't get confused. */
old. = /*define a default value for OLD.*/
old.1 = @'<%s>' ; new.1 = @'<lang %s>'
old.2 = @'</%s>' ; new.2 = @'</lang>'
old.3 = @'<code %s>' ; new.3 = @'<lang %s>'
old.4 = @'</code>' ; new.4 = @'</lang>'
 
old.ifid = 'Wikisource.txt' /* input file identifier. /*define a default value for OLD.*/
ifidofid = 'Wikisourceconverted.txt' /*output " " input file identifier. */
 
do while lines(ifid)\==0 /*keep trunkin' until done. */
old.1='<%s>' ; new.1='<lang %s>'
old.2='</%s>' ; new.2='</lang>'
old.3='<code %s>' ; new.3='<lang %s>'
old.4='</code>' ; new.4='</lang>'
 
ifid='Wikisource.txt' /* input file identifier. */
ofid='converted.txt' /*output " " */
 
do while lines(ifid)\==0 /*keep trunkin' until done. */
_=linein(ifid) /*read a record from the input. */
 
do k=1 while old.j\=='' /*change old --> new until done. */
_=changestr(new.k,_,old.k) /*let REXX do the heavy lifting. */
end /*k*/
 
call lineout ofid,_ /*write out the re-formatted rec.*/
end /*while lines(ifid)\==0*/
exit /*stick a fork in it, we're done.*/</lang>
Some older REXXes don't have the '''changestr''' bif, so one is include herebelow.
 
<lang rexx>/*───────────────────────────CHANGESTR subroutine───────────────────────*/
changestr: procedure; parse arg o,h,n; r=; w=length(o); if w==0 then return n||h
do forever; parse var h y (o) _ +(w) h; if _=='' then return r||y; r=r||y||n; end</lang>