[Scummvm-git-logs] scummvm master -> 64a71d4edfa986fb2ebcd98dd8fc4cefb4a8bb76
sev-
sev at scummvm.org
Fri Jan 17 21:02:27 UTC 2020
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
64a71d4edf AMIGAOS4: Propagated changes from RM2AG.rexx to .in
Commit: 64a71d4edfa986fb2ebcd98dd8fc4cefb4a8bb76
https://github.com/scummvm/scummvm/commit/64a71d4edfa986fb2ebcd98dd8fc4cefb4a8bb76
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-01-17T22:02:10+01:00
Commit Message:
AMIGAOS4: Propagated changes from RM2AG.rexx to .in
Changed paths:
dists/amiga/RM2AG.rexx.in
diff --git a/dists/amiga/RM2AG.rexx.in b/dists/amiga/RM2AG.rexx.in
index 62d6ef6..8eb3971 100644
--- a/dists/amiga/RM2AG.rexx.in
+++ b/dists/amiga/RM2AG.rexx.in
@@ -1,32 +1,81 @@
/*
-README(.md) to .guide converter $VER: RM2AG.rexx 0.20 (18.05.2019)
-This script converts a given markdown README file of ScummVM to a basic
-hypertext Amiga guide file.
+$VER: RM2AG.rexx 0.23 (24.10.2019) README(.md) to .guide converter.
+This script converts a given markdown README file (right now, only
+ScummVM is supported) to a basic hypertext Amiga guide file and installs
+it to a given path, if available.
*/
-PARSE ARG readme_md
+PARSE ARG readme_md install_path
/*
-Check if the given file is really the readme.
-If a given filename has spaces, AmigaDOS/AmigaCLI will add extra
-quotation marks to secure a sane working path. We get rid of them to make
-AREXX find the file.
+Check if arguments are available, otherwise quit.
*/
-readme_md=COMPRESS(readme_md,'"')
-OPEN(check_readme,readme_md,'R')
-IF READCH(check_readme,18) = '# [ScummVM README]' THEN
- CLOSE(check_readme)
+IF ~ARG() THEN DO
+ SAY 'No Arguments given!'
+ SAY 'Usage: RM2AG.rexx README_MD INSTALL_PATH'
+ EXIT
+END
+
+/*
+If the given filename/path has spaces in it, AmigaDOS/CLI
+will add extra quotation marks to secure a sane working path.
+Get rid of them to make AREXX find the file and remove leading
+and trailing spaces.
+*/
+IF ~EXISTS(readme_md) THEN DO
+ SAY readme_md' not available!'
+ EXIT
+END
+ELSE DO
+ readme_md=STRIP(readme_md)
+ readme_md=COMPRESS(readme_md,'"')
+END
+IF installpath='' THEN DO
+ SAY 'No installation destination given!'
+ EXIT
+END
+ELSE DO
+ install_path=STRIP(install_path)
+ install_path=STRIP(install_path,'T','/')
+ install_path=COMPRESS(install_path,'"')
+ /*
+ Check for destination path and create it, if needed.
+ */
+ IF ~EXISTS(install_path'/') THEN
+ ADDRESS COMMAND 'makedir 'install_path
+END
+
+IF ~OPEN(check_readme,readme_md,'R') THEN DO
+ SAY readme_md' opening failed!'
+ EXIT
+END
+
+IF READCH(check_readme,18) = '# [ScummVM README]' THEN DO
+ IF ~CLOSE(check_readme) THEN DO
+ SAY readme_md' closing failed!'
+ EXIT
+ END
+END
ELSE DO
+ IF ~CLOSE(check_readme) THEN DO
+ SAY readme_md' closing failed!'
+ EXIT
+ END
SAY "Not the ScummVM README.md file. Aborting!"
- CLOSE(check_readme)
- EXIT 0
+ EXIT
END
-OPEN(readme_read,readme_md,'R')
-OPEN(guide_write,'README.guide','W')
+IF ~OPEN(readme_read,readme_md,'R') THEN DO
+ SAY 'File 'readme_md' opening failed!'
+ EXIT
+END
+IF ~OPEN(guide_write,'README.guide','W') THEN DO
+ SAY README.guide' opening failed!'
+ EXIT
+END
/*
-Prepare the Amiga guide file, add the intro and fixed text.
+Prepare the Amiga guide file, add intro and fixed text.
*/
WRITELN(guide_write,'@DATABASE ScummVM README.guide')
WRITELN(guide_write,'@$VER: ScummVM Readme @VERSION@')
@@ -39,22 +88,21 @@ WRITELN(guide_write,SUBSTR(READLN(readme_read),4,14))
WRITELN(guide_write,'@{ub}')
/*
-Creating the main (TOC) link nodes.
+Creating main (TOC) link nodes.
*/
DO WHILE EOF(readme_read) = 0
working_line=READLN(readme_read)
/*
- Check for the start of actual the content and, if found, leave the
- TOC link loop.
+ Check for start of actual content and, if available, leave TOC link loop.
*/
IF POS('## <>1.0<>)',working_line) = 1 THEN
LEAVE
/*
- Check for any "rolled over" lines, if found, read in the rest (on the
- following line) and rejoin them again, before processing any further.
+ Check for any "rolled over" lines and, if available, read in the rest
+ (on the following line) and rejoin them again before processing any further.
e.g. - [<>3.6.3<>) Broken Sword games
cutscenes](#363-broken-sword-games-cutscenes)
*/
@@ -72,19 +120,19 @@ DO WHILE EOF(readme_read) = 0
WRITELN(guide_write,working_line)
ELSE DO
/*
- Fix the empty chapters:
- Two chapters (1.0 and 7.8) are "empty", consisting of only it's
- chapter names. We link them to their respective sub chapters
- (1.1 and 7.8.1), so we don't end up displaying a blank page.
-
- If chapter 1.0 is found, add a link node to chapter 1.1.
+ Fix empty chapters:
+ Two chapters (1.0 and 7.8) are "empty", consisting of only
+ it`s chapter names. Link them to their respective sub chapters
+ (1.1 and 7.8.1) to not display a blank page.
+
+ If chapter 1.0 is found, add a link node to chapter 1.1.
*/
IF POS(' - [<>1.0<>)',working_line) = 1 THEN DO
/*
- Get rid of the markers, so the following loops won't process
+ Get rid of the markers, so the following loops won`t process
them again.
*/
- working_line=COMPRESS(working_line,'-[<>')
+ working_line=COMPRESS(working_line,'[<>')
WRITELN(guide_write,' @{" 1.0 " Link "1.1"} 'SUBSTR(working_line,1,LASTPOS(']',working_line)-1))
END
@@ -93,38 +141,38 @@ DO WHILE EOF(readme_read) = 0
*/
IF POS(' - [<>7.8<>)',working_line) = 1 THEN DO
/*
- Get rid of the markers, so the following loops won't process
+ Get rid of the markers, so the following loops won`t process
them again.
*/
- working_line=COMPRESS(working_line,'-[<>')
+ working_line=COMPRESS(working_line,'[<>')
WRITELN(guide_write,' @{" 7.8 " Link "7.8.1"} 'SUBSTR(working_line,1,LASTPOS(']',working_line)-1))
END
/*
- If a single number main chapter is found (1.0 upto 9.0), prepare
- and write the link node.
+ If a single number main chapter is found (1.0 upto 9.0),
+ prepare and write the link node.
Just for the record:
A "\" (backslash) is treated as escape character in AmigaGuides.
- Thus we remove it from the node links.
+ Remove it from the node links.
*/
IF POS('- [<>',working_line) = 3 THEN DO
WRITELN(guide_write,' ')
WRITELN(guide_write,' @{" 'SUBSTR(working_line,POS('<>',working_line)+2,LASTPOS('<>',working_line)-POS('<>',working_line)-2) '" Link "'SUBSTR(working_line,POS('<>',working_line)+2,LASTPOS('<>',working_line)-POS('<>',working_line)-2)'"} 'COMPRESS(SUBSTR(working_line,1,LASTPOS(']',working_line)-1),'*<>[]\'))
/*
- Get rid of the markers, so the following loops won't process
+ Get rid of the markers, so the following loops won`t process
them again.
*/
working_line=COMPRESS(working_line,'-[<>')
END
/*
- If a single number level one sub chapter is found
- (i.e. 1.1, 1.2 etc.), prepare and write the link node.
+ If a level one sub chapter is found (i.e. 1.1, 1.2 etc.),
+ prepare and write the link node.
*/
IF POS('- [<>',working_line) = 7 THEN DO
WRITELN(guide_write,' @{" 'SUBSTR(working_line,POS('<>',working_line)+2,LASTPOS('<>',working_line)-POS('<>',working_line)-2) '" Link "'SUBSTR(working_line,POS('<>',working_line)+2,LASTPOS('<>',working_line)-POS('<>',working_line)-2)'"} 'COMPRESS(SUBSTR(working_line,1,LASTPOS(']',working_line)-1),'*<>[]\'))
/*
- Get rid of the markers, so the following loops won't process
+ Get rid of the markers, so the following loops won`t process
them again.
*/
working_line=COMPRESS(working_line,'.[<>')
@@ -137,7 +185,7 @@ DO WHILE EOF(readme_read) = 0
IF POS('- [<>',working_line) = 11 THEN DO
WRITELN(guide_write,' @{" 'SUBSTR(working_line,POS('<>',working_line)+2,LASTPOS('<>',working_line)-POS('<>',working_line)-2) '" Link "'SUBSTR(working_line,POS('<>',working_line)+2,LASTPOS('<>',working_line)-POS('<>',working_line)-2)'"} 'COMPRESS(SUBSTR(working_line,1,LASTPOS(']',working_line)-1),'*<>[]\'))
/*
- Get rid of the markers, so the following loops won't process
+ Get rid of the markers, so the following loops won`t process
them again.
*/
working_line=COMPRESS(working_line,'.[<>')
@@ -146,8 +194,8 @@ DO WHILE EOF(readme_read) = 0
END
/*
-Finish the TOC (Hardcoded due the outro text would be read in last, but
-needs to be written after the TOC creation).
+Finish TOC (hardcoded as the outro text would be read in last,
+but needs to be written after TOC creation finished).
*/
WRITELN(guide_write,'-----')
WRITELN(guide_write,' ')
@@ -156,11 +204,11 @@ WRITELN(guide_write,'The ScummVM team.')
WRITELN(guide_write,'@{"https://www.scummvm.org/" System "URLOpen https://www.scummvm.org/"}')
/*
-Creating the sub link nodes.
+Creating sub link nodes.
*/
DO WHILE EOF(readme_read) = 0
/*
- Change the html/markdown links to AmigaGuide ones
+ Change html/markdown links to AmigaGuide ones.
*/
IF POS('[here](',working_line) > 0 THEN DO
working_line=INSERT('@{"',working_line,POS('[',working_line)-1)
@@ -177,26 +225,26 @@ DO WHILE EOF(readme_read) = 0
ELSE DO
/*
Fix empty chapters:
- Two chapters (1.0 and 7.8) are "empty", consisting of only it's
- chapter names. We link them to their respective sub chapters
- (1.1 and 7.8.1), so we don't end up displaying a blank page.
- If chapter 1.1 is found don't close the NODE, just write the line.
+ Two chapters (1.0 and 7.8) are "empty", consisting of only
+ it`s chapter names. Link them to their respective sub chapters
+ (1.1 and 7.8.1) to not display a blank page.
+
+ If chapter 1.1 is found, don`t close the NODE, just write the line.
*/
IF POS('<>1.1<>',working_line) = 1 THEN DO
/*
- Get rid of the markers, so the following loops won't process
+ Get rid of the markers, so the following loops won`t process
them again.
*/
WRITELN(guide_write,COMPRESS(working_line,'<>'))
END
/*
- If chapter 7.8.1 is found don't close the NODE, just write the
- line.
+ If chapter 7.8.1 is found don`t close the NODE, just write the line.
*/
IF POS('<>7.8.1<>',working_line) = 1 THEN DO
/*
- Get rid of the markers, so the following loops won't process
+ Get rid of the markers, so the following loops won`t process
them again.
*/
WRITELN(guide_write,COMPRESS(working_line,'<>'))
@@ -210,20 +258,20 @@ DO WHILE EOF(readme_read) = 0
IF POS('section <>',working_line) > 0 THEN DO
working_line=SUBSTR(working_line,1,POS('<>',working_line)-1)'@{"'SUBSTR(working_line,POS('<>',working_line)+2,LASTPOS('<>',working_line)-POS('<>',working_line)-2)'" Link "'SUBSTR(working_line,POS('<>',working_line)+2,LASTPOS('<>',working_line)-POS('<>',working_line)-2)'"}'SUBSTR(working_line,LASTPOS('<>',working_line)+2)
/*
- Get rid of the markers, so the following loops won't
+ Get rid of the markers, so the following loops won`t
process them again.
*/
WRITELN(guide_write,COMPRESS(working_line,'<>'))
END
ELSE DO
/*
- If a chapter has been found, prepare and write the link.
+ If a chapter has been found, prepare and write the link node.
*/
WRITELN(guide_write,'@ENDNODE')
WRITELN(guide_write,'@NODE "'SUBSTR(working_line,POS('<>',working_line)+2,LASTPOS('<>',working_line)-POS('<>',working_line)-2)'" "'COMPRESS(working_line,'<>#')'"')
WRITELN(guide_write,' ')
/*
- Get rid of the markers, so the following loops won't process
+ Get rid of the markers, so the following loops won`t process
them again.
*/
WRITELN(guide_write,COMPRESS(working_line,'<>'))
@@ -237,7 +285,7 @@ DO WHILE EOF(readme_read) = 0
working_line=READLN(readme_read)
/*
- If the outtro text is found, leave the loop and prepare for closing.
+ If the outtro text has been found, leave loop and prepare for closing.
*/
IF POS('-----',working_line,1) =1 THEN
LEAVE
@@ -246,11 +294,24 @@ END
WRITELN(guide_write,'@ENDNODE')
/*
-Close the guide and clean up.
+Close guide and clean up.
*/
WRITELN(guide_write,'@ENDNODE')
-CLOSE(readme_read)
-CLOSE(guide_write)
+IF ~CLOSE(readme_read) THEN DO
+ SAY readme_md' closing failed!'
+ EXIT
+END
+IF ~CLOSE(guide_write) THEN DO
+ SAY 'README.guide closing failed!'
+ EXIT
+END
+
+/*
+Install finished README.guide to installation path
+and delete README.guide.
+*/
+ADDRESS COMMAND 'copy README.guide 'install_path
+ADDRESS COMMAND 'delete README.guide'
-EXIT 0
+EXIT
More information about the Scummvm-git-logs
mailing list