OSDN Git Service

[Refactor] #37353 コメント整理。 / Refactor comments.
[hengband/hengband.git] / src / z-form.c
index d0d6c88..ce2b3de 100644 (file)
@@ -11,7 +11,6 @@
 /* Purpose: Low level text formatting -BEN- */
 
 #include "z-form.h"
-
 #include "z-util.h"
 #include "z-virt.h"
 
  *   Append the character "c".
  *   Do not use the "+" or "0" flags.
  *
- * Format("%s", cptr s)
+ * Format("%s", concptr s)
  *   Append the string "s".
  *   Do not use the "+" or "0" flags.
  *   Note that a "NULL" value of "s" is converted to the empty string.
 /*
  * The "type" of the "user defined print routine" pointer
  */
-typedef uint (*vstrnfmt_aux_func)(char *buf, uint max, cptr fmt, vptr arg);
+typedef uint (*vstrnfmt_aux_func)(char *buf, uint max, concptr fmt, vptr arg);
 
 /*
  * The "default" user defined print routine.  Ignore the "fmt" string.
  */
-static uint vstrnfmt_aux_dflt(char *buf, uint max, cptr fmt, vptr arg)
+static uint vstrnfmt_aux_dflt(char *buf, uint max, concptr fmt, vptr arg)
 {
        uint len;
        char tmp[32];
@@ -232,9 +231,9 @@ static vstrnfmt_aux_func vstrnfmt_aux = vstrnfmt_aux_dflt;
  * the given buffer to a length of zero, and return a "length" of zero.
  * The contents of "buf", except for "buf[0]", may then be undefined.
  */
-uint vstrnfmt(char *buf, uint max, cptr fmt, va_list vp)
+uint vstrnfmt(char *buf, uint max, concptr fmt, va_list vp)
 {
-       cptr s;
+       concptr s;
 
        /* The argument is "long" */
        bool do_long;
@@ -282,8 +281,6 @@ uint vstrnfmt(char *buf, uint max, cptr fmt, va_list vp)
 
                        /* Save the character */
                        buf[n++] = *s++;
-
-                       /* Continue */
                        continue;
                }
 
@@ -301,8 +298,6 @@ uint vstrnfmt(char *buf, uint max, cptr fmt, va_list vp)
 
                        /* Skip the "%" */
                        s++;
-
-                       /* Continue */
                        continue;
                }
 
@@ -319,8 +314,6 @@ uint vstrnfmt(char *buf, uint max, cptr fmt, va_list vp)
 
                        /* Skip the "n" */
                        s++;
-
-                       /* Continue */
                        continue;
                }
 
@@ -332,8 +325,6 @@ uint vstrnfmt(char *buf, uint max, cptr fmt, va_list vp)
 
                        /* Skip the "r" */
                        s++;
-
-                       /* Continue */
                        continue;
                }
 
@@ -466,9 +457,8 @@ uint vstrnfmt(char *buf, uint max, cptr fmt, va_list vp)
                                arg = va_arg(vp, int);
 
                                /* Format the argument */
-                               sprintf(tmp, aux, arg);
+                               sprintf(tmp, "%c", arg);
 
-                               /* Done */
                                break;
                        }
 
@@ -496,7 +486,6 @@ uint vstrnfmt(char *buf, uint max, cptr fmt, va_list vp)
                                        sprintf(tmp, aux, arg);
                                }
 
-                               /* Done */
                                break;
                        }
 
@@ -510,7 +499,6 @@ uint vstrnfmt(char *buf, uint max, cptr fmt, va_list vp)
                                        /* Access next argument */
                                        arg = va_arg(vp, unsigned long);
 
-                                       /* Format the argument */
                                        sprintf(tmp, aux, arg);
                                }
                                else
@@ -519,12 +507,10 @@ uint vstrnfmt(char *buf, uint max, cptr fmt, va_list vp)
 
                                        /* Access next argument */
                                        arg = va_arg(vp, unsigned int);
-
-                                       /* Format the argument */
                                        sprintf(tmp, aux, arg);
+
                                }
 
-                               /* Done */
                                break;
                        }
 
@@ -541,7 +527,6 @@ uint vstrnfmt(char *buf, uint max, cptr fmt, va_list vp)
                                /* Format the argument */
                                sprintf(tmp, aux, arg);
 
