• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

変愚蛮怒のメインリポジトリです


Commit MetaInfo

Revisiónad322d83c7f53abd684a261086e81c175fdf5726 (tree)
Tiempo2020-03-01 17:57:38
AutorHourier <hourier@user...>
CommiterHourier

Log Message

[Refactor] #39962 Separated tokenizer.c/h from files.c

Cambiar Resumen

Diferencia incremental

--- a/Hengband_vcs2017/Hengband/Hengband.vcxproj
+++ b/Hengband_vcs2017/Hengband/Hengband.vcxproj
@@ -191,6 +191,7 @@
191191 <ClCompile Include="..\..\src\horror-descriptions.c" />
192192 <ClCompile Include="..\..\src\init.c" />
193193 <ClCompile Include="..\..\src\io\gf-descriptions.c" />
194+ <ClCompile Include="..\..\src\io\tokenizer.c" />
194195 <ClCompile Include="..\..\src\monster-dist-offsets.c" />
195196 <ClCompile Include="..\..\src\monster-process.c" />
196197 <ClCompile Include="..\..\src\monster-status.c" />
@@ -332,6 +333,7 @@
332333 <ClInclude Include="..\..\src\english.h" />
333334 <ClInclude Include="..\..\src\horror-descriptions.h" />
334335 <ClInclude Include="..\..\src\io\gf-descriptions.h" />
336+ <ClInclude Include="..\..\src\io\tokenizer.h" />
335337 <ClInclude Include="..\..\src\monster-dist-offsets.h" />
336338 <ClInclude Include="..\..\src\object-flavor.h" />
337339 <ClInclude Include="..\..\src\player-inventory.h" />
--- a/Hengband_vcs2017/Hengband/Hengband.vcxproj.filters
+++ b/Hengband_vcs2017/Hengband/Hengband.vcxproj.filters
@@ -451,6 +451,9 @@
451451 <ClCompile Include="..\..\src\view\display-player-middle.c">
452452 <Filter>view</Filter>
453453 </ClCompile>
454+ <ClCompile Include="..\..\src\io\tokenizer.c">
455+ <Filter>io</Filter>
456+ </ClCompile>
454457 </ItemGroup>
455458 <ItemGroup>
456459 <ClInclude Include="..\..\src\gamevalue.h" />
@@ -884,6 +887,9 @@
884887 <ClInclude Include="..\..\src\view\display-player-middle.h">
885888 <Filter>view</Filter>
886889 </ClInclude>
890+ <ClInclude Include="..\..\src\io\tokenizer.h">
891+ <Filter>io</Filter>
892+ </ClInclude>
887893 </ItemGroup>
888894 <ItemGroup>
889895 <None Include="..\..\src\wall.bmp" />
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -27,6 +27,7 @@ hengband_SOURCES = \
2727 player/temporary-resistances.c player/temporary-resistances.h \
2828 \
2929 io/gf-descriptions.c io/gf-descriptions.h \
30+ io/tokenizer.c io/tokenizer.h \
3031 signal-handlers.c signal-handlers.h uid-checker.c uid-checker.h \
3132 character-dump.c character-dump.h core.c core.h files.c files.h \
3233 \
--- a/src/dungeon-file.c
+++ b/src/dungeon-file.c
@@ -35,6 +35,7 @@
3535 #include "util.h"
3636 #include "core.h"
3737
38+#include "io/tokenizer.h"
3839 #include "files.h"
3940 #include "dungeon-file.h"
4041 #include "rooms-vault.h"
--- a/src/files.c
+++ b/src/files.c
@@ -32,6 +32,7 @@
3232 #include "autopick.h"
3333 #include "save.h"
3434 #include "io/gf-descriptions.h"
35+#include "io/tokenizer.h"
3536
3637 #define PREF_TYPE_NORMAL 0
3738 #define PREF_TYPE_AUTOPICK 1
@@ -59,60 +60,6 @@ char savefile[1024];
5960 char savefile_base[40];
6061
6162 /*!
62- * @brief 各種データテキストをトークン単位に分解する / Extract the first few "tokens" from a buffer
63- * @param buf データテキストの参照ポインタ
64- * @param num トークンの数
65- * @param tokens トークンを保管する文字列参照ポインタ配列
66- * @param mode オプション
67- * @return 解釈した文字列数
68- * @details
69- * <pre>
70- * This function uses "colon" and "slash" as the delimeter characters.
71- * We never extract more than "num" tokens. The "last" token may include
72- * "delimeter" characters, allowing the buffer to include a "string" token.
73- * We save pointers to the tokens in "tokens", and return the number found.
74- * Hack -- Attempt to handle the 'c' character formalism
75- * Hack -- An empty buffer, or a final delimeter, yields an "empty" token.
76- * Hack -- We will always extract at least one token
77- * </pre>
78- */
79-s16b tokenize(char *buf, s16b num, char **tokens, BIT_FLAGS mode)
80-{
81- s16b i = 0;
82- char *s = buf;
83- while (i < num - 1)
84- {
85- char *t;
86- for (t = s; *t; t++)
87- {
88- if ((*t == ':') || (*t == '/')) break;
89-
90- if ((mode & TOKENIZE_CHECKQUOTE) && (*t == '\''))
91- {
92- t++;
93- if (*t == '\\') t++;
94- if (!*t) break;
95-
96- t++;
97- if (*t != '\'') *t = '\'';
98- }
99-
100- if (*t == '\\') t++;
101- }
102-
103- if (!*t) break;
104-
105- *t++ = '\0';
106- tokens[i++] = s;
107- s = t;
108- }
109-
110- tokens[i++] = s;
111- return i;
112-}
113-
114-
115-/*!
11663 * @brief 設定ファイルの各行から各種テキスト情報を取得する /
11764 * Parse a sub-file of the "extra info" (format shown below)
11865 * @param creature_ptr プレーヤーへの参照ポインタ
--- a/src/files.h
+++ b/src/files.h
@@ -1,7 +1,5 @@
11 #pragma once
22
3-#define TOKENIZE_CHECKQUOTE 0x01 /* Special handling of single quotes */
4-
53 extern char savefile[1024];
64 extern char savefile_base[40];
75
--- /dev/null
+++ b/src/io/tokenizer.c
@@ -0,0 +1,54 @@
1+#include "io/tokenizer.h"
2+
3+/*!
4+ * @brief 各種データテキストをトークン単位に分解する / Extract the first few "tokens" from a buffer
5+ * @param buf データテキストの参照ポインタ
6+ * @param num トークンの数
7+ * @param tokens トークンを保管する文字列参照ポインタ配列
8+ * @param mode オプション
9+ * @return 解釈した文字列数
10+ * @details
11+ * <pre>
12+ * This function uses "colon" and "slash" as the delimeter characters.
13+ * We never extract more than "num" tokens. The "last" token may include
14+ * "delimeter" characters, allowing the buffer to include a "string" token.
15+ * We save pointers to the tokens in "tokens", and return the number found.
16+ * Hack -- Attempt to handle the 'c' character formalism
17+ * Hack -- An empty buffer, or a final delimeter, yields an "empty" token.
18+ * Hack -- We will always extract at least one token
19+ * </pre>
20+ */
21+s16b tokenize(char *buf, s16b num, char **tokens, BIT_FLAGS mode)
22+{
23+ s16b i = 0;
24+ char *s = buf;
25+ while (i < num - 1)
26+ {
27+ char *t;
28+ for (t = s; *t; t++)
29+ {
30+ if ((*t == ':') || (*t == '/')) break;
31+
32+ if ((mode & TOKENIZE_CHECKQUOTE) && (*t == '\''))
33+ {
34+ t++;
35+ if (*t == '\\') t++;
36+ if (!*t) break;
37+
38+ t++;
39+ if (*t != '\'') *t = '\'';
40+ }
41+
42+ if (*t == '\\') t++;
43+ }
44+
45+ if (!*t) break;
46+
47+ *t++ = '\0';
48+ tokens[i++] = s;
49+ s = t;
50+ }
51+
52+ tokens[i++] = s;
53+ return i;
54+}
--- /dev/null
+++ b/src/io/tokenizer.h
@@ -0,0 +1,7 @@
1+#pragma once
2+
3+#include "angband.h"
4+
5+#define TOKENIZE_CHECKQUOTE 0x01 /* Special handling of single quotes */
6+
7+s16b tokenize(char *buf, s16b num, char **tokens, BIT_FLAGS mode);
--- a/src/rumor.c
+++ b/src/rumor.c
@@ -1,6 +1,7 @@
11 #include "angband.h"
22 #include "util.h"
33
4+#include "io/tokenizer.h"
45 #include "files.h"
56 #include "object-flavor.h"
67 #include "artifact.h"
--- a/src/wild.c
+++ b/src/wild.c
@@ -26,6 +26,7 @@
2626 #include "monster-status.h"
2727 #include "quest.h"
2828 #include "dungeon-file.h"
29+#include "io/tokenizer.h"
2930 #include "files.h"
3031 #include "feature.h"
3132 #include "floor-town.h"