rewrite model_bin_match(), rename --> model_name_match()
This commit is contained in:
parent
a7dd20f5ca
commit
b663731379
|
|
@ -1681,33 +1681,6 @@ get_subckts_for_subckt(struct line *start_card, char *subckt_name,
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
check if current token matches model bin name -- <token>.[0-9]+
|
||||
*/
|
||||
|
||||
static bool
|
||||
model_bin_match(char *token, char *model_name)
|
||||
{
|
||||
char *dot_char;
|
||||
bool flag = FALSE;
|
||||
|
||||
if (strncmp(model_name, token, strlen(token)) == 0)
|
||||
if ((dot_char = strchr(model_name, '.')) != NULL) {
|
||||
flag = TRUE;
|
||||
dot_char++;
|
||||
while (*dot_char != '\0') {
|
||||
if (!isdigit(*dot_char)) {
|
||||
flag = FALSE;
|
||||
break;
|
||||
}
|
||||
dot_char++;
|
||||
}
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
iterate through the deck and comment out unused subckts, models
|
||||
(don't want to waste time processing everything)
|
||||
|
|
@ -1879,9 +1852,10 @@ comment_out_unused_subckt_models(struct line *start_card, int no_of_lines)
|
|||
} else {
|
||||
found_model = FALSE;
|
||||
for (i = 0; i < num_used_model_names; i++)
|
||||
if (strcmp(used_model_names[i], model_name) == 0 ||
|
||||
model_bin_match(used_model_names[i], model_name))
|
||||
if (model_name_match(used_model_names[i], model_name)) {
|
||||
found_model = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
tfree(model_type);
|
||||
if (!found_model)
|
||||
|
|
|
|||
|
|
@ -1457,36 +1457,6 @@ gettrans(const char *name, const char *name_end)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
check if current token matches model bin name -- <token>.[0-9]+
|
||||
*/
|
||||
static bool
|
||||
model_bin_match(char *token, char *model_name)
|
||||
{
|
||||
/* find last dot in model_name */
|
||||
char *dot_char = strrchr(model_name, '.');
|
||||
bool flag = FALSE;
|
||||
/* check if token equals the substring before last dot in model_name */
|
||||
if (dot_char) {
|
||||
char *mtoken = copy_substring(model_name, dot_char);
|
||||
if (cieq(mtoken, token)) {
|
||||
flag = TRUE;
|
||||
dot_char++;
|
||||
/* check if model_name has binning info (trailing digit(s)) */
|
||||
while (*dot_char != '\0') {
|
||||
if (!isdigit(*dot_char)) {
|
||||
flag = FALSE;
|
||||
break;
|
||||
}
|
||||
dot_char++;
|
||||
}
|
||||
}
|
||||
tfree(mtoken);
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------*/
|
||||
/*-------------------------------------------------------------------*/
|
||||
static int
|
||||
|
|
@ -1560,11 +1530,11 @@ numnodes(char *name, struct subs *subs, wordlist const *modnames)
|
|||
txfree(gettok(&s)); /* Skip component name */
|
||||
while ((i < n) && (*s) && !gotit) {
|
||||
t = gettok_node(&s); /* get nodenames . . . */
|
||||
for (wl = modnames; wl; wl = wl->wl_next) {
|
||||
/* also need to check if binnable device mos model */
|
||||
if (eq(t, wl->wl_word) || model_bin_match(t, wl->wl_word))
|
||||
for (wl = modnames; wl; wl = wl->wl_next)
|
||||
if (model_name_match(t, wl->wl_word)) {
|
||||
gotit = 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
tfree(t);
|
||||
} /* while . . . . */
|
||||
|
|
@ -1950,27 +1920,11 @@ devmodtranslate(struct line *s, char *subname, wordlist * const orig_modnames)
|
|||
found = 0;
|
||||
while (!found) {
|
||||
/* Now, is this a subcircuit model? */
|
||||
for (wlsub = orig_modnames; wlsub; wlsub = wlsub->wl_next) {
|
||||
/* FIXME, probably too unspecific */
|
||||
int i = (int) strlen(wlsub->wl_word);
|
||||
int j = 0; /* Now, have we a binned model? */
|
||||
char* dot_char;
|
||||
if ((dot_char = strstr(wlsub->wl_word, ".")) != NULL) {
|
||||
dot_char++;
|
||||
j++;
|
||||
while (*dot_char != '\0') {
|
||||
if (!isdigit(*dot_char)) {
|
||||
break;
|
||||
}
|
||||
dot_char++;
|
||||
j++;
|
||||
}
|
||||
}
|
||||
if (strncmp(name, wlsub->wl_word, (size_t) (i - j)) == 0) {
|
||||
for (wlsub = orig_modnames; wlsub; wlsub = wlsub->wl_next)
|
||||
if (model_name_match(name, wlsub->wl_word)) {
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) { /* name was not a model - was a netname */
|
||||
(void) sprintf(buffer + strlen(buffer), "%s ", name);
|
||||
tfree(name);
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ char * stripWhiteSpacesInsideParens(char *str);
|
|||
char * gettok(char **s);
|
||||
char * gettok_instance(char **);
|
||||
char * gettok_char(char **s, char p, bool inc_p, bool nested);
|
||||
bool model_name_match(const char *token, const char *model_name);
|
||||
|
||||
extern char *tvprintf(const char *fmt, va_list args);
|
||||
|
||||
|
|
|
|||
|
|
@ -680,3 +680,42 @@ get_comma_separated_values( char *values[], char *str ) {
|
|||
values[count++] = strdup(str);
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
check if the given token matches a model name
|
||||
either exact
|
||||
or
|
||||
modulo a trailing model binning extension '\.[0-9]+'
|
||||
*/
|
||||
|
||||
bool
|
||||
model_name_match(const char *token, const char *model_name)
|
||||
{
|
||||
const char *p;
|
||||
size_t token_len = strlen(token);
|
||||
|
||||
if (strncmp(token, model_name, token_len) != 0)
|
||||
return FALSE;
|
||||
|
||||
p = model_name + token_len;
|
||||
|
||||
// exact match
|
||||
if (*p == '\0')
|
||||
return TRUE;
|
||||
|
||||
// check for .
|
||||
if (*p++ != '.')
|
||||
return FALSE;
|
||||
|
||||
// minimum one trailing char
|
||||
if (*p == '\0')
|
||||
return FALSE;
|
||||
|
||||
// all of them digits
|
||||
for (; *p; p++)
|
||||
if (!isdigit(*p))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue