Skip to content
Browse files

some updates for building on mingw

  • Loading branch information...
1 parent 95469ed commit a035323121ac6d1901062d29770c01239ac98d78 @monkeyiq monkeyiq committed Dec 23, 2012
View
4 fontforge/Makefile.am
@@ -139,7 +139,7 @@ is_LIGATURE:
if GRAPHICAL_USER_INTERFACE
-libfontforgeexe_la_SOURCES = alignment.c anchorsaway.c \
+libfontforgeexe_la_SOURCES = alignment.c anchorsaway.c \
autowidth2dlg.c basedlg.c bdfinfo.c bitmapdlg.c bitmapview.c \
charinfo.c charview.c clipui.c combinations.c contextchain.c \
cursors.c cvaddpoints.c cvdebug.c cvdgloss.c cvexportdlg.c \
@@ -154,7 +154,7 @@ libfontforgeexe_la_SOURCES = alignment.c anchorsaway.c \
scstylesui.c searchview.c sftextfield.c showatt.c simplifydlg.c \
splashimage.c startui.c statemachine.c tilepath.c transform.c \
ttfinstrsui.c uiutil.c windowmenu.c justifydlg.c deltaui.c \
- usermenu.c
+ usermenu.c
else !GRAPHICAL_USER_INTERFACE
View
4 fontforge/autotrace.c
@@ -42,6 +42,8 @@
#include <errno.h> /* for errors */
#include <dirent.h> /* for opendir,etc. */
+#include <glib.h>
+
int preferpotrace = false;
/* Interface to Martin Weber's autotrace program */
@@ -193,7 +195,7 @@ static int mytempnam(char *buffer) {
else
strcpy(buffer,P_tmpdir);
strcat(buffer,"/PfaEdXXXXXX");
- fd = mkstemp(buffer);
+ fd = g_mkstemp(buffer);
#if 0
old = copy(buffer);
strcat(buffer,".bmp");
View
9 fontforge/cvundoes.c
@@ -29,6 +29,12 @@
#include <ustring.h>
#include <utype.h>
+#if defined(__MINGW32__)
+// no backtrace on windows yet
+#else
+ #include <execinfo.h>
+#endif
+
extern char *coord_sep;
int onlycopydisplayed = 0;
@@ -50,12 +56,15 @@ extern void BackTraceFD( int fd );
extern void BackTrace( const char* msg );
void BackTraceFD( int fd ) {
+#if defined(__MINGW32__)
+#else
const int arraysz = 500;
void* array[arraysz];
size_t size;
size = backtrace( array, arraysz );
backtrace_symbols_fd( array, size, fd );
+#endif
}
void BackTrace( const char* msg ) {
View
22 fontforge/langfreq.c
@@ -8,6 +8,8 @@
#include "splinefont.h"
#include <intl.h>
+#include <glib.h>
+
#define ISOL 0
#define INIT 1
#define MEDI 2
@@ -1866,7 +1868,7 @@ static int RandomWordLength(float *wl) {
wl = word_lengths;
retry:
- cum = random()/(double) RAND_MAX;
+ cum = g_random_int()/(double) RAND_MAX;
for ( i=0; i<30; ++i ) {
if ( cum<wl[i] )
return( i );
@@ -1916,7 +1918,7 @@ return( -1 );
percent = space;
}
for ( tries=0; tries<5; ++tries ) {
- cum = random()/(double) RAND_MAX;
+ cum = g_random_int()/(double) RAND_MAX;
for ( i=0; freq[i].utf8_letter!=NULL; ++i ) {
if ( cum<=percent[i] && percent[i]!=0 ) {
if ( sf==NULL || SFHasUtf8Sequence(sf,freq[i].utf8_letter))
@@ -1930,7 +1932,7 @@ return( i );
}
for ( tries=0; tries<10; ++tries ) {
- cum = random()/(double) RAND_MAX;
+ cum = g_random_int()/(double) RAND_MAX;
for ( i=0; freq[i].utf8_letter!=NULL; ++i ) {
if ( cum<freq[i].frequency[pos] ) {
if ( sf==NULL || SFHasUtf8Sequence(sf,freq[i].utf8_letter))
@@ -1948,7 +1950,7 @@ return( i );
if ( cnt==0 )
return( -1 );
for ( tries=0; tries<10; ++tries ) {
- i = random()%cnt;
+ i = g_random_int()%cnt;
if ( sf==NULL || SFHasUtf8Sequence(sf,freq[i].utf8_letter))
return( i );
}
@@ -2000,7 +2002,7 @@ static char *RandomWord(struct lang_frequencies *lf, SplineFont *sf) {
/* Now there are some "words" with no vowels: "Mrs", "Dr", "PhD" */
/* so this is not an absolute */
if ( len>1 && all_consonant_count++<4 &&
- random()/(double) RAND_MAX >= lf->all_consonants[len] ) {
+ g_random_int()/(double) RAND_MAX >= lf->all_consonants[len] ) {
clen = 1;
pt = word_buf;
for ( last=0; freq[last].utf8_letter!=NULL; ++last )
@@ -2021,9 +2023,9 @@ static char *RandomWord(struct lang_frequencies *lf, SplineFont *sf) {
/* and divide by the prob of a two vowel sequence, and check */
if (( vlen>1 && isv ) || ( clen>1 && !isv )) {
if ( isv )
- retry = random()/(double) RAND_MAX >= lf->vowel_run[vlen+1]/lf->vowel_run[2];
+ retry = g_random_int()/(double) RAND_MAX >= lf->vowel_run[vlen+1]/lf->vowel_run[2];
else
- retry = random()/(double) RAND_MAX >= lf->consonant_run[vlen+1]/lf->consonant_run[2];
+ retry = g_random_int()/(double) RAND_MAX >= lf->consonant_run[vlen+1]/lf->consonant_run[2];
if ( retry ) {
int j;
for ( j=0; j<10; ++j ) {
@@ -2153,7 +2155,7 @@ return( buffer );
static char *ScriptRandomChar(struct script_chars *chrs) {
int i;
- i = random()%chrs->cnt;
+ i = g_random_int()%chrs->cnt;
return( ch2utf8( chrs->chars[i]) );
}
@@ -2175,7 +2177,7 @@ return( word_buf );
static char *RandomPara(struct lang_frequencies *lf,
struct script_chars *chrs, SplineFont *sf) {
/* paragraphs will be somewhere between 20 and 84 words */
- int i, len = 20 + (random()/(RAND_MAX>>6));
+ int i, len = 20 + (g_random_int()/(RAND_MAX>>6));
#define PARA_MAX (84*(WORD_MAX+1)+10)
char parabuf[PARA_MAX];
char *pt = parabuf;
@@ -2240,7 +2242,7 @@ char *RandomParaFromScript(uint32 script, uint32 *lang, SplineFont *sf) {
++cnt;
}
if ( cnt!=0 ) {
- int pos = random()%(cnt+1);
+ int pos = g_random_int()%(cnt+1);
if ( pos<cnt ) {
cnt = 0;
for ( i=0; lang_frequencies[i].script!=0; ++i ) {
View
10 fontforge/noprefs.c
@@ -44,6 +44,8 @@
# include <langinfo.h>
#endif
+#include <glib.h>
+
static char *othersubrsfile = NULL;
extern int adjustwidth;
@@ -443,6 +445,10 @@ return( prefs );
static char *NOUI_getFontForgeShareDir(void) {
#if defined(__MINGW32__)
+ #ifndef MAX_PATH
+ #define MAX_PATH 4096
+ #endif
+
static char* sharedir = NULL;
if(!sharedir){
char path[MAX_PATH+32];
@@ -676,8 +682,8 @@ static void DefaultXUID(void) {
r1 = rand()&0x3ff;
} while ( r1==0 ); /* I reserve "0" for me! */
gettimeofday(&tv,NULL);
- srandom(tv.tv_usec+1);
- r2 = random();
+ g_random_set_seed(tv.tv_usec+1);
+ r2 = g_random_int();
sprintf( buffer, "1021 %d %d", r1, r2 );
free(xuid);
xuid = copy(buffer);
View
6 fontforge/prefs.c
@@ -48,6 +48,8 @@
# include <langinfo.h>
#endif
+#include <glib/grand.h>
+
#define RAD2DEG (180/3.1415926535897932)
extern int splash;
@@ -989,8 +991,8 @@ static void DefaultXUID(void) {
r1 = rand()&0x3ff;
} while ( r1==0 ); /* I reserve "0" for me! */
gettimeofday(&tv,NULL);
- srandom(tv.tv_usec+1);
- r2 = random();
+ g_random_set_seed(tv.tv_usec+1);
+ r2 = g_random_int();
sprintf( buffer, "1021 %d %d", r1, r2 );
free(xuid);
xuid = copy(buffer);
View
4 fontforge/sfd.c
@@ -41,6 +41,8 @@
#include <dirent.h>
#include <limits.h> /* For NAME_MAX or _POSIX_NAME_MAX */
+#include <glib/gfileutils.h>
+
#ifndef NAME_MAX
# ifndef _POSIX_NAME_MAX
# define _POSIX_NAME_MAX 512
@@ -2024,7 +2026,7 @@ FILE* MakeTemporaryFile() {
strcpy( template, getSlashTempName() );
strcat( template, "/" );
strcat( template, "fontforge-stemp-XXXXXX" );
- fd = mkstemp( template );
+ fd = g_mkstemp( template );
ret = fdopen( fd, "r+" );
unlink( template );
return ret;
View
4 fontforge/start.c
@@ -37,6 +37,8 @@
# include <stdlib.h> /* getenv,setenv */
#endif
+#include <glib.h>
+
int32 unicode_from_adobestd[256];
struct lconv localeinfo;
char *coord_sep = ",";
@@ -63,7 +65,7 @@ static void initrand(void) {
gettimeofday(&tv,NULL);
srand(tv.tv_usec);
- srandom(tv.tv_usec);
+ g_random_set_seed(tv.tv_usec);
}
/* FIXME: Is this necessary or desirable, given we now are using
View
2 fontforge/startui.c
@@ -67,8 +67,6 @@ extern void RunApplicationEventLoop(void);
#if defined(__MINGW32__)
#include <Windows.h>
-int srandom( int n ){ srand(n); }
-int random( void ){ return rand();}
void sleep( int n ){ _sleep(n);}
#endif
View
4 gtkui/prefs.c
@@ -746,8 +746,8 @@ static void DefaultXUID(void) {
r1 = rand()&0x3ff;
} while ( r1==0 ); /* I reserve "0" for me! */
gettimeofday(&tv,NULL);
- srandom(tv.tv_usec+1);
- r2 = random();
+ g_random_set_seed(tv.tv_usec+1);
+ r2 = g_random_int();
sprintf( buffer, "1021 %d %d", r1, r2 );
free(xuid);
xuid = copy(buffer);
View
6 tests/randomtest.c
@@ -222,9 +222,9 @@ return( error_count + ceil(error_fraction*item->len));
static int getRandom(int low, int high) {
if ( low-high<0x10000 )
-return( low + ((random()>>8)%(high+1-low)) );
+return( low + ((g_random_int()>>8)%(high+1-low)) );
-return( low + (random()%(high+1-low)) );
+return( low + (g_random_int()%(high+1-low)) );
}
static int copyfont(struct fontlist *item,char *newfont) {
@@ -479,7 +479,7 @@ exit(1);
ExecuteTest(testfile); /* This should never return */
time(&now);
- srandom(now);
+ g_random_set_seed(now);
FindFonts(dirs,exts);
mkdir(results_dir,0755);

0 comments on commit a035323

Please sign in to comment.
Something went wrong with that request. Please try again.