* 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
* 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 "%".
* 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;".
* 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
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;
/* Floating Point -- various formats */
case 'f':
+ case 'F':
case 'e':
case 'E':
case 'g':
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';