<ClCompile Include="..\..\src\artifact.c" />\r
<ClCompile Include="..\..\src\autopick\autopick-entry.c" />\r
<ClCompile Include="..\..\src\autopick\autopick-menu-data-table.c" />\r
+ <ClCompile Include="..\..\src\autopick\autopick-util.c" />\r
<ClCompile Include="..\..\src\autopick\autopick.c" />\r
<ClCompile Include="..\..\src\avatar.c" />\r
<ClCompile Include="..\..\src\birth.c" />\r
<ClCompile Include="..\..\src\cmd\cmd-knowledge.c" />\r
<ClCompile Include="..\..\src\cmd\cmd-process-screen.c" />\r
<ClCompile Include="..\..\src\cmd\dump-util.c" />\r
+ <ClCompile Include="..\..\src\io\dump-remover.c" />\r
<ClCompile Include="..\..\src\io\mutations-dump.c" />\r
<ClCompile Include="..\..\src\knowledge\knowledge-autopick.c" />\r
<ClCompile Include="..\..\src\knowledge\knowledge-features.c" />\r
<ClInclude Include="..\..\src\cmd\cmd-knowledge.h" />\r
<ClInclude Include="..\..\src\cmd\cmd-process-screen.h" />\r
<ClInclude Include="..\..\src\cmd\dump-util.h" />\r
+ <ClInclude Include="..\..\src\io\dump-remover.h" />\r
<ClInclude Include="..\..\src\io\mutations-dump.h" />\r
<ClInclude Include="..\..\src\knowledge\knowledge-autopick.h" />\r
<ClInclude Include="..\..\src\knowledge\knowledge-features.h" />\r
<ClCompile Include="..\..\src\autopick\autopick-entry.c">
<Filter>autopick</Filter>
</ClCompile>
+ <ClCompile Include="..\..\src\autopick\autopick-util.c">
+ <Filter>autopick</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\io\dump-remover.c">
+ <Filter>io</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\src\gamevalue.h" />
<ClInclude Include="..\..\src\autopick\autopick-entry.h">
<Filter>autopick</Filter>
</ClInclude>
+ <ClInclude Include="..\..\src\io\dump-remover.h">
+ <Filter>io</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\src\wall.bmp" />
autopick/autopick-editor-table.h autopick/autopick-flags-table.h \
autopick/autopick-key-flag-process.h autopick/autopick-key-table.h \
autopick/autopick-menu-data-table.c autopick/autopick-menu-data-table.h \
- autopick/autopick-methods-table.h autopick/autopick-util.h \
+ autopick/autopick-methods-table.h \
+ autopick/autopick-util.c autopick/autopick-util.h \
autopick/autopick-entry.c autopick/autopick-entry.h \
\
avatar.h avatar.c birth.c birth.h \
player/permanent-resistances.c player/permanent-resistances.h \
player/temporary-resistances.c player/temporary-resistances.h \
\
+ io/dump-remover.c io/dump-remover.h \
io/gf-descriptions.c io/gf-descriptions.h \
io/tokenizer.c io/tokenizer.h \
io/interpret-pref-file.c io/interpret-pref-file.h \
#include "cmd/dump-util.h"
#include "gameterm.h"
#include "core.h" // 暫定。後で消す.
+#include "io/dump-remover.h"
#include "io/read-pref-file.h"
#include "io/interpret-pref-file.h"
#include "chuukei.h"
-/*!
- * @brief prefファイルを選択して処理する /
- * Ask for a "user pref line" and process it
- * @brief prf出力内容を消去する /
- * Remove old lines automatically generated before.
- * @param orig_file 消去を行うファイル名
- */
-static void remove_auto_dump(concptr orig_file, concptr auto_dump_mark)
-{
- char buf[1024];
- bool between_mark = FALSE;
- bool changed = FALSE;
- int line_num = 0;
- long header_location = 0;
- char header_mark_str[80];
- char footer_mark_str[80];
-
- sprintf(header_mark_str, auto_dump_header, auto_dump_mark);
- sprintf(footer_mark_str, auto_dump_footer, auto_dump_mark);
- size_t mark_len = strlen(footer_mark_str);
-
- FILE *orig_fff;
- orig_fff = my_fopen(orig_file, "r");
- if (!orig_fff) return;
-
- FILE *tmp_fff = NULL;
- char tmp_file[FILE_NAME_SIZE];
- if (!open_temporary_file(&tmp_fff, tmp_file)) return;
-
- while (TRUE)
- {
- if (my_fgets(orig_fff, buf, sizeof(buf)))
- {
- if (between_mark)
- {
- fseek(orig_fff, header_location, SEEK_SET);
- between_mark = FALSE;
- continue;
- }
- else
- {
- break;
- }
- }
-
- if (!between_mark)
- {
- if (!strcmp(buf, header_mark_str))
- {
- header_location = ftell(orig_fff);
- line_num = 0;
- between_mark = TRUE;
- changed = TRUE;
- }
- else
- {
- fprintf(tmp_fff, "%s\n", buf);
- }
-
- continue;
- }
-
- if (!strncmp(buf, footer_mark_str, mark_len))
- {
- int tmp;
- if (!sscanf(buf + mark_len, " (%d)", &tmp)
- || tmp != line_num)
- {
- fseek(orig_fff, header_location, SEEK_SET);
- }
-
- between_mark = FALSE;
- continue;
- }
-
- line_num++;
- }
-
- my_fclose(orig_fff);
- my_fclose(tmp_fff);
-
- if (changed)
- {
- tmp_fff = my_fopen(tmp_file, "r");
- orig_fff = my_fopen(orig_file, "w");
- while (!my_fgets(tmp_fff, buf, sizeof(buf)))
- fprintf(orig_fff, "%s\n", buf);
-
- my_fclose(orig_fff);
- my_fclose(tmp_fff);
- }
-
- fd_kill(tmp_file);
-}
-
-
#ifdef JP
#else
/*!
--- /dev/null
+#include "angband.h"
+#include "cmd/dump-util.h"
+#include "io/dump-remover.h"
+#include "io/read-pref-file.h"
+
+/*!
+ * @brief prefファイルを選択して処理する /
+ * Ask for a "user pref line" and process it
+ * @brief prf出力内容を消去する /
+ * Remove old lines automatically generated before.
+ * @param orig_file 消去を行うファイル名
+ */
+void remove_auto_dump(concptr orig_file, concptr auto_dump_mark)
+{
+ char buf[1024];
+ bool between_mark = FALSE;
+ bool changed = FALSE;
+ int line_num = 0;
+ long header_location = 0;
+ char header_mark_str[80];
+ char footer_mark_str[80];
+
+ sprintf(header_mark_str, auto_dump_header, auto_dump_mark);
+ sprintf(footer_mark_str, auto_dump_footer, auto_dump_mark);
+ size_t mark_len = strlen(footer_mark_str);
+
+ FILE *orig_fff;
+ orig_fff = my_fopen(orig_file, "r");
+ if (!orig_fff) return;
+
+ FILE *tmp_fff = NULL;
+ char tmp_file[FILE_NAME_SIZE];
+ if (!open_temporary_file(&tmp_fff, tmp_file)) return;
+
+ while (TRUE)
+ {
+ if (my_fgets(orig_fff, buf, sizeof(buf)))
+ {
+ if (between_mark)
+ {
+ fseek(orig_fff, header_location, SEEK_SET);
+ between_mark = FALSE;
+ continue;
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ if (!between_mark)
+ {
+ if (!strcmp(buf, header_mark_str))
+ {
+ header_location = ftell(orig_fff);
+ line_num = 0;
+ between_mark = TRUE;
+ changed = TRUE;
+ }
+ else
+ {
+ fprintf(tmp_fff, "%s\n", buf);
+ }
+
+ continue;
+ }
+
+ if (!strncmp(buf, footer_mark_str, mark_len))
+ {
+ int tmp;
+ if (!sscanf(buf + mark_len, " (%d)", &tmp)
+ || tmp != line_num)
+ {
+ fseek(orig_fff, header_location, SEEK_SET);
+ }
+
+ between_mark = FALSE;
+ continue;
+ }
+
+ line_num++;
+ }
+
+ my_fclose(orig_fff);
+ my_fclose(tmp_fff);
+
+ if (changed)
+ {
+ tmp_fff = my_fopen(tmp_file, "r");
+ orig_fff = my_fopen(orig_file, "w");
+ while (!my_fgets(tmp_fff, buf, sizeof(buf)))
+ fprintf(orig_fff, "%s\n", buf);
+
+ my_fclose(orig_fff);
+ my_fclose(tmp_fff);
+ }
+
+ fd_kill(tmp_file);
+}
--- /dev/null
+#pragma once
+
+void remove_auto_dump(concptr orig_file, concptr auto_dump_mark);
*/
#include "angband.h"
+#include "io/dump-remover.h"
#include "io/read-pref-file.h"
#include "io/interpret-pref-file.h"
#include "autopick/autopick.h"
/*!
- * @brief prf出力内容を消去する /
- * Remove old lines automatically generated before.
- * @param orig_file 消去を行うファイル名
- */
-static void remove_auto_dump(concptr orig_file, concptr auto_dump_mark)
-{
- char header_mark_str[80];
- char footer_mark_str[80];
- sprintf(header_mark_str, auto_dump_header, auto_dump_mark);
- sprintf(footer_mark_str, auto_dump_footer, auto_dump_mark);
- size_t mark_len = strlen(footer_mark_str);
- FILE *orig_fff;
- orig_fff = my_fopen(orig_file, "r");
- if (!orig_fff) return;
-
- char tmp_file[1024];
- FILE *tmp_fff;
- tmp_fff = my_fopen_temp(tmp_file, 1024);
- if (!tmp_fff)
- {
- msg_format(_("一時ファイル %s を作成できませんでした。", "Failed to create temporary file %s."), tmp_file);
- msg_print(NULL);
- return;
- }
-
- char buf[1024];
- bool between_mark = FALSE;
- bool changed = FALSE;
- int line_num = 0;
- long header_location = 0;
- while (TRUE)
- {
- if (my_fgets(orig_fff, buf, sizeof(buf)))
- {
- if (between_mark)
- {
- fseek(orig_fff, header_location, SEEK_SET);
- between_mark = FALSE;
- continue;
- }
- else
- {
- break;
- }
- }
-
- if (!between_mark)
- {
- if (!strcmp(buf, header_mark_str))
- {
- header_location = ftell(orig_fff);
- line_num = 0;
- between_mark = TRUE;
- changed = TRUE;
- }
- else
- {
- fprintf(tmp_fff, "%s\n", buf);
- }
-
- continue;
- }
-
- if (!strncmp(buf, footer_mark_str, mark_len))
- {
- int tmp;
- if (!sscanf(buf + mark_len, " (%d)", &tmp)
- || tmp != line_num)
- {
- fseek(orig_fff, header_location, SEEK_SET);
- }
-
- between_mark = FALSE;
- continue;
- }
-
- line_num++;
- }
-
- my_fclose(orig_fff);
- my_fclose(tmp_fff);
-
- if (changed)
- {
- tmp_fff = my_fopen(tmp_file, "r");
- orig_fff = my_fopen(orig_file, "w");
- while (!my_fgets(tmp_fff, buf, sizeof(buf)))
- fprintf(orig_fff, "%s\n", buf);
-
- my_fclose(orig_fff);
- my_fclose(tmp_fff);
- }
-
- fd_kill(tmp_file);
-}
-
-
-/*!
* @brief prfファイルのフォーマットに従った内容を出力する /
* Dump a formatted line, using "vstrnfmt()".
* @param fmt 出力内容