[pinpoint] parsing: replace strchr with a ugly inline wrapper



commit f6b0f5b438d8050f923b5602d1ccf9a863f7c5a6
Author: �yvind Kolås <pippin gimp org>
Date:   Mon May 23 23:10:34 2011 +0100

    parsing: replace strchr with a ugly inline wrapper
    
    On linux with gcc (Debian 4.6.0-8) 4.6.1 20110521 (prerelease) the strchr
    function/macro expands to uncompilable code in some circumstances, wrapping
    it in an inline function makes it compile.

 pinpoint.c |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)
---
diff --git a/pinpoint.c b/pinpoint.c
index 737cb5d..e99afca 100644
--- a/pinpoint.c
+++ b/pinpoint.c
@@ -312,6 +312,20 @@ pp_get_shading_position_size (float stage_width,
 
 void     pp_parse_slides  (PinPointRenderer *renderer,
                            const char       *slide_src);
+
+static inline char *my_strchr_coz_gcc_is_broken (const char *s, int c)
+{
+  /* by directly using strchr in the below code gcc balks out with the
+   * following error :
+   *
+   * pinpoint.c: In function â??parse_settingâ??:
+   * pinpoint.c:358:58: error: expected expression before â??)â?? token
+   *
+   * .. for the expansion of the hacky float macro below.
+   */
+  return strchr (s, c);
+}
+
 /*
  * Parsing
  */
@@ -329,8 +343,8 @@ parse_setting (PinPointPoint *point,
 #define END_PARSER   }
 #define IF_PREFIX(prefix) } else if (g_str_has_prefix (setting, prefix)) {
 #define IF_EQUAL(string) } else if (g_str_equal (setting, string)) {
-#define char g_intern_string (strchr (setting, '=') + 1)
-#define float g_ascii_strtod (strchr (setting, '=') + 1, NULL);
+#define char g_intern_string (my_strchr_coz_gcc_is_broken (setting, '=') + 1)
+#define float g_ascii_strtod (my_strchr_coz_gcc_is_broken (setting, '=') + 1, NULL)
 #define enum(r,t,s) \
   do { \
       int _i; \



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]