}
basic * ex::last_created_or_assigned_bp=0;
+basic * ex::dummy_bp=0;
+long ex::last_created_or_assigned_exp=0;
#endif // def OBSCURE_CINT_HACK
{
int l = strlen(s);
int pos = 0;
- while ((pos<l)&&is_whitespace_char(s[pos])) pos++;
+ while ((pos<l)&&is_whitespace_char(s[pos]))
+ pos++;
return s[pos];
}
char last_non_whitespace_char(char const * s)
{
int pos = strlen(s)-1;
- while ((pos>=0) && is_whitespace_char(s[pos])) pos--;
+ while ((pos>=0) && is_whitespace_char(s[pos]))
+ pos--;
return s[pos];
}
fout << "{" << endl << command << endl << "}" << endl;
fout.close();
G__store_undo_position();
- retval=G__exec_tempfile(tmpfilename);
+ retval = G__exec_tempfile(tmpfilename);
G__security_recover(stdout);
remove(tmpfilename);
free(tmpfilename);
static unsigned out_count = 0;
if (TYPES_EQUAL(retval,ref_ex)) {
- if (ex::last_created_or_assigned_bp_can_be_converted_to_ex()) {
- string varname = "Out"+ToString(++out_count);
+ string varname = "Out"+ToString(++out_count);
+ if (retval.obj.i!=ex::last_created_or_assigned_exp) {
+ // an ex was returned, but this is not the ex which was created last
+ // => this is not a temporary ex, but one that resides safely in memory
+
+ // cout << "warning: using ex from retval (experimental)" << endl;
+ ex::dummy_bp=((ex *)(void *)(retval.obj.i))->bp;
+ exec_tempfile("ex "+varname+"(*ex::dummy_bp);");
+ } else if (ex::last_created_or_assigned_bp_can_be_converted_to_ex()) {
//string varfill;
//for (int i=4-int(log10(out_count)); i>0; --i)
// varfill += ' ';
- exec_tempfile("ex "+varname+"(*ex::last_created_or_assigned_bp);\n"
- +"LLLAST=LLAST;\n"
- +"LLAST=LAST;\n"
- +"LAST="+varname+";\n"
- +"cout << \""+varname+" = \" << "+varname+" << endl << endl;");
+ exec_tempfile("ex "+varname+"(*ex::last_created_or_assigned_bp);");
} else {
cout << "warning: last_created_or_assigned_bp modified 0 or not evaluated or not dynallocated" << endl;
}
+ exec_tempfile(string()+"LLLAST=LLAST;\n"
+ +"LLAST=LAST;\n"
+ +"LAST="+varname+";\n"
+ +"cout << \""+varname+" = \" << "+varname+" << endl << endl;");
}
#endif // def OBSCURE_CINT_HACK
}
<< " __, _______ requested, at this moment, for commercial use. Send e-mail to" << endl
<< " (__) * | <MXJ02154@niftyserve.or.jp>. The registration is free." << endl
<< " ._) i N a C | The GiNaC framework is Copyright by Johannes Gutenberg Univ.," << endl
- << "<-------------' Germany and licensed under the terms and conditions of the GPL." << endl << endl;
+ << "<-------------' Germany and licensed under the terms and conditions of the GPL." << endl
+ << endl;
}
int main(void)
char *line;
char prompt[G__ONELINE];
- greeting();
+ if (isatty(0))
+ greeting();
atexit(cleanup);
signal(SIGTERM,sigterm_handler);
while (!quit) {
strcpy(prompt,"GiNaC> ");
int open_braces = 0;
- bool end_of_command=false;
+ bool end_of_command = false;
string command;
while (!end_of_command) {
line = G__input(prompt);
-
+
int pos = 0;
- bool double_quote=false;
- bool single_quote=false;
+ bool double_quote = false;
+ bool single_quote = false;
while(line[pos]!='\0') {
switch(line[pos]) {
case '"':