#include "autopick/autopick-key-flag-process.h"
#include "autopick/autopick-methods-table.h"
#include "system/angband.h"
+#include "util/string-processor.h"
typedef struct
{
#include "sv-definition/sv-wand-types.h"
#include "player/player-move.h"
#include "player/player-race-types.h"
+#include "util/string-processor.h"
#include "view/display-messages.h"
/*!
#include "object/object-info.h"
#include "perception/object-perception.h"
#include "util/quarks.h"
+#include "util/string-processor.h"
#ifdef JP
static char kanji_colon[] = ":";
#include "term/screen-processor.h"
#include "term/term-color-types.h"
#include "util/int-char-converter.h"
+#include "util/string-processor.h"
/*
* @brief \97^\82¦\82ç\82ê\82½\83A\83C\83e\83\80\82ª\8e©\93®\8fE\82¢\82Ì\83\8a\83X\83g\82É\93o\98^\82³\82ê\82Ä\82¢\82é\82©\82Ç\82¤\82©\82ð\8c\9f\8dõ\82·\82é
#include "object/object-value.h"
#include "object/object-info.h"
#include "object-enchant/special-object-flags.h"
+#include "util/string-processor.h"
/*
* A function for Auto-picker/destroyer
#include "io/files-util.h"
#include "io/read-pref-file.h"
#include "util/angband-files.h"
+#include "util/string-processor.h"
#include "view/display-messages.h"
/*
#include "term/screen-processor.h"
#include "term/term-color-types.h"
#include "util/int-char-converter.h"
+#include "util/string-processor.h"
#include "view/display-main-window.h"
#include "view/display-messages.h"
#include "world/world.h"
#include "term/screen-processor.h"
#include "term/term-color-types.h"
#include "util/int-char-converter.h"
+#include "util/string-processor.h"
#include "view/display-main-window.h"
#include "view/display-lore.h"
#include "spell/spells-status.h"
#include "sv-definition/sv-food-types.h"
#include "sv-definition/sv-other-types.h"
+#include "util/string-processor.h"
#include "view/display-main-window.h"
#include "view/display-messages.h"
#include "view/object-describer.h"
#include "term/screen-processor.h"
#include "term/term-color-types.h"
#include "util/int-char-converter.h"
+#include "util/string-processor.h"
#include "view/display-main-window.h" // 暫定。後で消す.
#include "view/display-messages.h"
#include "view/display-player.h" // 暫定。後で消す.
#include "term/screen-processor.h"
#include "term/term-color-types.h"
#include "util/int-char-converter.h"
+#include "util/string-processor.h"
#include "view/display-messages.h"
/*
#include "term/term-color-types.h"
#include "util/angband-files.h"
#include "util/int-char-converter.h"
+#include "util/string-processor.h"
#include "view/display-messages.h"
#include "world/world.h"
#include "term/term-color-types.h"
#include "util/angband-files.h"
#include "util/int-char-converter.h"
+#include "util/string-processor.h"
#include "view/display-messages.h"
/*!
#include "object-enchant/artifact.h"
#include "object-enchant/tr-types.h"
#include "util/bit-flags-calculator.h"
+#include "util/string-processor.h"
#include "view/display-messages.h"
/*!
#include "info-reader/parse-error-types.h"
#include "info-reader/race-info-tokens-table.h"
#include "io/tokenizer.h"
+#include "util/string-processor.h"
#include "view/display-messages.h"
/*!
#include "object-enchant/object-ego.h"
#include "object-enchant/tr-types.h"
#include "util/bit-flags-calculator.h"
+#include "util/string-processor.h"
#include "view/display-messages.h"
/*!
#include "room/rooms.h"
#include "term/gameterm.h"
#include "util/bit-flags-calculator.h"
+#include "util/string-processor.h"
#include "view/display-main-window.h"
#include "view/display-messages.h"
#include "io/files-util.h"
#include "system/system-variables.h"
#include "util/angband-files.h"
+#include "util/string-processor.h"
#include "view/display-messages.h"
#include "world/world.h"
#include "system/building-type-definition.h"
#include "system/system-variables.h"
#include "util/angband-files.h"
+#include "util/string-processor.h"
/*!
* @brief パース関数に基づいてデータファイルからデータを読み取る /
#include "object/object-kind.h"
#include "term/gameterm.h"
#include "util/bit-flags-calculator.h"
+#include "util/string-processor.h"
#include "view/display-messages.h"
/*!
#include "info-reader/magic-reader.h"
+#include "util/string-processor.h"
/*!
* @brief 職業魔法情報(m_info)のパース関数 /
#include "info-reader/race-reader.h"
#include "info-reader/race-info-tokens-table.h"
#include "term/gameterm.h"
+#include "util/string-processor.h"
#include "view/display-messages.h"
/*!
#include "info-reader/vault-reader.h"
#include "room/rooms-vault.h"
+#include "util/string-processor.h"
/*!
* @brief Vault情報(v_info)のパース関数 /
#include "spell-kind/spells-teleport.h"
#include "spell/spells-summon.h"
#include "util/bit-flags-calculator.h"
+#include "util/string-processor.h"
#include "util/quarks.h"
#include "view/display-messages.h"
#include "term/term-color-types.h"
#include "util/int-char-converter.h"
#include "util/quarks.h"
+#include "util/string-processor.h"
#include "view/display-main-window.h"
#include "view/display-messages.h"
#include "object/object-kind.h"
#include "player/player-move.h"
#include "util/quarks.h"
+#include "util/string-processor.h"
#include "view/display-messages.h"
/*!
#include "term/screen-processor.h" // todo 相互依存している、後で何とかする.
#include "util/int-char-converter.h"
#include "util/quarks.h"
+#include "util/string-processor.h"
#include "view/display-main-window.h" // todo panel_row_min が依存している。後で移設を検討する.
#include "view/display-messages.h"
#include "io/pref-file-expressor.h"
#include "game-option/runtime-arguments.h"
#include "system/system-variables.h"
+#include "util/string-processor.h"
/*!
* @brief process_pref_fileのサブルーチンとして条件分岐処理の解釈と結果を返す
#include "term/term-color-types.h"
#include "util/angband-files.h"
#include "util/int-char-converter.h"
+#include "util/string-processor.h"
#include "view/display-main-window.h" // 暫定、後で消す.
#include "view/display-lore.h"
#include "view/display-monster-status.h"
#include "locale/english.h"
+#include "util/string-processor.h"
/*!
* @brief 英単語、句、説を複数形を変換する / Pluralize a monster name
*/
#include "locale/japanese.h"
+#include "util/string-processor.h"
#include "view/display-messages.h"
#ifdef JP
#include "term/screen-processor.h"
#include "term/term-color-types.h"
#include "util/int-char-converter.h"
+#include "util/string-processor.h"
#include "view/display-main-window.h"
#include "view/display-lore.h"
#include "monster-race/race-flags1.h"
#include "monster-race/race-flags3.h"
#include "monster/monster-status.h"
+#include "util/string-processor.h"
#include "view/display-messages.h"
#include "world/world.h"
#include "monster/smart-learn-types.h"
#include "mspell/summon-checker.h"
#include "spell/spells-summon.h"
+#include "util/string-processor.h"
#include "view/display-messages.h"
#define MON_SCAT_MAXD 10 /*!< mon_scatter()関数によるモンスター配置で許される中心からの最大距離 */
#include "monster/monster-list.h"
#include "monster/monster-util.h"
#include "mspell/monster-spell.h"
-#include "util/util.h"
+#include "util/string-processor.h"
/*! 通常pit生成時のモンスターの構成条件ID / Race index for "monster pit (clone)" */
int vault_aux_race;
#include "monster/monster-flag-types.h"
#include "monster/monster-info.h"
#include "util/quarks.h"
+#include "util/string-processor.h"
#include "view/display-messages.h"
/*!
#include "monster-race/race-indice-types.h"
#include "monster/monster-util.h"
#include "spell/spells-summon.h"
+#include "util/string-processor.h"
/*!
* @brief 指定されたモンスター種族がsummon_specific_typeで指定された召喚条件に合うかどうかを返す
#include "sv-definition/sv-lite-types.h"
#include "util/bit-flags-calculator.h"
#include "util/quarks.h"
+#include "util/string-processor.h"
#include "world/world.h"
/*!
#include "sv-definition/sv-protector-types.h"
#include "sv-definition/sv-weapon-types.h"
#include "util/bit-flags-calculator.h"
+#include "util/string-processor.h"
#include "view/display-main-window.h"
#include "world/world.h"
#include "term/screen-processor.h"
#include "term/term-color-types.h"
#include "util/bit-flags-calculator.h"
+#include "util/string-processor.h"
#include "view/display-main-window.h"
#include "view/display-messages.h"
#include "world/world.h"
#include "term/screen-processor.h"
#include "util/bit-flags-calculator.h"
#include "util/quarks.h"
+#include "util/string-processor.h"
#include "view/display-main-window.h"
#include "view/display-messages.h"
#include "world/world.h"
#include "store/store-util.h"
#include "store/store.h"
#include "term/gameterm.h"
-#include "util/int-char-converter.h"
#include "term/screen-processor.h"
+#include "util/int-char-converter.h"
+#include "util/string-processor.h"
#include "view/display-messages.h"
#include "world/world.h"
#include "term/screen-processor.h"
#include "term/term-color-types.h"
#include "util/angband-files.h"
+#include "util/string-processor.h"
#include "world/world.h"
/*!
#include "realm/realm-song-numbers.h"
#include "realm/realm-song.h"
#include "util/bit-flags-calculator.h"
+#include "util/string-processor.h"
#include "view/display-messages.h"
/*!
#include "spell/spells-status.h"
#include "spell/spell-types.h"
#include "sv-definition/sv-other-types.h"
+#include "util/string-processor.h"
#include "view/display-messages.h"
/*!
#include "sv-definition/sv-scroll-types.h"
#include "sv-definition/sv-weapon-types.h"
#include "util/bit-flags-calculator.h"
+#include "util/string-processor.h"
#include "world/world-object.h"
int cur_store_num = 0;
#include "system/system-variables.h"
#include "term/term-color-types.h"
#include "util/quarks.h"
+#include "util/string-processor.h"
/*
* Convert an "attr"/"char" pair into a "pict" (P)
*s = '\0';
}
+
+/*
+ * The angband_strcpy() function copies up to 'bufsize'-1 characters from 'src'
+ * to 'buf' and NUL-terminates the result. The 'buf' and 'src' strings may
+ * not overlap.
+ *
+ * angband_strcpy() returns strlen(src). This makes checking for truncation
+ * easy. Example: if (angband_strcpy(buf, src, sizeof(buf)) >= sizeof(buf)) ...;
+ *
+ * This function should be equivalent to the strlcpy() function in BSD.
+ */
+size_t angband_strcpy(char *buf, concptr src, size_t bufsize)
+{
+#ifdef JP
+ char *d = buf;
+ concptr s = src;
+ size_t len = 0;
+
+ if (bufsize > 0) {
+ /* reserve for NUL termination */
+ bufsize--;
+
+ /* Copy as many bytes as will fit */
+ while (*s && (len < bufsize)) {
+ if (iskanji(*s)) {
+ if (len + 1 >= bufsize || !*(s + 1))
+ break;
+ *d++ = *s++;
+ *d++ = *s++;
+ len += 2;
+ } else {
+ *d++ = *s++;
+ len++;
+ }
+ }
+ *d = '\0';
+ }
+
+ while (*s++)
+ len++;
+ return len;
+
+#else
+ size_t len = strlen(src);
+ size_t ret = len;
+ if (bufsize == 0)
+ return ret;
+
+ if (len >= bufsize)
+ len = bufsize - 1;
+
+ (void)memcpy(buf, src, len);
+ buf[len] = '\0';
+ return ret;
+#endif
+}
+
+/*
+ * The angband_strcat() tries to append a string to an existing NUL-terminated string.
+ * It never writes more characters into the buffer than indicated by 'bufsize' and
+ * NUL-terminates the buffer. The 'buf' and 'src' strings may not overlap.
+ *
+ * angband_strcat() returns strlen(buf) + strlen(src). This makes checking for
+ * truncation easy. Example:
+ * if (angband_strcat(buf, src, sizeof(buf)) >= sizeof(buf)) ...;
+ *
+ * This function should be equivalent to the strlcat() function in BSD.
+ */
+size_t angband_strcat(char *buf, concptr src, size_t bufsize)
+{
+ size_t dlen = strlen(buf);
+ if (dlen < bufsize - 1) {
+ return (dlen + angband_strcpy(buf + dlen, src, bufsize - dlen));
+ } else {
+ return (dlen + strlen(src));
+ }
+}
+
+/*
+ * A copy of ANSI strstr()
+ *
+ * angband_strstr() can handle Kanji strings correctly.
+ */
+char *angband_strstr(concptr haystack, concptr needle)
+{
+ int l1 = strlen(haystack);
+ int l2 = strlen(needle);
+
+ if (l1 >= l2) {
+ for (int i = 0; i <= l1 - l2; i++) {
+ if (!strncmp(haystack + i, needle, l2))
+ return (char *)haystack + i;
+
+#ifdef JP
+ if (iskanji(*(haystack + i)))
+ i++;
+#endif
+ }
+ }
+
+ return NULL;
+}
+
+/*
+ * A copy of ANSI strchr()
+ *
+ * angband_strchr() can handle Kanji strings correctly.
+ */
+char *angband_strchr(concptr ptr, char ch)
+{
+ for (; *ptr != '\0'; ptr++) {
+ if (*ptr == ch)
+ return (char *)ptr;
+
+#ifdef JP
+ if (iskanji(*ptr))
+ ptr++;
+#endif
+ }
+
+ return NULL;
+}
void text_to_ascii(char *buf, concptr str);
void ascii_to_text(char *buf, concptr str);
+size_t angband_strcpy(char *buf, concptr src, size_t bufsize);
+size_t angband_strcat(char *buf, concptr src, size_t bufsize);
+char *angband_strstr(concptr haystack, concptr needle);
+char *angband_strchr(concptr ptr, char ch);
*/
errr type_string(concptr str, uint len)
{
- errr err = 0;
- term *old = Term;
- if (!str) return -1;
- if (!len) len = strlen(str);
-
- Term_activate(term_screen);
- for (concptr s = str; s < str + len; s++)
- {
- if (*s == '\0') break;
-
- err = Term_keypress(*s);
- if (err) break;
- }
-
- Term_activate(old);
- return err;
+ errr err = 0;
+ term *old = Term;
+ if (!str)
+ return -1;
+ if (!len)
+ len = strlen(str);
+
+ Term_activate(term_screen);
+ for (concptr s = str; s < str + len; s++) {
+ if (*s == '\0')
+ break;
+
+ err = Term_keypress(*s);
+ if (err)
+ break;
+ }
+
+ Term_activate(old);
+ return err;
}
-
void roff_to_buf(concptr str, int maxlen, char *tbuf, size_t bufsize)
{
- int read_pt = 0;
- int write_pt = 0;
- int line_len = 0;
- int word_punct = 0;
- char ch[3];
- ch[2] = '\0';
-
- while (str[read_pt])
- {
+ int read_pt = 0;
+ int write_pt = 0;
+ int line_len = 0;
+ int word_punct = 0;
+ char ch[3];
+ ch[2] = '\0';
+
+ while (str[read_pt]) {
#ifdef JP
- bool kinsoku = FALSE;
- bool kanji;
+ bool kinsoku = FALSE;
+ bool kanji;
#endif
- int ch_len = 1;
- ch[0] = str[read_pt];
- ch[1] = '\0';
+ int ch_len = 1;
+ ch[0] = str[read_pt];
+ ch[1] = '\0';
#ifdef JP
- kanji = iskanji(ch[0]);
+ kanji = iskanji(ch[0]);
- if (kanji)
- {
- ch[1] = str[read_pt + 1];
- ch_len = 2;
+ if (kanji) {
+ ch[1] = str[read_pt + 1];
+ ch_len = 2;
- if (strcmp(ch, "。") == 0 ||
- strcmp(ch, "、") == 0 ||
- strcmp(ch, "ィ") == 0 ||
- strcmp(ch, "ー") == 0)
- kinsoku = TRUE;
- }
- else if (!isprint(ch[0]))
- ch[0] = ' ';
+ if (strcmp(ch, "。") == 0 || strcmp(ch, "、") == 0 || strcmp(ch, "ィ") == 0 || strcmp(ch, "ー") == 0)
+ kinsoku = TRUE;
+ } else if (!isprint(ch[0]))
+ ch[0] = ' ';
#else
- if (!isprint(ch[0]))
- ch[0] = ' ';
-#endif
-
- if (line_len + ch_len > maxlen - 1 || str[read_pt] == '\n')
- {
- int word_len = read_pt - word_punct;
-#ifdef JP
- if (kanji && !kinsoku)
- /* nothing */;
- else
-#endif
- if (ch[0] == ' ' || word_len >= line_len / 2)
- read_pt++;
- else
- {
- read_pt = word_punct;
- if (str[word_punct] == ' ')
- read_pt++;
- write_pt -= word_len;
- }
-
- tbuf[write_pt++] = '\0';
- line_len = 0;
- word_punct = read_pt;
- continue;
- }
-
- if (ch[0] == ' ')
- word_punct = read_pt;
-
-#ifdef JP
- if (!kinsoku) word_punct = read_pt;
-#endif
-
- if ((size_t)(write_pt + 3) >= bufsize) break;
-
- tbuf[write_pt++] = ch[0];
- line_len++;
- read_pt++;
-#ifdef JP
- if (kanji)
- {
- tbuf[write_pt++] = ch[1];
- line_len++;
- read_pt++;
- }
+ if (!isprint(ch[0]))
+ ch[0] = ' ';
#endif
- }
- tbuf[write_pt] = '\0';
- tbuf[write_pt + 1] = '\0';
- return;
-}
-
-
-/*
- * The angband_strcpy() function copies up to 'bufsize'-1 characters from 'src'
- * to 'buf' and NUL-terminates the result. The 'buf' and 'src' strings may
- * not overlap.
- *
- * angband_strcpy() returns strlen(src). This makes checking for truncation
- * easy. Example: if (angband_strcpy(buf, src, sizeof(buf)) >= sizeof(buf)) ...;
- *
- * This function should be equivalent to the strlcpy() function in BSD.
- */
-size_t angband_strcpy(char *buf, concptr src, size_t bufsize)
-{
+ if (line_len + ch_len > maxlen - 1 || str[read_pt] == '\n') {
+ int word_len = read_pt - word_punct;
#ifdef JP
- char *d = buf;
- concptr s = src;
- size_t len = 0;
-
- if (bufsize > 0) {
- /* reserve for NUL termination */
- bufsize--;
-
- /* Copy as many bytes as will fit */
- while (*s && (len < bufsize))
- {
- if (iskanji(*s))
- {
- if (len + 1 >= bufsize || !*(s + 1)) break;
- *d++ = *s++;
- *d++ = *s++;
- len += 2;
- }
- else
- {
- *d++ = *s++;
- len++;
- }
- }
- *d = '\0';
- }
-
- while (*s++) len++;
- return len;
-
-#else
- size_t len = strlen(src);
- size_t ret = len;
- if (bufsize == 0) return ret;
-
- if (len >= bufsize) len = bufsize - 1;
-
- (void)memcpy(buf, src, len);
- buf[len] = '\0';
- return ret;
+ if (kanji && !kinsoku)
+ /* nothing */;
+ else
#endif
-}
-
-
-/*
- * The angband_strcat() tries to append a string to an existing NUL-terminated string.
- * It never writes more characters into the buffer than indicated by 'bufsize' and
- * NUL-terminates the buffer. The 'buf' and 'src' strings may not overlap.
- *
- * angband_strcat() returns strlen(buf) + strlen(src). This makes checking for
- * truncation easy. Example:
- * if (angband_strcat(buf, src, sizeof(buf)) >= sizeof(buf)) ...;
- *
- * This function should be equivalent to the strlcat() function in BSD.
- */
-size_t angband_strcat(char *buf, concptr src, size_t bufsize)
-{
- size_t dlen = strlen(buf);
- if (dlen < bufsize - 1)
- {
- return (dlen + angband_strcpy(buf + dlen, src, bufsize - dlen));
- }
- else
- {
- return (dlen + strlen(src));
- }
-}
-
-
-/*
- * A copy of ANSI strstr()
- *
- * angband_strstr() can handle Kanji strings correctly.
- */
-char *angband_strstr(concptr haystack, concptr needle)
-{
- int l1 = strlen(haystack);
- int l2 = strlen(needle);
-
- if (l1 >= l2)
- {
- for (int i = 0; i <= l1 - l2; i++)
- {
- if (!strncmp(haystack + i, needle, l2))
- return (char *)haystack + i;
+ if (ch[0] == ' ' || word_len >= line_len / 2)
+ read_pt++;
+ else {
+ read_pt = word_punct;
+ if (str[word_punct] == ' ')
+ read_pt++;
+ write_pt -= word_len;
+ }
+
+ tbuf[write_pt++] = '\0';
+ line_len = 0;
+ word_punct = read_pt;
+ continue;
+ }
+
+ if (ch[0] == ' ')
+ word_punct = read_pt;
#ifdef JP
- if (iskanji(*(haystack + i))) i++;
+ if (!kinsoku)
+ word_punct = read_pt;
#endif
- }
- }
-
- return NULL;
-}
+ if ((size_t)(write_pt + 3) >= bufsize)
+ break;
-/*
- * A copy of ANSI strchr()
- *
- * angband_strchr() can handle Kanji strings correctly.
- */
-char *angband_strchr(concptr ptr, char ch)
-{
- for (; *ptr != '\0'; ptr++)
- {
- if (*ptr == ch) return (char *)ptr;
-
+ tbuf[write_pt++] = ch[0];
+ line_len++;
+ read_pt++;
#ifdef JP
- if (iskanji(*ptr)) ptr++;
+ if (kanji) {
+ tbuf[write_pt++] = ch[1];
+ line_len++;
+ read_pt++;
+ }
#endif
- }
+ }
- return NULL;
+ tbuf[write_pt] = '\0';
+ tbuf[write_pt + 1] = '\0';
+ return;
}
-
/*
* Convert string to lower case
*/
void str_tolower(char *str)
{
- for (; *str; str++)
- {
+ for (; *str; str++) {
#ifdef JP
- if (iskanji(*str))
- {
- str++;
- continue;
- }
+ if (iskanji(*str)) {
+ str++;
+ continue;
+ }
#endif
- *str = (char)tolower(*str);
- }
+ *str = (char)tolower(*str);
+ }
}
errr type_string(concptr str, uint len);
void roff_to_buf(concptr str, int wlen, char *tbuf, size_t bufsize);
-size_t angband_strcpy(char *buf, concptr src, size_t bufsize);
-size_t angband_strcat(char *buf, concptr src, size_t bufsize);
-char *angband_strstr(concptr haystack, concptr needle);
-char *angband_strchr(concptr ptr, char ch);
void str_tolower(char *str);
#include "term/screen-processor.h"
#include "term/term-color-types.h"
#include "util/bit-flags-calculator.h"
+#include "util/string-processor.h"
#include "view/display-lore.h"
#include "view/display-messages.h"
#include "view/display-player.h"