double eval_double (MNode* cell, MlEnv* mlenv) {
MNodePtr p;
-
p = eval (cell, mlenv);
- if (p ())
- return p ()->to_double ();
- else
- return 0.;
+ return to_double (p ());
}
int eval_int (MNode* cell, MlEnv* mlenv) {
- return (int) eval_double (cell, mlenv);
+ MNodePtr p;
+ p = eval (cell, mlenv);
+ return to_int (p ());
}
ustring eval_str (MNode* cell, MlEnv* mlenv) {
MNodePtr p;
-
p = eval (cell, mlenv);
return to_string (p ());
}
ustring eval_text1 (MNode* cell, MlEnv* mlenv) {
- ustring ans = eval_str (cell, mlenv);
- return omitCtrl (ans);
+ MNodePtr p;
+ p = eval (cell, mlenv);
+ return to_text1 (p ());
}
ustring eval_asciiword (MNode* cell, MlEnv* mlenv) {
- ustring ans = eval_str (cell, mlenv);
- return omitNonAsciiWord (ans);
+ MNodePtr p;
+ p = eval (cell, mlenv);
+ return to_asciiword (p ());
}
bool eval_bool (MNode* cell, MlEnv* mlenv) {
MNodePtr p;
-
p = eval (cell, mlenv);
return to_bool (p ());
}
#define ML_H
#include "util_const.h"
+#include "util_string.h"
#include "ustring.h"
#include <iostream>
#include <assert.h>
}
inline int to_int (MNode* c) {
- return (int)to_double (c);
+ if (c) {
+ return (int)(c->to_double ());
+ } else {
+ return 0;
+ }
}
bool to_bool (const ustring& v);
return uEmpty;
}
+inline ustring to_text1 (MNode* c) {
+ if (c)
+ return omitCtrl (c->to_string ());
+ else
+ return uEmpty;
+}
+
+inline ustring to_asciiword (MNode* c) {
+ if (c)
+ return omitNonAsciiWord (c->to_string ());
+ else
+ return uEmpty;
+}
+
inline ustring dump_to_sexp (MNode* c) {
if (c)
return c->to_sexp ();
void nextNode (MNode*& arg);
void nextNodeNonNil (MNode*& arg);
+#define evkw(n,v) (keywords[n] && ! isNil (v = eval (keywords[n], mlenv)))
+
#endif /* ML_H */
ustring* u;
int n;
ustring* ans;
+ MNodePtr t;
static paramList kwlist[] = {
{CharConst ("http"), true},
{CharConst ("https"), true},
setParams (arg, 1, ¶ms, kwlist, &keywords, NULL);
url = eval_text1 (params[0], mlenv);
- if (eval_bool (keywords[0], mlenv))
+ if (keywords[0] && eval_bool (keywords[0], mlenv))
proto = PROTO_HTTP;
- if (eval_bool (keywords[1], mlenv))
+ if (keywords[1] && eval_bool (keywords[1], mlenv))
proto = PROTO_HTTPS;
- if (eval_bool (keywords[2], mlenv)) {
- n = eval_int (keywords[2], mlenv);
+ if (evkw (2, t)) {
+ n = to_int (t ());
if (1 <= n && n <= 65535)
port = n;
}
ustring name;
bool fxserial = false;
MNodePtr errfn;
+ MNodePtr t;
std::vector<MNode*> params;
std::vector<MNode*> keywords;
MNode* rest;
setParams (arg, 1, ¶ms, kwlist, &keywords, &rest);
name = eval_str (params[0], mlenv);
- if (keywords[0])
- obj->limit = eval_int (keywords[0], mlenv);
- if (obj->limit <= 0)
- obj->limit = 1;
- if (obj->limit > kARRAYMAX)
- obj->limit = kARRAYMAX;
+ if (evkw (0, t)) {
+ obj->limit = to_int (t ());
+ if (obj->limit <= 0)
+ obj->limit = 1;
+ if (obj->limit > kARRAYMAX)
+ obj->limit = kARRAYMAX;
+ }
if (keywords[1])
fxserial = eval_bool (keywords[1], mlenv);
if (keywords[2])
}
static void formvar_input_readopt (MNode*& arg, MlEnv* mlenv, ustring& name, FormVarOp& opt) {
+ MNodePtr t;
std::vector<MNode*> params;
std::vector<MNode*> keywords;
static paramList kwlist[] = {
if (opt.max < 0)
opt.max = 0;
opt.nowhite = eval_bool (keywords[1], mlenv) || eval_bool (keywords[2], mlenv);
- if (keywords[3])
- opt.filter.assign (eval_str (keywords[3], mlenv));
- if (keywords[4]) {
- MNodePtr f;
+ if (evkw (3, t))
+ opt.filter.assign (to_string (t ()));
+ if (evkw (4, t)) {
ustring n;
MNode* p = NULL;
- f = eval (keywords[4], mlenv);
- checkDefun (f (), n, p);
+ checkDefun (t (), n, p);
if (n == uLambda) {
- opt.errFilter = f ();
+ opt.errFilter = t ();
}
}
if (keywords[5])
opt.fvalue = eval_bool (keywords[5], mlenv);
- if (keywords[6])
- opt.defaultVal = eval_str (keywords[6], mlenv);
+ if (evkw (6, t))
+ opt.defaultVal = to_string (t ());
if (name.size () == 0)
throw (uErrorVarNameEmpty);
ustring tgt;
ustring filename;
int idx;
+ MNodePtr t;
std::vector<MNode*> params;
std::vector<MNode*> keywords;
static paramList kwlist[] = {
opt.max = eval_int (keywords[0], mlenv);
if (opt.max < 0)
opt.max = 0;
- if (keywords[1])
- opt.filter.assign (eval_str (keywords[1], mlenv));
- if (keywords[2]) {
- MNodePtr f;
+ if (evkw (1, t))
+ opt.filter.assign (to_string (t ()));
+ if (evkw (2, t)) {
ustring n;
MNode* p = NULL;
- f = eval (keywords[2], mlenv);
- checkDefun (f (), n, p);
+ checkDefun (t (), n, p);
if (n == uLambda) {
- opt.errFilter = f ();
+ opt.errFilter = t ();
}
}
if (keywords[3])
MNodePtr query;
AutoDelete<ustring> ans;
ustring u;
+ MNodePtr t;
std::vector<MNode*> params;
std::vector<MNode*> keywords;
static paramList kwlist[] = {
pwd = eval (keywords[1], mlenv);
if (keywords[2]) // pw
pwd = eval (keywords[2], mlenv);
- if (keywords[3]) // port
- port = eval_int (keywords[3], mlenv);
+ if (evkw (3, t)) // port
+ port = to_int (t ());
if (keywords[4]) // query
query = eval (keywords[4], mlenv);
MNode* arg = cell->cdr ();
AutoDelete<ustring> ans;
ustring u;
+ MNodePtr t;
+ int c = 0;
ans = new ustring;
while (arg) {
- u = eval_str (arg->car (), mlenv);
- if (u.length () > 0)
- ans ()->append (uSlash).append (urlencode (u.begin (), u.end ()));
+ t = eval (arg->car (), mlenv);
+ if (! isNil (t ())) {
+ u = to_string (t ());
+ if (c == 0) {
+ ans ()->append (urlencode (u.begin (), u.end ()));
+ c ++;
+ } else {
+ ans ()->append (uSlash).append (urlencode (u.begin (), u.end ()));
+ }
+ }
nextNode (arg);
}
std::vector<MNode*> keywords;
MNode* rest;
MNodePtr ans;
+ MNodePtr t;
static paramList kwlist[] = {
{CharConst ("get"), true}, // 0
{CharConst ("post"), true}, // 1
obj.http = new HTTPSendIConv ("SHIFT_JIS");
else if (keywords[21] && eval_bool (keywords[21], mlenv)) // euc-jp
obj.http = new HTTPSendIConv ("EUC-JP");
- else if (keywords[22]) {
- ustring code = eval_str (keywords[22], mlenv);
+ else if (evkw (22, t)) {
+ ustring code = to_string (t ());
static uregex re ("^[a-zA-Z0-9][a-zA-Z0-9_.:-]*$");
umatch m;
if (usearch (code, m, re)) {
obj.http->setMethod (HTTPSend::M_DELETE);
if (keywords[4] && eval_bool (keywords[4], mlenv)) // file
obj.http->setPostFileMethod ();
- if (keywords[5]) // id
- obj.http->id = omitCtrl (eval_str (keywords[5], mlenv));
- if (keywords[6]) // password
- obj.http->pw = omitCtrl (eval_str (keywords[6], mlenv));
- if (keywords[7]) // pw
- obj.http->pw = omitCtrl (eval_str (keywords[7], mlenv));
- if (keywords[8]) // query
- obj.http->params = eval (keywords[8], mlenv);
- if (keywords[9]) // get-query
- obj.http->getparams = eval (keywords[9], mlenv);
- if (keywords[10]) // post-file-serial
- obj.http->fileparams_store = eval (keywords[10], mlenv);
- if (keywords[11]) // post-file-named
- obj.http->fileparams_storage = eval (keywords[11], mlenv);
- if (keywords[12]) // post-file-static
- obj.http->fileparams_static = eval (keywords[12], mlenv);
- // post-file-static
- if (keywords[13]) // cookie
- cookie = eval (keywords[13], mlenv);
- if (keywords[14]) // header
- headerquery = eval (keywords[14], mlenv);
- if (keywords[15]) { // proxy-host
- MNodePtr h;
- h = eval (keywords[15], mlenv);
- if (! isNil (h ())) {
- obj.http->host.host = omitNonAsciiWord (to_string (h ()));
- obj.http->useproxy = true;
- if (keywords[16]) // proxy-port
- obj.http->host.port = to_uint32 (eval_str (keywords[16], mlenv));
- if (keywords[17]) // proxy-id
- obj.http->proxyid = omitCtrl (eval_str (keywords[17], mlenv));
- if (keywords[18]) // proxy-password
- obj.http->proxypw = omitCtrl (eval_str (keywords[18], mlenv));
- if (keywords[19]) // proxy-pw
- obj.http->proxypw = omitCtrl (eval_str (keywords[19], mlenv));
- }
+ if (evkw (5, t)) // id
+ obj.http->id = omitCtrl (to_string (t ()));
+ if (evkw (6, t)) // password
+ obj.http->pw = omitCtrl (to_string (t ()));
+ if (evkw (7, t)) // pw
+ obj.http->pw = omitCtrl (to_string (t ()));
+ if (evkw (8, t)) // query
+ obj.http->params = t ();
+ if (evkw (9, t)) // get-query
+ obj.http->getparams = t ();
+ if (evkw (10, t)) // post-file-serial
+ obj.http->fileparams_store = t ();
+ if (evkw (11, t)) // post-file-named
+ obj.http->fileparams_storage = t ();
+ if (evkw (12, t)) // post-file-static
+ obj.http->fileparams_static = t ();
+ if (evkw (13, t)) // cookie
+ cookie = t ();
+ if (evkw (14, t)) // header
+ headerquery = t ();
+ if (evkw (15, t)) { // proxy-host
+ obj.http->host.host = omitNonAsciiWord (to_string (t ()));
+ obj.http->useproxy = true;
+ if (evkw (16, t)) // proxy-port
+ obj.http->host.port = to_uint32 (to_string (t ()));
+ if (evkw (17, t)) // proxy-id
+ obj.http->proxyid = omitCtrl (to_string (t ()));
+ if (evkw (18, t)) // proxy-password
+ obj.http->proxypw = omitCtrl (to_string (t ()));
+ if (evkw (19, t)) // proxy-pw
+ obj.http->proxypw = omitCtrl (to_string (t ()));
}
if (keywords[23])
errfn = eval (keywords[23], mlenv);
if (keywords[24])
fnoverify = eval_bool (keywords[24], mlenv);
- if (keywords[25])
- obj.http->rawquery = eval_str (keywords[25], mlenv);
- if (keywords[26]) {
- obj.http->querytype = eval_str (keywords[26], mlenv);
+ if (evkw (25, t))
+ obj.http->rawquery = to_string (t ());
+ if (evkw (26, t)) {
+ obj.http->querytype = to_string (t ());
if (!checkASCII (obj.http->querytype))
throw (obj.http->querytype + ustring (CharConst (": bad type")));
}
- if (keywords[27]) // raw-file-serial
- obj.http->rawqueryfile = mlenv->env->path_store_file (eval_str (keywords[27], mlenv));
- if (keywords[28]) // raw-file-named
- obj.http->rawqueryfile = mlenv->env->path_storage_file (eval_str (keywords[28], mlenv));
- if (keywords[29]) // raw-file-static
- obj.http->rawqueryfile = mlenv->env->path_static_file (eval_str (keywords[29], mlenv));
+ if (evkw (27, t)) // raw-file-serial
+ obj.http->rawqueryfile = mlenv->env->path_store_file (to_string (t ()));
+ if (evkw (28, t)) // raw-file-named
+ obj.http->rawqueryfile = mlenv->env->path_storage_file (to_string (t ()));
+ if (evkw (29, t)) // raw-file-static
+ obj.http->rawqueryfile = mlenv->env->path_static_file (to_string (t ()));
if (keywords[30]) // no-encode
fnoencode = eval_bool (keywords[30], mlenv);
bool finline = false;
ustring name;
ustring charset;
+ MNodePtr t;
std::vector<MNode*> params;
std::vector<MNode*> keywords;
static paramList kwlist[] = {
type = eval_asciiword (params[0], mlenv);
if (keywords[0])
finline = eval_bool (keywords[0], mlenv);
- if (keywords[1])
- name = eval_text1 (keywords[1], mlenv);
- if (keywords[2])
- charset = eval_asciiword (keywords[2], mlenv);
+ if (evkw (1, t))
+ name = to_text1 (t ());
+ if (evkw (2, t))
+ charset = to_asciiword (t ());
if (type.empty ())
throw (ustring (CharConst ("missing type.")));
ustring encoding;
bool cflag = false;
StoreType storetype (mlenv);
+ MNodePtr t;
std::vector<MNode*> params;
std::vector<MNode*> keywords;
static paramList kwlist[] = {
storetype.setStatic ();
setParams (arg, 1, ¶ms, kwlist, &keywords, NULL, true);
file = eval_str (params[0], mlenv);
- if (keywords[0]) { // type
- type = eval_asciiword (keywords[0], mlenv);
+ if (evkw (0, t)) { // type
+ type = to_asciiword (t ());
if (! checkMimeType (type))
type.resize (0);
}
if (keywords[1]) // error
ferr = eval_bool (keywords[1], mlenv);
- if (keywords[2]) // code
- encoding = eval_str (keywords[2], mlenv);
+ if (evkw (2, t)) // code
+ encoding = to_string (t ());
if (keywords[3] && eval_bool (keywords[3], mlenv)) // continue
cflag = true;
if (keywords[4] && eval_bool (keywords[4], mlenv)) // serial
time_t span = 0;
time_t limit = 0;
bool fsecure = false;
+ MNodePtr t;
std::vector<MNode*> params;
std::vector<MNode*> keywords;
static paramList kwlist[] = {
setParams (arg, 2, ¶ms, kwlist, &keywords, NULL);
name = eval_asciiword (params[0], mlenv);
value = eval_str (params[1], mlenv);
- if (keywords[0])
- path = eval_asciiword (keywords[0], mlenv);
- if (keywords[1])
- domain = eval_asciiword (keywords[1], mlenv);
- if (keywords[2]) {
- span = eval_int (keywords[2], mlenv);
+ if (evkw (0, t))
+ path = to_asciiword (t ());
+ if (evkw (1, t))
+ domain = to_asciiword (t ());
+ if (evkw (2, t)) {
+ span = to_int (t ());
if (span < 0)
span = 0;
}
- if (keywords[3]) {
- limit = eval_int (keywords[3], mlenv);
+ if (evkw (3, t)) {
+ limit = to_int (t ());
if (limit < 0)
limit = 0;
}
std::vector<ustring> taddr;
ustring subject;
MNodePtr tolist;
- ustring t;
+ ustring u;
+ MNodePtr t;
std::vector<MNode*> params;
std::vector<MNode*> keywords;
static paramList kwlist[] = {
setParams (arg, 1, ¶ms, kwlist, &keywords, NULL, true);
storetype.setStatic ();
file = eval_str (params[0], mlenv);
- if (keywords[0])
- faddr = eval_str (keywords[0], mlenv);
+ if (evkw (0, t))
+ faddr = to_string (t ());
if (keywords[1])
tolist = eval (keywords[1], mlenv);
if (keywords[2] && eval_bool (keywords[2], mlenv)) // serial
if (tolist () && tolist ()->isCons ()) {
MNode* a = tolist ();
while (a) {
- t = to_string (a->car ());
- if (checkMailAddr (t)) {
- taddr.push_back (t);
+ u = to_string (a->car ());
+ if (checkMailAddr (u)) {
+ taddr.push_back (u);
}
nextNode (a);
}
} else {
- t = to_string (tolist ());
- if (! checkMailAddr (t)) {
+ u = to_string (tolist ());
+ if (! checkMailAddr (u)) {
if (mlenv->log)
- *mlenv->log << t << uErrorBadMailAddr << "\n";
+ *mlenv->log << u << uErrorBadMailAddr << "\n";
} else {
- taddr.push_back (t);
+ taddr.push_back (u);
}
}
if (taddr.size () > TO_LIST_MAX)
throw (ustring ("too many addresses"));
-// if (file.size () == 0)
-// throw (uErrorFilenameEmpty);
-// if (! checkResourceName (file))
-// throw (file + uErrorBadFile);
if (faddr.size () > 0 && taddr.size () > 0) {
ustring f;
-// if (mlenv->env->path_resource (file, f))
f = storetype.src (mlenv, file);
sendmail (faddr, taddr, f, mlenv);
} else {
StoreType storetype (mlenv);
ustring encoding;
ustring data;
+ MNodePtr t;
std::vector<MNode*> params;
std::vector<MNode*> keywords;
static paramList kwlist[] = {
setParams (arg, 1, ¶ms, kwlist, &keywords, NULL);
name = eval_str (params[0], mlenv);
- if (keywords[0])
- encoding = eval_str (keywords[0], mlenv);
+ if (evkw (0, t))
+ encoding = to_string (t ());
if (keywords[1] && eval_bool (keywords[1], mlenv)) // serial
storetype.setSerial ();
if (keywords[2] && eval_bool (keywords[2], mlenv)) // named
ustring encoding;
bool fcrlf = false;
ustring data;
+ MNodePtr t;
std::vector<MNode*> params;
std::vector<MNode*> keywords;
static paramList kwlist[] = {
setParams (arg, 2, ¶ms, kwlist, &keywords, NULL);
name = eval_str (params[0], mlenv);
data = eval_str (params[1], mlenv);
- if (keywords[0])
- encoding = eval_str (keywords[0], mlenv);
+ if (evkw (0, t))
+ encoding = to_string (t ());
if (keywords[1])
fcrlf = eval_bool (keywords[1], mlenv);
if (keywords[2] && eval_bool (keywords[2], mlenv)) // serial
void proc (MNode* cell, MlEnv* mlenv, bool fmotor) {
MNode* arg = cell->cdr ();
ustring filename;
+ MNodePtr t;
std::vector<MNode*> params;
std::vector<MNode*> keywords;
static paramList kwlist_motor[] = {
storetype.setNamed ();
if (keywords[2] && eval_bool (keywords[2], mlenv)) // static
storetype.setStatic ();
- if (keywords[3]) // type
- type = eval_str (keywords[3], mlenv);
+ if (evkw (3, t)) // type
+ type = to_string (t ());
if (keywords[4] && eval_bool (keywords[4], mlenv)) // continue
cflag = true;
if (! fmotor) {
if (keywords[5])
finline = eval_bool (keywords[5], mlenv); // inline
- if (keywords[6])
- dispname = omitCtrl (eval_str (keywords[6], mlenv)); // name
+ if (evkw (6, t))
+ dispname = to_text1 (t ()); // name
}
if (type.empty ()) {
setParams (arg, 2, ¶ms, kwlist, &keywords, NULL);
reg = eval_str (params[0], mlenv);
text = eval_str (params[1], mlenv);
- if (eval_bool (keywords[0], mlenv))
+ if (keywords[0] && eval_bool (keywords[0], mlenv))
f |= boost::regex_constants::icase;
ans = wsearch_env (mlenv, text, reg, f);
MNode* ml_string_filter (MNode* cell, MlEnv* mlenv) {
MNode* arg = cell->cdr ();
ustring reg;
- ustring t;
+ ustring text;
boost::wregex::flag_type f = boost::regex_constants::normal;
size_t max = 0;
+ MNodePtr t;
std::vector<MNode*> params;
std::vector<MNode*> keywords;
static paramList kwlist[] = {
setParams (arg, 2, ¶ms, kwlist, &keywords, NULL);
reg = eval_str (params[0], mlenv);
- t = eval_str (params[1], mlenv);
- if (eval_bool (keywords[0], mlenv))
+ text = eval_str (params[1], mlenv);
+ if (keywords[0] && eval_bool (keywords[0], mlenv))
f |= boost::regex_constants::icase;
- if (eval_bool (keywords[1], mlenv)) {
- max = eval_int (keywords[1], mlenv);
+ if (evkw (1, t)) {
+ max = to_int (t ());
if (max < 0)
max = 0;
}
- if (wsearch_env (mlenv, t, reg, f)) {
+ if (wsearch_env (mlenv, text, reg, f)) {
ustring ans = wtou (std::wstring (mlenv->regmatch[0].first, mlenv->regmatch[0].second));
if (max > 0) {
substring (ans, 0, max, true, ans);
reg = eval_str (params[0], mlenv);
to = eval_str (params[1], mlenv);
text = eval_str (params[2], mlenv);
- if (eval_bool (keywords[0], mlenv))
+ if (keywords[0] && eval_bool (keywords[0], mlenv))
f |= boost::regex_constants::icase;
- if (eval_bool (keywords[1], mlenv))
+ if (keywords[1] && eval_bool (keywords[1], mlenv))
fglobal = true;
- if (eval_bool (keywords[2], mlenv))
+ if (keywords[2] && eval_bool (keywords[2], mlenv))
fglobal = true;
if (! fglobal)
setParams (arg, 2, ¶ms, kwlist, &keywords, NULL);
reg = eval_str (params[0], mlenv);
text = eval_str (params[1], mlenv);
- if (eval_bool (keywords[0], mlenv))
+ if (keywords[0] && eval_bool (keywords[0], mlenv))
f |= boost::regex_constants::icase;
if (wsearch_env (mlenv, text, reg, f)) {
setParams (arg, 1, ¶ms, kwlist, &keywords, NULL);
h = eval (params[0], mlenv);
- if (eval_bool (keywords[0], mlenv))
+ if (keywords[0] && eval_bool (keywords[0], mlenv))
fdesc = false;
- if (eval_bool (keywords[1], mlenv))
+ if (keywords[1] && eval_bool (keywords[1], mlenv))
fdesc = true;
a = h ();
double step = 1.;
std::vector<ustring> lv;
double i;
- MNodePtr h;
MNodePtr ans;
int j;
bool kp;
+ MNodePtr t;
std::vector<MNode*> params;
std::vector<MNode*> keywords;
MNode* rest;
to = eval_double (params[2], mlenv);
if (keywords[0])
step = eval_double (keywords[0], mlenv);
- if (keywords[1]) {
+ if (evkw (1, t)) {
MNode* a;
- h = eval (keywords[1], mlenv);
- a = h ();
+ a = t ();
if (a && a->isSym ()) {
lv.push_back (a->to_string ());
} else if (a && a->isCons ()) {
nextNode (a);
}
} else {
- throw (to_string (h ()) + ustring (": bad argument."));
+ throw (to_string (t ()) + ustring (": bad argument."));
}
}
if (step > 0) {
kp = true;
for (i = from; kp && i <= to; i += step) {
- h = newMNode_num (i);
- mlenv->setVar (iv, h ());
+ t = newMNode_num (i);
+ mlenv->setVar (iv, t ());
if (i > 0)
for (j = 0; j < lv.size (); j ++)
mlenv->setVar (lv[j], mlenv->getAry (lv[j], (size_t)i));
} else if (step < 0) {
kp = true;
for (i = from; kp && i >= to; i += step) {
- h = newMNode_num (i);
- mlenv->setVar (iv, h ());
+ t = newMNode_num (i);
+ mlenv->setVar (iv, t ());
if (i > 0)
for (j = 0; j < lv.size (); j ++)
mlenv->setVar (lv[j], mlenv->getAry (lv[j], (size_t)i));
MNode* arg = cell->cdr ();
std::vector<ustring> lv;
std::vector<ustring> setvar;
- MNodePtr vlist;
ustring iv;
size_t i, n;
int it, nlv, nsv;
ustring val;
MNodePtr ans;
- MNodePtr h;
+ MNodePtr t;
bool kp;
std::vector<MNode*> params;
std::vector<MNode*> keywords;
};
setParams (arg, 1, ¶ms, kwlist, &keywords, &rest);
- vlist = eval (params[0], mlenv);
- if (vlist () && vlist ()->isSym ()) {
- lv.push_back (vlist ()->to_string ());
- } else if (vlist () && vlist ()->isCons ()) {
- MNode* a = vlist ();
+ t = eval (params[0], mlenv);
+ if (t () && t ()->isSym ()) {
+ lv.push_back (t ()->to_string ());
+ } else if (t () && t ()->isCons ()) {
+ MNode* a = t ();
while (a && a->isCons ()) {
lv.push_back (to_string (a->car ()));
nextNode (a);
}
} else {
- throw (to_string (vlist ()) + ustring (": bad argument."));
+ throw (dump_to_sexp (t ()) + ustring (": bad argument."));
}
- if (keywords[0])
- iv = eval_str (keywords[0], mlenv);
- if (keywords[1]) {
- vlist = eval (keywords[1], mlenv);
- if (vlist () && vlist ()->isSym ()) {
- setvar.push_back (to_string (vlist ()));
- } else if (vlist () && vlist ()->isCons ()) {
- MNode* a = vlist ();
+ if (evkw (0, t))
+ iv = to_string (t ());
+ if (evkw (1, t)) {
+ if (t () && t ()->isSym ()) {
+ setvar.push_back (to_string (t ()));
+ } else if (t () && t ()->isCons ()) {
+ MNode* a = t ();
while (a && a->isCons ()) {
setvar.push_back (to_string (a->car ()));
nextNode (a);
}
} else {
- throw (ustring (CharConst (":setvar ")) + to_string (vlist ()) + ustring (": bad argument."));
+ throw (ustring (CharConst (":setvar ")) + dump_to_sexp (t ()) + ustring (": bad argument."));
}
}
}
}
if (iv.size () > 0) {
- h = newMNode_num (i);
- mlenv->setVar (iv, h ());
+ t = newMNode_num (i);
+ mlenv->setVar (iv, t ());
}
ans = progn (rest, mlenv);
if (mlenv->breaksym ()) {
-// if (mlenv->breaksym ()->isNil () || eq (mlenv->breaksym (), cell->car ())) mlenv->setBreaksym (NULL);
mlenv->stopBreak (cell->car ());
kp = false;
}