diff -u gtypist-2.7/cursmenu.c gtypist-2.7-mingw/cursmenu.c --- gtypist-2.7/cursmenu.c Mon Sep 29 06:35:22 2003 +++ gtypist-2.7-mingw/cursmenu.c Fri Apr 4 10:14:23 2008 @@ -406,6 +406,9 @@ #ifdef DJGPP case '\x0D': #endif +#ifdef MINGW + case '\x0D': +#endif case ASCII_SPACE: ch = KEY_ENTER; case KEY_ENTER: diff -u gtypist-2.7/gtypist.c gtypist-2.7-mingw/gtypist.c --- gtypist-2.7/gtypist.c Mon Sep 29 06:35:22 2003 +++ gtypist-2.7-mingw/gtypist.c Fri Apr 4 10:32:25 2008 @@ -655,6 +655,10 @@ if ( c == 0x0D ) rc = c = 0x0A; #endif +#ifdef MINGW + if ( c == 0x0D ) + rc = c = 0x0A; +#endif while ( rc == KEY_BACKSPACE || c == ASCII_BS || c == ASCII_DEL ) @@ -1206,8 +1210,13 @@ if (toupper (resp) == 'Y' || toupper (resp) == YN[0]) resp = 0; - if (toupper (resp) == 'N' || toupper (resp) == YN[2]) + else if (toupper (resp) == 'N' || toupper (resp) == YN[2]) resp = -1; + /* Some PDCURSES implementations return -1 when no key is pressed + for a second or so. So, unless resp is explicitly set to Y/N, + don't exit! */ + else + resp = 2; } while (resp != 0 && resp != -1); /* clear out the message line */ @@ -1932,8 +1941,15 @@ strcpy( script_file, argv[optind] ); else sprintf( script_file,"%s/%s",DATADIR,DEFAULT_SCRIPT); - - script = fopen( script_file, "r" ); + +#ifdef MINGW + /* MinGW's ftell doesn't work properly for absolute file positions in + text mode, so open in binary mode instead. */ +# define FILE_READ_MODE "rb" +#else +# define FILE_READ_MODE "r" +#endif + script = fopen( script_file, FILE_READ_MODE ); if (script==NULL && getenv( "GTYPIST_PATH" ) != NULL ) { p = strtok( getenv( "GTYPIST_PATH" ), ":" ); @@ -1943,7 +1959,7 @@ strcpy( filepath, p ); strcat( filepath, "/" ); strcat( filepath, script_file ); - if ( (script = fopen( filepath, "r" )) != NULL ) + if ( (script = fopen( filepath, FILE_READ_MODE )) != NULL ) break; } } @@ -1952,7 +1968,7 @@ strcpy( filepath, DATADIR ); strcat( filepath, "/" ); strcat( filepath, script_file ); - script = fopen( filepath, "r" ); + script = fopen( filepath, FILE_READ_MODE ); } if ( script == NULL ) @@ -1965,12 +1981,16 @@ /* prepare for curses stuff, and set up a signal handler to undo curses if we get interrupted */ scr = initscr(); - signal( SIGHUP, catcher ); signal( SIGINT, catcher ); + signal( SIGINT, catcher ); + signal( SIGTERM, catcher ); +#ifndef MINGW + signal( SIGHUP, catcher ); signal( SIGQUIT, catcher ); #ifndef DJGPP signal( SIGCHLD, catcher ); #endif - signal( SIGPIPE, catcher ); signal( SIGTERM, catcher ); + signal( SIGPIPE, catcher ); +#endif clear(); refresh(); typeahead( -1 ); keypad( scr, TRUE ); noecho(); curs_set( 0 ); raw(); diff -u gtypist-2.7/script.h gtypist-2.7-mingw/script.h --- gtypist-2.7/script.h Mon Sep 29 06:35:22 2003 +++ gtypist-2.7-mingw/script.h Fri Apr 4 10:24:58 2008 @@ -50,10 +50,14 @@ #define C_ON_FAILURE_SET 'F' #define C_MENU 'M' -#ifndef DJGPP -#define ASCII_ENTER '\n' +#ifdef DJGPP +#define ASCII_ENTER 0x0D #else +#ifdef MINGW #define ASCII_ENTER 0x0D +#else +#define ASCII_ENTER '\n' +#endif #endif #define ASCII_NL '\n' #define ASCII_NULL '\0' --- /dev/null Fri Apr 4 10:44:08 2008 +++ gtypist-2.7-mingw/Makefile.mingw32 Fri Apr 4 11:20:47 2008 @@ -0,0 +1,23 @@ +# gtypist: Makefile for MinGW +# By Paul Goins: general@vultaire.net +# Based off the makefile generated for DJGPP +# +# To use, just type "make -f Makefile.mingw32". mingw32-make also works. +# However, read the following note: +# +# Building under MinGW requires PDCurses, available from +# pdcurses.sourceforge.net. This was tested using a plain PDCurses build +# (static, non-Unicode). If building PDCurses using the win32\mingwin32.mak +# make file, make sure that Windows copy/del are in your path (mainly an issue +# for MSys users). Also, the link libs probably will not be preceded with +# "lib", so you'll need to rename pdcurses.a, panel.a to +# libpdcurses.a, libpanel.a by hand. + + +# Define the path to a compiled PDCurses library below. +PDCURSES_PATH=c:/devel/pdcurses + +gtypist.exe: + gcc -DMINGW -I$(PDCURSES_PATH) -static -O -DNCURSES -o gtypist error.c \ + script.c cursmenu.c gtypist.c getopt.c getopt1.c \ + -L$(PDCURSES_PATH)/win32 -lpdcurses -lpanel