+ * Add a text to the text-storage and store offset to it.
+ *
+ * Returns FALSE when there isn't enough space available to store
+ * the text.
+ */
+static bool add_text(u32b *offset, header *head, cptr buf, bool normal_text)
+{
+ /* Hack -- Verify space */
+ if (head->text_size + strlen(buf) + 8 > FAKE_TEXT_SIZE)
+ return (FALSE);
+
+ /* New text? */
+ if (*offset == 0)
+ {
+ /* Advance and save the text index */
+ *offset = ++head->text_size;
+ }
+
+ /* Additional text */
+ else if (normal_text)
+ {
+ /*
+ * If neither the end of the last line nor
+ * the beginning of current line is not a space,
+ * fill up a space as a correct separator of two words.
+ */
+ if (head->text_size > 0 &&
+#ifdef JP
+ (*(head->text_ptr + head->text_size - 1) != ' ') &&
+ ((head->text_size == 1) || !iskanji(*(head->text_ptr + head->text_size - 2))) &&
+ (buf[0] != ' ') && !iskanji(buf[0])
+#else
+ (*(head->text_ptr + head->text_size - 1) != ' ') &&
+ (buf[0] != ' ')
+#endif
+ )
+ {
+ /* Append a space */
+ *(head->text_ptr + head->text_size) = ' ';
+
+ /* Advance the index */
+ head->text_size++;
+ }
+ }
+
+ /* Append chars to the text */
+ strcpy(head->text_ptr + head->text_size, buf);
+
+ /* Advance the index */
+ head->text_size += strlen(buf);
+
+ /* Success */
+ return (TRUE);
+}
+
+
+/*
+ * Add a name to the name-storage and return an offset to it.
+ *
+ * Returns FALSE when there isn't enough space available to store
+ * the name.
+ */
+static bool add_name(u32b *offset, header *head, cptr buf)
+{
+ /* Hack -- Verify space */
+ if (head->name_size + strlen(buf) + 8 > FAKE_NAME_SIZE)
+ return (FALSE);
+
+ /* New name? */
+ if (*offset == 0)
+ {
+ /* Advance and save the name index */
+ *offset = ++head->name_size;
+ }
+
+ /* Append chars to the names */
+ strcpy(head->name_ptr + head->name_size, buf);
+
+ /* Advance the index */
+ head->name_size += strlen(buf);
+
+ /* Success */
+ return (TRUE);
+}
+
+
+/*
+ * Add a tag to the tag-storage and return an offset to it.
+ *
+ * Returns FALSE when there isn't enough space available to store
+ * the name.
+ */
+static bool add_tag(s16b *offset, header *head, cptr buf)
+{
+ u32b i;
+
+ /* Search for an existing (fake) tag */
+ for (i = 1; i < head->tag_size; i += strlen(&head->tag_ptr[i]) + 1)
+ {
+ /* Found it */
+ if (streq(&head->tag_ptr[i], buf)) break;
+ }
+
+ /* There was no existing tag */
+ if (i >= head->tag_size)
+ {
+ /* Hack -- Verify space */
+ if (head->tag_size + strlen(buf) + 8 > FAKE_TAG_SIZE)
+ return FALSE;
+
+ /* Append chars to the tags */
+ strcpy(head->tag_ptr + head->tag_size, buf);
+
+ /* Point the new tag */
+ i = head->tag_size;
+
+ /* Advance the index */
+ head->tag_size += strlen(buf) + 1;
+ }
+
+ /* Return offset of the tag */
+ *offset = (s16b)i;
+
+ /* Success */
+ return TRUE;
+}
+
+
+/*