From 924ddd14e563d4d3e35046070054b99985eac35a Mon Sep 17 00:00:00 2001 From: saintel Date: Sun, 2 Nov 2008 18:23:14 +0000 Subject: [PATCH] *** empty log message *** --- ChangeLog | 5 ++ README.tcl | 93 +++++++++++++++++++++++++++++++++++++ src/tclspice.c | 13 ++++-- tests/tcl/test_vectoblt.tcl | 8 +++- 4 files changed, 114 insertions(+), 5 deletions(-) create mode 100644 README.tcl diff --git a/ChangeLog b/ChangeLog index ae42a1f23..2b1cf2952 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-11-02 Lionel Sainte Cluque + * src/tclspice.c : tcl_vfprintf corrects the stou bug + * README.tcl : Creation + * tests/tcl/test_vectoblt.tcl : modified invocation and package loading + 2008-10-27 Dietmar Warning * src/spicelib/parser/inp2q.c VBIC is standard - not ADMS (yet) * src/spicelib/devices/vbic/vbicnoise.c correct naming array order according vbicdefs.h diff --git a/README.tcl b/README.tcl new file mode 100644 index 000000000..c7718845f --- /dev/null +++ b/README.tcl @@ -0,0 +1,93 @@ +********************************************************************************* +*Copied and written by Stefan Jones (stefan.jones@multigig.com) at Multigig Ltd * +*Code based on and copied from ScriptEDA * +*(http://www-cad.eecs.berkeley.edu/~pinhong/scriptEDA ) * +*Copyright (C) 200 Author * +* * +*This program is free software; you can redistribute it and/or * +*modify it under the terms of the GNU Lesser General Public License * +*as published by the Free Software Foundation; either version 2 * +*of the License, or (at your option) any later version. * +* * +*This program is distributed in the hope that it will be useful, * +*but WITHOUT ANY WARRANTY; without even the implied warranty of * +*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +*GNU Lesser General Public License for more details. * +* * +*You should have received a copy of the GNU Lesser General Public License * +*along with this program; if not, write to the Free Software * +*Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.* +********************************************************************************* + +Welcome to tclspice README_tcl + +This files acompanies ngspice sources starting with ngspice-rework-18. It +describes what tclspice is, its installation, and points to resources that will +help you to start with it. It also contains usefull datas to keep informed, +get help, or get involved in the project. + +Enjoy + +Lionel (saintel@users.sourceforge.net) + + + +What is tclspice: + +tclspice is a variant of ngspice. It share 95% of its code (approx). The +different between plain NGspice and tclspice is the type of binary it produces, +and the way to access it. NGspice is a standalone program that you can execute +and which can either automatically process a spice directives script. It can +also propose you a command line interface. +tclspice is a tcl package name. It is based on libspice shared library. This +library is specifically designed to be loaded in tcl interpreters such as tclsh +or wish. Then all spice directives are available as tcl functions. libspice also +feature some new commands that are usefull for the integration into the tcl +environment. + +tclspice differs from ngspice by its printf (bundled to tcl printf), malloc (tcl + malloc), data handling and plotting (BLT toolkit extensions to tcl/tk). + + +Installing: + +Tclspice relies on three packages that are not included in ngspice: +tcl : the tcl command interpreter, for interpretion of user scipt +tk : the graphical extension of tcl, to represent data graphically and for GUIs +blt : BLT toolkit gives number handling and plotting features to tcl/tk + +The most tested configuration is the latest: +tclspice-18 +tcl 8.4 +tk 8.4 +blt 2.4 + +Tclspice is built and installed the same way as ngspice. Then, after reading this +paragraph, the information you lack will probably be in README file in this directory. +There is a configuration flag to set in order to compile tclspice library rather than +plain ngspice, that is a standalone program. This flag is --with-tcl. It accepts an +argument the path to tclConfig.sh + +If you don't provide any argument, configure script will try to find it automatically. + ./configure --enable-xspice --disable-cider --disable-xgraph --enable-numparam --with-readline=no --enable-adms=non --with-tcl + +If its does not, then it will propose you some possible locations. + can't find Tcl configuration script "tclConfig.sh" + Should you add --with-tcl=/usr/lib/tcl8.4/tclConfig.sh to ./configure arguments? + +If it does not, check that tcl8.4 is installed, and manually specify the path. + ./configure --enable-xspice --disable-cider --disable-xgraph --enable-numparam --with-readline=no --enable-adms=non --with-tcl=/usr/lib/tcl8.4 + +Tclspice is not compatible with ngspice graphical code. Then when building tclspice, +--no-x is automatically configured. + + + +Support and help : + +First of all (but last recourse), mail me at saintel@users.sourceforge.net + +For any kind of information on tclspice: + http://ngspice.sourceforge.net/tclspice.html +It gives plenty of information. There is an index of good resources that you can +read to get into tclspice quickly and proficently. diff --git a/src/tclspice.c b/src/tclspice.c index 6c56dcc7d..26c72aa7b 100755 --- a/src/tclspice.c +++ b/src/tclspice.c @@ -2289,7 +2289,11 @@ bot: int tcl_vfprintf(FILE *f, const char *fmt, ...) { - static char outstr[128] = "puts -nonewline std"; +#define ostr_sz 128 + static char outstr[ostr_sz] = "puts -nonewline std"; + //outstr a buffer initialised with tcl print command + // offset for out: 19 +#define ostr_off 19 char *outptr, *bigstr = NULL, *finalstr = NULL; int i, nchars, result, escapes = 0; va_list arg; @@ -2303,10 +2307,11 @@ int tcl_vfprintf(FILE *f, const char *fmt, ...) ) return fprintf(f,fmt, arg); - strcpy (outstr + 18, (f == stderr) ? "err \"" : "out \""); + strcpy (outstr + ostr_off, (f == stderr) ? "err \"" : "out \""); + //5 characters for ->out "<- outptr = outstr; - nchars = snprintf(outptr + 20, 102, fmt, arg); - if (nchars >= 102) + nchars = snprintf(outptr + ostr_off + 5, ostr_sz - 5 - ostr_off, fmt, arg); + if (nchars >= ostr_sz - 5 - ostr_off) { bigstr = Tcl_Alloc(nchars + 26); strncpy(bigstr, outptr, 24); diff --git a/tests/tcl/test_vectoblt.tcl b/tests/tcl/test_vectoblt.tcl index bacbffb5d..9ef7a06ed 100644 --- a/tests/tcl/test_vectoblt.tcl +++ b/tests/tcl/test_vectoblt.tcl @@ -1,4 +1,10 @@ -package require spice +#!/bin/sh +# WishFix \ + exec wish -f "$0" ${1+"$@"} + ### + +package require BLT +load ../../src/.libs/libspice.so spice::source "diffpair.cir" spice::op