Browse Source

Re-enable compiling ngsconvert again

Capability to compile ngsconvert is extremely sensitive to changes in
associated files as found in makefile.am and may esily be
broken again next time. Requires manual tweaking.
pre-master-46
Holger Vogt 5 years ago
parent
commit
8abd8069a8
  1. 21
      src/Makefile.am
  2. 93
      src/ngsconvert.c

21
src/Makefile.am

@ -262,14 +262,19 @@ endif !NO_HELP
## sconvert:
ngsconvert_SOURCES = ngsconvert.c
ngsconvert_LDADD = \
frontend/com_history.lo \
frontend/libfte.la \
frontend/parser/libparser.la \
maths/misc/libmathmisc.la \
misc/libmisc.la
ngsconvert_LDADD = \
frontend/dvec.lo \
frontend/rawfile.lo \
frontend/typesdef.lo \
frontend/variable.lo \
frontend/dimens.lo \
frontend/quote.lo \
frontend/parser/lexical.lo \
frontend/parser/numparse.lo \
misc/string.lo \
misc/wlist.lo \
misc/misc_time.lo \
misc/alloc.lo
## proc2mod:

93
src/ngsconvert.c

@ -15,9 +15,13 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
#include "ngspice/ftedefs.h"
#include "ngspice/sim.h"
#include "ngspice/suffix.h"
#include "ngspice/compatmode.h"
#include "frontend/display.h"
#include "../misc/mktemp.h"
#include <errno.h>
FILE *cp_in = NULL;
FILE *cp_out = NULL;
FILE *cp_err = NULL;
@ -31,6 +35,9 @@ bool ft_stricterror = FALSE;
bool ft_parsedb = FALSE;
struct circ *ft_curckt = NULL;
struct plot *plot_cur = NULL;
int cp_maxhistlength = 0;
bool cp_no_histsubst = FALSE;
struct compat newcompat;
char *cp_program = "sconvert";
@ -45,6 +52,67 @@ char *cp_program = "sconvert";
fprintf(cp_err, "Write error\n"); \
return; }
#define TMALLOC(t, n) (t*) tmalloc(sizeof(t) * (size_t)(n))
#define TREALLOC(t, p, n) (t*) trealloc(p, sizeof(t) * (size_t)(n))
char *
smktemp(char *id)
{
if (!id)
id = "sp";
const char* const home = getenv("HOME");
if (home) {
return tprintf("%s/"TEMPFORMAT, home, id, getpid());
}
const char* const usr = getenv("USERPROFILE");
if (usr) {
return tprintf("%s\\"TEMPFORMAT, usr, id, getpid());
}
return tprintf(TEMPFORMAT, id, getpid());
}
int
inchar(FILE *fp)
{
#if !defined(__MINGW32__)
char c;
ssize_t i;
do
i = read(fileno(fp), &c, 1);
while (i == -1 && errno == EINTR);
if (i == 0 || c == '\004')
return EOF;
if (i == -1) {
perror("read");
return EOF;
}
return (int) c;
#elif
return getc(fp);
#endif
}
int
input(FILE *fp)
{
REQUEST request;
RESPONSE response;
request.option = char_option;
request.fp = fp;
Input(&request, &response);
return (inchar(fp));
}
void
Input(REQUEST *request, RESPONSE *response)
@ -74,7 +142,7 @@ fixdate(char *date)
buf[i] = buf[i - 1];
buf[8] = ' ';
buf[18] = '\0';
return (copy(buf));
return (strdup(buf));
}
@ -101,11 +169,11 @@ oldread(char *name)
for (i = (int) strlen(buf) - 1; (i > 1) && (buf[i] == ' '); i--)
;
buf[i + 1] = '\0';
pl->pl_title = copy(buf);
pl->pl_title = strdup(buf);
tfread(buf, 1, 16, fp);
buf[16] = '\0';
pl->pl_date = copy(fixdate(buf));
pl->pl_date = strdup(fixdate(buf));
tfread(&nv, sizeof (short), 1, fp);
@ -124,7 +192,7 @@ oldread(char *name)
end = v;
tfread(buf, 1, 8, fp);
buf[8] = '\0';
v->v_name = copy(buf);
v->v_name = strdup(buf);
}
for (v = pl->pl_dvecs; v; v = v->v_next) {
tfread(&a, sizeof (short), 1, fp);
@ -151,7 +219,7 @@ oldread(char *name)
}
tfread(buf, 1, 24, fp);
buf[24] = '\0';
pl->pl_name = copy(buf);
pl->pl_name = strdup(buf);
/* Now to figure out how many points of data there are left in
* the file.
*/
@ -319,12 +387,6 @@ main(int ac, char **av)
char *infile = NULL;
char *outfile = NULL;
FILE *fp;
cp_in = stdin;
cp_out = stdout;
cp_err = stderr;
cp_curin = stdin;
cp_curout = stdout;
cp_curerr = stderr;
switch (ac) {
case 5:
@ -352,7 +414,7 @@ main(int ac, char **av)
case 1: printf("Input file: ");
(void) fflush(stdout);
(void) fgets(buf, BSIZE_SP, stdin);
sf = copy(buf);
sf = strdup(buf);
printf("Input type: ");
(void) fflush(stdout);
(void) fgets(buf, BSIZE_SP, stdin);
@ -360,7 +422,7 @@ main(int ac, char **av)
printf("Output file: ");
(void) fflush(stdout);
(void) fgets(buf, BSIZE_SP, stdin);
af = copy(buf);
af = strdup(buf);
printf("Output type: ");
(void) fflush(stdout);
(void) fgets(buf, BSIZE_SP, stdin);
@ -425,6 +487,7 @@ main(int ac, char **av)
exit(EXIT_NORMAL);
}
void cp_pushcontrol(void) { }
void cp_popcontrol(void) { }
void out_init(void) { }
@ -432,7 +495,7 @@ void cp_doquit(void) { exit(0); }
struct variable *cp_usrvars(void) { return NULL; }
int cp_evloop(char *s) { NG_IGNORE(s); return (0); }
void cp_ccon(bool o) { NG_IGNORE(o); }
char*if_errstring(int c) { NG_IGNORE(c); return copy("error"); }
char*if_errstring(int c) { NG_IGNORE(c); return strdup("error"); }
void out_printf(char *fmt, ...) { NG_IGNORE(fmt); }
void out_send(char *string) { NG_IGNORE(string); }
struct variable * cp_enqvar(const char *word, int *tbfreed) { NG_IGNORE(word); NG_IGNORE(*tbfreed); return (NULL); }
@ -446,5 +509,7 @@ int cp_usrset(struct variable *v, bool i) {
NG_IGNORE(v); return(US_OK); }
wordlist * cp_doalias(wordlist *wlist) {NG_IGNORE(wlist); return NULL;}
void controlled_exit(int no){exit(no);}
int disptype;
Loading…
Cancel
Save