summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohannes Hofmann <Johannes.Hofmann@gmx.de>2006-12-21 20:07:46 +0100
committerJohannes Hofmann <Johannes.Hofmann@gmx.de>2006-12-21 20:07:46 +0100
commitf270d9e315bd95e673b6b7c4c60d853c90f01f22 (patch)
tree515e1e7266da3d2f226cf1bd02f402ae9da8a53e /src
parent19d955e58ec7ca58f9d2bf25b4233f4059dcbade (diff)
use ssubst() from stringproc for variable translation
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.lsq_funcs4
-rw-r--r--src/expr2c.mac14
2 files changed, 11 insertions, 7 deletions
diff --git a/src/Makefile.lsq_funcs b/src/Makefile.lsq_funcs
index c33fe5f..46bab6e 100644
--- a/src/Makefile.lsq_funcs
+++ b/src/Makefile.lsq_funcs
@@ -1,7 +1,7 @@
all: ProjectionRectilinear_funcs.cxx ProjectionCylindrical_funcs.cxx
ProjectionRectilinear_funcs.cxx: lsq_rectilinear.mac expr2c.mac
- maxima -b lsq_rectilinear.mac | grep "^double" | sed s/%/_/g > ProjectionRectilinear_funcs.cxx
+ maxima -b lsq_rectilinear.mac | grep "^double" > ProjectionRectilinear_funcs.cxx
ProjectionCylindrical_funcs.cxx: lsq_cylindrical.mac expr2c.mac
- maxima -b lsq_cylindrical.mac | grep "^double" | sed s/%/_/g > ProjectionCylindrical_funcs.cxx
+ maxima -b lsq_cylindrical.mac | grep "^double" > ProjectionCylindrical_funcs.cxx
diff --git a/src/expr2c.mac b/src/expr2c.mac
index 2a33090..b1fe8d1 100644
--- a/src/expr2c.mac
+++ b/src/expr2c.mac
@@ -1,17 +1,21 @@
+load("stringproc")$
+
+varsubst(v) := ssubst("_", "%", string(v))$
+
printdecl(vars) := (
- sprint("double", first(vars)),
- for v in rest(vars) do sprint(",", v),
+ sprint("double", varsubst(first(vars))),
+ for v in rest(vars) do sprint(",", varsubst(v)),
sprint(";"))$
-printdef(expr) := sprint(first(expr), "=", second(expr), ";")$
+printdef(expr) := sprint(varsubst(first(expr)), "=", varsubst(second(expr)), ";")$
block2c(expr) :=
if ?equal(op(expr), block) then (
printdecl(first(expr)),
for d in reverse(rest(reverse(rest(expr)))) do printdef(d),
- sprint("return", string(last(expr)), ";"))
+ sprint("return", varsubst(last(expr)), ";"))
else
- sprint("return", string(expr), ";")$
+ sprint("return", varsubst(expr), ";")$
expr2c(funcname, argstr, expr) := (
sprint("double", funcname, "(", argstr, ") {"),