-                               /* Done */
                                break;
                        }
 
@@ -556,18 +541,17 @@ uint vstrnfmt(char *buf, uint max, cptr fmt, va_list vp)
                                /* Format the argument */
                                sprintf(tmp, aux, arg);
 
-                               /* Done */
                                break;
                        }
 
                        /* String */
                        case 's':
                        {
-                               cptr arg;
+                               concptr arg;
                                char arg2[1024];
 
                                /* Access next argument */
-                               arg = va_arg(vp, cptr);
+                               arg = va_arg(vp, concptr);
 
                                /* Hack -- convert NULL to EMPTY */
                                if (!arg) arg = "";
@@ -577,9 +561,8 @@ uint vstrnfmt(char *buf, uint max, cptr fmt, va_list vp)
                                arg2[1023] = '\0';
 
                                /* Format the argument */
-                               sprintf(tmp, aux, arg2);
+                               sprintf(tmp, aux, arg);
 
-                               /* Done */
                                break;
                        }
 
@@ -593,14 +576,12 @@ uint vstrnfmt(char *buf, uint max, cptr fmt, va_list vp)
                                arg = va_arg(vp, vptr);
 
                                /* Format the "user data" */
-                               (void)vstrnfmt_aux(tmp, 1000, aux, arg);
+                               sprintf(tmp, aux, arg);
 
-                               /* Done */
                                break;
                        }
 
 
-                       /* Oops */
                        default:
                        {
                                /* Error -- illegal format char */
@@ -626,9 +607,8 @@ uint vstrnfmt(char *buf, uint max, cptr fmt, va_list vp)
                                {
                                        /* Capitalize if possible */
                                        if (islower(tmp[q]))
-                                               tmp[q] = toupper(tmp[q]);
+                                               tmp[q] = (char)toupper(tmp[q]);
 
-                                       /* Done */
                                        break;
                                }
                        }
@@ -658,7 +638,7 @@ uint vstrnfmt(char *buf, uint max, cptr fmt, va_list vp)
  * Do a vstrnfmt (see above) into a (growable) static buffer.
  * This buffer is usable for very short term formatting of results.
  */
-char *vformat(cptr fmt, va_list vp)
+char *vformat(concptr fmt, va_list vp)
 {
        static char *format_buf = NULL;
        static huge format_len = 0;
@@ -699,7 +679,7 @@ char *vformat(cptr fmt, va_list vp)
 /*
  * Do a vstrnfmt (see above) into a buffer of a given size.
  */
-uint strnfmt(char *buf, uint max, cptr fmt, ...)
+uint strnfmt(char *buf, uint max, concptr fmt, ...)
 {
        uint len;
 
@@ -723,7 +703,7 @@ uint strnfmt(char *buf, uint max, cptr fmt, ...)
  * Do a vstrnfmt (see above) into a buffer of unknown size.
  * Since the buffer size is unknown, the user better verify the args.
  */
-uint strfmt(char *buf, cptr fmt, ...)
+uint strfmt(char *buf, concptr fmt, ...)
 {
        uint len;
 
@@ -751,7 +731,7 @@ uint strfmt(char *buf, cptr fmt, ...)
  * Note that the buffer is (technically) writable, but only up to
  * the length of the string contained inside it.
  */
-char *format(cptr fmt, ...)
+char *format(concptr fmt, ...)
 {
        char *res;
        va_list vp;
@@ -775,7 +755,7 @@ char *format(cptr fmt, ...)
 /*
  * Vararg interface to plog()
  */
-void plog_fmt(cptr fmt, ...)
+void plog_fmt(concptr fmt, ...)
 {
        char *res;
        va_list vp;
@@ -798,7 +778,7 @@ void plog_fmt(cptr fmt, ...)
 /*
  * Vararg interface to quit()
  */
-void quit_fmt(cptr fmt, ...)
+void quit_fmt(concptr fmt, ...)
 {
        char *res;
        va_list vp;
@@ -821,7 +801,7 @@ void quit_fmt(cptr fmt, ...)
 /*
  * Vararg interface to core()
  */
-void core_fmt(cptr fmt, ...)
+void core_fmt(concptr fmt, ...)
 {
        char *res;
        va_list vp;