~ubuntu-branches/ubuntu/trusty/ruby1.9/trusty

« back to all changes in this revision

Viewing changes to oniguruma.h

  • Committer: Bazaar Package Importer
  • Author(s): Lucas Nussbaum
  • Date: 2006-05-08 22:23:12 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060508222312-w2wqeaz030ifi59j
Tags: 1.9.0+20060423-3ubuntu1
* Resynchronized with Debian.
* Only change from Debian is the addition of
  debian/patches/903_sparc_fix_define.patch to fix illegal instructions
  at runtime on sparc. (change from 1.9.0+20050921-1ubuntu1)

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
  oniguruma.h - Oniguruma (regular expression library)
5
5
**********************************************************************/
6
6
/*-
7
 
 * Copyright (c) 2002-2005  K.Kosako  <sndgk393 AT ybb DOT ne DOT jp>
 
7
 * Copyright (c) 2002-2006  K.Kosako  <sndgk393 AT ybb DOT ne DOT jp>
8
8
 * All rights reserved.
9
9
 *
10
10
 * Redistribution and use in source and binary forms, with or without
34
34
#endif
35
35
 
36
36
#define ONIGURUMA
37
 
#define ONIGURUMA_VERSION_MAJOR   3
38
 
#define ONIGURUMA_VERSION_MINOR   7
39
 
#define ONIGURUMA_VERSION_TEENY   0
 
37
#define ONIGURUMA_VERSION_MAJOR   4
 
38
#define ONIGURUMA_VERSION_MINOR   0
 
39
#define ONIGURUMA_VERSION_TEENY   2
40
40
 
41
41
#ifdef __cplusplus
42
42
# ifndef  HAVE_PROTOTYPES
79
79
 
80
80
/* PART: character encoding */
81
81
 
82
 
typedef unsigned char  UChar;
 
82
#ifndef ONIG_ESCAPE_UCHAR_COLLISION
 
83
#define UChar OnigUChar
 
84
#endif
 
85
 
 
86
typedef unsigned char  OnigUChar;
83
87
typedef unsigned long  OnigCodePoint;
84
88
typedef unsigned int   OnigDistance;
85
89
 
149
153
#else
150
154
 
151
155
typedef struct {
152
 
  int    (*mbc_enc_len)(const UChar* p);
 
156
  int    (*mbc_enc_len)(const OnigUChar* p);
153
157
  const char*   name;
154
158
  int           max_enc_len;
155
159
  int           min_enc_len;
156
160
  OnigAmbigType support_ambig_flag;
157
161
  OnigMetaCharTableType meta_char_table;
158
 
  int    (*is_mbc_newline)(const UChar* p, const UChar* end);
159
 
  OnigCodePoint (*mbc_to_code)(const UChar* p, const UChar* end);
 
162
  int    (*is_mbc_newline)(const OnigUChar* p, const OnigUChar* end);
 
163
  OnigCodePoint (*mbc_to_code)(const OnigUChar* p, const OnigUChar* end);
160
164
  int    (*code_to_mbclen)(OnigCodePoint code);
161
 
  int    (*code_to_mbc)(OnigCodePoint code, UChar *buf);
162
 
  int    (*mbc_to_normalize)(OnigAmbigType flag, const UChar** pp, const UChar* end, UChar* to);
163
 
  int    (*is_mbc_ambiguous)(OnigAmbigType flag, const UChar** pp, const UChar* end);
164
 
  int    (*get_all_pair_ambig_codes)(OnigAmbigType flag, OnigPairAmbigCodes** acs);
165
 
  int    (*get_all_comp_ambig_codes)(OnigAmbigType flag, OnigCompAmbigCodes** acs);
 
165
  int    (*code_to_mbc)(OnigCodePoint code, OnigUChar *buf);
 
166
  int    (*mbc_to_normalize)(OnigAmbigType flag, const OnigUChar** pp, const OnigUChar* end, OnigUChar* to);
 
167
  int    (*is_mbc_ambiguous)(OnigAmbigType flag, const OnigUChar** pp, const OnigUChar* end);
 
168
  int    (*get_all_pair_ambig_codes)(OnigAmbigType flag, const OnigPairAmbigCodes** acs);
 
169
  int    (*get_all_comp_ambig_codes)(OnigAmbigType flag, const OnigCompAmbigCodes** acs);
166
170
  int    (*is_code_ctype)(OnigCodePoint code, unsigned int ctype);
167
 
  int    (*get_ctype_code_range)(int ctype, OnigCodePoint* sb_range[], OnigCodePoint* mb_range[]);
168
 
  UChar* (*left_adjust_char_head)(const UChar* start, const UChar* p);
169
 
  int    (*is_allowed_reverse_match)(const UChar* p, const UChar* end);
 
171
  int    (*get_ctype_code_range)(int ctype, const OnigCodePoint* sb_range[], const OnigCodePoint* mb_range[]);
 
172
  OnigUChar* (*left_adjust_char_head)(const OnigUChar* start, const OnigUChar* p);
 
173
  int    (*is_allowed_reverse_match)(const OnigUChar* p, const OnigUChar* end);
170
174
} OnigEncodingType;
171
175
 
