- size_t cutout_len = strlen(world.queue);
- if (0 < cutout_len)
- {
- cutout_len++;
- message = try_malloc(cutout_len, f_name);
- memcpy(message, world.queue, cutout_len);
- }
- for (;
- cutout_len != world.queue_size && '\0' == world.queue[cutout_len];
- cutout_len++);
- world.queue_size = world.queue_size - cutout_len;
- if (0 == world.queue_size)
- {
- free(world.queue); /* NULL so read_file_into_queue() may free() */
- world.queue = NULL; /* this every time, even when it's */
- } /* un-allocated first. */
- else
+ try_fputc('\'', file, __func__);
+ }
+ try_fwrite(string, strlen(string), 1, file, __func__);
+ if (contains_space)
+ {
+ try_fputc('\'', file, __func__);
+ }
+}
+
+
+
+static void write_key_space_uvalue(FILE * file, char * key, uint32_t value)
+{
+ write_key_space(file, key);
+ write_uvalue(file, value);
+ try_fputc('\n', file, __func__);
+}
+
+
+
+static void write_key_space_svalue(FILE * file, char * key, int32_t value)
+{
+ write_key_space(file, key);
+ char * line = try_malloc(11, __func__);
+ exit_trouble(-1 == sprintf(line, "%d", value), __func__, s[S_FCN_SPRINTF]);
+ try_fwrite(line, strlen(line), 1, file, __func__);
+ free(line);
+ try_fputc('\n', file, __func__);
+}
+
+
+
+static void write_key_space_string(FILE * file, char * key, char * string)
+{
+ write_key_space(file, key);
+ write_string(file, string);
+ try_fputc('\n', file, __func__);
+}
+
+
+
+static void write_mem_map(FILE * file, char * map, char * command)
+{
+ if (map)
+ {
+ uint32_t map_size = world.map.length * world.map.length;/* snprintf() */
+ char * map_copy = try_malloc(map_size + 1, __func__); /* reads one */
+ memcpy(map_copy, map, map_size); /* byte beyond map_size */
+ map_copy[map_size] = '\0'; /* if string is not \0-terminated. */
+ uint16_t y;
+ char string[UINT8_MAX + 1 + 1];
+ for (y = 0; y < world.map.length; y++)