diff options
author | Joshua M. Clulow <[email protected]> | 2016-01-30 21:20:58 +0100 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2016-02-05 13:04:58 -0800 |
commit | 007595564ea8e28ca2e91e523f744821d021c465 (patch) | |
tree | 237211ec553587239a95982907b4fa4748ce19bd /lib | |
parent | e989f19cba2beffb03351842c2da1409f68e4466 (diff) |
Illumos 4448 - zfs diff misprints unicode characters
4448 zfs diff misprints unicode characters
Reviewed by: Igor Kozhukhov <[email protected]>
Reviewed by: Toomas Soome <[email protected]>
Approved by: Matthew Ahrens <[email protected]>
References:
https://www.illumos.org/issues/4448
https://github.com/illumos/illumos-gate/commit/b211eb9
Porting Notes:
- [lib/libzfs/libzfs_diff.c]
- 38145d6 Ensure that zfs diff prints unicode safely.
- 141b638 Change 3-digit octal escapes to 4-digit ones
Ported-by: kernelOfTruth [email protected]
Signed-off-by: Brian Behlendorf <[email protected]>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libzfs/libzfs_diff.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/libzfs/libzfs_diff.c b/lib/libzfs/libzfs_diff.c index 1a4529a40..c03603934 100644 --- a/lib/libzfs/libzfs_diff.c +++ b/lib/libzfs/libzfs_diff.c @@ -22,7 +22,7 @@ /* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. * Copyright 2015 Nexenta Systems, Inc. All rights reserved. - * Copyright 2015 Joyent, Inc. + * Copyright 2016 Joyent, Inc. */ /* @@ -130,11 +130,14 @@ get_stats_for_obj(differ_info_t *di, const char *dsname, uint64_t obj, static void stream_bytes(FILE *fp, const char *string) { - while (*string) { - if (*string > ' ' && *string != '\\' && *string < '\177') - (void) fprintf(fp, "%c", *string++); - else - (void) fprintf(fp, "\\%04o", (unsigned char)*string++); + char c; + + while ((c = *string++) != '\0') { + if (c > ' ' && c != '\\' && c < '\177') { + (void) fprintf(fp, "%c", c); + } else { + (void) fprintf(fp, "\\%04o", (uint8_t)c); + } } } |