diff options
author | Karl Williamson <khw@cpan.org> | 2014-12-06 23:08:38 -0700 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2015-03-18 09:44:16 -0600 |
commit | 8944ce7878105d0b5c56b840db0a95a593e01244 (patch) | |
tree | 13bedebae72d96aff77e5120c1726511eb7021c2 /ext/SDBM_File | |
parent | 89ad707a5b059d12b8c7715313147fabda58d12f (diff) | |
download | perl-8944ce7878105d0b5c56b840db0a95a593e01244.tar.gz |
ext/SDBM_File/sdbm/dbu.c Generalize for EBCDIC platforms
This also fixed a bug which hasn't shown up in the tests, in that it
uses 'char' where it should be 'U8'.
Diffstat (limited to 'ext/SDBM_File')
-rw-r--r-- | ext/SDBM_File/dbu.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/ext/SDBM_File/dbu.c b/ext/SDBM_File/dbu.c index d861c0f1b1..4631d40acd 100644 --- a/ext/SDBM_File/dbu.c +++ b/ext/SDBM_File/dbu.c @@ -224,19 +224,29 @@ static void prdatum(FILE *stream, datum d) { int c; - char *p = d.dptr; + U8 *p = (U8 *) d.dptr; int n = d.dsize; while (n--) { - c = *p++ & 0377; + c = *p++; +#ifndef EBCDIC /* Meta notation doesn't make sense on EBCDIC systems*/ if (c & 0200) { - fprintf(stream, "M-"); - c &= 0177; + fprintf(stream, "M-"); + c &= 0177; } - if (c == 0177 || c < ' ') - fprintf(stream, "^%c", (c == 0177) ? '?' : c + '@'); - else - putc(c, stream); +#endif + /* \c notation applies for \0 . \x1f, plus \c? */ + if (c <= 0x1F || c == QUESTION_MARK_CTRL) { + fprintf(stream, "^%c", toCTRL(c)); + } +#ifdef EBCDIC /* Instead of meta, use \x{} for non-printables */ + else if (! isPRINT_A(c)) { + fprintf(stream, "\\x{%02x}", c); + } +#endif + else { /* must be an ASCII printable */ + putc(c, stream); + } } } |