sapidlib-dev team mailing list archive
-
sapidlib-dev team
-
Mailing list archive
-
Message #00009
Re: [Branch ~sapidlib-dev-core/sapidlib/devel] Rev 75: Placed format_mixed back in the lib with a header to explain inclusion.
I've filed a bug about this:
https://bugs.edge.launchpad.net/sapidlib/+bug/245722
"Please remove dependency on simul-efuns format_mixed and f_format_mixed as
they are deprecated. The correct path of migration is to use the (s)printf
efun with the %O token (see (s)printf documentation for details). Components
requiring functionality or depend on the formatting produced by format_mixed
should re-implement desired functionality (please do not copy and paste
existing efun - only implement parts that you require) locally. This
simul-efun will be removed within the next week or so."
Introducing simul-efuns should be only done when the case *really* *really*
warrants it as it introduceds a direct dependency on our mudlib instead of
just another object (making code harder to port) and can cause confusion for
new developers ("now where is that function defined?"). In this specific
case, the functionality is already provided by printf (an efun and one that
most drivers have) - no need to have our own implementation.
Cheers,
On Fri, Jul 4, 2008 at 10:00 PM, <noreply@xxxxxxxxxxxxx> wrote:
> ------------------------------------------------------------
> revno: 75
> committer: Richard Harrison <harrison.rt@xxxxxxxxx>
> branch nick: dev
> timestamp: Sat 2008-07-05 01:57:54 +0100
> message:
> Placed format_mixed back in the lib with a header to explain inclusion.
> modified:
> .bzrignore
> lib/adm/simul_efun/strings.c
>
> === modified file '.bzrignore'
> --- a/.bzrignore 2008-06-30 15:42:27 +0000
> +++ b/.bzrignore 2008-07-05 00:57:54 +0000
> @@ -3,8 +3,5 @@
> lib/adm/tmp/*
> bin/*
> etc/startmud.*
> -lib/data/daemons/history/announce-00000000
> -lib/data/daemons/history/history.o
> -lib/data/daemons/history_d/announce-00000000
> -lib/data/daemons/history_d/history.o
> -lib/data/daemons/history_d/intermud3-00000000
> +lib/data/*
> +lib/data/**/*
>
> === modified file 'lib/adm/simul_efun/strings.c'
> --- a/lib/adm/simul_efun/strings.c 2008-06-30 15:10:24 +0000
> +++ b/lib/adm/simul_efun/strings.c 2008-07-05 00:57:54 +0000
> @@ -121,6 +121,130 @@
> return tmp;
> }
>
> +/* Function name: format_mixed
> + * Description: This is an updated version of identify found in the
> + * Dead Souls lib. Cratylus has given permission for it to
> be
> + * included here.
> + * New features include class disassembly and buffer
> + * disassembly.
> + * Author: Tricky
> + */
> +/* Original header from Dead Souls */
> +/* /secure/sefun/identify.c
> + * from the Dead Souls LPC Library
> + * represent a variable of any type as a string, now out of date
> + * remains for backwards compat
> + * created by Pallando@Dead Souls (Douglas Reay) 921212
> + */
> +
> +string format_mixed(array args ...);
> +
> +staticf string f_format_mixed(mixed mixvar)
> +{
> + int sz;
> + string ret;
> +
> + if (undefinedp(mixvar)) return "UNDEFINED";
> + if (intp(mixvar)) return "" + mixvar;
> + if (floatp(mixvar)) return "" + mixvar;
> + if (objectp(mixvar))
> + {
> + if (ret = mixvar->query_name()) ret += " ";
> + else ret = "";
> +
> + return "OBJECT(" + ret + file_name(mixvar) + ")";
> + }
> + if (stringp(mixvar))
> + {
> + mixvar = replace_string(mixvar, "\"", "\\\"");
> + mixvar = "\"" + mixvar + "\"";
> + mixvar = replace_string(mixvar, "\\", "\\\\");
> + mixvar = replace_string(mixvar, "\\\"", "\"");
> + mixvar = replace_string(mixvar, "\n", "\\n");
> + mixvar = replace_string(mixvar, "\t", "\\t");
> +
> + return mixvar;
> + }
> + if (arrayp(mixvar))
> + {
> + ret = "ARRAY({ ";
> + sz = sizeof(mixvar);
> +
> + for (int i = 0 ; i < sz ; i++)
> + {
> + if (i != 0) ret += ", ";
> +
> + ret += format_mixed(mixvar[i]);
> + }
> +
> + return ret + (sz != 0 ? " " : "") + "})";
> + }
> + if (bufferp(mixvar))
> + {
> + ret = "BUFFER({ ";
> + sz = sizeof(mixvar);
> +
> + for (int i = 0 ; i < sz ; i++)
> + {
> + if (i != 0) ret += ", ";
> +
> + ret += format_mixed(mixvar[i]);
> + }
> +
> + return ret + (sz != 0 ? " " : "") + "})";
> + }
> + if (classp(mixvar))
> + {
> + ret = "CLASS( ({ ";
> + mixvar = disassemble_class(mixvar);
> + sz = sizeof(mixvar);
> +
> + for (int i = 0 ; i < sz ; i++)
> + {
> + if (i != 0) ret += ", ";
> +
> + ret += format_mixed(mixvar[i]);
> + }
> +
> + return ret + (sz != 0 ? " " : "") + "}) )";
> + }
> + if (mapp(mixvar))
> + {
> + mixed ks, vs;
> +
> + ret = "MAPPING([ ";
> + ks = keys(mixvar);
> + vs = values(mixvar);
> + sz = sizeof(ks);
> +
> + for (int i = 0 ; i < sz ; i++)
> + {
> + if (i != 0) ret += ", ";
> +
> + ret += format_mixed(ks[i]) + ": " + format_mixed(vs[i]);
> + }
> +
> + return ret + (sz != 0 ? " " : "") + "])";
> + }
> + if (functionp(mixvar)) return sprintf("FUNCTION(%O)", mixvar);
> +
> + return "UNKNOWN";
> +}
> +
> +string format_mixed(array args ...)
> +{
> + string array ret = ({ });
> + int sz = sizeof(args);
> +
> + if (sz == 0) ret = ({ f_format_mixed(UNDEFINED_VALUE) });
> + else if (sz == 1) ret = ({ f_format_mixed(args[0]) });
> + else
> + for (int i = 0 ; i < sz ; i++)
> + ret += ({ f_format_mixed(args[i]) });
> +
> + return implode(ret, ", ");
> +}
> +
> /*
> * Fuzzymatch code:
> * original code by Stig Sther Bakken (Auronthas) 940715
>
>
>
> --
> Sapidlib mainline development branch
> https://code.launchpad.net/~sapidlib-dev-core/sapidlib/devel<https://code.launchpad.net/%7Esapidlib-dev-core/sapidlib/devel>
>
> You are receiving this branch notification because you are subscribed to
> it.
>
--
Cody A.W. Somerville
Software Engineer
Red Cow Marketing & Technologies, Inc.
Office: 506-458-1290
Toll Free: 1-877-733-2699
Fax: 506-453-9112
Cell: 506-449-5899
Email: cody@xxxxxxxxx
http://www.redcow.ca