Permalink
Browse files

use default syntax and encoding

  • Loading branch information...
1 parent d7db6c6 commit 81242c78697fa86829956ba39966c435c5858964 Zhigang Chen committed Jun 7, 2012
Showing with 4 additions and 7 deletions.
  1. +2 −4 chelper.c
  2. +1 −1 chelper.h
  3. +1 −2 regex.go
View
6 chelper.c
@@ -7,7 +7,7 @@
#include "chelper.h"
int NewOnigRegex( char *pattern, int pattern_length, int option,
- OnigRegex *regex, OnigRegion **region, OnigEncoding *encoding, OnigErrorInfo **error_info, char **error_buffer) {
+ OnigRegex *regex, OnigRegion **region, OnigErrorInfo **error_info, char **error_buffer) {
int ret = ONIG_NORMAL;
int error_msg_len = 0;
@@ -17,15 +17,13 @@ int NewOnigRegex( char *pattern, int pattern_length, int option,
*error_info = (OnigErrorInfo *) malloc(sizeof(OnigErrorInfo));
memset(*error_info, 0, sizeof(OnigErrorInfo));
- *encoding = (void*)ONIG_ENCODING_UTF8;
-
*error_buffer = (char*) malloc(ONIG_MAX_ERROR_MESSAGE_LEN * sizeof(char));
memset(*error_buffer, 0, ONIG_MAX_ERROR_MESSAGE_LEN * sizeof(char));
*region = onig_region_new();
- ret = onig_new(regex, pattern_start, pattern_end, (OnigOptionType)(option), *encoding, OnigDefaultSyntax, *error_info);
+ ret = onig_new_default(regex, pattern_start, pattern_end, (OnigOptionType)(option), *error_info);
if (ret != ONIG_NORMAL) {
error_msg_len = onig_error_code_to_str((unsigned char*)(*error_buffer), ret, *error_info);
View
2 chelper.h
@@ -1,7 +1,7 @@
#include <oniguruma.h>
extern int NewOnigRegex( char *pattern, int pattern_length, int option,
- OnigRegex *regex, OnigRegion **region, OnigEncoding *encoding, OnigErrorInfo **error_info, char **error_buffer);
+ OnigRegex *regex, OnigRegion **region, OnigErrorInfo **error_info, char **error_buffer);
extern int SearchOnigRegex( void *str, int str_length, int offset, int option,
OnigRegex regex, OnigRegion *region, OnigErrorInfo *error_info, char *error_buffer, int *captures, int *numCaptures);
View
3 regex.go
@@ -40,7 +40,6 @@ type Regexp struct {
pattern string
regex C.OnigRegex
region *C.OnigRegion
- encoding C.OnigEncoding
errorInfo *C.OnigErrorInfo
errorBuf *C.char
matchData *MatchData
@@ -54,7 +53,7 @@ func NewRegexp(pattern string, option int) (re *Regexp, err error) {
mutex.Lock()
defer mutex.Unlock()
- error_code := C.NewOnigRegex(patternCharPtr, C.int(len(pattern)), C.int(option), &re.regex, &re.region, &re.encoding, &re.errorInfo, &re.errorBuf)
+ error_code := C.NewOnigRegex(patternCharPtr, C.int(len(pattern)), C.int(option), &re.regex, &re.region, &re.errorInfo, &re.errorBuf)
if error_code != C.ONIG_NORMAL {
err = errors.New(C.GoString(re.errorBuf))
} else {

0 comments on commit 81242c7

Please sign in to comment.