An introduction, first compiles, first offerings


To ng-spice-devel@ieee.ing.uniroma1.it
From Steven Borley <sjb@salix.demon.co.uk>
Date Sun, 20 May 2001 23:42:27 +0100
Delivered-To mailing list ng-spice-devel@ieee.ing.uniroma1.it
In-Reply-To <Pine.LNX.3.96.1010520125143.27208A-100000@ieee.ing.uniroma1.it >
Mailing-List contact ng-spice-devel-help@ieee.ing.uniroma1.it; run by ezmlm
Reply-To ng-spice-devel@ieee.ing.uniroma1.it

Hello,

Let me introduce myself.  I am an electronic engineer, working in the field
of optical fibre comunications. I use Spice from time to time, not a lot,
but it can be useful.

I am also an amateur programmer with some small experience of C and linux.
I run Linux on a Macintosh.

I have downloaded ng-spice-rework-13 and compiled it.  It runs, albeit with
a few bug. Most notably the install uses /usr/local/share/ng-spice-rework
but ngspice looks in  /usr/local/share/ng-spice.

I fixed this by a symbolic link.  Has this been fixed in 
ng-spice-rework-14pre?

More recently I downloaded ng-spice-rework-14pre3. This fails to compile
because the spicelib/devices/mos9 directory contains source files with DOS
line endings (CR LF). This foo-bars the #defines at the very least.
However, it was easy to fix.

Now it compiles I can see that things get installed a little better (I
don't know if the bug mentioned above was fixed as my symbolic link was
still in place).

I have a bug fix and an improvement I'd like to offer the project. I don't
know how I should do this so I'll beg your forgivness and just paste the
diff in here. Perhaps some one can enlighten me (note: I don't have an
internet connection when running Linux so cannot use CVS).

Both address the help command.  The first modification fixes a bug in
src/lib/hlp/readhelp.c where '=' was use in place of '==' in an if().

The second improves upon the poor word look up ability of the help command.
The new code make help look-up case insensitive and allows partial matching
of subject titles. Thus, 'help simu' will find  '4.1.  SIMULATOR VARIABLES
(.OPTIONS)'.

Diff follows.

Regards,

Steven

--- start ---

--- src/frontend/help/readhelp.c.orig   Sun May 20 14:21:47 2001
+++ src/frontend/help/readhelp.c        Sun May 20 14:31:45 2001
@@ -4,7 +4,12 @@
 Modified 1999 Emmanuel Rouat
 **********/

-
+/*
+ * SJB 20 May 2001
+ * Bug fix in help_read()
+ * findsubject() now ignores case and does additional searches for partial
matches
+ * when a complete match is not found - additional code based on code in
MacSpice.
+ */

 #include <config.h>
 #include "ngspice.h"
@@ -84,7 +89,7 @@
     /* skip to TEXT: */
     while (fgets(buf, BSIZE_SP, place->fp)) {
       if (!strncmp("TEXT: ", buf, 6)) break;
-      if ((*buf = '\0') ||
+      if ((*buf == '\0') ||            /* SJB - bug fix */
         !strncmp("SEEALSO: ", buf, 9) ||
         !strncmp("SUBTOPIC: ", buf, 10)) {
         /* no text */
@@ -244,8 +249,39 @@
       return(-1);
     }

+    /* try it exactly (but ignore case) */
+    while(fread((char *) &indexitem, sizeof (struct hlp_index), 1, fp)) {
+      if (!strncasecmp(subject, indexitem.subject, 64)) { /* sjb - ignore
case */
+        fclose(fp);
+        return(indexitem.fpos);
+      }
+    }
+
+    fclose(fp);
+
+    if (!(fp = fopen(buf, "rb"))) {
+      perror(buf);
+      return(-1);
+    }
+
+    /* try it abbreviated (ignore case)  */
+    while(fread((char *) &indexitem, sizeof (struct hlp_index), 1, fp)) {
+      if (!strncasecmp(indexitem.subject,subject, strlen(subject))) {
+        fclose(fp);
+        return(indexitem.fpos);
+      }
+    }
+
+    fclose(fp);
+
+    if (!(fp = fopen(buf, "rb"))) {
+      perror(buf);
+      return(-1);
+    }
+
+       /* try it within */ /* FIXME: need a case independent version of
strstr() */
     while(fread((char *) &indexitem, sizeof (struct hlp_index), 1, fp)) {
-      if (!strncmp(subject, indexitem.subject, 64)) {
+         if (strstr(indexitem.subject,subject)) {
         fclose(fp);
         return(indexitem.fpos);
       }

--- end ---



-----------
Steven Borley
sjb@salix.demon.co.uk
-----------



Partial thread listing: