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

This commit is contained in:
Jim Monte 2019-12-05 00:37:32 -05:00
parent 0dfba3b826
commit c86b7692f5
6 changed files with 16 additions and 11 deletions

View File

@ -98,7 +98,7 @@ cadd(DSTRINGPTR dstr_p, char c)
void
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) {
controlled_exit(-1);
}
@ -127,6 +127,7 @@ pscopy(DSTRINGPTR dstr_p, const char *t, const char *stop)
stop = strchr(t, '\0');
}
ds_clear(dstr_p);
if (ds_cat_mem(dstr_p, t, stop - t) != DS_E_OK) {
controlled_exit(-1);
}

View File

@ -16,7 +16,7 @@ struct card;
extern char *nupa_copy(struct card *c);
extern int nupa_eval(struct card *card);
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 double nupa_get_param(char *param_name, int *found);
extern void nupa_add_param(char *param_name, double value);

View File

@ -58,7 +58,7 @@ typedef struct { /* the input scanner data structure */
void initdico(dico_t *);
int donedico(dico_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);
bool nupa_substitute(dico_t *, const char *s, char *r);
bool nupa_assignment(dico_t *, const char *s, char mode);

View File

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

View File

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

View File

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