Skip to content

Commit

Permalink
Remove dependence on ruby.h.
Browse files Browse the repository at this point in the history
  • Loading branch information
brixen committed Feb 16, 2012
1 parent 13204ae commit 4d99dcf
Show file tree
Hide file tree
Showing 20 changed files with 66 additions and 57 deletions.
2 changes: 1 addition & 1 deletion enc/trans/big5.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/* src="big5-uao-tbl.rb", len=375883, checksum=11045 */

#include "transcoder.h"

#include "ruby/ruby.h"


static const unsigned char
Expand Down
2 changes: 1 addition & 1 deletion enc/trans/chinese.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/* src="chinese.trans", len=768, checksum=58884 */

#include "transcoder.h"

#include "ruby/ruby.h"


static const unsigned char
Expand Down
2 changes: 1 addition & 1 deletion enc/trans/emoji.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/* src="emoji-exchange-tbl.rb", len=524703, checksum=40005 */

#include "transcoder.h"

#include "ruby/ruby.h"


static const unsigned char
Expand Down
10 changes: 5 additions & 5 deletions enc/trans/emoji_iso2022_kddi.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/* src="emoji_iso2022_kddi.trans", len=6332, checksum=38881 */

#include "transcoder.h"

#include "ruby/ruby.h"


static const unsigned char
Expand Down Expand Up @@ -15036,16 +15036,16 @@ iso2022jp_kddi_init(void *statep)
return 0;
}

static VALUE
static unsigned int
fun_si_iso2022jp_kddi_decoder(void *statep, const unsigned char *s, size_t l)
{
unsigned char *sp = statep;
if (*sp == G0_ASCII)
return (VALUE)NOMAP;
return NOMAP;
else if (0x21 <= s[0] && s[0] <= 0x7e)
return (VALUE)iso2022jp_kddi_decoder_jisx0208_rest;
return (unsigned int)iso2022jp_kddi_decoder_jisx0208_rest;
else
return (VALUE)INVALID;
return INVALID;
}

static ssize_t
Expand Down
2 changes: 1 addition & 1 deletion enc/trans/emoji_sjis_docomo.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/* src="emoji_sjis_docomo.trans", len=1233, checksum=8248 */

#include "transcoder.h"

#include "ruby/ruby.h"


static const unsigned char
Expand Down
2 changes: 1 addition & 1 deletion enc/trans/emoji_sjis_kddi.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/* src="emoji_sjis_kddi.trans", len=1292, checksum=10590 */

#include "transcoder.h"

#include "ruby/ruby.h"


static const unsigned char
Expand Down
2 changes: 1 addition & 1 deletion enc/trans/emoji_sjis_softbank.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/* src="emoji_sjis_softbank.trans", len=1247, checksum=10137 */

#include "transcoder.h"

#include "ruby/ruby.h"


static const unsigned char
Expand Down
2 changes: 1 addition & 1 deletion enc/trans/escape.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/* src="escape.trans", len=1986, checksum=23676 */

#include "transcoder.h"

#include "ruby/ruby.h"


static const unsigned char
Expand Down
6 changes: 3 additions & 3 deletions enc/trans/gb18030.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/* src="gb18030-tbl.rb", len=1357449, checksum=30205 */

#include "transcoder.h"

#include "ruby/ruby.h"


