]> diplodocus.org Git - nmh/blobdiff - uip/fmttest.c
In mhshow, copy result of call to norm_charmap() and get_charset()
[nmh] / uip / fmttest.c
index 2bcebd7a557c1faa3d2a5683a6ea7868b7ba5b98..2f45e7b5363b96b5b0f7aee34c5837f94da42615 100644 (file)
@@ -121,13 +121,7 @@ main (int argc, char **argv)
     int dat[5];
     struct fmt_callbacks cb, *cbp = NULL;
 
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
-    invo_name = r1bindex (argv[0], '/');
-
-    /* read user profile/context */
-    context_read();
+    if (nmh_init(argv[0], 1)) { return 1; }
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
@@ -761,7 +755,8 @@ test_trace(void *context, struct format *fmt, int num, char *str, char *outbuf)
     if (str != ctx->str) {
        if (changed++)
            printf(" ");
-       printf("str=\"%s\"", str ? str : "NULL");
+       printf("str=");
+       litputs(str);
        ctx->str = str;
     }
 
@@ -769,7 +764,9 @@ test_trace(void *context, struct format *fmt, int num, char *str, char *outbuf)
        printf("\n");
 
     if (strcmp(outbuf, ctx->outbuf) != 0) {
-       printf("outbuf=\"%s\"\n", outbuf);
+       printf("outbuf=");
+       litputs(outbuf);
+       putchar('\n');
        free(ctx->outbuf);
        ctx->outbuf = getcpy(outbuf);
     }
@@ -1165,11 +1162,8 @@ static void
 litputc(char c)
 {
        if (c & ~ 0177) {
-               putc('M', stdout);
-               putc('-', stdout);
-               c &= 0177;
-       }
-       if (c < 0x20 || c == 0177) {
+               printf("\\x%02x", (unsigned char) c);
+       } else if (c < 0x20 || c == 0177) {
                if (c == '\b') {
                        putc('\\', stdout);
                        putc('b', stdout);