Skip to content

Commit

Permalink
Merge pull request #2375 from jtanx/winbugs
Browse files Browse the repository at this point in the history
Windows Mingw+CygWin patches
  • Loading branch information
frank-trampe committed Jun 30, 2015
2 parents 93065ba + f810b3f commit 176a172
Show file tree
Hide file tree
Showing 8 changed files with 127 additions and 233 deletions.
5 changes: 4 additions & 1 deletion configure.ac
Expand Up @@ -468,11 +468,14 @@ case $host in
;;
*-apple-darwin*)
;;
*mingw* | *cygwin*)
*mingw*)
dnl Explicitly export all symbols on Windows, since FontForge lacks an export table
dnl See issue #1238 on GitHub for more information.
my_lib_ldflags="${my_lib_ldflags} -no-undefined -Wl,--export-all-symbols"
;;
*cygwin*)
my_lib_ldflags="${my_lib_ldflags} -Wl,-no-undefined -Wl,--export-all-symbols"
;;
*) saved_LDFLAGS=$LDFLAGS
AC_MSG_CHECKING([whether the linker supports --no-undefined])
LDFLAGS="$saved_LDFLAGS -Wl,--no-undefined"
Expand Down
92 changes: 55 additions & 37 deletions fontforge/sfd.c
Expand Up @@ -9142,63 +9142,81 @@ return( NULL );
return( sf );
}

