David R. Morrison wrote:
> 
> 
> Begin forwarded message:
[]
>> Let me restart. I got a new mac running 10.6.2. I installed xfig using fink. 
>> I 
>> cannot change the font of TEXT objects. No matter what  font I choose, the 
>> TEXT 
>> objects always stick with the "Default" font.

Found it. This is due to a very weird bug in Snow Leopard's gcc-4.2 
compiler optimization concerning a funny typecast in the file 
w_fontpanel.c in the xfig sources.

Here is a little program that shows the bug:

#include<stdio.h>
typedef char * caddr_t;
int main(){
  int i;
  for(i=0; i<6; i++){
    printf("i: %d, i-1: %d\n",(caddr_t) i, (caddr_t)(i-1));
   }
}

If you compile this with Snow Leopard's gcc (=gcc-4.2), then

- if you use no optimization or -O0 or -O1, the program runs correctly, 
i.e. you get two columns, the first from 0 to 5, the second from -1 to 
4. The same result is obtained with gcc-4.0 and any level of optimization.

- if you use gcc -O2 or -Os or above, then the second column stays at -1 
and does not increment. This is the behavior in xfig, where the font 
number -1 corresponds to the default postscript font. For the latex 
fonts, this bug does not show up, because there the fonts are numbered 
starting from 0 and not from -1.

If you start the loop from at -1 instead of 0, then it is the first 
column that does not increment. Somehow the compiler "optimizes" that 
typecast to give -1 in the whole loop if the first value was -1.

The workaround is simple: In xfig.info, in the CompileScript between 
the lines
   xmkmf
and
   make PREFIX=%p
insert a line
   make PREFIX=%p CDEBUGFLAGS=-O0 w_fontpanel.o

I tested this on 10.6/64, but I don't see why it shouldn't work anywhere 
else, too.

-- 
Martin




------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Fink-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fink-users

Reply via email to