diff --git a/ChangeLog b/ChangeLog
index eabf4327c..ee6916cde 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2007-10-11 Paolo Nenzi
+ * src/main.c, src/frontend/{inpcom.c, miscvars.c}: added option -a
+ and --autorun to add the control section ans run the loaded netlist.
+ In the original implementation by Phil Barker, the loaded circuit was
+ always run, both in interactive and batch mode.
+
2007-10-09 Paolo Nenzi
* src/frontend/{device.c, miscvars.c}: added "altshow" option to
enable the new (Phil Barker) version of the show command. The
diff --git a/src/frontend/inpcom.c b/src/frontend/inpcom.c
index 5feb3777e..d9f557505 100644
--- a/src/frontend/inpcom.c
+++ b/src/frontend/inpcom.c
@@ -982,6 +982,8 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name)
bool found_library, found_lib_name, found_end = FALSE, shell_eol_continuation = FALSE;
bool dir_name_flag = FALSE;
+ struct variable *v;
+
/* Must set this to NULL or non-tilde includes segfault. -- Tim Molteno */
/* copys = NULL; */ /* This caused a parse error with gcc 2.96. Why??? */
@@ -1493,7 +1495,9 @@ inp_readall(FILE *fp, struct line **data, int call_depth, char *dir_name)
inp_fix_inst_calls_for_numparam(working);
inp_fix_gnd_name(working);
inp_chk_for_multi_in_vcvs(working, &line_number);
- inp_add_control_section(working, &line_number);
+
+ if (cp_getvar("addcontrol", VT_BOOL, (char *) &v))
+ inp_add_control_section(working, &line_number);
}
*data = cc;
return;
diff --git a/src/frontend/miscvars.c b/src/frontend/miscvars.c
index f8a8f4c15..0a53959ab 100644
--- a/src/frontend/miscvars.c
+++ b/src/frontend/miscvars.c
@@ -25,6 +25,7 @@ bool ft_asyncdb = FALSE;
char *ft_setkwords[] = {
"acct",
+ "addcontrol",
"altshow",
"appendwrite",
"bypass",
diff --git a/src/main.c b/src/main.c
index ac47361ea..a2da1cdc6 100644
--- a/src/main.c
+++ b/src/main.c
@@ -515,6 +515,7 @@ show_help(void)
printf("Usage: %s [OPTION]... [FILE]...\n"
"Simulate the electical circuits in FILE.\n"
"\n"
+ " -a --autorun run the loaded netlist\n"
" -b, --batch process FILE in batch mode\n"
" -c, --circuitfile=FILE set the circuitfile\n"
" -i, --interactive run in interactive mode\n"
@@ -633,6 +634,9 @@ main(int argc, char **argv)
int err;
bool gotone = FALSE;
char* copystring;/*DG*/
+ char addctrlsect = TRUE; /* PN: for autorun */
+
+
#ifdef SIMULATOR
int error2;
@@ -738,6 +742,7 @@ main(int argc, char **argv)
{"help", 0, 0, 'h'},
{"version", 0, 0, 'v'},
{"batch", 0, 0, 'b'},
+ {"autorun", 0, 0, 'a'},
{"circuitfile", 0, 0, 'c'},
{"interactive", 0, 0, 'i'},
{"no-spiceinit", 0, 0, 'n'},
@@ -749,7 +754,7 @@ main(int argc, char **argv)
{0, 0, 0, 0}
};
- c = getopt_long (argc, argv, "hvbc:ihno:qr:st:",
+ c = getopt_long (argc, argv, "hvbac:ihno:qr:st:",
long_options, &option_index);
if (c == -1)
break;
@@ -767,8 +772,17 @@ main(int argc, char **argv)
case 'b': /* Batch mode */
ft_batchmode = TRUE;
+ addctrlsect = FALSE;
+ cp_vset("addcontrol",VT_BOOL,&addctrlsect);
break;
+ case 'a': /* Add control section for autorun */
+ if (!ft_batchmode) {
+ addctrlsect = TRUE;
+ cp_vset("addcontrol",VT_BOOL, &addctrlsect);
+ }
+ break;
+
case 'c': /* Circuit file */
if (optarg) {
if (!(circuit_file = fopen(optarg, "r"))) {