From 0955c664aa7c5fc5f0bd345c58219c40f04ab9c1 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 13 Feb 2011 10:52:18 +0000 Subject: fix for warnings from Sparse static source code checker, mostly BKE/BLI and python functions. - use NULL rather then 0 where possible (makes code & function calls more readable IMHO). - set static variables and functions (exposed some unused vars/funcs). - use func(void) rather then func() for definitions. --- source/blender/blenfont/intern/blf_glyph.c | 8 ++--- source/blender/blenfont/intern/blf_internal.h | 47 +++++++++++++++------------ source/blender/blenfont/intern/blf_lang.c | 12 ++++--- source/blender/blenfont/intern/blf_util.c | 1 + 4 files changed, 38 insertions(+), 30 deletions(-) (limited to 'source/blender/blenfont') diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index c36496fb542..8d13975b83a 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -205,7 +205,7 @@ GlyphBLF *blf_glyph_search(GlyphCacheBLF *gc, unsigned int c) return(NULL); } -GlyphBLF *blf_glyph_add(FontBLF *font, FT_UInt index, unsigned int c) +GlyphBLF *blf_glyph_add(FontBLF *font, unsigned int index, unsigned int c) { FT_GlyphSlot slot; GlyphBLF *g; @@ -220,9 +220,9 @@ GlyphBLF *blf_glyph_add(FontBLF *font, FT_UInt index, unsigned int c) return(g); if (sharp) - err = FT_Load_Glyph(font->face, index, FT_LOAD_TARGET_MONO); + err = FT_Load_Glyph(font->face, (FT_UInt)index, FT_LOAD_TARGET_MONO); else - err = FT_Load_Glyph(font->face, index, FT_LOAD_TARGET_NORMAL | FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP); /* Sure about NO_* flags? */ + err = FT_Load_Glyph(font->face, (FT_UInt)index, FT_LOAD_TARGET_NORMAL | FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP); /* Sure about NO_* flags? */ if (err) return(NULL); @@ -249,7 +249,7 @@ GlyphBLF *blf_glyph_add(FontBLF *font, FT_UInt index, unsigned int c) g->next= NULL; g->prev= NULL; g->c= c; - g->idx= index; + g->idx= (FT_UInt)index; g->tex= 0; g->build_tex= 0; g->bitmap= NULL; diff --git a/source/blender/blenfont/intern/blf_internal.h b/source/blender/blenfont/intern/blf_internal.h index afe40973269..72d4fc4d54a 100644 --- a/source/blender/blenfont/intern/blf_internal.h +++ b/source/blender/blenfont/intern/blf_internal.h @@ -28,6 +28,11 @@ #ifndef BLF_INTERNAL_H #define BLF_INTERNAL_H +struct FontBLF; +struct GlyphBLF; +struct GlyphCacheBLF; +struct rctf; + unsigned int blf_next_p2(unsigned int x); unsigned int blf_hash(unsigned int val); int blf_utf8_next(unsigned char *buf, int *iindex); @@ -39,30 +44,30 @@ int blf_dir_split(const char *str, char *file, int *size); int blf_font_init(void); void blf_font_exit(void); -FontBLF *blf_font_new(const char *name, const char *filename); -FontBLF *blf_font_new_from_mem(const char *name, unsigned char *mem, int mem_size); -void blf_font_attach_from_mem(FontBLF *font, const unsigned char *mem, int mem_size); +struct FontBLF *blf_font_new(const char *name, const char *filename); +struct FontBLF *blf_font_new_from_mem(const char *name, unsigned char *mem, int mem_size); +void blf_font_attach_from_mem(struct FontBLF *font, const unsigned char *mem, int mem_size); -void blf_font_size(FontBLF *font, int size, int dpi); -void blf_font_draw(FontBLF *font, const char *str, unsigned int len); -void blf_font_draw_ascii(FontBLF *font, const char *str, unsigned int len); -void blf_font_buffer(FontBLF *font, const char *str); -void blf_font_boundbox(FontBLF *font, const char *str, rctf *box); -void blf_font_width_and_height(FontBLF *font, const char *str, float *width, float *height); -float blf_font_width(FontBLF *font, const char *str); -float blf_font_height(FontBLF *font, const char *str); -float blf_font_fixed_width(FontBLF *font); -void blf_font_free(FontBLF *font); +void blf_font_size(struct FontBLF *font, int size, int dpi); +void blf_font_draw(struct FontBLF *font, const char *str, unsigned int len); +void blf_font_draw_ascii(struct FontBLF *font, const char *str, unsigned int len); +void blf_font_buffer(struct FontBLF *font, const char *str); +void blf_font_boundbox(struct FontBLF *font, const char *str, struct rctf *box); +void blf_font_width_and_height(struct FontBLF *font, const char *str, float *width, float *height); +float blf_font_width(struct FontBLF *font, const char *str); +float blf_font_height(struct FontBLF *font, const char *str); +float blf_font_fixed_width(struct FontBLF *font); +void blf_font_free(struct FontBLF *font); -GlyphCacheBLF *blf_glyph_cache_find(FontBLF *font, int size, int dpi); -GlyphCacheBLF *blf_glyph_cache_new(FontBLF *font); -void blf_glyph_cache_clear(FontBLF *font); -void blf_glyph_cache_free(GlyphCacheBLF *gc); +struct GlyphCacheBLF *blf_glyph_cache_find(struct FontBLF *font, int size, int dpi); +struct GlyphCacheBLF *blf_glyph_cache_new(struct FontBLF *font); +void blf_glyph_cache_clear(struct FontBLF *font); +void blf_glyph_cache_free(struct GlyphCacheBLF *gc); -GlyphBLF *blf_glyph_search(GlyphCacheBLF *gc, unsigned int c); -GlyphBLF *blf_glyph_add(FontBLF *font, FT_UInt index, unsigned int c); +struct GlyphBLF *blf_glyph_search(struct GlyphCacheBLF *gc, unsigned int c); +struct GlyphBLF *blf_glyph_add(struct FontBLF *font, unsigned int index, unsigned int c); -void blf_glyph_free(GlyphBLF *g); -int blf_glyph_render(FontBLF *font, GlyphBLF *g, float x, float y); +void blf_glyph_free(struct GlyphBLF *g); +int blf_glyph_render(struct FontBLF *font, struct GlyphBLF *g, float x, float y); #endif /* BLF_INTERNAL_H */ diff --git a/source/blender/blenfont/intern/blf_lang.c b/source/blender/blenfont/intern/blf_lang.c index ebfb7f4eb65..a0d12359f12 100644 --- a/source/blender/blenfont/intern/blf_lang.c +++ b/source/blender/blenfont/intern/blf_lang.c @@ -29,6 +29,8 @@ #include #include +#include "BLF_api.h" + #ifdef INTERNATIONAL #include @@ -54,9 +56,9 @@ #define FONT_SIZE_DEFAULT 12 /* locale options. */ -char global_messagepath[1024]; -char global_language[32]; -char global_encoding_name[32]; +static char global_messagepath[1024]; +static char global_language[32]; +static char global_encoding_name[32]; void BLF_lang_init(void) @@ -97,7 +99,7 @@ void BLF_lang_set(const char *str) BLI_strncpy(global_language, str, sizeof(global_language)); } -void BLF_lang_encoding(const char *str) +static void BLF_lang_encoding(const char *str) { BLI_strncpy(global_encoding_name, str, sizeof(global_encoding_name)); /* bind_textdomain_codeset(DOMAIN_NAME, encoding_name); */ @@ -110,7 +112,7 @@ void BLF_lang_init(void) return; } -void BLF_lang_encoding(const char *str) +static void BLF_lang_encoding(const char *str) { (void)str; return; diff --git a/source/blender/blenfont/intern/blf_util.c b/source/blender/blenfont/intern/blf_util.c index 30e6e3fd3f5..9316d47cabe 100644 --- a/source/blender/blenfont/intern/blf_util.c +++ b/source/blender/blenfont/intern/blf_util.c @@ -30,6 +30,7 @@ #include #include +#include "blf_internal.h" unsigned int blf_next_p2(unsigned int x) { -- cgit v1.2.3