172
176
typedef OnigEncodingType* OnigEncoding;
200
204
ONIG_EXTERN OnigEncodingType OnigEncodingKOI8;
201
205
ONIG_EXTERN OnigEncodingType OnigEncodingKOI8_R;
202
206
ONIG_EXTERN OnigEncodingType OnigEncodingBIG5;
 
207
ONIG_EXTERN OnigEncodingType OnigEncodingGB18030;
203
208
 
204
209
#define ONIG_ENCODING_ASCII        (&OnigEncodingASCII)
205
210
#define ONIG_ENCODING_ISO_8859_1   (&OnigEncodingISO_8859_1)
230
235
#define ONIG_ENCODING_KOI8         (&OnigEncodingKOI8)
231
236
#define ONIG_ENCODING_KOI8_R       (&OnigEncodingKOI8_R)
232
237
#define ONIG_ENCODING_BIG5         (&OnigEncodingBIG5)
 
238
#define ONIG_ENCODING_GB18030      (&OnigEncodingGB18030)
233
239
 
234
240
#endif /* else RUBY && M17N */
235
241
 
333
339
ONIG_EXTERN
334
340
int onigenc_is_code_ctype P_((OnigEncoding enc, OnigCodePoint code, int ctype));
335
341
ONIG_EXTERN
336
 
int onigenc_code_to_mbc P_((OnigEncoding enc, OnigCodePoint code, UChar *buf));
337
 
ONIG_EXTERN
338
 
int onigenc_mbc_to_normalize P_((OnigEncoding enc, OnigAmbigType flag, const UChar** pp, const UChar* end, UChar* buf));
339
 
ONIG_EXTERN
340
 
int onigenc_is_mbc_ambiguous P_((OnigEncoding enc, OnigAmbigType flag, const UChar** pp, const UChar* end));
341
 
ONIG_EXTERN
342
 
int onigenc_is_allowed_reverse_match P_((OnigEncoding enc, const UChar* s, const UChar* end));
 
342
int onigenc_code_to_mbc P_((OnigEncoding enc, OnigCodePoint code, OnigUChar *buf));
 
343
ONIG_EXTERN
 
344
int onigenc_mbc_to_normalize P_((OnigEncoding enc, OnigAmbigType flag, const OnigUChar** pp, const OnigUChar* end, OnigUChar* buf));
 
345
ONIG_EXTERN
 
346
int onigenc_is_mbc_ambiguous P_((OnigEncoding enc, OnigAmbigType flag, const OnigUChar** pp, const OnigUChar* end));
 
347
ONIG_EXTERN
 
348
int onigenc_is_allowed_reverse_match P_((OnigEncoding enc, const OnigUChar* s, const OnigUChar* end));
343
349
 
344
350
#else  /* ONIG_RUBY_M17N */
345
351
 
346
352
#define ONIGENC_NAME(enc)                      ((enc)->name)
347
353
 
348
354
#define ONIGENC_MBC_TO_NORMALIZE(enc,flag,pp,end,buf) \
349
 
  (enc)->mbc_to_normalize(flag,(const UChar** )pp,end,buf)
 
355
  (enc)->mbc_to_normalize(flag,(const OnigUChar** )pp,end,buf)
