From: Habu Date: Tue, 27 Dec 2022 13:43:10 +0000 (+0900) Subject: [Fix] z-form.cpp の書式で使用できる機能の整理 X-Git-Tag: 3.0.0Alpha74^2~10^2~2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=4d2c9b9b5a59c01ef46772d1044157936a48984d;p=hengbandforosx%2Fhengbandosx.git [Fix] z-form.cpp の書式で使用できる機能の整理 - 独自拡張 %r, %v の削除 - 今回もしくは以前から削除されておりサポートしていない機能についてのコメントを削除 - なぜか %F が使えなかったので追加 --- diff --git a/src/term/z-form.cpp b/src/term/z-form.cpp index 8b8304b2b..2c7e89bf4 100644 --- a/src/term/z-form.cpp +++ b/src/term/z-form.cpp @@ -25,9 +25,7 @@ * of the resulting string, not including the (mandatory) terminator. * * The format strings allow the basic "sprintf()" format sequences, though - * some of them are processed slightly more carefully or portably, as well - * as a few "special" sequences, including the "%r" and "%v" sequences, and - * the "capilitization" sequences of "%C", "%S", and "%V". + * some of them are processed slightly more carefully or portably. * * Note that some "limitations" are enforced by the current implementation, * for example, no "format sequence" can exceed 100 characters, including any @@ -45,7 +43,7 @@ * removed from the "format sequence", and replaced by the textual form * of the next argument in the argument list. See examples below. * - * Legal format characters: %,n,p,c,s,d,i,o,u,X,x,E,e,F,f,G,g,r,v. + * Legal format characters: %,n,p,c,s,d,i,o,u,X,x,E,e,F,f,G,g. * * Format("%%") * Append the literal "%". @@ -110,16 +108,6 @@ * Do not use the "+" or "0" flags. * Note that a "nullptr" value of "s" is converted to the empty string. * - * Format("%V", vptr v) - * Note -- possibly significant mode flag - * Format("%v", vptr v) - * Append the object "v", using the current "user defined print routine". - * User specified modifiers, often ignored. - * - * Format("%r", vstrnfmt_aux_func *fp) - * Set the "user defined print routine" (vstrnfmt_aux) to "fp". - * No legal modifiers. - * * * For examples below, assume "int n = 0; int m = 100; char buf[100];", * plus "char *s = nullptr;", and unknown values "char *txt; int i;". @@ -139,51 +127,12 @@ * For example: "s = buf; n = vstrnfmt(s+n, 100-n, ...); ..." will allow * multiple bounded "appends" to "buf", with constant access to "strlen(buf)". * - * For example: "format("The %r%v was destroyed!", obj_desc, obj);" - * (where "obj_desc(buf, max, fmt, obj)" will "append" a "description" - * of the given object to the given buffer, and return the total length) - * will return a "useful message" about the object "obj", for example, - * "The Large Shield was destroyed!". - * * For example: "format("%^-.*s", i, txt)" will produce a string containing * the first "i" characters of "txt", left justified, with the first non-space * character capitilized, if reasonable. */ /* - * The "type" of the "user defined print routine" pointer - */ -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, concptr fmt, vptr arg) -{ - uint len; - char tmp[32]; - - /* XXX XXX */ - fmt = fmt ? fmt : 0; - - /* Pointer display */ - snprintf(tmp, sizeof(tmp), "<<%p>>", arg); - len = strlen(tmp); - if (len >= max) { - len = max - 1; - } - tmp[len] = '\0'; - strcpy(buf, tmp); - return len; -} - -/* - * The "current" user defined print routine. It can be changed - * dynamically by sending the proper "%r" sequence to "vstrnfmt()" - */ -static vstrnfmt_aux_func vstrnfmt_aux = vstrnfmt_aux_dflt; - -/* * Basic "vararg" format function. * * This function takes a buffer, a max byte count, a format string, and @@ -326,16 +275,6 @@ uint vstrnfmt(char *buf, uint max, concptr fmt, va_list vp) continue; } - /* Hack -- Pre-process "%r" */ - if (*s == 'r') { - /* Extract the next argument, and save it (globally) */ - vstrnfmt_aux = va_arg(vp, vstrnfmt_aux_func); - - /* Skip the "r" */ - s++; - continue; - } - /* Begin the "aux" string */ q = 0; @@ -526,6 +465,7 @@ uint vstrnfmt(char *buf, uint max, concptr fmt, va_list vp) /* Floating Point -- various formats */ case 'f': + case 'F': case 'e': case 'E': case 'g': @@ -577,20 +517,6 @@ uint vstrnfmt(char *buf, uint max, concptr fmt, va_list vp) break; } - /* User defined data */ - case 'V': - case 'v': { - vptr arg; - - /* Access next argument */ - arg = va_arg(vp, vptr); - - /* Format the "user data" */ - snprintf(tmp, sizeof(tmp), aux, arg); - - break; - } - default: { /* Error -- illegal format char */ buf[0] = '\0';