3 source/macro.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++--
4 1 file changed, 51 insertions(+), 2 deletions(-)
6 diff --quilt old/source/macro.c new/source/macro.c
9 @@ -2644,6 +2644,48 @@ static int beepMS(WindowInfo *window, Da
13 +static int printDataValue(FILE *stream, DataValue value, int *len, char **errMsg)
15 +#define cond_fprintf(stream, ...) \
16 + if (stream) *len += fprintf(stream, __VA_ARGS__)
18 + switch (value.tag) {
20 + cond_fprintf(stream, "%d", value.val.n);
23 + cond_fprintf(stream, "%s", value.val.str.rep);
26 + SparseArrayEntry *iter = arrayIterateFirst(&value);
27 + const char *sep = "";
28 + cond_fprintf(stream, "{ ");
31 + if (StringToNum(iter->key, &num)) {
32 + cond_fprintf(stream, "%s[%d] = ", sep, num);
34 + cond_fprintf(stream, "%s[\"%s\"] = ", sep, iter->key);
36 + if (!printDataValue(stream, iter->value, len, errMsg)) {
39 + iter = arrayIterateNext(iter);
42 + cond_fprintf(stream, " }");
46 + *errMsg = "can't print non-scalar/non-array argument";
55 static int printOut(FILE *stream, WindowInfo *window, DataValue *argList,
56 int nArgs, DataValue *result, char **errMsg)
58 @@ -2654,11 +2696,18 @@ static int printOut(FILE *stream, Window
60 return tooFewArgsErr(errMsg);
63 + /* check arguments */
64 for (i = 0; i < nArgs; i++) {
65 - if (!readStringArg(argList[i], &string, stringStorage, errMsg)) {
66 + if (!printDataValue(NULL, argList[i], NULL, errMsg)) {
69 - len += fprintf(stream, "%s%s", sep, string);
72 + /* print arguments */
73 + for (i = 0; i < nArgs; i++) {
74 + len += fprintf(stream, "%s", sep);
75 + printDataValue(stream, argList[i], &len, errMsg);