+#define HISTPREF_LIMIT 1024
+static char *histpref_buf = NULL;
+
+/*
+ * Hook function for reading the histpref.prf file.
+ */
+void add_history_from_pref_line(cptr t)
+{
+ /* Do nothing if the buffer is not ready */
+ if (!histpref_buf) return;
+
+ my_strcat(histpref_buf, t, HISTPREF_LIMIT);
+}
+
+
+static bool do_cmd_histpref(void)
+{
+ char buf[80];
+ errr err;
+ int i, j, n;
+ char *s, *t;
+ char temp[64 * 4];
+ char histbuf[HISTPREF_LIMIT];
+
+#ifdef JP
+ if (!get_check("À¸¤¤Î©¤ÁÀßÄê¥Õ¥¡¥¤¥ë¤ò¥í¡¼¥É¤·¤Þ¤¹¤«? ")) return FALSE;
+#else
+ if (!get_check("Load background history preference file? ")) return FALSE;
+#endif
+
+ /* Prepare the buffer */
+ histbuf[0] = '\0';
+ histpref_buf = histbuf;
+
+#ifdef JP
+ sprintf(buf, "histedit-%s.prf", player_name);
+#else
+ sprintf(buf, "histpref-%s.prf", player_name);
+#endif
+ err = process_histpref_file(buf);
+
+ /* Process 'hist????.prf' if 'hist????-<name>.prf' doesn't exist */
+ if (0 > err)
+ {
+#ifdef JP
+ strcpy(buf, "histedit.prf");
+#else
+ strcpy(buf, "histpref.prf");
+#endif
+ err = process_histpref_file(buf);
+ }
+
+ if (err)
+ {
+#ifdef JP
+ msg_print("À¸¤¤Î©¤ÁÀßÄê¥Õ¥¡¥¤¥ë¤ÎÆɤ߹þ¤ß¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£");
+#else
+ msg_print("Failed to load background history preference.");
+#endif
+ msg_print(NULL);
+
+ /* Kill the buffer */
+ histpref_buf = NULL;
+
+ return FALSE;
+ }
+
+ /* Clear the previous history strings */
+ for (i = 0; i < 4; i++) p_ptr->history[i][0] = '\0';
+
+ /* Skip leading spaces */
+ for (s = histpref_buf; *s == ' '; s++) /* loop */;
+
+ /* Get apparent length */
+ n = strlen(s);
+
+ /* Kill trailing spaces */
+ while ((n > 0) && (s[n - 1] == ' ')) s[--n] = '\0';
+
+ roff_to_buf(s, 60, temp, sizeof(temp));
+ t = temp;
+ for (i = 0; i < 4; i++)
+ {
+ if (t[0] == 0) break;
+ else
+ {
+ strcpy(p_ptr->history[i], t);
+ t += strlen(t) + 1;
+ }
+ }
+
+ /* Fill the remaining spaces */
+ for (i = 0; i < 4; i++)
+ {
+ for (j = 0; p_ptr->history[i][j]; j++) /* loop */;
+
+ for (; j < 59; j++) p_ptr->history[i][j] = ' ';
+ p_ptr->history[i][59] = '\0';
+ }
+
+ /* Kill the buffer */
+ histpref_buf = NULL;
+
+ return TRUE;
+}
+