| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,3 +1,10 @@ | |||
| 1 | + 2011-12-06 Bastian Maerkisch <bmaerkisch@web.de> | ||
| 2 | + | ||
| 3 | + * src/win/winmain.c src/win/wtext.h config/config.mgw config/config.nt | ||
| 4 | + config/mingw/Makefile config/msvc/Makefile: Emulation of popen/pclose | ||
| 5 | + for wgnuplot via temporary files. Briefly opens a console window for | ||
| 6 | + every pipe and read and write pipes are supported. | ||
| 7 | + | ||
| 1 | 8 | 2011-12-05 Bastian Maerkisch <bmaerkisch@web.de> | |
| 2 | 9 | ||
| 3 | 10 | * src/win/winmain.c: Automatic language detection can be overridden | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,6 +3,7 @@ New features, changes and fixes since gnuplot version 4.6 | |||
| 3 | 3 | ||
| 4 | 4 | * NEW geographic (DMS) data axes | |
| 5 | 5 | * NEW set arrow <tag> from <start> length <len> angle <ang> | |
| 6 | + * CHANGE Pipe (popen/pclose) emulation within wgnuplot | ||
| 6 | 7 | * CHANGE Draw the z-axis label at a fixed distance to the left of the z-axis | |
| 7 | 8 | * FIX various improvements to the qt terminal | |
| 8 | 9 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -606,5 +606,14 @@ | |||
| 606 | 606 | ||
| 607 | 607 | #define GP_INLINE inline | |
| 608 | 608 | ||
| 609 | + /* Emulated pipe support for wgnuplot */ | ||
| 610 | + #ifdef USE_FAKEPIPES | ||
| 611 | + # ifndef PIPES | ||
| 612 | + # define PIPES | ||
| 613 | + # endif | ||
| 614 | + # define popen fake_popen | ||
| 615 | + # define pclose fake_pclose | ||
| 616 | + #endif | ||
| 617 | + | ||
| 609 | 618 | /* gnuplot.gih is not used by wgnuplot */ | |
| 610 | 619 | #define NO_GIH 1 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -591,12 +591,18 @@ | |||
| 591 | 591 | #define GP_MATHERR _matherr | |
| 592 | 592 | #define snprintf _snprintf | |
| 593 | 593 | /*#define vsnprintf _vsnprintf*/ | |
| 594 | - #ifdef PIPES | ||
| 594 | + #define isnan _isnan | ||
| 595 | + #define ftruncate _chsize | ||
| 596 | + | ||
| 597 | + /* Emulated pipe support for wgnuplot */ | ||
| 598 | + #ifdef USE_FAKEPIPES | ||
| 599 | + # define PIPES | ||
| 600 | + # define popen fake_popen | ||
| 601 | + # define pclose fake_pclose | ||
| 602 | + #elif defined(PIPES) | ||
| 595 | 603 | # define popen _popen | |
| 596 | 604 | # define pclose _pclose | |
| 597 | 605 | #endif | |
| 598 | - #define isnan _isnan | ||
| 599 | - #define ftruncate _chsize | ||
| 600 | 606 | ||
| 601 | 607 | /* gnuplot.gih is not used by wgnuplot */ | |
| 602 | 608 | #define NO_GIH 1 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,5 @@ | |||
| 1 | 1 | # Hello, emacs: this is a -*- Makefile -*- | |
| 2 | - # $Id: Makefile,v 1.16 2011/11/26 14:24:26 markisch Exp $ | ||
| 2 | + # $Id: Makefile,v 1.17 2011/11/27 22:17:38 markisch Exp $ | ||
| 3 | 3 | # | |
| 4 | 4 | # GNUPLOT Makefile for MinGW/MSYS on Windows | |
| 5 | 5 | # This assumes usual installation of the MinGW32 toolkit, the free | |
@@ -200,9 +200,9 @@ ifeq ($(TARGET),wgnuplot.exe) | |||
| 200 | 200 | PGNUPLOT=pgnuplot.exe | |
| 201 | 201 | MENUFILE=wgnuplot.mnu | |
| 202 | 202 | O=o | |
| 203 | + CFLAGSEXTRA=-DUSE_FAKEPIPES | ||
| 203 | 204 | endif | |
| 204 | 205 | ifeq ($(TARGET),wgnuplot_pipes.exe) | |
| 205 | - PGNUPLOT=pgnuplot.exe | ||
| 206 | 206 | MENUFILE=wgnuplot.mnu | |
| 207 | 207 | PIPES=1 | |
| 208 | 208 | O=po | |
@@ -438,7 +438,7 @@ endif | |||
| 438 | 438 | # default rules | |
| 439 | 439 | .SUFFIXES: .exe .$(O) .c | |
| 440 | 440 | .c.$(O): | |
| 441 | - $(CC) -c $(CFLAGS) -o $@ $< | ||
| 441 | + $(CC) -c $(CFLAGS) $(CFLAGSEXTRA) -o $@ $< | ||
| 442 | 442 | ||
| 443 | 443 | LDLIBS = -lkernel32 -lgdi32 -lwinspool -lcomdlg32 -lcomctl32 -ladvapi32 -lshell32 -lmsimg32 -lgdiplus | |
| 444 | 444 | ||
@@ -461,10 +461,10 @@ wgplt_res.$(O) : $(W)/wgnuplot.rc $(W)/wgnuplib.rc $(W)/wresourc.h texticon.ico | |||
| 461 | 461 | $(RES2COFF) | |
| 462 | 462 | ||
| 463 | 463 | show.$(O): show.c plot.h setshow.h | |
| 464 | - $(CC) -c $(CFLAGS) -DHELPFILE=\"$(HELPFILE)\" -DBINDIR=\"$(bindir)\" -DGNUPLOT_PS_DIR=\"$(GNUPLOT_PS_DIR)\" -o $@ $< | ||
| 464 | + $(CC) -c $(CFLAGS) $(CFLAGSEXTRA) -DHELPFILE=\"$(HELPFILE)\" -DBINDIR=\"$(bindir)\" -DGNUPLOT_PS_DIR=\"$(GNUPLOT_PS_DIR)\" -o $@ $< | ||
| 465 | 465 | ||
| 466 | 466 | term.$(O): term.c term.h plot.h setshow.h bitmap.h $(CORETERM) | |
| 467 | - $(CC) -c $(CFLAGS) $(TERMFLAGS) -o $@ $< | ||
| 467 | + $(CC) -c $(CFLAGS) $(CFLAGSEXTRA) $(TERMFLAGS) -o $@ $< | ||
| 468 | 468 | ||
| 469 | 469 | version.$(O): $(S)/version.c | |
| 470 | 470 | ||
@@ -476,43 +476,43 @@ endif | |||
| 476 | 476 | WINDEPS = $(W)/wgnuplib.h $(W)/wcommon.h $(W)/wresourc.h $(W)/screenbuf.h $(W)/wgdiplus.h | |
| 477 | 477 | ||
| 478 | 478 | winmain.$(O): $(W)/winmain.c $(W)/wgnuplib.h $(W)/wtext.h plot.h | |
| 479 | - $(CC) -c $(CFLAGS) -o $@ -DHELPFILE=\"$(HELPFILE)\" $< | ||
| 479 | + $(CC) -c $(CFLAGS) $(CFLAGSEXTRA) -o $@ -DHELPFILE=\"$(HELPFILE)\" $< | ||
| 480 | 480 | ||
| 481 | 481 | wgnuplib.$(O): $(W)/wgnuplib.c $(WINDEPS) | |
| 482 | - $(CC) -c $(CFLAGS) -o $@ $< | ||
| 482 | + $(CC) -c $(CFLAGS) $(CFLAGSEXTRA) -o $@ $< | ||
| 483 | 483 | ||
| 484 | 484 | wmenu.$(O): $(W)/wmenu.c $(WINDEPS) | |
| 485 | - $(CC) -c $(CFLAGS) -o $@ $< | ||
| 485 | + $(CC) -c $(CFLAGS) $(CFLAGSEXTRA) -o $@ $< | ||
| 486 | 486 | ||
| 487 | 487 | wtext.$(O): $(W)/wtext.c $(WINDEPS) | |
| 488 | - $(CC) -c $(CFLAGS) -o $@ $< | ||
| 488 | + $(CC) -c $(CFLAGS) $(CFLAGSEXTRA) -o $@ $< | ||
| 489 | 489 | ||
| 490 | 490 | screenbuf.$(O): $(W)/screenbuf.c $(WINDEPS) | |
| 491 | - $(CC) -c $(CFLAGS) -o $@ $< | ||
| 491 | + $(CC) -c $(CFLAGS) $(CFLAGSEXTRA) -o $@ $< | ||
| 492 | 492 | ||
| 493 | 493 | wpause.$(O): $(W)/wpause.c $(S)/wxterminal/wxt_term.h $(WINDEPS) | |
| 494 | - $(CC) -c $(CFLAGS) -o $@ $< | ||
| 494 | + $(CC) -c $(CFLAGS) $(CFLAGSEXTRA) -o $@ $< | ||
| 495 | 495 | ||
| 496 | 496 | wprinter.$(O): $(W)/wprinter.c $(WINDEPS) | |
| 497 | - $(CC) -c $(CFLAGS) -o $@ $< | ||
| 497 | + $(CC) -c $(CFLAGS) $(CFLAGSEXTRA) -o $@ $< | ||
| 498 | 498 | ||
| 499 | 499 | wgraph.$(O): $(W)/wgraph.c $(WINDEPS) | |
| 500 | - $(CC) -c $(CFLAGS) -o $@ $< | ||
| 500 | + $(CC) -c $(CFLAGS) $(CFLAGSEXTRA) -o $@ $< | ||
| 501 | 501 | ||
| 502 | 502 | wgdiplus.$(O): $(W)/wgdiplus.cpp $(WINDEPS) | |
| 503 | - $(CXX) -c $(CXXFLAGS) -o $@ $< | ||
| 503 | + $(CXX) -c $(CXXFLAGS) $(CFLAGSEXTRA) -o $@ $< | ||
| 504 | 504 | ||
| 505 | 505 | wgnuplot.mnu: $(W)/wgnuplot.mnu | |
| 506 | 506 | $(CP) $^ $@ | |
| 507 | 507 | ||
| 508 | 508 | wxt_gui.$(O): $(S)/wxterminal/wxt_gui.cpp $(S)/wxterminal/wxt_gui.h | |
| 509 | - $(CXX) -c $(CFLAGS) $(CXXFLAGS) $(CAIRO_CFLAGS) -o $@ $< | ||
| 509 | + $(CXX) -c $(CFLAGS) $(CFLAGSEXTRA) $(CXXFLAGS) $(CAIRO_CFLAGS) -o $@ $< | ||
| 510 | 510 | ||
| 511 | 511 | gp_cairo.$(O): $(S)/wxterminal/gp_cairo.c $(S)/wxterminal/gp_cairo.h | |
| 512 | - $(CC) -c $(CFLAGS) $(CXXFLAGS) $(PANGOCAIRO_CFLAGS) -o $@ $< | ||
| 512 | + $(CC) -c $(CFLAGS) $(CFLAGSEXTRA) $(CXXFLAGS) $(PANGOCAIRO_CFLAGS) -o $@ $< | ||
| 513 | 513 | ||
| 514 | 514 | gp_cairo_helpers.$(O): $(S)/wxterminal/gp_cairo_helpers.c $(S)/wxterminal/gp_cairo_helpers.h | |
| 515 | - $(CC) -c $(CFLAGS) -o $@ $< | ||
| 515 | + $(CC) -c $(CFLAGS) $(CFLAGSEXTRA) -o $@ $< | ||
| 516 | 516 | ||
| 517 | 517 | # extract icons from wgnuplot.rc | |
| 518 | 518 | texticon.ico: grpicon.ico | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,5 @@ | |||
| 1 | 1 | # | |
| 2 | - # $Id: Makefile,v 1.2 2011/10/30 18:31:01 markisch Exp $ | ||
| 2 | + # $Id: Makefile,v 1.3 2011/11/27 22:18:36 markisch Exp $ | ||
| 3 | 3 | # | |
| 4 | 4 | # GNUPLOT Makefile Microsoft Visual C++ 2005 or newer | |
| 5 | 5 | ||
@@ -85,6 +85,7 @@ LD = link | |||
| 85 | 85 | # /MD means include multi-thread support (DLL) | |
| 86 | 86 | CBASEFLAGS = /EHsc /GR /MD /O2 /nologo | |
| 87 | 87 | CFLAGS = $(CBASEFLAGS) /I. /I$(TOP) /I$(S) /D_Windows /DWIN32 /DHAVE_CONFIG_H /D__MSC__ /DHELPFILE=\"$(HELPFILE)\" $(OPTIONS) | |
| 88 | + WIN_CFLAGS = /DUSE_FAKEPIPES | ||
| 88 | 89 | CONSOLE_CFLAGS = /DWGP_CONSOLE /DCONSOLE_SWITCH_CP /DPIPES | |
| 89 | 90 | OPTIONS = /DUSE_MOUSE | |
| 90 | 91 | OPTIONS = $(OPTIONS) /DGNUPLOT_HISTORY | |
@@ -165,19 +166,19 @@ ALL_CONSOLE_OBJS = $(OBJS:.obj=.cobj) $(WINOBJS:.obj=.cobj) | |||
| 165 | 166 | ||
| 166 | 167 | # default rules | |
| 167 | 168 | {$(S)}.c.obj: | |
| 168 | - $(CC) /c $(CFLAGS) $(S)\\$*.c | ||
| 169 | + $(CC) /c $(CFLAGS) $(WIN_CFLAGS) $(S)\\$*.c | ||
| 169 | 170 | ||
| 170 | 171 | {$(S)}.c.cobj: | |
| 171 | 172 | $(CC) /c $(CFLAGS) $(CONSOLE_CFLAGS) $(S)\\$*.c /Fo$@ | |
| 172 | 173 | ||
| 173 | 174 | {$(W)}.c.obj: | |
| 174 | - $(CC) /c $(CFLAGS) $(W)$*.c /Fo$@ | ||
| 175 | + $(CC) /c $(CFLAGS) $(WIN_CFLAGS) $(W)$*.c /Fo$@ | ||
| 175 | 176 | ||
| 176 | 177 | {$(W)}.c.cobj: | |
| 177 | 178 | $(CC) /c $(CFLAGS) $(CONSOLE_CFLAGS) $(W)$*.c /Fo$@ | |
| 178 | 179 | ||
| 179 | 180 | {$(W)}.cpp.obj: | |
| 180 | - $(CC) /c $(CFLAGS) $(W)$*.cpp /Fo$@ | ||
| 181 | + $(CC) /c $(CFLAGS) $(WIN_CFLAGS) $(W)$*.cpp /Fo$@ | ||
| 181 | 182 | ||
| 182 | 183 | {$(W)}.cpp.cobj: | |
| 183 | 184 | $(CC) /c $(CFLAGS) $(CONSOLE_CFLAGS) $(W)$*.cpp /Fo$@ | |
@@ -257,13 +258,13 @@ linkopt-c.msw: Makefile | |||
| 257 | 258 | # rules | |
| 258 | 259 | ||
| 259 | 260 | term.obj: $(S)\term.c $(S)\term.h $(S)\plot.h $(S)\setshow.h $(S)\bitmap.h $(CORETERM) | |
| 260 | - $(CC) /c $(CFLAGS) $(TERMFLAGS) $(S)\$(*B).c /Fo$@ | ||
| 261 | + $(CC) /c $(CFLAGS) $(WIN_CFLAGS) $(TERMFLAGS) $(S)\$(*B).c /Fo$@ | ||
| 261 | 262 | ||
| 262 | 263 | term.cobj: $(S)\term.c $(S)\term.h $(S)\plot.h $(S)\setshow.h $(S)\bitmap.h $(CORETERM) | |
| 263 | 264 | $(CC) /c $(CFLAGS) $(CONSOLE_CFLAGS) $(TERMFLAGS) $(S)\$(*B).c /Fo$@ | |
| 264 | 265 | ||
| 265 | 266 | winmain.obj: $(W)winmain.c $(W)wgnuplib.h $(W)wtext.h $(S)\plot.h | |
| 266 | - $(CC) /c $(CFLAGS) $(W)$(*B).c /Fo$@ | ||
| 267 | + $(CC) /c $(CFLAGS) $(WIN_CFLAGS) $(W)$(*B).c /Fo$@ | ||
| 267 | 268 | ||
| 268 | 269 | winmain.cobj: $(W)winmain.c $(W)wgnuplib.h $(W)wtext.h $(S)\plot.h | |
| 269 | 270 | $(CC) /c $(CFLAGS) $(CONSOLE_CFLAGS) $(W)winmain.c /Fo$@ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,5 @@ | |||
| 1 | 1 | #ifndef lint | |
| 2 | - static char *RCSid() { return RCSid("$Id: winmain.c,v 1.52 2011/11/14 21:03:38 markisch Exp $"); } | ||
| 2 | + static char *RCSid() { return RCSid("$Id: winmain.c,v 1.53 2011/12/05 19:25:10 markisch Exp $"); } | ||
| 3 | 3 | #endif | |
| 4 | 4 | ||
| 5 | 5 | /* GNUPLOT - win/winmain.c */ | |
@@ -829,6 +829,107 @@ MyFRead(void *ptr, size_t size, size_t n, FILE *file) | |||
| 829 | 829 | return fread(ptr, size, n, file); | |
| 830 | 830 | } | |
| 831 | 831 | ||
| 832 | + | ||
| 833 | + #ifdef USE_FAKEPIPES | ||
| 834 | + | ||
| 835 | + static char pipe_type = NUL; | ||
| 836 | + static char * pipe_filename = NULL; | ||
| 837 | + static char * pipe_command = NULL; | ||
| 838 | + | ||
| 839 | + FILE * | ||
| 840 | + fake_popen(const char * command, const char * type) | ||
| 841 | + { | ||
| 842 | + FILE * f = NULL; | ||
| 843 | + char tmppath[MAX_PATH]; | ||
| 844 | + char tmpfile[MAX_PATH]; | ||
| 845 | + DWORD ret; | ||
| 846 | + | ||
| 847 | + if (type == NULL) return NULL; | ||
| 848 | + | ||
| 849 | + pipe_type = NUL; | ||
| 850 | + if (pipe_filename != NULL) | ||
| 851 | + free(pipe_filename); | ||
| 852 | + | ||
| 853 | + /* Random temp file name in %TEMP% */ | ||
| 854 | + ret = GetTempPath(sizeof(tmppath), tmppath); | ||
| 855 | + if ((ret == 0) || (ret > sizeof(tmppath))) | ||
| 856 | + return NULL; | ||
| 857 | + ret = GetTempFileName(tmppath, "gpp", 0, tmpfile); | ||
| 858 | + if (ret == 0) | ||
| 859 | + return NULL; | ||
| 860 | + pipe_filename = strdup(tmpfile); | ||
| 861 | + | ||
| 862 | + if (*type == 'r') { | ||
| 863 | + char * cmd; | ||
| 864 | + int rc; | ||
| 865 | + pipe_type = *type; | ||
| 866 | + /* Execute command with redirection of stdout to temporary file. */ | ||
| 867 | + cmd = (char *) malloc(strlen(command) + strlen(pipe_filename) + 5); | ||
| 868 | + sprintf(cmd, "%s > %s", command, pipe_filename); | ||
| 869 | + rc = system(cmd); | ||
| 870 | + free(cmd); | ||
| 871 | + /* Now open temporary file. */ | ||
| 872 | + /* system() returns 1 if the command could not be executed. */ | ||
| 873 | + if (rc != 1) | ||
| 874 | + f = fopen(pipe_filename, "r"); | ||
| 875 | + else { | ||
| 876 | + remove(pipe_filename); | ||
| 877 | + free(pipe_filename); | ||
| 878 | + pipe_filename = NULL; | ||
| 879 | + errno = EINVAL; | ||
| 880 | + } | ||
| 881 | + } else if (*type == 'w') { | ||
| 882 | + pipe_type = *type; | ||
| 883 | + /* Write output to temporary file and handle the rest in fake_pclose. */ | ||
| 884 | + if (type[1] == 'b') | ||
| 885 | + int_error(NO_CARET, "Could not execute pipe '%s'. Writing to binary pipes is not supported.", command); | ||
| 886 | + else | ||
| 887 | + f = fopen(pipe_filename, "w"); | ||
| 888 | + pipe_command = strdup(command); | ||
| 889 | + } | ||
| 890 | + | ||
| 891 | + return f; | ||
| 892 | + } | ||
| 893 | + | ||
| 894 | + | ||
| 895 | + int fake_pclose(FILE *stream) | ||
| 896 | + { | ||
| 897 | + int rc = 0; | ||
| 898 | + if (!stream) return ECHILD; | ||
| 899 | + | ||
| 900 | + /* Close temporary file */ | ||
| 901 | + fclose(stream); | ||
| 902 | + | ||
| 903 | + /* Finally, execute command with redirected stdin. */ | ||
| 904 | + if (pipe_type == 'w') { | ||
| 905 | + char * cmd; | ||
| 906 | + cmd = (char *) malloc(strlen(pipe_command) + strlen(pipe_filename) + 10); | ||
| 907 | + /* FIXME: this won't work for binary data. We need a proper `cat` replacement. */ | ||
| 908 | + sprintf(cmd, "type %s | %s", pipe_filename, pipe_command); | ||
| 909 | + rc = system(cmd); | ||
| 910 | + free(cmd); | ||
| 911 | + } | ||
| 912 | + | ||
| 913 | + /* Delete temp file again. */ | ||
| 914 | + if (pipe_filename) { | ||
| 915 | + remove(pipe_filename); | ||
| 916 | + errno = 0; | ||
| 917 | + free(pipe_filename); | ||
| 918 | + pipe_filename = NULL; | ||
| 919 | + } | ||
| 920 | + | ||
| 921 | + if (pipe_command) { | ||
| 922 | + /* system() returns 255 if the command could not be executed. | ||
| 923 | + The real popen would have returned an error already. */ | ||
| 924 | + if (rc == 255) | ||
| 925 | + int_error(NO_CARET, "Could not execute pipe '%s'.", pipe_command); | ||
| 926 | + free(pipe_command); | ||
| 927 | + } | ||
| 928 | + | ||
| 929 | + return rc; | ||
| 930 | + } | ||
| 931 | + #endif | ||
| 932 | + | ||
| 832 | 933 | #else /* WGP_CONSOLE */ | |
| 833 | 934 | ||
| 834 | 935 | DWORD WINAPI stdin_pipe_reader(LPVOID param) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,5 @@ | |||
| 1 | 1 | /* | |
| 2 | - * $Id: wtext.h,v 1.9 2004/07/01 17:10:11 broeker Exp $ | ||
| 2 | + * $Id: wtext.h,v 1.10 2008/11/07 11:55:46 mikulik Exp $ | ||
| 3 | 3 | */ | |
| 4 | 4 | ||
| 5 | 5 | /* GNUPLOT - win/wtext.h */ | |
@@ -104,6 +104,11 @@ int MyPrintF(const char *fmt, ...); | |||
| 104 | 104 | size_t MyFWrite(const void *ptr, size_t size, size_t n, FILE *stream); | |
| 105 | 105 | size_t MyFRead(void *ptr, size_t size, size_t n, FILE *stream); | |
| 106 | 106 | ||
| 107 | + #ifdef USE_FAKEPIPES | ||
| 108 | + FILE *fake_popen(const char *command, const char *type); | ||
| 109 | + int fake_pclose(FILE *stream); | ||
| 110 | + #endif | ||
| 111 | + | ||
| 107 | 112 | #else /* WGP_CONSOLE */ | |
| 108 | 113 | ||
| 109 | 114 | #define getch ConsoleGetch | |
| Back | FazBrowse Home | New Git URL |
0 commit comments