From: <arj...@us...> - 2013-12-09 19:18:25
|
Revision: 12835 http://sourceforge.net/p/plplot/code/12835 Author: arjenmarkus Date: 2013-12-09 19:18:22 +0000 (Mon, 09 Dec 2013) Log Message: ----------- Changes to get the Tk bindings compilable on Windows for the ntk. Not all the code involved in this change set is actually used by the ntk device, but the compiler and linker complain otherwise. Modified Paths: -------------- trunk/bindings/tk/plframe.c trunk/bindings/tk/pltkd.h trunk/bindings/tk/tcpip.c trunk/bindings/tk/tkMain.c Modified: trunk/bindings/tk/plframe.c =================================================================== --- trunk/bindings/tk/plframe.c 2013-12-09 19:16:11 UTC (rev 12834) +++ trunk/bindings/tk/plframe.c 2013-12-09 19:18:22 UTC (rev 12835) @@ -1195,7 +1195,11 @@ dbug_enter( "PlFrameKeyEH" ); +#if !defined( __WIN32__ ) nchars = XLookupString( event, string, 10, &keysym, &cs ); +#else + nchars = 0; +#endif string[nchars] = '\0'; pldebug( "PlFrameKeyEH", "Keysym %x, translation: %s\n", keysym, string ); @@ -2544,7 +2548,11 @@ (char *) NULL ); return TCL_ERROR; } +#if !defined( __WIN32__ ) if ( ( iodev->fd = open( argv[1], O_RDONLY ) ) == -1 ) +#else + if ( 1 ) +#endif { Tcl_AppendResult( interp, "cannot open fifo ", argv[1], " for read", (char *) NULL ); @@ -2552,7 +2560,11 @@ } iodev->type = 0; iodev->typeName = "fifo"; +#if !defined( __WIN32__ ) iodev->file = fdopen( iodev->fd, "rb" ); +#else + iodev->file = NULL; +#endif } // Open socket @@ -2863,7 +2875,11 @@ if ( plFramePtr->plpr_cmd == NULL ) plFramePtr->plpr_cmd = plFindCommand( "plpr" ); +#if !defined( __WIN32__ ) if ( ( plFramePtr->plpr_cmd == NULL ) || ( pid = fork() ) < 0 ) +#else + if ( 1 ) +#endif { Tcl_AppendResult( interp, "Error -- cannot fork print process", @@ -2872,8 +2888,12 @@ } else if ( pid == 0 ) { +#if !defined( __WIN32__ ) if ( execl( plFramePtr->plpr_cmd, plFramePtr->plpr_cmd, sfnam, (char *) 0 ) ) +#else + if ( 1 ) +#endif { fprintf( stderr, "Unable to exec print command.\n" ); free( sfnam ); Modified: trunk/bindings/tk/pltkd.h =================================================================== --- trunk/bindings/tk/pltkd.h 2013-12-09 19:16:11 UTC (rev 12834) +++ trunk/bindings/tk/pltkd.h 2013-12-09 19:18:22 UTC (rev 12835) @@ -21,6 +21,11 @@ #include <dp.h> #endif +// Define the type pid_t - a dummy for the moment - for MS Windows +#if defined(__WIN32__) +typedef unsigned int pid_t; +#endif + // One of these holds the TK driver state information typedef struct Modified: trunk/bindings/tk/tcpip.c =================================================================== --- trunk/bindings/tk/tcpip.c 2013-12-09 19:16:11 UTC (rev 12834) +++ trunk/bindings/tk/tcpip.c 2013-12-09 19:18:22 UTC (rev 12835) @@ -105,9 +105,18 @@ #include <sys/types.h> #include <fcntl.h> #include <ctype.h> +#if !defined( __WIN32__ ) #include <sys/uio.h> +#endif #include <errno.h> +// Supply dummy macros for the low-level I/O functions - Windows +#if defined( __WIN32__ ) +#define read(a,b,c) 0 +#define close(a) +#define write(a,b,c) 0 +#endif + //extern int errno; #ifndef MIN Modified: trunk/bindings/tk/tkMain.c =================================================================== --- trunk/bindings/tk/tkMain.c 2013-12-09 19:16:11 UTC (rev 12834) +++ trunk/bindings/tk/tkMain.c 2013-12-09 19:18:22 UTC (rev 12835) @@ -108,7 +108,12 @@ // extern int isatty _ANSI_ARGS_((int fd)); // extern int read _ANSI_ARGS_((int fd, char *buf, size_t size)); // +#if !defined(__WIN32__) extern char * strrchr _ANSI_ARGS_( ( CONST char *string, int c ) ); +#else +// On Windows we do not have a convenient console to work with +#define isatty( a ) 0 +#endif // // Global variables used by the main program: @@ -199,6 +204,7 @@ // // Parse command-line arguments. // + fprintf( stderr, "Before Tk_ParseArgv\n"); if ( Tk_ParseArgv( interp, (Tk_Window) NULL, &argc, argv, argTable, 0 ) != TCL_OK ) @@ -206,6 +212,7 @@ fprintf( stderr, "%s\n", Tcl_GetStringResult( interp ) ); exit( 1 ); } + fprintf( stderr, "After Tk_ParseArgv\n"); if ( name == NULL ) { if ( fileName != NULL ) @@ -308,6 +315,7 @@ // and "argv". Also set the "geometry" variable from the geometry // specified on the command line. // + fprintf( stderr, "Before Tcl_Merge\n"); args = Tcl_Merge( argc - 1, ( CONST char * CONST * )argv + 1 ); Tcl_SetVar( interp, "argv", args, TCL_GLOBAL_ONLY ); @@ -315,6 +323,7 @@ sprintf( buf, "%d", argc - 1 ); Tcl_SetVar( interp, "argc", buf, TCL_GLOBAL_ONLY ); + fprintf( stderr, "After Tcl_Merge\n"); if ( geometry != NULL ) { Tcl_SetVar( interp, "geometry", geometry, TCL_GLOBAL_ONLY ); @@ -336,6 +345,7 @@ // // Invoke application-specific initialization. // + fprintf( stderr, "Before AppInit\n"); if ( ( *AppInit )( interp ) != TCL_OK ) { @@ -359,6 +369,7 @@ // // Process the startup script, if any. // + fprintf( stderr, "Before startup\n"); if ( script != NULL ) { @@ -373,6 +384,7 @@ // // Invoke the script specified on the command line, if any. // + fprintf( stderr, "Before source\n"); if ( fileName != NULL ) { @@ -436,6 +448,7 @@ // are no windows left, Tk_MainLoop returns and we exit. // + fprintf( stderr, "Before Tk_MainLoop\n"); Tk_MainLoop(); // @@ -489,7 +502,11 @@ int code, count; const char *res; +#if !defined(__WIN32__) count = (int) read( fileno( stdin ), input, BUFFER_SIZE ); +#else + count = fread( input, BUFFER_SIZE, sizeof( char ), stdin ); +#endif if ( count <= 0 ) { if ( !gotPartial ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |