From 4e726a3547fd84a8741b4662efbac664bf8894d7 Mon Sep 17 00:00:00 2001 From: John van Groningen Date: Mon, 19 Apr 2004 15:10:53 +0000 Subject: port to gcc on Mac OS X --- cg.c | 42 +++++++++++++++++++++++++++--------------- cginput.c | 2 +- cgpas.c | 6 +++++- cgport.h | 8 +------- cgpwas.c | 4 ++++ 5 files changed, 38 insertions(+), 24 deletions(-) diff --git a/cg.c b/cg.c index 9db12d3..7275380 100644 --- a/cg.c +++ b/cg.c @@ -396,25 +396,37 @@ char *this_module_name; # define FOLDER_SEPARATOR ':' #endif -#ifdef PROJECT_BUILDER +#if defined (POWER) && defined (GNU_C) static FILE *fopen_with_file_name_conversion (char *file_name,char *mode) { - static char file_name_s[257]; - char *p; + FSSpec fs_spec; + FSRef fs_ref; + CFURLRef CFURL_ref; + char buffer[512+1]; + int string_size; + Boolean r; + OSErr e; + + buffer[0]=strlen (file_name); + strcpy (&buffer[1],file_name); + + e=FSMakeFSSpec (0/*vRefNum*/,0/*dirID*/,buffer,&fs_spec); + if (e!=noErr) + return NULL; + + e=FSpMakeFSRef (&fs_spec,&fs_ref); + if (e!=noErr) + return NULL; + + CFURL_ref=CFURLCreateFromFSRef (NULL,&fs_ref); - for (p=file_name; *p!='\0' && *p!=':'; ++p) - ; + string_size=512; + r=CFURLGetFileSystemRepresentation (CFURL_ref,1,buffer,string_size); - if (*p==':'){ - strcpy (file_name_s,"/Volumes/"); - strcat (file_name_s,file_name); - - for (p=file_name_s; *p!='\0'; ++p) - if (*p==':') - *p='/'; - - file_name=file_name_s; - } + if (!r) + return NULL; + + file_name=buffer; return fopen (file_name,mode); } diff --git a/cginput.c b/cginput.c index 6fde2e0..ded9c69 100644 --- a/cginput.c +++ b/cginput.c @@ -410,7 +410,7 @@ static int parse_string_character (char *c_p) switch (last_char){ case 'b': *c_p='\b'; break; case 'f': *c_p='\f'; break; -#if (defined (M68000) && !defined (SUN)) || defined (__MWERKS__) || defined (__MRC__) +#if (defined (M68000) && !defined (SUN)) || defined (__MWERKS__) || defined (__MRC__) || defined (POWER) case 'n': *c_p='\xd'; break; case 'r': *c_p='\xa'; break; #else diff --git a/cgpas.c b/cgpas.c index 263eedb..64d55af 100644 --- a/cgpas.c +++ b/cgpas.c @@ -17,7 +17,7 @@ #if defined (LINUX_ELF) # define ELF # include -#elif defined (PROJECT_BUILDER) || defined (MACH_O) +#elif defined (MACH_O) || defined (GNU_C) # define G_MACH_O # define G_MACH_O_SCATTERED # include @@ -27,6 +27,10 @@ # define XCOFF #endif +#ifdef GNU_C +# include +#endif + #define for_l(v,l,n) for(v=(l);v!=NULL;v=v->n) #undef USE_DCBZ diff --git a/cgport.h b/cgport.h index 61abeda..6840dd5 100644 --- a/cgport.h +++ b/cgport.h @@ -1,13 +1,7 @@ #define FINALIZERS -#undef PROJECT_BUILDER - -#ifdef PROJECT_BUILDER -# define GNU_C -#endif - -#if defined (__MWERKS__) || defined (__MRC__) || defined (PROJECT_BUILDER) +#if defined (__MWERKS__) || defined (__MRC__) # define POWER # ifdef __cplusplus # include "cgrenameglobals.h" diff --git a/cgpwas.c b/cgpwas.c index e7bf7c0..776cadd 100644 --- a/cgpwas.c +++ b/cgpwas.c @@ -48,6 +48,10 @@ #include "cgptoc.h" #include "cgpwas.h" +#ifdef GNU_C +# include +#endif + #define FP_REVERSE_SUB_DIV_OPERANDS 1 #define for_l(v,l,n) for(v=(l);v!=NULL;v=v->n) -- cgit v1.2.3