diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2022-11-22 14:20:45 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2022-11-22 14:20:45 +0900 |
commit | 20b9d7b9fde83c98046eacdfcb40e8cb6607963e (patch) | |
tree | 30924cae1d882370f3ecfe3e5d3f41b7a56d8004 /pack.c | |
parent | 8c02084ac8412dc57367ac1282cf5ab07554c94c (diff) | |
download | ruby-20b9d7b9fde83c98046eacdfcb40e8cb6607963e.tar.gz |
Use `enum` over `int`
Diffstat (limited to 'pack.c')
-rw-r--r-- | pack.c | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -939,13 +939,14 @@ hex2num(char c) # define AVOID_CC_BUG #endif -/* unpack mode */ -#define UNPACK_ARRAY 0 -#define UNPACK_BLOCK 1 -#define UNPACK_1 2 +enum unpack_mode { + UNPACK_ARRAY, + UNPACK_BLOCK, + UNPACK_1 +}; static VALUE -pack_unpack_internal(VALUE str, VALUE fmt, int mode, long offset) +pack_unpack_internal(VALUE str, VALUE fmt, enum unpack_mode mode, long offset) { #define hexdigits ruby_hexdigits char *s, *send; @@ -1624,7 +1625,7 @@ pack_unpack_internal(VALUE str, VALUE fmt, int mode, long offset) static VALUE pack_unpack(rb_execution_context_t *ec, VALUE str, VALUE fmt, VALUE offset) { - int mode = rb_block_given_p() ? UNPACK_BLOCK : UNPACK_ARRAY; + enum unpack_mode mode = rb_block_given_p() ? UNPACK_BLOCK : UNPACK_ARRAY; return pack_unpack_internal(str, fmt, mode, RB_NUM2LONG(offset)); } |