Debian Codegraph @

ipl/packs/loadfuncpp/savex.icn

raw
1
2 procedure main(arg)
3 usage := "Copies iexample.icn and iexample.cpp to doc/<name>.icn\n" ||
4 "and <name>.cpp to doc/<name>.cpp\nUsage: savex <name>"
5 exname := !arg | stop(usage)
6 examples := open("doc/examples.txt") | stop("Unable to open doc/examples.txt")
7 template := open("doc/Makefile.mak") | stop("Unable to open doc/Makefile.mak")
8 makefile := open("doc/Makefile", "w") | stop("Unable to open doc/Makefile")
9 in := open("iexample.icn") | stop("Unable to open iexample.icn")
10 out := open("doc/"||exname||".icn", "w") | stop("Unable to open "||exname||".icn")
11 ls := [exname]
12 while put(ls, ""~==trim(read(examples), ' \t'))
13 ls := sort(ls)
14 write(makefile, "\n#Automatically generated from Makefile.mak and examples.txt by ../savex.icn")
15 while line := read(template) do line ? {
16 if writes(makefile, tab(find("#exe#"))) then {
17 every writes(makefile, !ls, ".exe ")
18 write(makefile)
19 next
20 }
21 if writes(makefile, tab(find("#so#"))) then {
22 every writes(makefile, !ls, ".so ")
23 write(makefile)
24 next
25 }
26 write(makefile, line)
27 }
28 while line := read(in) do line ? {
29 if p := find("iexample.so") then {
30 writes(out, tab(p))
31 writes(out, exname)
32 ="iexample"
33 write(out, tab(0))
34 } else write(out, line)
35 }
36 every close(examples|template|makefile|in|out)
37 system("cp iexample.cpp doc/" || exname || ".cpp")
38 examples := open("doc/examples.txt", "w") | stop("Unable to open doc/examples.txt")
39 every write(examples, !ls)
40 end
41