static int ask_about_file(FILE *asfd,int *state,char *filename) {
/**
* Asks the user whether or not to recover, skip or delete an autosaved file.
* If requested by the user, this function will attempt to delete the file.
* @param [in] filename The path to the autosaved file.
* @param [in,out] state The current state.
* state&1: Recover all. state&2: Forget all.
* @param [out] asfd Location to store the file pointer to the autosaved file.
* @return true iff the file is to be recovered. If true, asfd will hold the
* corresponding file pointer, which must be closed by the caller. If
* false, asfd will hold NULL.
*/
static int ask_about_file(char *filename, int *state, FILE **asfd) {
int ret;
char *buts[6];
char buffer[800], *pt;

if ( *state&1 )
return( true );
else if ( *state&2 ) {
unlink(filename);
return( false );
if ((*asfd = fopen(filename, "r")) == NULL) {
return false;
} else if (*state&1) { //Recover all
return true;
} else if (*state&2) { //Forget all
fclose(*asfd);
*asfd = NULL;
unlink(filename);
return false;
}

fgets(buffer,sizeof(buffer),asfd);
rewind(asfd);
if ( strncmp(buffer,"Base: ",6)!=0 )
strcpy(buffer+6, "<New File>");
fgets(buffer,sizeof(buffer),*asfd);
rewind(*asfd);
if (strncmp(buffer,"Base: ",6) != 0) {
strcpy(buffer+6, "<New File>");
}
pt = buffer+6;
if ( strlen(buffer+6)>70 ) {
pt = strrchr(buffer+6,'/');
if ( pt==NULL )
pt = buffer+6;
if (strlen(buffer+6) > 70) {
pt = strrchr(buffer+6,'/');
if (pt == NULL)
pt = buffer+6;
}

buts[0] = _("Yes"); buts[1] = _("Yes to _All");
buts[2] = _("_Skip for now");
buts[3] = _("Forget _to All"); buts[4] = _("_Forget about it");
buts[5] = NULL;
ret = ff_ask(_("Recover old edit"),(const char **) buts,0,3,_("You appear to have an old editing session on %s.\nWould you like to recover it?"), pt );
switch ( ret ) {
case 0:
return( true );
case 1:
*state = 1;
return( true );
case 2:
return( false );
case 3:
*state = 2;
/* Fall through */
case 4:
unlink(filename);
return( false );
default:
break;
ret = ff_ask(_("Recover old edit"),(const char **) buts,0,3,_("You appear to have an old editing session on %s.\nWould you like to recover it?"), pt);
switch (ret) {
case 1: //Recover all
*state = 1;
break;
case 2: //Skip one
fclose(*asfd);
*asfd = NULL;
return false;
case 3: //Forget all
*state = 2;
/* Fall through */
case 4: //Forget one
fclose(*asfd);
*asfd = NULL;
unlink(filename);
return false;
default: //Recover one
break;
}
return( true );
return true;
}

SplineFont *SFRecoverFile(char *autosavename,int inquire,int *state) {
FILE *asfd = fopen( autosavename,"r");
FILE *asfd;
SplineFont *ret;
char tok[1025];

if ( asfd==NULL )
return(NULL);
if ( inquire && !ask_about_file(asfd,state,autosavename)) {
fclose( asfd );
if (!inquire) {
*state = 1; //Default to recover all
}
if (!ask_about_file(autosavename, state, &asfd)) {
return( NULL );
}
locale_t tmplocale; locale_t oldlocale; // Declare temporary locale storage.
Expand Down
2 changes: 1 addition & 1 deletion fontforge/splinefont.h
Expand Up @@ -3548,7 +3548,7 @@ char * delimit_null(const char * input, char delimiter);

#include "ustring.h"

#ifdef __MINGW32__
#ifdef _WIN32
#define BAD_LOCALE_HACK
typedef char* locale_t;
#define LC_GLOBAL_LOCALE ((locale_t)-1)
Expand Down
16 changes: 5 additions & 11 deletions fontforgeexe/charview.c
Expand Up @@ -272,26 +272,23 @@ static struct resed charview2_re[] = {
};

/* return 1 if anything changed */
static int update_spacebar_hand_tool(CharView *cv) {
static void update_spacebar_hand_tool(CharView *cv) {
if ( GDrawKeyState(' ') ) {
if ( !cv->spacebar_hold && !cv_auto_goto ) {
cv->spacebar_hold = 1;
cv->b1_tool_old = cv->b1_tool;
cv->b1_tool = cvt_hand;
cv->active_tool = cvt_hand;
CVMouseDownHand(cv);
return 1;
}
} else {
if ( cv->spacebar_hold ) {
cv->spacebar_hold = 0;
cv->b1_tool = cv->b1_tool_old;
cv->active_tool = cvt_none;
cv->b1_tool_old = cvt_none;
return 1;
}
}
return 0;
}

/**
Expand Down Expand Up @@ -4758,7 +4755,7 @@ return; /* I treat this more like a modifier key change than a button press */
if( cv->charselector && cv->charselector == GWindowGetFocusGadgetOfWindow(cv->gw))
GWindowClearFocusGadgetOfWindow(cv->gw);

update_spacebar_hand_tool(cv); /* needed? (left from MINGW) */
update_spacebar_hand_tool(cv);

CVToolsSetCursor(cv,event->u.mouse.state|(1<<(7+event->u.mouse.button)), event->u.mouse.device );
if( override_showing_tool != cvt_none )
Expand Down Expand Up @@ -5246,18 +5243,15 @@ static void CVMouseMove(CharView *cv, GEvent *event ) {
GEvent fake;
int stop_motion = false;
int has_spiro = hasspiro();
int spacebar_changed;

/* Debug wacom !!!! */
/* TRACE( "dev=%s (%d,%d) 0x%x\n", event->u.mouse.device!=NULL?event->u.mouse.device:"<None>", */
/* event->u.mouse.x, event->u.mouse.y, event->u.mouse.state); */

spacebar_changed = update_spacebar_hand_tool(cv);

if ( event->u.mouse.device!=NULL || spacebar_changed )
if ( event->u.mouse.device!=NULL )
CVToolsSetCursor(cv,event->u.mouse.state,event->u.mouse.device);

if ( !cv->p.pressed && !cv->spacebar_hold ) {
if ( !cv->p.pressed ) {
CVUpdateInfo(cv, event);
if ( cv->showing_tool==cvt_pointer ) {
CVCheckResizeCursors(cv);
Expand Down Expand Up @@ -5506,7 +5500,7 @@ static void CVMouseUp(CharView *cv, GEvent *event ) {
}
cv->p.pressed = false;
CVFreePreTransformSPL( cv );
update_spacebar_hand_tool(cv); /* needed? (left from MINGW) */
update_spacebar_hand_tool(cv);

if ( cv->p.rubberbanding ) {
CVDrawRubberRect(cv->v,cv);
Expand Down

0 comments on commit 176a172

Please sign in to comment.