diff --git a/src/frontend/Makefile.am b/src/frontend/Makefile.am index 73af9aa2e..fc18840e9 100644 --- a/src/frontend/Makefile.am +++ b/src/frontend/Makefile.am @@ -9,6 +9,8 @@ libfte_a_SOURCES = \ commands.h \ com_ahelp.c \ com_ahelp.h \ + com_alias.c \ + com_alias.h \ com_asciiplot.c \ com_asciiplot.h \ com_cdump.c \ diff --git a/src/parser/alias.c b/src/frontend/com_alias.c similarity index 90% rename from src/parser/alias.c rename to src/frontend/com_alias.c index 28682a430..4d8960954 100644 --- a/src/parser/alias.c +++ b/src/frontend/com_alias.c @@ -3,18 +3,54 @@ Copyright 1990 Regents of the University of California. All rights reserved. Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group **********/ -/* - * Do alias substitution. - */ +/* Do alias substitution. */ #include "ngspice.h" #include "cpdefs.h" -#include "alias.h" - -static wordlist *asubst(wordlist *wlist); +#include "com_alias.h" struct alias *cp_aliases = NULL; + + +/* Return NULL if no alias was found. We can get away with just + * calling cp_histsubst now because the line will have gone onto the + * history list by now and cp_histsubst will look in the right place. */ +static wordlist * +asubst(wordlist *wlist) +{ + struct alias *al; + wordlist *wl, *w = NULL; + char *word; + + word = wlist->wl_word; + if (*word == '\\') { + wlist->wl_word++; + return (NULL); + } + for (al = cp_aliases; al; al = al->al_next) + if (eq(word, al->al_name)) + break; + if (!al) + return (NULL); + wl = cp_histsubst(wl_copy(al->al_text)); + + if (cp_didhsubst) { + /* Make sure that we have an up-to-date last history entry. */ + wl_free(cp_lastone->hi_wlist); + cp_lastone->hi_wlist = wl_copy(wl); + } else { + /* If it had no history args, then append the rest of the wl */ + for (w = wl; w->wl_next; w = w->wl_next); + w->wl_next = wl_copy(wlist->wl_next); + if (w->wl_next) + w->wl_next->wl_prev = w; + } + return (wl); +} + + + wordlist * cp_doalias(wordlist *wlist) { @@ -26,11 +62,10 @@ cp_doalias(wordlist *wlist) wlist = wlist->wl_next; wlist->wl_prev = NULL; - /* The alias process is going to modify the "last" line typed, - * so save a copy of what it really is and restore it after - * aliasing is done. We have to do tricky things do get around - * the problems with ; ... - */ + /* The alias process is going to modify the "last" line typed, so + * save a copy of what it really is and restore it after aliasing + * is done. We have to do tricky things do get around the problems + * with ; ... */ realw = wl_copy(cp_lastone->hi_wlist); comm = wlist; do { @@ -85,46 +120,8 @@ cp_doalias(wordlist *wlist) return (wlist); } -/* Return NULL if no alias was found. We can get away with just calling - * cp_histsubst now because the line will have gone onto the history list - * by now and cp_histsubst will look in the right place. - */ - -static wordlist * -asubst(wordlist *wlist) -{ - struct alias *al; - wordlist *wl, *w = NULL; - char *word; - - word = wlist->wl_word; - if (*word == '\\') { - wlist->wl_word++; - return (NULL); - } - for (al = cp_aliases; al; al = al->al_next) - if (eq(word, al->al_name)) - break; - if (!al) - return (NULL); - wl = cp_histsubst(wl_copy(al->al_text)); - - if (cp_didhsubst) { - /* Make sure that we have an up-to-date last history entry. */ - wl_free(cp_lastone->hi_wlist); - cp_lastone->hi_wlist = wl_copy(wl); - } else { - /* If it had no history args, then append the rest of the wl */ - for (w = wl; w->wl_next; w = w->wl_next); - w->wl_next = wl_copy(wlist->wl_next); - if (w->wl_next) - w->wl_next->wl_prev = w; - } - return (wl); -} /* If we use this, aliases will be in alphabetical order. */ - void cp_setalias(char *word, wordlist *wlist) { @@ -164,10 +161,9 @@ cp_setalias(char *word, wordlist *wlist) al->al_name = copy(word); al->al_text = wl_copy(wlist); cp_striplist(al->al_text); - /* We can afford to not worry about the bits, because before - * the keyword lookup is done the alias is evaluated. - * Make everything file completion, just in case... - */ + /* We can afford to not worry about the bits, because before the + * keyword lookup is done the alias is evaluated. Make everything + * file completion, just in case... */ cp_addcomm(word, (long) 1, (long) 1, (long) 1, (long) 1); /* printf("word %s, next = %s, prev = %s...\n", al->al_name, al->al_next ? al->al_next->al_name : "(none)", diff --git a/src/parser/alias.h b/src/frontend/com_alias.h similarity index 100% rename from src/parser/alias.h rename to src/frontend/com_alias.h diff --git a/src/parser/Makefile.am b/src/parser/Makefile.am index f88f4083f..2a39cc898 100644 --- a/src/parser/Makefile.am +++ b/src/parser/Makefile.am @@ -3,26 +3,18 @@ noinst_LIBRARIES = libparser.a libparser_a_SOURCES = \ - alias.c \ - alias.h \ backq.c \ backq.h \ complete.c \ complete.h \ cshpar.c \ cshpar.h \ - front.c \ - front.h \ glob.c \ glob.h \ - history.c \ - history.h \ input.c \ input.h \ lexical.c \ lexical.h \ - modify.c \ - modify.h \ numparse.c \ numparse.h \ quote.c \ @@ -30,8 +22,6 @@ libparser_a_SOURCES = \ std.c \ unixcom.c \ unixcom.h \ - variable.c \ - variable.h \ var2.c \ var2.h \ wlist.c \ diff --git a/src/parser/cshpar.c b/src/parser/cshpar.c index 578e9dcd2..b351bef76 100644 --- a/src/parser/cshpar.c +++ b/src/parser/cshpar.c @@ -96,7 +96,7 @@ cp_parse(char *string) pwlist(wlist, "After history substitution"); if (cp_didhsubst) { wl_print(wlist, stdout); - (void) putc('\n', stdout); + putc('\n', stdout); } /* Add the word list to the history. */ @@ -281,30 +281,30 @@ error: wl_free(wl); return (NULL); } -/* Reset the cp_* FILE pointers to the standard ones. This is tricky, since - * if we are sourcing a command file, and io has been redirected from inside - * the file, we have to reset it back to what it was for the source, not for - * the top level. That way if you type "foo > bar" where foo is a script, - * and it has redirections of its own inside of it, none of the output from - * foo will get sent to stdout... - */ +/* Reset the cp_* FILE pointers to the standard ones. This is tricky, + * since if we are sourcing a command file, and io has been redirected + * from inside the file, we have to reset it back to what it was for + * the source, not for the top level. That way if you type "foo > + * bar" where foo is a script, and it has redirections of its own + * inside of it, none of the output from foo will get sent to + * stdout... */ void cp_ioreset(void) { if (cp_in != cp_curin) { if (cp_in) - (void) fclose(cp_in); + fclose(cp_in); cp_in = cp_curin; } if (cp_out != cp_curout) { if (cp_out) - (void) fclose(cp_out); + fclose(cp_out); cp_out = cp_curout; } if (cp_err != cp_curerr) { if (cp_err) - (void) fclose(cp_err); + fclose(cp_err); cp_err = cp_curerr; } @@ -344,11 +344,11 @@ com_shell(wordlist *wl) if (pid == 0) { fixdescriptors(); if (wl == NULL) { - (void) execl(shell, shell, 0); + execl(shell, shell, 0); _exit(99); } else { com = wl_flatten(wl); - (void) execl("/bin/sh", "sh", "-c", com, 0); + execl("/bin/sh", "sh", "-c", com, 0); } } else { /* XXX Better have all these signals */ @@ -359,17 +359,17 @@ com_shell(wordlist *wl) do { r = wait((union wait *) NULL); } while ((r != pid) && pid != -1); - (void) signal(SIGINT, (SIGNAL_FUNCTION) svint); - (void) signal(SIGQUIT, (SIGNAL_FUNCTION) svquit); - (void) signal(SIGTSTP, (SIGNAL_FUNCTION) svtstp); + signal(SIGINT, (SIGNAL_FUNCTION) svint); + signal(SIGQUIT, (SIGNAL_FUNCTION) svquit); + signal(SIGTSTP, (SIGNAL_FUNCTION) svtstp); } #else /* Easier to forget about changing the io descriptors. */ if (wl) { com = wl_flatten(wl); - (void) system(com); + system(com); } else - (void) system(shell); + system(shell); #endif return; @@ -382,11 +382,11 @@ void fixdescriptors(void) { if (cp_in != stdin) - (void) dup2(fileno(cp_in), fileno(stdin)); + dup2(fileno(cp_in), fileno(stdin)); if (cp_out != stdout) - (void) dup2(fileno(cp_out), fileno(stdout)); + dup2(fileno(cp_out), fileno(stdout)); if (cp_err != stderr) - (void) dup2(fileno(cp_err), fileno(stderr)); + dup2(fileno(cp_err), fileno(stderr)); return; } @@ -447,7 +447,8 @@ com_chdir(wordlist *wl) tfree(s); #ifdef HAVE_GETCWD - if ((s = (char *)getcwd(localbuf, sizeof(localbuf)))) + s = getcwd(localbuf, sizeof(localbuf)); + if (s) printf("Current directory: %s\n", s); else fprintf(cp_err, "Can't get current working directory.\n"); diff --git a/src/parser/front.c b/src/parser/front.c deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/parser/front.h b/src/parser/front.h deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/parser/history.c b/src/parser/history.c deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/parser/history.h b/src/parser/history.h deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/parser/modify.c b/src/parser/modify.c deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/parser/modify.h b/src/parser/modify.h deleted file mode 100644 index db3110874..000000000 --- a/src/parser/modify.h +++ /dev/null @@ -1,13 +0,0 @@ -/************* - * Header file for modify.c - * 1999 E. Rouat - ************/ - -#ifndef MODIFY_H_INCLUDED -#define MODIFY_H_INCLUDED - - -void cp_init(void); - - -#endif diff --git a/src/parser/variable.c b/src/parser/variable.c deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/parser/variable.h b/src/parser/variable.h deleted file mode 100644 index 2b012ec3d..000000000 --- a/src/parser/variable.h +++ /dev/null @@ -1,17 +0,0 @@ -/************* - * Header file for variable.c - * 1999 E. Rouat - ************/ - -#ifndef VARIABLE_H_INCLUDED -#define VARIABLE_H_INCLUDED - - -wordlist * cp_varwl(struct variable *var); -void cp_vset(char *varname, char type, char *value); -struct variable * cp_setparse(wordlist *wl); -void cp_remvar(char *varname); - - - -#endif