diff options
author | Sverker Eriksson <[email protected]> | 2012-12-21 15:50:21 +0100 |
---|---|---|
committer | Sverker Eriksson <[email protected]> | 2013-01-08 11:15:01 +0100 |
commit | 685d009efcfd7521e9c918a14b58eac19755299d (patch) | |
tree | 83515a7dcc21f52ecc008bf16da1e7278750e9ca /lib/erl_interface/src/decode/decode_boolean.c | |
parent | e4e007afd032f7aca359d2665f91ddb12727521a (diff) | |
download | otp-685d009efcfd7521e9c918a14b58eac19755299d.tar.gz otp-685d009efcfd7521e9c918a14b58eac19755299d.tar.bz2 otp-685d009efcfd7521e9c918a14b58eac19755299d.zip |
erl_interface: Enable decode of unicode atoms
No API changes or additions. Just the ability for erl_interface to decode
unicode atoms and convert them into latin1 strings to preserve backward
compatibility for the existing API.
Diffstat (limited to 'lib/erl_interface/src/decode/decode_boolean.c')
-rw-r--r-- | lib/erl_interface/src/decode/decode_boolean.c | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/lib/erl_interface/src/decode/decode_boolean.c b/lib/erl_interface/src/decode/decode_boolean.c index 9fd09c63f1..0a7a06f1d4 100644 --- a/lib/erl_interface/src/decode/decode_boolean.c +++ b/lib/erl_interface/src/decode/decode_boolean.c @@ -26,32 +26,20 @@ int ei_decode_boolean(const char *buf, int *index, int *p) { const char *s = buf + *index; const char *s0 = s; - int len; + char tbuf[MAXATOMLEN+1]; int t; - if (get8(s) != ERL_ATOM_EXT) return -1; + if (get_atom(&s, tbuf) < 0) return -1; - len = get16be(s); - - switch (len) { - case 4: - /* typecast makes ansi happy */ - if (strncmp((char*)s,"true",4)) return -1; - t = 1; - break; - - case 5: - if (strncmp((char*)s,"false",5)) return -1; - t = 0; - break; - - default: - return -1; - } - - s += len; + if (memcmp(tbuf, "true", 5) == 0) + t = 1; + else if (memcmp(tbuf, "false", 6) == 0) + t = 0; + else + return -1; + if (p) *p = t; *index += s-s0; - return 0; } + |