replaced glib function calls to g_strdup()
[rocksndiamonds.git] / src / game_bd / bd_bdcff.c
index 6f3b935b421aea5e5f30524f5c6c8eb27209ed69..a620fbc5a2f2c8e94b7187a916bcd054cad3be2d 100644 (file)
@@ -107,17 +107,17 @@ static boolean attrib_is_valid_for_cave(const char *attrib)
   int i;
 
   /* bdcff engine flag............ */
-  if (strcasecmp(attrib, "Engine")==0)
+  if (strcasecmp(attrib, "Engine") == 0)
     return TRUE;
 
   /* old flags - for compatibility */
-  if (strcasecmp(attrib, "BD1Scheduling")==0)
+  if (strcasecmp(attrib, "BD1Scheduling") == 0)
     return TRUE;
 
-  if (strcasecmp(attrib, "SnapExplosions")==0)
+  if (strcasecmp(attrib, "SnapExplosions") == 0)
     return TRUE;
 
-  if (strcasecmp(attrib, "AmoebaProperties")==0)
+  if (strcasecmp(attrib, "AmoebaProperties") == 0)
     return TRUE;
 
   /* search in property database */
@@ -150,8 +150,8 @@ static boolean struct_set_property(gpointer str, const GdStructDescriptor *prop_
   int i;
   boolean was_string;
 
-  params = g_strsplit_set(param, " ", -1);
-  paramcount = g_strv_length(params);
+  params = getSplitStringArray(param, " ", -1);
+  paramcount = getStringArrayLength(params);
   identifier_found = FALSE;
 
   /* check all known tags. do not exit this loop if identifier_found == true...
@@ -188,12 +188,10 @@ static boolean struct_set_property(gpointer str, const GdStructDescriptor *prop_
 
       if (prop_desc[i].type == GD_TYPE_LONGSTRING)
       {
-       GString *str = *(GString **)value;
-       char *compressed;
+       char **str = (char **)value;
 
-       compressed = g_strcompress(param);
-       g_string_assign(str, compressed);
-       free(compressed);
+       checked_free(*str);
+       *str = getUnescapedString(param);
 
        /* remember this to skip checking the number of parameters at the end of the function */
        was_string = TRUE;
@@ -330,7 +328,7 @@ static boolean struct_set_property(gpointer str, const GdStructDescriptor *prop_
   if (identifier_found && !was_string && paramindex < paramcount)
     Warn("excess parameters for attribute '%s': '%s'", attrib, params[paramindex]);
 
-  g_strfreev(params);
+  freeStringArray(params);
 
   return identifier_found;
 }
@@ -347,12 +345,12 @@ static boolean replay_store_more_from_bdcff(GdReplay *replay, const char *param)
   int i;
   boolean result = TRUE;
 
-  split = g_strsplit_set(param, " ", -1);
+  split = getSplitStringArray(param, " ", -1);
 
   for (i = 0; split[i] != 0; i++)
     result = result && replay_store_from_bdcff(replay, split[i]);
 
-  g_strfreev(split);
+  freeStringArray(split);
 
   return result;
 }
@@ -403,7 +401,7 @@ static boolean cave_process_tags_func(const char *attrib, const char *param, GdC
   char **params;
   boolean identifier_found;
 
-  params = g_strsplit_set(param, " ", -1);
+  params = getSplitStringArray(param, " ", -1);
   identifier_found = FALSE;
 
   if (strcasecmp(attrib, "SnapExplosions") == 0)
@@ -482,7 +480,7 @@ static boolean cave_process_tags_func(const char *attrib, const char *param, GdC
     identifier_found = struct_set_property(cave, gd_cave_properties, attrib, param, cave->w * cave->h);
   }
 
-  g_strfreev(params);
+  freeStringArray(params);
 
   /* a ghrfunc should return true if the identifier is to be removed */
   return identifier_found;
@@ -495,7 +493,7 @@ static void cave_report_and_copy_unknown_tags_func(char *attrib, char *param, gp
 
   Warn("unknown tag '%s'", attrib);
 
-  g_hash_table_insert(cave->tags, g_strdup(attrib), g_strdup(param));
+  g_hash_table_insert(cave->tags, getStringCopy(attrib), getStringCopy(param));
 }
 
 /* having read all strings belonging to the cave, process it. */
@@ -669,14 +667,14 @@ boolean gd_caveset_load_from_bdcff(const char *contents)
   replay_tags = g_hash_table_new_full(gd_str_case_hash, gd_str_case_equal, free, free);
 
   /* split into lines */
-  lines = g_strsplit_set (contents, "\n", 0);
+  lines = getSplitStringArray (contents, "\n", 0);
 
   /* attributes read will be set in cave. if no [cave]; they are stored
      in the default cave; like in a [game] */
   default_cave = gd_cave_new();
   cave = default_cave;
 
-  linenum = g_strv_length(lines);
+  linenum = getStringArrayLength(lines);
 
   for (lineno = 0; lineno < linenum; lineno++)
   {
@@ -958,7 +956,7 @@ boolean gd_caveset_load_from_bdcff(const char *contents)
       /* own tag: not too much thinking :P */
       if (reading_replay)
       {
-       g_hash_table_insert(replay_tags, g_strdup(attrib), g_strdup(param));
+       g_hash_table_insert(replay_tags, getStringCopy(attrib), getStringCopy(param));
       }
       else if (reading_mapcodes)
       {
@@ -1048,10 +1046,10 @@ boolean gd_caveset_load_from_bdcff(const char *contents)
        /* CHECK IF IT IS AN EFFECT */
        char **params;
 
-       params = g_strsplit_set(param, " ", -1);
+       params = getSplitStringArray(param, " ", -1);
 
        /* an effect command has two parameters */
-       if (g_strv_length(params) == 2)
+       if (getStringArrayLength(params) == 2)
        {
          int i;
 
@@ -1095,7 +1093,7 @@ boolean gd_caveset_load_from_bdcff(const char *contents)
        else
          Warn("invalid effect specification '%s'", param);
 
-       g_strfreev(params);
+       freeStringArray(params);
       }
       else
       {
@@ -1113,7 +1111,7 @@ boolean gd_caveset_load_from_bdcff(const char *contents)
          {
            /* it must be a default setting for all caves. is it a valid identifier? */
            /* yes, it is. add to the hash table, which will be copied for all caves. */
-           g_hash_table_insert(tags, g_strdup(attrib), g_strdup(param));
+           g_hash_table_insert(tags, getStringCopy(attrib), getStringCopy(param));
          }
          else
            /* unknown setting - report. */
@@ -1124,7 +1122,7 @@ boolean gd_caveset_load_from_bdcff(const char *contents)
          /* we are reading a [cave] */
          /* cave settings are immediately added to cave hash table. */
          /* if it is unknown, we have to remember it, and save it again. */
-         g_hash_table_insert(tags, g_strdup(attrib), g_strdup(param));
+         g_hash_table_insert(tags, getStringCopy(attrib), getStringCopy(param));
        }
       }
 
@@ -1149,7 +1147,7 @@ boolean gd_caveset_load_from_bdcff(const char *contents)
     Warn(_("Invalid BDCFF: [game] section has drawing objects defined"));
 
   /* cleanup */
-  g_strfreev (lines);
+  freeStringArray(lines);
   g_hash_table_destroy(tags);
   g_hash_table_destroy(replay_tags);
   gd_cave_free(default_cave);