Use custom ISPRINT macro so we don't depend on the current locale settings.
Showing
2 changed files
with
6 additions
and
2 deletions
... | @@ -22,6 +22,8 @@ | ... | @@ -22,6 +22,8 @@ |
22 | #include <string.h> | 22 | #include <string.h> |
23 | #include <mailutils/mailutils.h> | 23 | #include <mailutils/mailutils.h> |
24 | 24 | ||
25 | #define ISPRINT(c) ((c)>=' '&&(c)<127) | ||
26 | |||
25 | int | 27 | int |
26 | main (int argc, char * argv []) | 28 | main (int argc, char * argv []) |
27 | { | 29 | { |
... | @@ -86,7 +88,7 @@ main (int argc, char * argv []) | ... | @@ -86,7 +88,7 @@ main (int argc, char * argv []) |
86 | while (stream_read (flt, &buffer, sizeof (buffer), total, &size) == 0 | 88 | while (stream_read (flt, &buffer, sizeof (buffer), total, &size) == 0 |
87 | && size > 0) | 89 | && size > 0) |
88 | { | 90 | { |
89 | if (printable && !isprint (buffer)) | 91 | if (printable && !ISPRINT (buffer)) |
90 | { | 92 | { |
91 | char outbuf[24]; | 93 | char outbuf[24]; |
92 | sprintf (outbuf, "\\%03o", (unsigned int) buffer); | 94 | sprintf (outbuf, "\\%03o", (unsigned int) buffer); | ... | ... |
... | @@ -22,12 +22,14 @@ | ... | @@ -22,12 +22,14 @@ |
22 | 22 | ||
23 | #include <mailutils/mailutils.h> | 23 | #include <mailutils/mailutils.h> |
24 | 24 | ||
25 | #define ISPRINT(c) ((c)=='\t'||(c)==' '||(c)=='\n'||((c)>' '&&(c)<128)) | ||
26 | |||
25 | void | 27 | void |
26 | print (char *p, int printable) | 28 | print (char *p, int printable) |
27 | { | 29 | { |
28 | for (; *p; p++) | 30 | for (; *p; p++) |
29 | { | 31 | { |
30 | if (printable && *p != '\n' && !isprint (*p)) | 32 | if (printable && *p != '\n' && !ISPRINT (*p)) |
31 | printf ("\\%03o", *(unsigned char *) p); | 33 | printf ("\\%03o", *(unsigned char *) p); |
32 | else | 34 | else |
33 | putchar (*p); | 35 | putchar (*p); | ... | ... |
-
Please register or sign in to post a comment