aboutsummaryrefslogtreecommitdiffstats
path: root/lib/erl_interface/src/misc/ei_printterm.c
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2019-04-03 21:16:59 +0200
committerSverker Eriksson <[email protected]>2019-04-17 19:09:12 +0200
commit6465de7e3a5393a80ed0e2c63f012fd126de706f (patch)
treef85198d2afe765a8f3b7c94ed31b36830346b006 /lib/erl_interface/src/misc/ei_printterm.c
parent46aa940b9d771c4806aacaf065c2f637474e9815 (diff)
downloadotp-6465de7e3a5393a80ed0e2c63f012fd126de706f.tar.gz
otp-6465de7e3a5393a80ed0e2c63f012fd126de706f.tar.bz2
otp-6465de7e3a5393a80ed0e2c63f012fd126de706f.zip
erl_interface: Add bitstring and export fun support
Diffstat (limited to 'lib/erl_interface/src/misc/ei_printterm.c')
-rw-r--r--lib/erl_interface/src/misc/ei_printterm.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/erl_interface/src/misc/ei_printterm.c b/lib/erl_interface/src/misc/ei_printterm.c
index e83f29b0c1..a89b990ac1 100644
--- a/lib/erl_interface/src/misc/ei_printterm.c
+++ b/lib/erl_interface/src/misc/ei_printterm.c
@@ -249,6 +249,34 @@ static int print_term(FILE* fp, ei_x_buff* x,
xputc('>', fp, x); ++ch_written;
ei_free(p);
break;
+ case ERL_BIT_BINARY_EXT: {
+ size_t bits;
+ int trunc = 0;
+ p = ei_malloc(n);
+ if (p == NULL) goto err;
+ if (ei_decode_bitstring(buf, index, p, n, &bits) < 0) {
+ ei_free(p);
+ goto err;
+ }
+ ch_written += xprintf(fp, x, "#Bits<");
+ m = (bits+7) / 8;
+ if (m > BINPRINTSIZE) {
+ m = BINPRINTSIZE;
+ trunc = 1;
+ }
+ --m;
+ for (i = 0; i < m; ++i) {
+ ch_written += xprintf(fp, x, "%d,", p[i]);
+ }
+ ch_written += xprintf(fp, x, "%d", p[i]);
+ if (trunc)
+ ch_written += xprintf(fp, x, ",...");
+ else if (bits % 8 != 0)
+ ch_written += xprintf(fp, x, ":%u", (unsigned)(bits % 8));
+ xputc('>', fp, x); ++ch_written;
+ ei_free(p);
+ break;
+ }
case ERL_SMALL_INTEGER_EXT:
case ERL_INTEGER_EXT:
if (ei_decode_long(buf, index, &l) < 0) goto err;