Project

General

Profile

Backport #1935 ยป onigtest.c

nobu (Nobuyoshi Nakada), 08/13/2009 03:33 PM

 
1
#include <stdio.h>
2
#include <stdlib.h>
3

    
4
#include "ruby.h"
5
#include "ruby/oniguruma.h"
6
#include "ruby/encoding.h"
7

    
8
void
9
onigtest(void)
10
{
11
    rb_encoding *enc = rb_enc_find("UTF-16LE");
12

    
13
    char * p = malloc (16);
14
    int l;
15

    
16
    p[0] = '\0';
17
    p[1] = 'a';
18
    p[2] = '\0';
19
    p[3] = '\0';
20

    
21
    /* Endless loop on next line: */
22
    l = onigenc_strlen_null(enc, (UChar*)p);
23

    
24
    printf ("%d\n", l);
25

    
26
    free (p);
27
}
28

    
29

    
30
int main(int argc, char* argv[])
31
{
32
    ruby_sysinit(&argc, &argv);
33
    {
34
	RUBY_INIT_STACK;
35
	ruby_init();
36
	ruby_init_loadpath();
37
	onigtest();
38
	return ruby_cleanup(0);
39
    }
40
}
41