From: erg Date: Tue, 17 Jul 2007 21:46:06 +0000 (+0000) Subject: Fix gvpr code to work with stupid Windows dll variables. X-Git-Tag: LAST_LIBGRAPH~32^2~5519 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2e72734c0f6f387a453d7e3eb1301656bc20d8b2;p=graphviz Fix gvpr code to work with stupid Windows dll variables. --- diff --git a/cmd/gvpr/compile.c b/cmd/gvpr/compile.c index 30c5e27d4..3c9d4e07e 100644 --- a/cmd/gvpr/compile.c +++ b/cmd/gvpr/compile.c @@ -1750,8 +1750,12 @@ static void checkGuard(Exnode_t * gp, char *src, int line) gp = exnoncast(gp); if (gp && exisAssign(gp)) { if (src) { +#ifdef GVDLL + setErrorFileLine (src, line); +#else error_info.file = src; error_info.line = line; +#endif } error(ERROR_WARNING, "assignment used as bool in guard"); } @@ -1868,7 +1872,11 @@ comp_prog *compileProg(parse_prog * inp, Gpr_t * state, int flags) p->end_stmt = compile(p->prog, inp->source, inp->end_stmt, inp->l_end, "_end_", 0, VOID); sfclose(tmps); +#ifdef GVDLL + setErrorLine (0); +#else error_info.line = 0; /* execution errors have no line numbers */ +#endif return p; } @@ -1913,7 +1921,11 @@ static int ioflush(void *chan) static Agiodisc_t gprIoDisc = { iofread, ioputstr, ioflush }; +#ifdef GVDLL +static Agdisc_t gprDisc = { 0, 0, &gprIoDisc }; +#else static Agdisc_t gprDisc = { &AgMemDisc, &AgIdDisc, &gprIoDisc }; +#endif /* readG: * Read graph from file and initialize @@ -1923,6 +1935,10 @@ Agraph_t *readG(Sfio_t * fp) { Agraph_t *g; +#ifdef GVDLL + gprDisc.mem = &AgMemDisc; + gprDisc.id = &AgIdDisc; +#endif g = agread(fp, &gprDisc); if (g) { aginit(g, AGRAPH, UDATA, sizeof(gdata), 0); diff --git a/cmd/gvpr/gvpr.c b/cmd/gvpr/gvpr.c index b1745d3a9..cc2a4f611 100644 --- a/cmd/gvpr/gvpr.c +++ b/cmd/gvpr/gvpr.c @@ -239,7 +239,11 @@ static void scanArgs(int argc, char **argv) options.useFile = 0; options.argv = 0; options.argc = 0; +#ifdef GVDLL + setErrorId (options.cmdName); +#else error_info.id = options.cmdName; +#endif while ((c = getopt(argc, argv, ":?Vcia:f:o:")) != -1) { switch (c) { @@ -284,7 +288,11 @@ static void scanArgs(int argc, char **argv) if (options.useFile == 0) { if (argc == 0) { error(2, "No program supplied via argument or -f option"); +#ifdef GVDLL + setErrorErrors (1); +#else error_info.errors = 1; +#endif } else { options.program = *argv++; argc--; @@ -299,7 +307,11 @@ static void scanArgs(int argc, char **argv) else options.outFile = sfstdout; +#ifdef GVDLL + if (getErrorErrors ()) +#else if (error_info.errors) +#endif error(ERROR_USAGE | 4, "%s", usage); } @@ -590,7 +602,11 @@ static int ing_close(void *fp) return sfclose((Sfio_t *) fp); } +#ifdef GVDLL +static ingdisc ingDisc = { ing_open, ing_read, ing_close, 0 }; +#else static ingdisc ingDisc = { ing_open, ing_read, ing_close, &_Sfstdin }; +#endif int main(int argc, char *argv[]) { @@ -600,6 +616,9 @@ int main(int argc, char *argv[]) Gpr_t *state; gpr_info info; +#ifdef GVDLL + ingDisc.dflt = &_Sfstdin; +#endif scanArgs(argc, argv); prog = parseProg(options.program, options.useFile);