summaryrefslogtreecommitdiff
path: root/cad/spice/files/patch-src_lib_inp_inpfindl_c
blob: c7d55cb9da97bf216cd0b3f9d1986af34591b3ba (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
--- src/lib/inp/inpfindl.c.orig	Mon Apr  8 23:41:39 1991
+++ src/lib/inp/inpfindl.c	Thu Jul 17 02:45:08 2003
@@ -1,11 +1,13 @@
 /**********
 Copyright 1990 Regents of the University of California.  All rights reserved.
 Author: 1985 Thomas L. Quarles
+Modified: 1999 Paolo Nenzi - Now we can use a two digits level code -
 **********/
 
-    /* INPfindLev(line)
+    /* INPfindLev(line,level)
      *      find the 'level' parameter on the given line and return its
-     *      value (1,2,or 3 for now, 1 default)
+     *      value (1,2,..,99 for now, 1 default)
+     *  NOTE: now limited to 9 for compatibility
      */
 
 #include "spice.h"
@@ -24,58 +26,41 @@
     char *where;
 
     where = line;
-
-    while(1) {
-        where = index(where,'l');
-        if(where == 0) {    /* no 'l' in the line => no 'level' => default */
-            *level = 1;
-            return((char *)NULL);
-        }
-        if(strncmp(where,"level",5)!=0) {   /* this l isn't in the word 
-                                             * 'level', so lets try again */
-            where++;    /* make sure we don't match same char again */
-            continue;
-        }
-        /* found the word level, lets look at the rest of the line */
-        where += 5;
+    
+    where=strstr(line, "level");
+    
+    if (where!=NULL) {        /* found a level keyword on the line */
+        
+        where += 5;  /* skip the level keyword */
         while( (*where == ' ') || (*where == '\t') || (*where == '=') ||
                 (*where == ',') || (*where == '(') || (*where == ')') ||
                 (*where == '+') ) { /* legal white space - ignore */
-            where++;
+              where++;
         }
+    
         /* now the magic number */
-        switch(*where) {
-        case '1':
+        sscanf(where,"%2d",level);     /* We get the level number */
+        if (*level<0) {
+          *level=1;
+          return(INPmkTemp(" illegal (negative) argument to level parameter - level=1 assumed"));
+           } 
+        
+        if (*level>9) { /* Limit to change in the future */ 
             *level=1;
+            return(INPmkTemp(" illegal (too high) argument to level parameter - level=1 assumed"));
+            }
+            
             return((char *)NULL);
-        case '2':
-            *level=2;
-            return((char *)NULL);
-        case '3':
-            *level=3;
-            return((char *)NULL);
-        case '4':
-            *level=4;
-            return((char *)NULL);
-        case '5':
-            *level=5;
-            return((char *)NULL);
-        case '6':
-            *level=6;
-            return((char *)NULL);
-        case '7':
-            *level=7;
-            return((char *)NULL);
-        case '8':
-            *level=8;
-            return((char *)NULL);
-        case '9':
-            *level=9;
-            return((char *)NULL);
-        default:
-            *level=1;
-            return(INPmkTemp(
-                    " illegal argument to level parameter - level=1 assumed"));
-        }
-    }
+          }     
+    
+
+    
+    else {                  /* no level on the line => default */
+      *level = 1;
+      return((char *)NULL);
+      }
+      
+  
+        
+        
 }