static const unsigned char
Expand Down Expand Up @@ -21509,7 +21509,7 @@ fun_so_to_gb18030(void *statep, const unsigned char *s, size_t l, unsigned char

/* GB18030 2byte, UTF-8 3byte and GB18030 4byte, UTF-8 3byte*/
static ssize_t
fun_sio_from_gb18030(void *statep, const unsigned char *s, size_t l, VALUE info, unsigned char *o, size_t osize)
fun_sio_from_gb18030(void *statep, const unsigned char *s, size_t l, unsigned int info, unsigned char *o, size_t osize)
{
unsigned int diff = (unsigned int)(info >> 8);
unsigned int u; /* Unicode Scalar Value */
Expand All @@ -21527,7 +21527,7 @@ fun_sio_from_gb18030(void *statep, const unsigned char *s, size_t l, VALUE info,

/* GB18030 2byte, UTF-8 3byte and GB18030 4byte, UTF-8 3byte*/
static ssize_t
fun_sio_to_gb18030(void *statep, const unsigned char *s, size_t l, VALUE info, unsigned char *o, size_t osize)
fun_sio_to_gb18030(void *statep, const unsigned char *s, size_t l, unsigned int info, unsigned char *o, size_t osize)
{
unsigned int diff = (unsigned int)(info >> 8);
unsigned int u; /* Unicode Scalar Value */
Expand Down
2 changes: 1 addition & 1 deletion enc/trans/gbk.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/* src="gbk-tbl.rb", len=413888, checksum=52830 */

#include "transcoder.h"

#include "ruby/ruby.h"


static const unsigned char
Expand Down
24 changes: 12 additions & 12 deletions enc/trans/iso2022.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/* src="iso2022.trans", len=15906, checksum=38089 */

#include "transcoder.h"

#include "ruby/ruby.h"


static const unsigned char
Expand Down Expand Up @@ -254,16 +254,16 @@ iso2022jp_init(void *statep)
return 0;
}

static VALUE
static unsigned int
fun_si_iso2022jp_decoder(void *statep, const unsigned char *s, size_t l)
{
unsigned char *sp = statep;
if (*sp == G0_ASCII)
return (VALUE)NOMAP;
return NOMAP;
else if (0x21 <= s[0] && s[0] <= 0x7e)
return (VALUE)iso2022jp_decoder_jisx0208_rest;
return (unsigned int)iso2022jp_decoder_jisx0208_rest;
else
return (VALUE)INVALID;
return INVALID;
}

static ssize_t
Expand Down Expand Up @@ -440,35 +440,35 @@ rb_eucjp_to_stateless_iso2022jp = {
NULL, NULL, NULL, fun_so_eucjp_to_stateless_iso2022jp,
};

static VALUE
static unsigned int
fun_si_cp50221_decoder(void *statep, const unsigned char *s, size_t l)
{
unsigned char *sp = statep;
int c;
switch (*sp) {
case G0_ASCII:
if (0xA1 <= s[0] && s[0] <= 0xDF)
return (VALUE)FUNso;
return (VALUE)NOMAP;
return (unsigned int)FUNso;
return NOMAP;
case G0_JISX0201_KATAKANA:
c = s[0] & 0x7F;
if (0x21 <= c && c <= 0x5f)
return (VALUE)FUNso;
return (unsigned int)FUNso;
break;
case G0_JISX0208_1978:
if ((0x21 <= s[0] && s[0] <= 0x28) || (0x30 <= s[0] && s[0] <= 0x74))
return (VALUE)iso2022jp_decoder_jisx0208_rest;
return (unsigned int)iso2022jp_decoder_jisx0208_rest;
break;
case G0_JISX0208_1983:
if ((0x21 <= s[0] && s[0] <= 0x28) ||
s[0] == 0x2D ||
(0x30 <= s[0] && s[0] <= 0x74) ||
(0x79 <= s[0] && s[0] <= 0x7C))
/* 0x7F <= s[0] && s[0] <= 0x92) */
return (VALUE)iso2022jp_decoder_jisx0208_rest;
return (unsigned int)iso2022jp_decoder_jisx0208_rest;
break;
}
return (VALUE)INVALID;
return INVALID;
}

static ssize_t
Expand Down
2 changes: 1 addition & 1 deletion enc/trans/japanese.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/* src="japanese.trans", len=2261, checksum=31681 */

#include "transcoder.h"

#include "ruby/ruby.h"


static const unsigned char
Expand Down
2 changes: 1 addition & 1 deletion enc/trans/japanese_euc.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/* src="japanese_euc.trans", len=1697, checksum=58602 */

#include "transcoder.h"

#include "ruby/ruby.h"


static const unsigned char
Expand Down
2 changes: 1 addition & 1 deletion enc/trans/japanese_sjis.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/* src="japanese_sjis.trans", len=1028, checksum=11896 */

#include "transcoder.h"

#include "ruby/ruby.h"


static const unsigned char
Expand Down
2 changes: 1 addition & 1 deletion enc/trans/korean.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/* src="cp949-tbl.rb", len=167830, checksum=37452 */

#include "transcoder.h"

#include "ruby/ruby.h"


static const unsigned char
Expand Down
2 changes: 1 addition & 1 deletion enc/trans/newline.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/* src="newline.trans", len=3162, checksum=42485 */

#include "transcoder.h"

#include "ruby/ruby.h"


static const unsigned char
Expand Down
2 changes: 1 addition & 1 deletion enc/trans/single_byte.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
/* src="cp855-tbl.rb", len=2094, checksum=48066 */

#include "transcoder.h"

#include "ruby/ruby.h"


static const unsigned char
Expand Down
10 changes: 5 additions & 5 deletions enc/trans/utf8_mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/* src="utf8_mac-tbl.rb", len=24587, checksum=65335 */

#include "transcoder.h"

#include "ruby/ruby.h"


static const unsigned char
Expand Down Expand Up @@ -10735,15 +10735,15 @@ buf_output_all(struct from_utf8_mac_status *sp, unsigned char *o)
return n;
}

VALUE
get_info(VALUE next_info, struct from_utf8_mac_status *sp) {
unsigned int
get_info(unsigned int next_info, struct from_utf8_mac_status *sp) {
int pos = 0;
while (pos < buf_bytesize(sp)) {
unsigned char next_byte = buf_at(sp, pos++);
if (next_byte < BL_MIN_BYTE || BL_MAX_BYTE < next_byte)
next_info = INVALID;
else {
next_info = (VALUE)BL_ACTION(next_byte);
next_info = (unsigned int)BL_ACTION(next_byte);
}
if ((next_info & 3) == 0) continue;
break;
Expand All @@ -10755,7 +10755,7 @@ int
buf_apply(int mode, struct from_utf8_mac_status *sp, unsigned char *o)
{
int n = 0;
VALUE next_info = mode == 3 ? from_utf8_mac_nfc3 : from_utf8_mac_nfc2;
unsigned int next_info = mode == 3 ? from_utf8_mac_nfc3 : from_utf8_mac_nfc2;
next_info = get_info(next_info, sp);
switch (next_info & 0x1F) {
case THREEbt:
Expand Down
22 changes: 11 additions & 11 deletions enc/trans/utf_16_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/* src="utf_16_32.trans", len=15312, checksum=29120 */

#include "transcoder.h"

#include "ruby/ruby.h"


static const unsigned char
Expand Down Expand Up @@ -565,7 +565,7 @@ state_init(void *statep)
return 0;
}

static VALUE
static unsigned int
fun_si_from_utf_16(void *statep, const unsigned char *s, size_t l)
{
#define BE 1
Expand All @@ -584,22 +584,22 @@ fun_si_from_utf_16(void *statep, const unsigned char *s, size_t l)
break;
case BE:
if (s[0] < 0xD8 || 0xDF < s[0]) {
return (VALUE)FUNso;
return (unsigned int)FUNso;
}
else if (s[0] <= 0xDB) {
return (VALUE)from_UTF_16BE_D8toDB_00toFF;
return (unsigned int)from_UTF_16BE_D8toDB_00toFF;
}
break;
case LE:
if (s[1] < 0xD8 || 0xDF < s[1]) {
return (VALUE)FUNso;
return (unsigned int)FUNso;
}
else if (s[1] <= 0xDB) {
return (VALUE)from_UTF_16LE_00toFF_D8toDB;
return (unsigned int)from_UTF_16LE_00toFF_D8toDB;
}
break;
}
return (VALUE)INVALID;
return INVALID;
}

static ssize_t
Expand All @@ -615,7 +615,7 @@ fun_so_from_utf_16(void *statep, const unsigned char *s, size_t l, unsigned char
return 0;
}

static VALUE
static unsigned int
fun_si_from_utf_32(void *statep, const unsigned char *s, size_t l)
{
unsigned char *sp = statep;
Expand All @@ -633,15 +633,15 @@ fun_si_from_utf_32(void *statep, const unsigned char *s, size_t l)
case BE:
if (s[0] == 0 && ((0 < s[1] && s[1] <= 0x10) ||
(s[1] == 0 && (s[2] < 0xD8 || 0xDF < s[2]))))
return (VALUE)FUNso;
return (unsigned int)FUNso;
break;
case LE:
if (s[3] == 0 && ((0 < s[2] && s[2] <= 0x10) ||
(s[2] == 0 && (s[1] < 0xD8 || 0xDF < s[1]))))
return (VALUE)FUNso;
return (unsigned int)FUNso;
break;
}
return (VALUE)INVALID;
return INVALID;
}

static ssize_t
Expand Down
Loading

0 comments on commit 4d99dcf

Please sign in to comment.