Use enum over int

This commit is contained in:
Nobuyoshi Nakada 2022-11-22 14:20:45 +09:00
parent 8c02084ac8
commit 20b9d7b9fd
No known key found for this signature in database
GPG Key ID: 7CD2805BFA3770C6

13
pack.c
View File

@ -939,13 +939,14 @@ hex2num(char c)
# define AVOID_CC_BUG # define AVOID_CC_BUG
#endif #endif
/* unpack mode */ enum unpack_mode {
#define UNPACK_ARRAY 0 UNPACK_ARRAY,
#define UNPACK_BLOCK 1 UNPACK_BLOCK,
#define UNPACK_1 2 UNPACK_1
};
static VALUE 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 #define hexdigits ruby_hexdigits
char *s, *send; char *s, *send;
@ -1624,7 +1625,7 @@ pack_unpack_internal(VALUE str, VALUE fmt, int mode, long offset)
static VALUE static VALUE
pack_unpack(rb_execution_context_t *ec, VALUE str, VALUE fmt, VALUE offset) 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)); return pack_unpack_internal(str, fmt, mode, RB_NUM2LONG(offset));
} }