Dear David, dear all,

I'm currently working on a FreeType 2 backend for XFree86.  My goal
was to use pristine FreeType sources and only have a private set of
config files; unfortunately, that has proven impossible for two
reasons.  I would like to suggest that a number of minor changes to
FreeType should be made to fix this situation.

1. Include files

An XFree86 module does not include the files in /usr/include; instead,
it includes the file "xf86_ansic.h".  Thus, code that goes into a font
module typically starts with code such as the following:

  #ifndef FONTMODULE
  #include <string.h>
  #include <math.h>
  #else
  #include "Xmd.h"
  #include "Xdefs.h"
  #include "xf86_ansic.h"
  #endif

Unfortunately, the FreeType 2 sources contain a number of includes
within C files.  I suggest that a new file (which I called ftstdlib.h
-- see attachment) should be created that includes all the needed
headers.  This single file would be easier to customise for us.

2. Structure member names

Because things like ``read'' are actually #defines in XFree86 codes,
they should not be used for structure and union members.  FreeType 2
uses at least the following names for structure members:

  malloc, realloc, free, close, read

I have worked around the problem by creative use of #undef; I see no
good solution to this issue other than renaming the structure members.

I am attaching the complete changes against FreeType 2 that I have
needed to use.  Anything that will make this list smaller is welcome.

Thanks a lot,

                                        Juliusz

? xc/extras/freetype2/include/ftstdlib.h
Index: xc/extras/freetype2/include/freetype/internal/ftmemory.h
===================================================================
RCS file: /cvs/xc/extras/freetype2/include/freetype/internal/ftmemory.h,v
retrieving revision 1.1.1.4
diff -c -r1.1.1.4 ftmemory.h
*** xc/extras/freetype2/include/freetype/internal/ftmemory.h	2002/01/14 16:52:06	1.1.1.4
--- xc/extras/freetype2/include/freetype/internal/ftmemory.h	2002/04/03 23:45:08
***************
*** 174,180 ****
  
    /* This `#include' is needed by the MEM_xxx() macros; it should be */
    /* available on all platforms we know of.                          */
! #include <string.h>
  
  #define MEM_Set( dest, byte, count )     memset( dest, byte, count )
  
--- 174,180 ----
  
    /* This `#include' is needed by the MEM_xxx() macros; it should be */
    /* available on all platforms we know of.                          */
! #include <ftstdlib.h>
  
  #define MEM_Set( dest, byte, count )     memset( dest, byte, count )
  
Index: xc/extras/freetype2/src/autohint/ahglyph.c
===================================================================
RCS file: /cvs/xc/extras/freetype2/src/autohint/ahglyph.c,v
retrieving revision 1.1.1.5
diff -c -r1.1.1.5 ahglyph.c
*** xc/extras/freetype2/src/autohint/ahglyph.c	2002/01/14 16:52:08	1.1.1.5
--- xc/extras/freetype2/src/autohint/ahglyph.c	2002/04/03 23:45:13
***************
*** 26,33 ****
  #include "ahglobal.h"
  #include "aherrors.h"
  
! #include <stdio.h>
! 
  
  #ifdef AH_DEBUG
  
--- 26,32 ----
  #include "ahglobal.h"
  #include "aherrors.h"
  
! #include <ftstdlib.h>
  
  #ifdef AH_DEBUG
  
Index: xc/extras/freetype2/src/base/ftobjs.c
===================================================================
RCS file: /cvs/xc/extras/freetype2/src/base/ftobjs.c,v
retrieving revision 1.1.1.7
diff -c -r1.1.1.7 ftobjs.c
*** xc/extras/freetype2/src/base/ftobjs.c	2002/03/27 04:35:52	1.1.1.7
--- xc/extras/freetype2/src/base/ftobjs.c	2002/04/03 23:45:19
***************
*** 25,31 ****
  #include FT_TRUETYPE_TABLES_H
  #include FT_OUTLINE_H
  
! #include <string.h>     /* for strcmp() */
  
  
    /*************************************************************************/
--- 25,35 ----
  #include FT_TRUETYPE_TABLES_H
  #include FT_OUTLINE_H
  
! #include <ftstdlib.h>     /* for strcmp() */
! 
! #undef realloc
! #undef free
! #undef close
  
  
    /*************************************************************************/
