From 75a1d33bcfe767724e883737da9c9d5c3a031e17 Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 15 Sep 2015 05:49:52 +0000 Subject: [PATCH] enc: fundamental encindex * enc/{ascii,us_ascii,utf_8}.c: set encoding indexes of fundamental built-in encodings so that usable as well as allocated rb_encoding before rb_enc_init(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51862 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 +++++- common.mk | 3 +++ enc/ascii.c | 6 +++++- enc/us_ascii.c | 6 +++++- enc/utf_8.c | 6 +++++- 5 files changed, 23 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0a379f5c3a..412530dd25 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,8 @@ -Tue Sep 15 14:49:15 2015 Nobuyoshi Nakada +Tue Sep 15 14:49:43 2015 Nobuyoshi Nakada + + * enc/{ascii,us_ascii,utf_8}.c: set encoding indexes of + fundamental built-in encodings so that usable as well as + allocated rb_encoding before rb_enc_init(). * encindex.h: separate encoding index constants from internal.h. diff --git a/common.mk b/common.mk index 8896c0205b..21f7784349 100644 --- a/common.mk +++ b/common.mk @@ -1286,6 +1286,7 @@ dmyext.$(OBJEXT): {$(VPATH)}dmyext.c enc/ascii.$(OBJEXT): {$(VPATH)}config.h enc/ascii.$(OBJEXT): {$(VPATH)}defines.h enc/ascii.$(OBJEXT): {$(VPATH)}enc/ascii.c +enc/ascii.$(OBJEXT): {$(VPATH)}encindex.h enc/ascii.$(OBJEXT): {$(VPATH)}missing.h enc/ascii.$(OBJEXT): {$(VPATH)}oniguruma.h enc/ascii.$(OBJEXT): {$(VPATH)}regenc.h @@ -1314,12 +1315,14 @@ enc/unicode.$(OBJEXT): {$(VPATH)}subst.h enc/us_ascii.$(OBJEXT): {$(VPATH)}config.h enc/us_ascii.$(OBJEXT): {$(VPATH)}defines.h enc/us_ascii.$(OBJEXT): {$(VPATH)}enc/us_ascii.c +enc/us_ascii.$(OBJEXT): {$(VPATH)}encindex.h enc/us_ascii.$(OBJEXT): {$(VPATH)}missing.h enc/us_ascii.$(OBJEXT): {$(VPATH)}oniguruma.h enc/us_ascii.$(OBJEXT): {$(VPATH)}regenc.h enc/utf_8.$(OBJEXT): {$(VPATH)}config.h enc/utf_8.$(OBJEXT): {$(VPATH)}defines.h enc/utf_8.$(OBJEXT): {$(VPATH)}enc/utf_8.c +enc/utf_8.$(OBJEXT): {$(VPATH)}encindex.h enc/utf_8.$(OBJEXT): {$(VPATH)}missing.h enc/utf_8.$(OBJEXT): {$(VPATH)}oniguruma.h enc/utf_8.$(OBJEXT): {$(VPATH)}regenc.h diff --git a/enc/ascii.c b/enc/ascii.c index 72150c037c..4fdc976e12 100644 --- a/enc/ascii.c +++ b/enc/ascii.c @@ -29,6 +29,10 @@ */ #include "regenc.h" +#include "encindex.h" +#ifndef ENCINDEX_ASCII +#define ENCINDEX_ASCII 0 +#endif OnigEncodingDefine(ascii, ASCII) = { onigenc_single_byte_mbc_enc_len, @@ -47,7 +51,7 @@ OnigEncodingDefine(ascii, ASCII) = { onigenc_not_support_get_ctype_code_range, onigenc_single_byte_left_adjust_char_head, onigenc_always_true_is_allowed_reverse_match, - 0, + ENCINDEX_ASCII, ONIGENC_FLAG_NONE, }; ENC_ALIAS("BINARY", "ASCII-8BIT") diff --git a/enc/us_ascii.c b/enc/us_ascii.c index 18d0685040..f28300ebc6 100644 --- a/enc/us_ascii.c +++ b/enc/us_ascii.c @@ -1,4 +1,8 @@ #include "regenc.h" +#include "encindex.h" +#ifndef ENCINDEX_US_ASCII +#define ENCINDEX_US_ASCII 0 +#endif static int us_ascii_mbc_enc_len(const UChar* p, const UChar* e, OnigEncoding enc) @@ -25,7 +29,7 @@ OnigEncodingDefine(us_ascii, US_ASCII) = { onigenc_not_support_get_ctype_code_range, onigenc_single_byte_left_adjust_char_head, onigenc_always_true_is_allowed_reverse_match, - 0, + ENCINDEX_US_ASCII, ONIGENC_FLAG_NONE, }; ENC_ALIAS("ASCII", "US-ASCII") diff --git a/enc/utf_8.c b/enc/utf_8.c index 8ab8792a6d..ae5258dae2 100644 --- a/enc/utf_8.c +++ b/enc/utf_8.c @@ -28,6 +28,10 @@ */ #include "regenc.h" +#include "encindex.h" +#ifndef ENCINDEX_UTF_8 +#define ENCINDEX_UTF_8 0 +#endif #define USE_INVALID_CODE_SCHEME @@ -424,7 +428,7 @@ OnigEncodingDefine(utf_8, UTF_8) = { get_ctype_code_range, left_adjust_char_head, onigenc_always_true_is_allowed_reverse_match, - 0, + ENCINDEX_UTF_8, ONIGENC_FLAG_UNICODE, }; ENC_ALIAS("CP65001", "UTF-8")