350
356
#define ONIGENC_IS_MBC_AMBIGUOUS(enc,flag,pp,end) \
351
 
  (enc)->is_mbc_ambiguous(flag,(const UChar** )pp,end)
 
357
  (enc)->is_mbc_ambiguous(flag,(const OnigUChar** )pp,end)
352
358
#define ONIGENC_SUPPORT_AMBIG_FLAG(enc)        ((enc)->support_ambig_flag)
353
359
#define ONIGENC_IS_ALLOWED_REVERSE_MATCH(enc,s,end) \
354
360
        (enc)->is_allowed_reverse_match(s,end)
405
411
        (enc)->get_ctype_code_range(ctype,sbr,mbr)
406
412
 
407
413
ONIG_EXTERN
408
 
UChar* onigenc_step_back P_((OnigEncoding enc, const UChar* start, const UChar* s, int n));
 
414
OnigUChar* onigenc_step_back P_((OnigEncoding enc, const OnigUChar* start, const OnigUChar* s, int n));
409
415
 
410
416
#endif /* is not ONIG_RUBY_M17N */
411
417
 
418
424
ONIG_EXTERN
419
425
OnigEncoding onigenc_get_default_encoding P_(());
420
426
ONIG_EXTERN
421
 
void  onigenc_set_default_caseconv_table P_((const UChar* table));
422
 
ONIG_EXTERN
423
 
UChar* onigenc_get_right_adjust_char_head_with_prev P_((OnigEncoding enc, const UChar* start, const UChar* s, const UChar** prev));
424
 
ONIG_EXTERN
425
 
UChar* onigenc_get_prev_char_head P_((OnigEncoding enc, const UChar* start, const UChar* s));
426
 
ONIG_EXTERN
427
 
UChar* onigenc_get_left_adjust_char_head P_((OnigEncoding enc, const UChar* start, const UChar* s));
428
 
ONIG_EXTERN
429
 
UChar* onigenc_get_right_adjust_char_head P_((OnigEncoding enc, const UChar* start, const UChar* s));
430
 
ONIG_EXTERN
431
 
int onigenc_strlen P_((OnigEncoding enc, const UChar* p, const UChar* end));
432
 
ONIG_EXTERN
433
 
int onigenc_strlen_null P_((OnigEncoding enc, const UChar* p));
434
 
ONIG_EXTERN
435
 
int onigenc_str_bytelen_null P_((OnigEncoding enc, const UChar* p));
 
427
void  onigenc_set_default_caseconv_table P_((const OnigUChar* table));
 
428
ONIG_EXTERN
 
429
OnigUChar* onigenc_get_right_adjust_char_head_with_prev P_((OnigEncoding enc, const OnigUChar* start, const OnigUChar* s, const OnigUChar** prev));
 
430
ONIG_EXTERN
 
431
OnigUChar* onigenc_get_prev_char_head P_((OnigEncoding enc, const OnigUChar* start, const OnigUChar* s));
 
432
ONIG_EXTERN
 
433
OnigUChar* onigenc_get_left_adjust_char_head P_((OnigEncoding enc, const OnigUChar* start, const OnigUChar* s));
 
434
ONIG_EXTERN
 
435
OnigUChar* onigenc_get_right_adjust_char_head P_((OnigEncoding enc, const OnigUChar* start, const OnigUChar* s));
 
436
ONIG_EXTERN
 
437
int onigenc_strlen P_((OnigEncoding enc, const OnigUChar* p, const OnigUChar* end));
 
438
ONIG_EXTERN
 
439
int onigenc_strlen_null P_((OnigEncoding enc, const OnigUChar* p));
 
440
ONIG_EXTERN
 
441
int onigenc_str_bytelen_null P_((OnigEncoding enc, const OnigUChar* p));
436
442
 
437
443
 
438
444
 
442
448
#define ONIG_NREGION                          10
443
449
#define ONIG_MAX_BACKREF_NUM                1000
444
450
#define ONIG_MAX_REPEAT_NUM               100000
445
 
#define ONIG_MAX_MULTI_BYTE_RANGES_NUM      1000
 