Index: xc/extras/freetype2/src/base/ftstream.c
===================================================================
RCS file: /cvs/xc/extras/freetype2/src/base/ftstream.c,v
retrieving revision 1.1.1.3
diff -c -r1.1.1.3 ftstream.c
*** xc/extras/freetype2/src/base/ftstream.c	2001/12/16 17:49:27	1.1.1.3
--- xc/extras/freetype2/src/base/ftstream.c	2002/04/03 23:45:21
***************
*** 20,25 ****
--- 20,27 ----
  #include FT_INTERNAL_STREAM_H
  #include FT_INTERNAL_DEBUG_H
  
+ #undef read
+ 
  
    /*************************************************************************/
    /*                                                                       */
Index: xc/extras/freetype2/src/base/ftsystem.c
===================================================================
RCS file: /cvs/xc/extras/freetype2/src/base/ftsystem.c,v
retrieving revision 1.1.1.5
diff -c -r1.1.1.5 ftsystem.c
*** xc/extras/freetype2/src/base/ftsystem.c	2002/01/14 16:52:10	1.1.1.5
--- xc/extras/freetype2/src/base/ftsystem.c	2002/04/03 23:45:22
***************
*** 32,40 ****
  #include FT_ERRORS_H
  #include FT_TYPES_H
  
! #include <stdio.h>
! #include <stdlib.h>
! #include <string.h>
  
  
    /*************************************************************************/
--- 32,38 ----
  #include FT_ERRORS_H
  #include FT_TYPES_H
  
! #include <ftstdlib.h>
  
  
    /*************************************************************************/
***************
*** 133,139 ****
--- 131,141 ----
      free( block );
    }
  
+ #undef free
+ #undef malloc
+ #undef realloc
  
+ 
    /*************************************************************************/
    /*                                                                       */
    /*                     RESOURCE MANAGEMENT INTERFACE                     */
***************
*** 264,271 ****
    ft_mem_debug_done( FT_Memory  memory );
    
  #endif  
!       
!       
    /* documentation is in ftobjs.h */
  
    FT_EXPORT_DEF( FT_Memory )
--- 266,276 ----
    ft_mem_debug_done( FT_Memory  memory );
    
  #endif  
! 
! #ifdef FONTMODULE
! #define malloc(foo) xf86malloc(foo)
! #endif
! 
    /* documentation is in ftobjs.h */
  
    FT_EXPORT_DEF( FT_Memory )
Index: xc/extras/freetype2/src/psaux/t1decode.c
===================================================================
RCS file: /cvs/xc/extras/freetype2/src/psaux/t1decode.c,v
retrieving revision 1.1.1.5
diff -c -r1.1.1.5 t1decode.c
*** xc/extras/freetype2/src/psaux/t1decode.c	2002/01/14 16:52:14	1.1.1.5
--- xc/extras/freetype2/src/psaux/t1decode.c	2002/04/03 23:45:25
***************
*** 26,31 ****
--- 26,33 ----
  
  #include "psauxerr.h"
  
+ #undef close
+ 
  
    /*************************************************************************/
    /*                                                                       */
Index: xc/extras/freetype2/src/psnames/psmodule.c
===================================================================
RCS file: /cvs/xc/extras/freetype2/src/psnames/psmodule.c,v
retrieving revision 1.1.1.6
diff -c -r1.1.1.6 psmodule.c
*** xc/extras/freetype2/src/psnames/psmodule.c	2002/02/15 00:33:35	1.1.1.6
--- xc/extras/freetype2/src/psnames/psmodule.c	2002/04/03 23:45:26
***************
*** 25,32 ****
  
  #include "psnamerr.h"
  
! #include <stdlib.h>     /* for qsort()             */
! #include <string.h>     /* for strcmp(), strncpy() */
  
  
  #ifndef FT_CONFIG_OPTION_NO_POSTSCRIPT_NAMES
--- 25,31 ----
  
  #include "psnamerr.h"
  
! #include <ftstdlib.h>
  
  
  #ifndef FT_CONFIG_OPTION_NO_POSTSCRIPT_NAMES
