+void warrantymessage(void)
+{
+ std::cout << "GiNaC is free software; you can redistribute it and/or modify it under the\n"
+ << "the terms of the GNU General Public License as published by the Free Software\n"
+ << "Foundation; either version 2 of the License, or (at your option) any later\n"
+ << "version.\n"
+ << "This program is distributed in the hope that it will be useful, but WITHOUT\n"
+ << "ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n"
+ << "FOR A PARTICULAR PURPOSE. See the GNU General Public License for more\n"
+ << "details.\n"
+ << "You should have received a copy of the GNU General Public License along with\n"
+ << "this program. If not, write to the Free Software Foundation, 675 Mass Ave,\n"
+ << "Cambridge, MA 02139, USA.\n\n";
+ std::cout << "Cint and associated tools are copyright by Agilent Technologies Japan Company\n"
+ << "and Masaharu Goto <MXJ02154@niftyserve.or.jp>.\n"
+ << "Source code, binary executable or library of Cint and associated tools can be\n"
+ << "used, modified and distributed with no royalty for any purpose provided that\n"
+ << "the copyright notice appear in all copies and that both that copyright notice\n"
+ << "and this permission notice appear in supporting documentation.\n"
+ << "Agilent Technologies Japan and the author make no representations about the\n"
+ << "suitability of this software for any purpose. It is provided \"AS IS\"\n"
+ << "without express or implied warranty.\n";
+ return;
+}
+
+/** "preprocess" the line entered to be able to decide if the command shall be
+ * executed directly or more input is needed or this is a special command.
+ * All whitespace will be removed. All comments will be removed. Open and
+ * close braces ( { and } ) outside strings will be counted. */
+std::string preprocess(char const * const line, bool & comment, bool & single_quote,
+ bool & double_quote, unsigned & open_braces)
+{
+ std::string preprocessed;
+ int pos = 0;
+ bool end = false;
+ bool escape = false;
+ bool slash = false;
+ bool asterisk = false;
+ while ((line[pos]!='\0')&&!end) {
+ if (escape) {
+ // last character was a \, ignore this one
+ escape = false;
+ } else if (slash) {
+ // last character was a /, test if * or /
+ slash = false;
+ if (line[pos]=='/') {
+ end = true;
+ } else if (line[pos]=='*') {
+ comment = true;
+ } else {
+ preprocessed += '/';
+ preprocessed += line[pos];
+ }
+ } else if (asterisk) {
+ // last character was a *, test if /
+ asterisk = false;
+ if (line[pos]=='/') {
+ comment = false;
+ } else if (line[pos]=='*') {
+ preprocessed += '*';
+ asterisk = true;
+ }
+ } else {
+ switch (line[pos]) {
+ case ' ':
+ case '\t':
+ case '\n':
+ case '\r':
+ // whitespace: ignore
+ break;
+ case '\\':
+ // escape character, ignore next
+ escape = true;
+ break;
+ case '"':
+ if ((!single_quote)&&(!comment)) {
+ double_quote = !double_quote;
+ }
+ break;
+ case '\'':
+ if ((!double_quote)&&(!comment)) {
+ single_quote = !single_quote;
+ }
+ break;
+ case '{':
+ if ((!single_quote)&&(!double_quote)&&(!comment)) {
+ ++open_braces;
+ }
+ break;
+ case '}':
+ if ((!single_quote)&&(!double_quote)&&(!comment)&&(open_braces>0)) {
+ --open_braces;
+ }
+ break;
+ case '/':
+ slash = true;
+ break;
+ case '*':
+ asterisk = true;
+ break;
+ default:
+ preprocessed += line[pos];
+ }
+ }
+ ++pos;
+ }
+
+ return preprocessed;
+}
+
+void cleanup(void)
+{
+ for (cplist::iterator it=filenames.begin(); it!=filenames.end(); ++it) {
+ if (!silent)
+ std::cout << "removing file " << *it << std::endl;
+ remove(*it);
+ free(*it);
+ }
+}
+
+void sigterm_handler(int n)
+{
+ exit(1);
+}