451
#define ONIG_MAX_MULTI_BYTE_RANGES_NUM     10000
446
452
/* constants */
447
453
#define ONIG_MAX_ERROR_MESSAGE_LEN            90
448
454
 
465
471
#define ONIG_OPTION_NOTBOL               (ONIG_OPTION_CAPTURE_GROUP << 1)
466
472
#define ONIG_OPTION_NOTEOL               (ONIG_OPTION_NOTBOL << 1)
467
473
#define ONIG_OPTION_POSIX_REGION         (ONIG_OPTION_NOTEOL << 1)
 
474
#define ONIG_OPTION_MAXBIT               ONIG_OPTION_POSIX_REGION  /* limit */
468
475
 
469
476
#define ONIG_OPTION_ON(options,regopt)      ((options) |= (regopt))
470
477
#define ONIG_OPTION_OFF(options,regopt)     ((options) &= ~(regopt))
478
485
  OnigOptionType options;    /* default option */
479
486
} OnigSyntaxType;
480
487
 
 
488
ONIG_EXTERN OnigSyntaxType OnigSyntaxASIS;
481
489
ONIG_EXTERN OnigSyntaxType OnigSyntaxPosixBasic;
482
490
ONIG_EXTERN OnigSyntaxType OnigSyntaxPosixExtended;
483
491
ONIG_EXTERN OnigSyntaxType OnigSyntaxEmacs;
485
493
ONIG_EXTERN OnigSyntaxType OnigSyntaxGnuRegex;
486
494
ONIG_EXTERN OnigSyntaxType OnigSyntaxJava;
487
495
ONIG_EXTERN OnigSyntaxType OnigSyntaxPerl;
 
496
ONIG_EXTERN OnigSyntaxType OnigSyntaxPerl_NG;
488
497
ONIG_EXTERN OnigSyntaxType OnigSyntaxRuby;
489
498
 
490
499
/* predefined syntaxes (see regsyntax.c) */
 
500
#define ONIG_SYNTAX_ASIS               (&OnigSyntaxASIS)
491
501
#define ONIG_SYNTAX_POSIX_BASIC        (&OnigSyntaxPosixBasic)
492
502
#define ONIG_SYNTAX_POSIX_EXTENDED     (&OnigSyntaxPosixExtended)
493
503
#define ONIG_SYNTAX_EMACS              (&OnigSyntaxEmacs)
495
505
#define ONIG_SYNTAX_GNU_REGEX          (&OnigSyntaxGnuRegex)
496
506
#define ONIG_SYNTAX_JAVA               (&OnigSyntaxJava)
497
507
#define ONIG_SYNTAX_PERL               (&OnigSyntaxPerl)
 
508
#define ONIG_SYNTAX_PERL_NG            (&OnigSyntaxPerl_NG)
498
509
#define ONIG_SYNTAX_RUBY               (&OnigSyntaxRuby)
499
510
 
500
511
/* default syntax */
554
565
#define ONIG_SYN_OP2_ESC_P_BRACE_CIRCUMFLEX_NOT (1<<17)  /* \p{^..}, \P{^..} */
555
566
#define ONIG_SYN_OP2_CHAR_PROPERTY_PREFIX_IS    (1<<18)  /* \p{IsXDigit} */
556
567
#define ONIG_SYN_OP2_ESC_H_XDIGIT               (1<<19)  /* \h, \H */
 
568
#define ONIG_SYN_OP2_INEFFECTIVE_ESCAPE         (1<<20)  /* \ */
557
569
 
558
570
/* syntax (behavior) */
559
571
#define ONIG_SYN_CONTEXT_INDEP_ANCHORS           (1<<31) /* not implemented */
654
666
#define ONIGERR_INVALID_WIDE_CHAR_VALUE                      -400
655
667
#define ONIGERR_TOO_BIG_WIDE_CHAR_VALUE                      -401
656
668
#define ONIGERR_NOT_SUPPORTED_ENCODING_COMBINATION           -402
 
669
#define ONIGERR_INVALID_COMBINATION_OF_OPTIONS               -403
657
670
 
658
671
/* errors related to thread */
659
672
#define ONIGERR_OVER_THREAD_PASS_LIMIT_COUNT                -1001
695
708
typedef struct re_registers   OnigRegion;
696
709
 