Index: xc/extras/freetype2/src/raster/ftraster.c
===================================================================
RCS file: /cvs/xc/extras/freetype2/src/raster/ftraster.c,v
retrieving revision 1.1.1.5
diff -c -r1.1.1.5 ftraster.c
*** xc/extras/freetype2/src/raster/ftraster.c	2002/01/14 16:52:16	1.1.1.5
--- xc/extras/freetype2/src/raster/ftraster.c	2002/04/03 23:45:35
***************
*** 249,255 ****
--- 249,257 ----
    typedef unsigned long   ULong;
  
    typedef unsigned char   Byte, *PByte;
+ #ifndef FONTMODULE
    typedef char            Bool;
+ #endif
  
    typedef struct  TPoint_
    {
Index: xc/extras/freetype2/src/sfnt/sfdriver.c
===================================================================
RCS file: /cvs/xc/extras/freetype2/src/sfnt/sfdriver.c,v
retrieving revision 1.1.1.7
diff -c -r1.1.1.7 sfdriver.c
*** xc/extras/freetype2/src/sfnt/sfdriver.c	2002/03/27 04:35:58	1.1.1.7
--- xc/extras/freetype2/src/sfnt/sfdriver.c	2002/04/03 23:45:36
***************
*** 33,39 ****
  #include "ttpost.h"
  #endif
  
! #include <string.h>     /* for strcmp() */
  
  
    static void*
--- 33,39 ----
  #include "ttpost.h"
  #endif
  
! #include <ftstdlib.h>     /* for strcmp() */
  
  
    static void*
Index: xc/extras/freetype2/src/sfnt/ttload.c
===================================================================
RCS file: /cvs/xc/extras/freetype2/src/sfnt/ttload.c,v
retrieving revision 1.1.1.7
diff -c -r1.1.1.7 ttload.c
*** xc/extras/freetype2/src/sfnt/ttload.c	2002/03/27 04:35:58	1.1.1.7
--- xc/extras/freetype2/src/sfnt/ttload.c	2002/04/03 23:45:45
***************
*** 26,33 ****
  
  #include "sferrors.h"
  
! #include <stdlib.h>  /* for qsort */
! #include <stdio.h>   /* for printf */
  
    /*************************************************************************/
    /*                                                                       */
--- 26,32 ----
  
  #include "sferrors.h"
  
! #include <ftstdlib.h>
  
    /*************************************************************************/
    /*                                                                       */
Index: xc/extras/freetype2/src/type1/t1afm.c
===================================================================
RCS file: /cvs/xc/extras/freetype2/src/type1/t1afm.c,v
retrieving revision 1.1.1.4
diff -c -r1.1.1.4 t1afm.c
*** xc/extras/freetype2/src/type1/t1afm.c	2001/12/16 17:49:36	1.1.1.4
--- xc/extras/freetype2/src/type1/t1afm.c	2002/04/03 23:45:46
***************
*** 20,28 ****
  #include "t1afm.h"
  #include FT_INTERNAL_STREAM_H
  #include FT_INTERNAL_TYPE1_TYPES_H
! #include <stdlib.h>  /* for qsort()   */
! #include <string.h>  /* for strcmp()  */
! #include <ctype.h>   /* for isalnum() */
  
  
    /*************************************************************************/
--- 20,27 ----
  #include "t1afm.h"
  #include FT_INTERNAL_STREAM_H
  #include FT_INTERNAL_TYPE1_TYPES_H
! 
! #include <ftstdlib.h>
  
  
    /*************************************************************************/
Index: xc/extras/freetype2/src/type1/t1driver.c
===================================================================
RCS file: /cvs/xc/extras/freetype2/src/type1/t1driver.c,v
retrieving revision 1.1.1.7
diff -c -r1.1.1.7 t1driver.c
*** xc/extras/freetype2/src/type1/t1driver.c	2002/03/27 04:36:03	1.1.1.7
--- xc/extras/freetype2/src/type1/t1driver.c	2002/04/03 23:45:48
***************
*** 31,37 ****
  #include FT_INTERNAL_STREAM_H
  #include FT_INTERNAL_POSTSCRIPT_NAMES_H
  
! #include <string.h>     /* for strcmp() */
  
  
    /*************************************************************************/
--- 31,37 ----
  #include FT_INTERNAL_STREAM_H
  #include FT_INTERNAL_POSTSCRIPT_NAMES_H
  
! #include <ftstdlib.h>     /* for strcmp() */
  
  
    /*************************************************************************/
Index: xc/extras/freetype2/src/type1/t1gload.c
===================================================================
RCS file: /cvs/xc/extras/freetype2/src/type1/t1gload.c,v
retrieving revision 1.1.1.5
diff -c -r1.1.1.5 t1gload.c
*** xc/extras/freetype2/src/type1/t1gload.c	2002/01/14 16:52:26	1.1.1.5
--- xc/extras/freetype2/src/type1/t1gload.c	2002/04/03 23:45:49
***************
*** 25,31 ****
  
  #include "t1errors.h"
  
! #include <string.h>     /* for strcmp() */
  
  
    /*************************************************************************/
--- 25,31 ----
  
  #include "t1errors.h"
  
! #include <ftstdlib.h>     /* for strcmp() */
  
  
    /*************************************************************************/
Index: xc/extras/freetype2/src/type1/t1load.c
===================================================================
RCS file: /cvs/xc/extras/freetype2/src/type1/t1load.c,v
retrieving revision 1.1.1.7
diff -c -r1.1.1.7 t1load.c
*** xc/extras/freetype2/src/type1/t1load.c	2002/03/27 04:36:03	1.1.1.7
--- xc/extras/freetype2/src/type1/t1load.c	2002/04/03 23:45:55
***************
*** 71,78 ****
  
  #include "t1errors.h"
  
! #include <string.h>     /* for strncmp(), strcmp() */
! #include <ctype.h>      /* for isalnum()           */
  
  
    /*************************************************************************/
--- 71,77 ----
  
  #include "t1errors.h"
  
! #include <ftstdlib.h>
  
  
    /*************************************************************************/
Index: xc/extras/freetype2/src/type1/t1objs.c
===================================================================
RCS file: /cvs/xc/extras/freetype2/src/type1/t1objs.c,v
retrieving revision 1.1.1.7
diff -c -r1.1.1.7 t1objs.c
*** xc/extras/freetype2/src/type1/t1objs.c	2002/03/27 04:36:03	1.1.1.7
--- xc/extras/freetype2/src/type1/t1objs.c	2002/04/03 23:45:57
***************
*** 20,26 ****
  #include FT_INTERNAL_DEBUG_H
  #include FT_INTERNAL_STREAM_H
  
! #include <string.h>         /* strcmp() */
  
  #include "t1gload.h"
  #include "t1load.h"
--- 20,26 ----
  #include FT_INTERNAL_DEBUG_H
  #include FT_INTERNAL_STREAM_H
  
! #include <ftstdlib.h>         /* strcmp() */
  
  #include "t1gload.h"
  #include "t1load.h"
Index: xc/extras/freetype2/src/type1/t1parse.c
===================================================================
RCS file: /cvs/xc/extras/freetype2/src/type1/t1parse.c,v
retrieving revision 1.1.1.4
diff -c -r1.1.1.4 t1parse.c
*** xc/extras/freetype2/src/type1/t1parse.c	2001/12/16 17:49:37	1.1.1.4
--- xc/extras/freetype2/src/type1/t1parse.c	2002/04/03 23:45:58
***************
*** 43,49 ****
  
  #include "t1errors.h"
  
! #include <string.h>     /* for strncmp() */
  
  
    /*************************************************************************/
--- 43,49 ----
  
  #include "t1errors.h"
  
! #include <ftstdlib.h>     /* for strncmp() */
  
  
    /*************************************************************************/
*** /dev/null	Thu Jan  1 01:00:00 1970
--- xc/extras/freetype2/include/ftstdlib.h	Wed Apr  3 23:43:43 2002
***************
*** 0 ****
--- 1,18 ----
+ #ifndef _FT_STDLIB_H
+ #define _FT_STDLIB_H
+ #ifndef FONTMODULE
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
+ #include <ctype.h>
+ #else
+ #include "Xmd.h"
+ #include "Xdefs.h"
+ #include "xf86_ansic.h"
+ #endif
+ 
+ #ifndef offsetof
+ #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
+ #endif
+ 
+ #endif

Reply via email to