Commit Graph

61 Commits

Author SHA1 Message Date
Werner Lemberg 89f5064765 */*: Use FT_ERR_EQ, FT_ERR_NEQ, and FT_ERR where appropriate.
FT_Err_XXX and friends are no longer directly used in the source
code.
2013-03-14 17:50:49 +01:00
Werner Lemberg e3c9301581 */*: Use FT_Err_Ok only.
This is a purely mechanical conversion.
2013-03-14 11:21:17 +01:00
Werner Lemberg 059bc335ce */*: Use `FT_THROW'.
This is essentially a mechanical conversion, adding inclusion of
`FT_INTERNAL_DEBUG_H' where necessary, and providing the macros for
stand-alone compiling modes of the rasterizer modules.

To convert the remaining occurrences of FT_Err_XXX and friends it is
necessary to rewrite the code.  Note, however, that it doesn't harm
if some cases are not handled since FT_THROW is a no-op.
2013-03-14 10:27:35 +01:00
Werner Lemberg dbc6e3f192 Remove `FT_KEEP_ERR_PREFIX'.
The idea is to always have FT_ERR_PREFIX available internally.

* include/freetype/fterrors.h: Use FT2_BUILD_LIBRARY to guard
undefinition of FT_ERR_PREFIX

* src/gxvalid/gxverror.h, src/otvalid/otverror.h,
src/sfnt/sferrors.h: Updated.
2013-03-12 11:42:20 +01:00
Werner Lemberg c879f24562 [gxvalid] Fix module error.
* src/gxvalid/gxverror.h (FT_ERR_BASE): Define as
FT_Mod_Err_GXvalid.
* include/freetype/ftmoderr.h: Add module error for `GXvalid'.
2013-03-11 10:11:57 +01:00
Vinnie Falco 26dfeb6d63 Prepare source code for amalgamation.
* src\autofit\aferrors.h, src\bdf\bdferror.h, src\bzip2\ftbzip2.c,
src\cache\ftcerror.h, src\cff\cfferrs.h, src\cid\ciderrs.h,
src\gxvalid\gxverror.h, src\gzip\ftgzip.c, src\lzw\ftlzw.c,
src\otvalid\otverror.h, src\pcf\pcferror.h, src\pfr\pfrerror.h,
src\psaux\psauxerr.h, src\pshinter\pshnterr.h,
src\psnames\psnamerr.h, src\raster\rasterrs.h, src\sfnt\sferrors.h,
src\smooth\ftsmerrs.h, src\truetype\tterrors.h,
src\type1\t1errors.h, src\type42\t42error.h, src\winfonts\fnterrs.h:
Add #undef FT_ERR_PREFIX before #define FT_ERR_PREFIX.
2012-03-08 06:04:03 +01:00
Alexei Podtelezhnikov b25265c5e4 Avoid modulo operators against a power-of-two denominator.
* src/afcjk.c (af_hint_normal_stem), src/base/ftoutln.c
(ft_contour_has), src/cff/cffgload.c (cff_decoder_parse_charstrings)
<cff_op_vvcurveto, cff_op_hhcurveto, cff_op_hvcurveto>,
src/gxvalid/gxvcommn.c (GXV_32BIT_ALIGNMENT_VALIDATE),
src/gxvalid/gxvfeat.c (gxv_feat_setting_validate): Replace `%' with
`&' operator.
2012-02-29 13:45:24 +01:00
Werner Lemberg 22fff25385 Whitespace. 2012-02-26 08:47:20 +01:00
suzuki toshiya 7b02b70443 [gxvalid] Fix Savannah bug #35286.
Patch submitted by anonymous reporter.

* src/gxvalid/gxvcommn.c (gxv_XStateTable_subtable_setup):
gxv_set_length_by_ulong_offset() must be called with 3, not 4,
the number of the subtables in the state tables; classTable,
stateArray, entryTable.
2012-01-17 16:20:02 +09:00
suzuki toshiya 1749d8bc6a Remove trailing spaces. 2012-01-17 02:00:24 +09:00
Werner Lemberg c52f44d4fd Whitespace. 2011-11-30 10:46:53 +01:00
suzuki toshiya faddba4474 [gxvalid] Fix a bug to detect too large offset in morx table.
* src/gxvalid/gxvmorx2.c
(gxv_morx_subtable_type2_ligActionIndex_validate): Fix a bug
that too large positive offset cannot be detected.
2011-10-08 01:30:49 +09:00
suzuki toshiya c7e8028f3f [gxvalid] make the `prop' validation tracing verbose.
* src/gxvalid/gxvprop.c: Add tracing messages for errors.
2011-06-19 23:00:11 +09:00
suzuki toshiya 75b91a49aa [gxvalid] Cleanup.
Some invalid, overrunning, unrecommended non-zero values
are cared in paranoid validation mode only.  There are
many lines looking like:

  if ( valid->root->level >= FT_VALIDATE_PARANOID )
    FT_INVALID_xxx;

To simplify them, GXV_SET_ERR_IF_PARANOID( err ) is
introduced for more paranoid validation in future.

* src/gxvalid/gxvcommn.h (IS_PARANOID_VALIDATION):
New macro to assure valid->root->level is more or
equal to FT_VALIDATE_PARANOID.  (GXV_SET_ERR_IF_PARANOID):
New macro to raise an error if in paranoid validation.
* src/gxvalid/gxvcommn.c: Use GXV_SET_ERR_IF_PARANOID().
* src/gxvalid/gxvfeat.c: Ditto.
* src/gxvalid/gxvjust.c: Ditto.
* src/gxvalid/gxvkern.c: Ditto.
* src/gxvalid/gxvmort.c: Ditto.
* src/gxvalid/gxvmort0.c: Ditto.
* src/gxvalid/gxvmort1.c: Ditto.
* src/gxvalid/gxvmort2.c: Ditto.
* src/gxvalid/gxvmorx1.c: Ditto.
* src/gxvalid/gxvmorx2.c: Ditto.
2011-06-15 01:12:04 +09:00
suzuki toshiya f6f9b66781 [gxvalid] Fix gcc4.6 compiler warnings in gxvtrak.c.
* src/gxvalid/gxvtrak.c (gxv_trak_trackTable_validate):
Check different entries pointing same traking value.
(gxv_trak_validate): Remove unused variable `table_size'.
2011-06-14 23:55:57 +09:00
suzuki toshiya 05fc72c5c7 [gxvalid] Fix gcc4.6 compiler warnings in gxvmorx*.c.
* src/gxvalid/gxvmorx.c (gxv_morx_subtables_validate):
Conditionalize unvalidated variable `subFeatureFlags'.
(gxv_morx_chain_validate): Conditionalize unvalidated
variable `defaultFlags'.

* src/gxvalid/gxmorx0.c
(gxv_morx_subtable_type0_entry_validate):
Conditionalize unvalidated variables; `markFirst',
`dontAdvance', `markLast', `verb'.

* src/gxvalid/gxmorx1.c
(gxv_morx_subtable_type1_entry_validate): Conditionalize
unvalidated variables; `setMark', `dontAdvance'.

* src/gxvalid/gxvmorx2.c
(gxv_morx_subtable_type2_ligActionOffset_validate):
Conditionalize unvalidated variables; `last', `store'.
Checking for overrunning offset is added.
(gxv_morx_subtable_type2_entry_validate):
Conditionalize unvalidated variables; `setComponent',
`dontAdvance', `performAction'.
(gxv_morx_subtable_type2_ligatureTable_validate):
Check if the GID for ligature does not exceed the
max GID in `maxp' table.

* src/gxvalid/gxvmort5.c
(gxv_morx_subtable_type5_InsertList_validate):
Conditionalize unvalidated loading of `insert_glyphID'
array.  (gxv_morx_subtable_type5_entry_validate):
Conditionalize unvalidated variables; `setMark',
`dontAdvance', `currentIsKashidaLike',
`markedIsKashidaLike', `currentInsertBefore',
`markedInsertBefore'.
2011-06-14 23:54:10 +09:00
suzuki toshiya 56be3ac9b1 [gxvalid] Fix gcc4.6 compiler warnings in gxvmort*.c.
* src/gxvalid/gxvmort.c (gxv_mort_subtables_validate):
Conditionalize unvalidated variable `subFeatureFlags'.
(gxv_mort_chain_validate): Conditionalize unvalidated
variable `defaultFlags'.

* src/gxvalid/gxmort0.c
(gxv_mort_subtable_type0_entry_validate): Check the
conflict of the marks for the glyphs.

* src/gxvalid/gxmort1.c
(gxv_mort_subtable_type1_offset_to_subst_validate):
Local variables `min_gid', `max_gid' are replaced by
variables in the validator.
(gxv_mort_subtable_type1_entry_validate): Conditionalize
unvalidated variables; `setMark', `dontAdvance'.
(gxv_mort_subtable_type1_substTable_validate):
Validate the GID by the min/max GIDs in the validator.

* src/gxvalid/gxvmort2.c
(gxv_mort_subtable_type2_ligActionOffset_validate):
Conditionalize unvalidated variables; `last', `store'.
Checking for overrunning offset is added.
(gxv_mort_subtable_type2_entry_validate):
Conditionalize unvalidated variables; `setComponent',
`dontAdvance'.
(gxv_mort_subtable_type2_ligatureTable_validate):
Check if the GID for ligature does not exceed the
max GID in `maxp' table.

* src/gxvalid/gxvmort5.c
(gxv_mort_subtable_type5_InsertList_validate):
Conditionalize unvalidated loading of `insert_glyphID'
array.  (gxv_mort_subtable_type5_entry_validate):
Conditionalize unvalidated variables; `setMark',
`dontAdvance', `currentIsKashidaLike',
`markedIsKashidaLike', `currentInsertBefore',
`markedInsertBefore'.
2011-06-14 23:53:12 +09:00
suzuki toshiya 20c126c1ac [gxvalid] Fix gcc4.6 compiler warnings in gxvkern.c.
* src/gxvalid/gxvkern.c
(gxv_kern_subtable_fmt0_pairs_validate): Conditionalize
unvalidated variable `kernValue'.
(gxv_kern_subtable_fmt1_entry_validate): Conditionalize
unvalidated variables; `push', `dontAdvance', `kernAction',
`kernValue'.
(gxv_kern_coverage_new_apple_validate): Conditionalize
trace-only variables; `kernVertical', `kernCrossStream',
`kernVariation'.
(gxv_kern_coverage_classic_apple_validate): Conditionalize
trace-only variables; `horizontal', `cross_stream'.
(gxv_kern_coverage_classic_microsoft_validate):
Conditionalize trace-only variables; `horizontal',
`minimum', `cross_stream', `override'.
(gxv_kern_subtable_validate): Conditionalize trace-only
variables; `version', `tupleIndex'.
2011-06-14 23:50:39 +09:00
suzuki toshiya ce015ec8da [gxvalid] Fix gcc4.6 compiler warnings in gxvjust.c.
* src/gxvalid/gxvjust.c (gxv_just_check_max_gid):
New function to unify the checks of too large GID.
(gxv_just_wdp_entry_validate): Conditionalize unvalidated
variables; `beforeGrowLimit', `beforeShrinkGrowLimit',
`afterGrowLimit', `afterShrinkGrowLimit', `growFlags',
`shrinkFlags'.  Additional check for non-zero values in
unused storage `justClass' is added.
(gxv_just_actSubrecord_type0_validate): Conditionalize
unvalidated variable `order'.  GID is checked by
gxv_just_check_max_gid().  Additional check for upside-down
relationship between `lowerLimit' and `upperLimit' is added.
(gxv_just_actSubrecord_type1_validate): GID is checked by
gxv_just_check_max_gid().
(gxv_just_actSubrecord_type2_validate): Conditionalize
unvalidated variable `substThreshhold'.  GID is checked by
gxv_just_check_max_gid().
(gxv_just_actSubrecord_type5_validate): GID is checked by
gxv_just_check_max_gid().
(gxv_just_classTable_entry_validate): Conditionalize
unvalidated variables; `setMark', `dontAdvance',
`markClass', `currentClass'.
2011-06-14 23:49:34 +09:00
suzuki toshiya 248aa63973 [gxvalid] Preparation to fix gcc4.6 compiler warnings.
* src/gxvalid/gxvcommn.h (GXV_LOAD_TRACE_VARS): New macro to
conditionalize the variable which is only used for trace messages.
Automatically set by FT_DEBUG_LEVEL_TRACE.
(GXV_LOAD_UNUSED_VARS): New macro to conditionalize the loading of
unvalidated variables.  Undefined by default to calm gcc4.6 warning.
(GXV_ValidatorRec.{min_gid,max_gid}): New variables to hold defined
GID ranges, for the comparison of GID ranges in different subtables.
2011-06-14 23:47:21 +09:00
Werner Lemberg f765e4403c */*: Use module specific error names where appropriate. 2010-06-24 10:34:29 +02:00
suzuki toshiya 8eb551f1b3 gxvalid: Extend a few local variables to reduce the casts. 2009-08-01 00:37:55 +09:00
suzuki toshiya d365997759 gxvalid: Extend `settingTable' to take 32-bit offset. 2009-08-01 00:37:55 +09:00
suzuki toshiya eceaffef3e gxvalid: Guarantee `nFeatureFlags' size up to 32-bit. 2009-08-01 00:32:23 +09:00
suzuki toshiya 2f07c57f5a gxvalid: Guarantee `just' table size upto 32-bit. 2009-08-01 00:32:22 +09:00
suzuki toshiya 205a2a0cce gxvalid: Guarantee `trak' table size upto 32-bit. 2009-08-01 00:32:22 +09:00
suzuki toshiya 62aa9ec647 gxvalid: Pass the union by the pointer instead of the value. 2009-08-01 00:29:29 +09:00
Werner Lemberg 858abbedc0 For warning messages, replace FT_ERROR with FT_TRACE0.
FT_ERROR is now used only if a function produces a non-zero `error'
value.

Formatting, improving and harmonizing debug strings.
2009-06-26 06:15:41 +02:00
Oran Agra 1dcd0f2399 Add #error to modules and files that do not support PIC yet.
When FT_CONFIG_OPTION_PIC is defined the following files will
create #error:
* src/bdf/bdfdrivr.h
* src/cache/ftcmanag.c
* src/cid/cidriver.h
* src/gxvalid/gxvmod.h
* src/gzip/ftgzip.c
* src/lzw/ftlzw.c
* src/otvalid/otvmod.h
* src/pcf/pcfdrivr.h
* src/pfr/pfrdrivr.h
* src/psaux/psauxmod.h
* src/type1/t1driver.h
* src/type42/t42drivr.h
* src/winfonts/winfnt.h
2009-04-05 18:25:14 +03:00
Werner Lemberg f47acf2b5f Avoid compiler warnings.
* */*: s/do ; while ( 0 )/do { } while ( 0 )/.
Reported by Sean McBride <sean@rogue-research.com>.
2009-01-12 20:11:14 +00:00
Suzuki, Toshiya (鈴木俊哉) 68e16e0105 * src/gxvalid/gxvmort.c (gxv_mort_feature_validate): Fix wrong length check, Savannah patch #6682. 2009-01-09 08:01:15 +00:00
Werner Lemberg ce33a312da FT_USE_MODULE declares things as:
extern const FT_Module_Class

(or similar for C++).  However, the actual types of the variables
being declared are often different, e.g., FT_Driver_ClassRec or
FT_Renderer_Class.  (Some are, indeed, FT_Module_Class.)

This works with most C compilers (since those structs begin with an
FT_Module_Class struct), but technically it's undefined behavior.

To quote the ISO/IEC 9899:TC2 final committee draft, section 6.2.7
paragraph 2:

  All declarations that refer to the same object or function shall
  have compatible type; otherwise, the behavior is undefined.

(And they are not compatible types.)

Most C compilers don't reject (or even detect!) code which has this
issue, but the GCC LTO development branch compiler does.  (It
outputs the types of the objects while generating .o files, along
with a bunch of other information, then compares them when doing the
final link-time code generation pass.)

Patch from Savannah bug #25133.

* src/base/ftinit.c (FT_USE_MODULE): Include variable type.

* builds/amiga/include/freetype/config/ftmodule.h,
include/freetype/config/ftmodule.h, */module.mk: Updated to declare
pass correct types to FT_USE_MODULE.
2008-12-21 10:29:30 +00:00
Werner Lemberg 1a5d561dce * src/autofit/afcjk.c, src/base/ftoutln.c, src/base/ftrfork.c,
src/bdf/bdfdrivr.c, src/gxvalid/gxvmorx.c, src/otvalid/otvmath.c,
src/pcf/pcfdrivr.c, src/psnames/pstables.h, src/smooth/ftgrays.c,
src/tools/glnames.py, src/truetype/ttinterp.c, src/type1/t1load.c,
src/type42/t42objs.c, src/winfonts/winfnt.c: Fix compiler warnings
(Atari PureC).
2008-11-29 22:50:24 +00:00
Werner Lemberg a4cb0d95d9 * src/type/t1afm.c (compare_kern_pairs), src/pxaux/afmparse.c
(afm_compare_kern_pairs): Fix comparison.  This fixes Savannah bug
#24119.
2008-08-23 19:54:06 +00:00
Werner Lemberg 2b0b4221ab Cosmetic code changes. 2008-05-28 22:17:28 +00:00
Werner Lemberg 3033f4366b * src/truetype/ttgload.c (load_truetype_glyph): Always allow a
recursion depth of 1.  This was the maximum value in TrueType 1.0,
and some older fonts don't set this field correctly.

* src/gxvalid/gxvmort1.c
(gxv_mort_subtable_type1_substTable_validate): Fix tracing message.
2007-07-04 14:12:19 +00:00
Werner Lemberg 936346413f Remove tabs from source files. 2007-06-01 06:56:17 +00:00
Werner Lemberg 4b2e83d5b5 A new set of spelling fixes from Alexei.
Add some copyright messages.
2007-02-01 07:58:02 +00:00
Werner Lemberg 9b774e2822 Remove trailing whitespace. From Alexei. 2007-01-16 06:11:27 +00:00
Werner Lemberg 8c4120d0a3 Fix various compiler warnings.
* src/truetype/ttdriver.c (tt_size_select), src/cff/cffobjs.h,
src/cff/cffobjs.c (cff_size_request), src/type42/t42objs.h:
s/index/strike_index/.
* src/base/ftobjs.c (FT_Match_Size): s/index/size_index/.

* src/gxvalid/gxvmorx5.c
(gxv_morx_subtable_type5_InsertList_validate): s/index/table_index/.

* src/truetype/ttinterp.c (Compute_Point_Displacement),
src/pcf/pcfread.c (pcf_seek_to_table_type): Avoid possibly
uninitialized variables.
2007-01-15 06:42:40 +00:00
Werner Lemberg 6b87e6f0ff * src/gxvalid/gxvkern.c (gxv_kern_subtable_fmt0_pairs_validate):
Remove compiler warning.

Formatting.
2007-01-02 19:20:08 +00:00
Yamato, Masatake (大和正武) 55d5a1cbe9 (gxv_kern_subtable_fmt0_pairs_validate): Show the trace message after validating gids. 2006-12-30 20:24:30 +00:00
Yamato, Masatake (大和正武) d5d3e41dac (gxv_kern_subtable_fmt0_pairs_validate): New function. Checks uniqueness of the gid pairs.
(gxv_kern_subtable_fmt0_validate): Move some code to `gxv_kern_subtable_fmt0_pairs_validate'.
2006-12-30 20:17:30 +00:00
Jens Claudius a787f45580 2006-08-27 Jens Claudius <jens.claudius@yahoo.com>
Fix miscellaneous compiler warnings.

	* freetype2/include/freetype/internal/ftobjs.h: close
	comment with `*/' to avoid `/* in comment' compiler warning.

	* freetype2/src/base/ftdbgmem.c (ft_mem_table_get_source): Turn
	cast `(FT_UInt32)(void*)' into `(FT_UInt32)(FT_PtrDist)(void*)'
	since on 64-bit platforms void* is larger than FT_UInt32.

	* freetype2/src/base/ftobjs.c (t_validator_error): cast
	away volatileness of argument to ft_longjmp. Spotted by
	Werner `Putzfrau' Lemberg.

	* freetype2/src/bdf/bdflib.c (bdf_load_font): initialize
	local variable `lineno'.

	* freetype2/src/gxvalid/gxvmod.c (classic_kern_validate):
	mark local variable `error' volatile.
2006-08-27 11:26:18 +00:00
Jens Claudius 088e44e877 2006-08-22 Jens Claudius <jens.claudius@yahoo.com>
Fix for previous commit, which caused many compiler warnings/errors
	about addresses of volatile objects passed as function arguments
	as non-volatile pointers.


	* freetype2/include/freetype/internal/ftvalid.h: Make
	FT_Validator typedef a pointer to a volatile object.

	* freetype2/src/gxvalid/gxvmod.c (gxv_load_table): Make function
	argument `table' a pointer to a volatile object.

	* freetype2/src/otvalid/otvmod.c (otv_load_table): Make function
	argument `table' a pointer to a volatile object.
2006-08-22 14:24:30 +00:00
Werner Lemberg 1234299620 formatting 2006-08-19 11:18:09 +00:00
Jens Claudius 2652bd5412 2006-08-18 Jens Claudius <jens.claudius@yahoo.com>
* freetype2/src/gxvalid/gxvmod.c (GXV_TABLE_DECL): Mark local
	variable `_sfnt' as volatile since it must keep its value across
	a call to ft_setjmp.
	(gxv_validate): Same for local variables `memory' and `valid'.
	(classic_kern_validate): Same for local variables `memory',
	`ckern', and `valid'.

	* freetype2/src/otvalid/otvmod.c (otv_validate): Same for function
	parameter `face' and local variables `base', `gdef', `gpos', `gsub',
	`jstf', and 'valid'.

	* freetype2/src/sfnt/ttcmap.c (tt_face_build_cmaps): Same for
	local variable `cmap'.
2006-08-18 17:20:37 +00:00
Suzuki, Toshiya (鈴木俊哉) e261f426d6 * src/otvalid/otvmod.c, src/gxvalid/gxvmod.c: replace ft_validator_run by ft_setjmp 2006-08-15 17:00:43 +00:00
Werner Lemberg 8fe6539026 Further C library abstraction. Based on a patch from
msn2@bidyut.com.

* include/freetype/config/ftstdlib.h (FT_CHAR_BIT, FT_FILE,
ft_fopen, ft_fclose, ft_fseek, ft_ftell, ft_fread, ft_smalloc,
ft_scalloc, ft_srealloc, ft_sfree, ft_labs): New wrapper macros for
C library functions.  Update all users accordingly (and catch some
other places where the C library function was used instead of the
wrapper functions).

* src/base/ftsystem.c: Don't include stdio.h and stdlib.h.
* src/gzip/zutil.h [MSDOS && !(__TURBOC__ || __BORLANDC__)]: Don't
include malloc.h.
2006-04-29 07:31:16 +00:00
Werner Lemberg 38beff0083 * src/otvalid/module.mk: s/otvalid_module_class/otv_module_class/.
* src/gxvalid/module.mk: s/gxvalid_module_class/gxv_module_class/.
2006-02-01 05:14:25 +00:00