697
710
typedef struct {
698
 
  UChar* par;
699
 
  UChar* par_end;
 
711
  OnigUChar* par;
 
712
  OnigUChar* par_end;
700
713
} OnigErrorInfo;
701
714
 
702
715
typedef struct {
704
717
  int upper;
705
718
} OnigRepeatRange;
706
719
 
707
 
typedef void (*OnigWarnFunc) P_((const char* s, ...));
708
 
extern void onig_null_warn P_((const char* s, ...));
 
720
typedef void (*OnigWarnFunc) P_((const char* s));
 
721
extern void onig_null_warn P_((const char* s));
709
722
#define ONIG_NULL_WARN       onig_null_warn
710
723
 
711
724
#define ONIG_CHAR_TABLE_SIZE   256
760
773
 
761
774
  /* regex_t link chain */
762
775
  struct re_pattern_buffer* chain;  /* escape compile-conflict */
763
 
} regex_t;
 
776
} OnigRegexType;
 
777
 
 
778
typedef OnigRegexType*  OnigRegex;
 
779
 
 
780
#ifndef ONIG_ESCAPE_REGEX_T_COLLISION
 
781
  typedef OnigRegexType  regex_t;
 
782
#endif
764
783
 
765
784
 
766
785
typedef struct {
776
795
ONIG_EXTERN
777
796
int onig_init P_((void));
778
797
ONIG_EXTERN
779
 
int onig_error_code_to_str PV_((UChar* s, int err_code, ...));
 
798
int onig_error_code_to_str PV_((OnigUChar* s, int err_code, ...));
780
799
ONIG_EXTERN
781
800
void onig_set_warn_func P_((OnigWarnFunc f));
782
801
ONIG_EXTERN
783
802
void onig_set_verb_warn_func P_((OnigWarnFunc f));
784
803
ONIG_EXTERN
785
 
int onig_new P_((regex_t**, const UChar* pattern, const UChar* pattern_end, OnigOptionType option, OnigEncoding enc, OnigSyntaxType* syntax, OnigErrorInfo* einfo));
786
 
ONIG_EXTERN
787
 
int onig_new_deluxe P_((regex_t** reg, const UChar* pattern, const UChar* pattern_end, OnigCompileInfo* ci, OnigErrorInfo* einfo));
788
 
ONIG_EXTERN
789
 
void onig_free P_((regex_t*));
790
 
ONIG_EXTERN
791
 
int onig_recompile P_((regex_t*, const UChar* pattern, const UChar* pattern_end, OnigOptionType option, OnigEncoding enc, OnigSyntaxType* syntax, OnigErrorInfo* einfo));
792
 
ONIG_EXTERN
793
 
int onig_recompile_deluxe P_((regex_t* reg, const UChar* pattern, const UChar* pattern_end, OnigCompileInfo* ci, OnigErrorInfo* einfo));
794
 
ONIG_EXTERN
795
 
int onig_search P_((regex_t*, const UChar* str, const UChar* end, const UChar* start, const UChar* range, OnigRegion* region, OnigOptionType option));
796
 
ONIG_EXTERN
797
 
int onig_match P_((regex_t*, const UChar* str, const UChar* end, const UChar* at, OnigRegion* region, OnigOptionType option));
 
804
int onig_new P_((OnigRegex*, const OnigUChar* pattern, const OnigUChar* pattern_end, OnigOptionType option, OnigEncoding enc, OnigSyntaxType* syntax, OnigErrorInfo* einfo));
 
805
ONIG_EXTERN
 
806
int onig_new_deluxe P_((OnigRegex* reg, const OnigUChar* pattern, const OnigUChar* pattern_end, OnigCompileInfo* ci, OnigErrorInfo* einfo));
 
807
ONIG_EXTERN
 
808
void onig_free P_((OnigRegex));
 
809
ONIG_EXTERN
 
810
int onig_recompile P_((OnigRegex, const OnigUChar* pattern, const OnigUChar* pattern_end, OnigOptionType option, OnigEncoding enc, OnigSyntaxType* syntax, OnigErrorInfo* einfo));
 
811
ONIG_EXTERN
 
812
int onig_recompile_deluxe P_((OnigRegex reg, const OnigUChar* pattern, const OnigUChar* pattern_end, OnigCompileInfo* ci, OnigErrorInfo* einfo));
 
813
ONIG_EXTERN
 
814
int onig_search P_((OnigRegex, const OnigUChar* str, const OnigUChar* end, const OnigUChar* start, const OnigUChar* range, OnigRegion* region, OnigOptionType option));
 
815
ONIG_EXTERN
 
816
int onig_match P_((OnigRegex, const OnigUChar* str, const OnigUChar* end, const OnigUChar* at, OnigRegion* region, OnigOptionType option));
798
817
ONIG_EXTERN
799
818
OnigRegion* onig_region_new P_((void));
800
819
ONIG_EXTERN
810
829
ONIG_EXTERN
811
830
int onig_region_set P_((OnigRegion* region, int at, int beg, int end));
812
831
ONIG_EXTERN
813
 
int onig_name_to_group_numbers P_((regex_t* reg, const UChar* name, const UChar* name_end, int** nums));
814
 
ONIG_EXTERN
815
 
int onig_name_to_backref_number P_((regex_t* reg, const UChar* name, const UChar* name_end, OnigRegion *region));
816
 
ONIG_EXTERN
817
 
int onig_foreach_name P_((regex_t* reg, int (*func)(const UChar*, const UChar*,int,int*,regex_t*,void*), void* arg));
818
 
ONIG_EXTERN
819
 
int onig_number_of_names P_((regex_t* reg));
820
 
ONIG_EXTERN
821
 
int onig_number_of_captures P_((regex_t* reg));
822
 
ONIG_EXTERN
823
 
int onig_number_of_capture_histories P_((regex_t* reg));
 
832
int onig_name_to_group_numbers P_((OnigRegex reg, const OnigUChar* name, const OnigUChar* name_end, int** nums));
 
833
ONIG_EXTERN
 
834
int onig_name_to_backref_number P_((OnigRegex reg, const OnigUChar* name, const OnigUChar* name_end, OnigRegion *region));
 
835
ONIG_EXTERN
 
836
int onig_foreach_name P_((OnigRegex reg, int (*func)(const OnigUChar*, const OnigUChar*,int,int*,OnigRegex,void*), void* arg));
 
837
ONIG_EXTERN
 
838
int onig_number_of_names P_((OnigRegex reg));
 
839
ONIG_EXTERN
 
840
int onig_number_of_captures P_((OnigRegex reg));
 
841
ONIG_EXTERN
 
842
int onig_number_of_capture_histories P_((OnigRegex reg));
824
843
ONIG_EXTERN
825
844
OnigCaptureTreeNode* onig_get_capture_tree P_((OnigRegion* region));
826
845
ONIG_EXTERN
827
846
int onig_capture_tree_traverse P_((OnigRegion* region, int at, int(*callback_func)(int,int,int,int,int,void*), void* arg));
828
847
ONIG_EXTERN
829
 
OnigEncoding onig_get_encoding P_((regex_t* reg));
830
 
ONIG_EXTERN
831
 
OnigOptionType onig_get_options P_((regex_t* reg));
832
 
ONIG_EXTERN
833
 
OnigAmbigType onig_get_ambig_flag P_((regex_t* reg));
834
 
ONIG_EXTERN
835
 
OnigSyntaxType* onig_get_syntax P_((regex_t* reg));
 
848
int onig_noname_group_capture_is_active P_((OnigRegex reg));
 
849
ONIG_EXTERN
 
850
OnigEncoding onig_get_encoding P_((OnigRegex reg));
 
851
ONIG_EXTERN
 
852
OnigOptionType onig_get_options P_((OnigRegex reg));
 
853
ONIG_EXTERN
 
854
OnigAmbigType onig_get_ambig_flag P_((OnigRegex reg));
 
855
ONIG_EXTERN
 
856
OnigSyntaxType* onig_get_syntax P_((OnigRegex reg));
836
857
ONIG_EXTERN
837
858
int onig_set_default_syntax P_((OnigSyntaxType* syntax));
838
859
ONIG_EXTERN