Browse Source

Fixed usage of new dstring functions. Also added const to some parameters that did not change.

pre-master-46
Jim Monte 6 years ago
committed by Holger Vogt
parent
commit
4bd4a6e9be
  1. 3
      src/frontend/numparam/mystring.c
  2. 2
      src/frontend/numparam/numpaif.h
  3. 2
      src/frontend/numparam/numparam.h
  4. 7
      src/frontend/numparam/spicenum.c
  5. 2
      src/frontend/numparam/xpressn.c
  6. 11
      src/frontend/subckt.c

3
src/frontend/numparam/mystring.c

@ -98,7 +98,7 @@ cadd(DSTRINGPTR dstr_p, char c)
void void
scopyd(DSTRINGPTR dst, const DSTRINGPTR src) /* returns success flag */ scopyd(DSTRINGPTR dst, const DSTRINGPTR src) /* returns success flag */
{ {
(void) ds_clear(dst);
ds_clear(dst);
if (ds_cat_ds(dst, src) != DS_E_OK) { if (ds_cat_ds(dst, src) != DS_E_OK) {
controlled_exit(-1); controlled_exit(-1);
} }
@ -127,6 +127,7 @@ pscopy(DSTRINGPTR dstr_p, const char *t, const char *stop)
stop = strchr(t, '\0'); stop = strchr(t, '\0');
} }
ds_clear(dstr_p);
if (ds_cat_mem(dstr_p, t, stop - t) != DS_E_OK) { if (ds_cat_mem(dstr_p, t, stop - t) != DS_E_OK) {
controlled_exit(-1); controlled_exit(-1);
} }

2
src/frontend/numparam/numpaif.h

@ -16,7 +16,7 @@ struct card;
extern char *nupa_copy(struct card *c); extern char *nupa_copy(struct card *c);
extern int nupa_eval(struct card *card); extern int nupa_eval(struct card *card);
extern void nupa_signal(int sig); extern void nupa_signal(int sig);
extern void nupa_scan(struct card *card);
extern void nupa_scan(const struct card *card);
extern void nupa_list_params(FILE *cp_out); extern void nupa_list_params(FILE *cp_out);
extern double nupa_get_param(char *param_name, int *found); extern double nupa_get_param(char *param_name, int *found);
extern void nupa_add_param(char *param_name, double value); extern void nupa_add_param(char *param_name, double value);

2
src/frontend/numparam/numparam.h

@ -58,7 +58,7 @@ typedef struct { /* the input scanner data structure */
void initdico(dico_t *); void initdico(dico_t *);
int donedico(dico_t *); int donedico(dico_t *);
void dico_free_entry(entry_t *); void dico_free_entry(entry_t *);
bool defsubckt(dico_t *, struct card *);
bool defsubckt(dico_t *, const struct card *);
int findsubckt(dico_t *, const char *s); int findsubckt(dico_t *, const char *s);
bool nupa_substitute(dico_t *, const char *s, char *r); bool nupa_substitute(dico_t *, const char *s, char *r);
bool nupa_assignment(dico_t *, const char *s, char mode); bool nupa_assignment(dico_t *, const char *s, char mode);

7
src/frontend/numparam/spicenum.c

@ -246,8 +246,9 @@ transform(dico_t *dico, DSTRINGPTR dstr_p, bool incontrol)
char *params; char *params;
/* split off any "params" tail */ /* split off any "params" tail */
params = strstr(s, "params:"); params = strstr(s, "params:");
if (params)
pscopy(dstr_p, s, params);
if (params) {
ds_set_length(dstr_p, params - s);
}
category = 'S'; category = 'S';
} else if (prefix(".control", s)) { } else if (prefix(".control", s)) {
category = 'C'; category = 'C';
@ -387,7 +388,7 @@ nupa_done(void)
/* SJB - Scan the line for subcircuits */ /* SJB - Scan the line for subcircuits */
void void
nupa_scan(struct card *card)
nupa_scan(const struct card *card)
{ {
defsubckt(dicoS, card); defsubckt(dicoS, card);
} }

2
src/frontend/numparam/xpressn.c

@ -494,7 +494,7 @@ nupa_define(dico_t *dico,
bool bool
defsubckt(dico_t *dico, struct card *card)
defsubckt(dico_t *dico, const struct card *card)
/* called on 1st pass of spice source code, /* called on 1st pass of spice source code,
to enter subcircuit names to enter subcircuit names
*/ */

11
src/frontend/subckt.c

@ -239,13 +239,17 @@ inp_subcktexpand(struct card *deck) {
nupa_signal(NUPADECKCOPY); nupa_signal(NUPADECKCOPY);
/* get the subckt names from the deck */ /* get the subckt names from the deck */
for (c = deck; c; c = c->nextcard) /* first Numparam pass */
if (ciprefix(".subckt", c->line))
for (c = deck; c; c = c->nextcard) { /* first Numparam pass */
if (ciprefix(".subckt", c->line)) {
nupa_scan(c); nupa_scan(c);
}
}
/* now copy instances */ /* now copy instances */
for (c = deck; c; c = c->nextcard) { /* first Numparam pass */ for (c = deck; c; c = c->nextcard) { /* first Numparam pass */
if (*(c->line) == '*')
if (*(c->line) == '*') {
continue; continue;
}
c->line = nupa_copy(c); c->line = nupa_copy(c);
} }
@ -456,7 +460,6 @@ doit(struct card *deck, wordlist *modnames) {
struct card *prev_of_c = NULL; struct card *prev_of_c = NULL;
while (c) { while (c) {
if (ciprefix(sbend, c->line)) { /* if line == .ends */ if (ciprefix(sbend, c->line)) { /* if line == .ends */
fprintf(cp_err, "Error: misplaced %s line: %s\n", sbend, fprintf(cp_err, "Error: misplaced %s line: %s\n", sbend,
c->line); c->line);

Loading…
Cancel
Save