Project

General

Profile

Feature #5820 ยป 0003-support-for-Ruby-1.9.3-compatible-b-B-and-POSIX-brac.patch

k_takata (Ken Takata), 01/09/2012 05:28 AM

View differences:

oniguruma.h
367 367
#define ONIG_OPTION_POSIX_REGION         (ONIG_OPTION_NOTEOL << 1)
368 368
/* options (ctype range) */
369 369
#define ONIG_OPTION_ASCII_RANGE          (ONIG_OPTION_POSIX_REGION << 1)
370
#define ONIG_OPTION_POSIX_BRACKET_ALL_RANGE (ONIG_OPTION_ASCII_RANGE << 1)
371
#define ONIG_OPTION_WORD_BOUND_ALL_RANGE    (ONIG_OPTION_POSIX_BRACKET_ALL_RANGE << 1)
370 372
/* options (newline) */
371
#define ONIG_OPTION_NEWLINE_CRLF         (ONIG_OPTION_ASCII_RANGE << 1)
373
#define ONIG_OPTION_NEWLINE_CRLF         (ONIG_OPTION_WORD_BOUND_ALL_RANGE << 1)
372 374
#define ONIG_OPTION_MAXBIT               ONIG_OPTION_NEWLINE_CRLF  /* limit */
373 375

  
374 376
#define ONIG_OPTION_ON(options,regopt)      ((options) |= (regopt))
......
452 454
#define ONIG_SYN_OP2_ESC_CAPITAL_Q_QUOTE        (1U<<0)  /* \Q...\E */
453 455
#define ONIG_SYN_OP2_QMARK_GROUP_EFFECT         (1U<<1)  /* (?...) */
454 456
#define ONIG_SYN_OP2_OPTION_PERL                (1U<<2)  /* (?imsxadlu), (?-imsx), (?^imsxalu) */
455
#define ONIG_SYN_OP2_OPTION_RUBY                (1U<<3)  /* (?imx), (?-imx)  */
457
#define ONIG_SYN_OP2_OPTION_RUBY                (1U<<3)  /* (?imxadu), (?-imx)  */
456 458
#define ONIG_SYN_OP2_PLUS_POSSESSIVE_REPEAT     (1U<<4)  /* ?+,*+,++ */
457 459
#define ONIG_SYN_OP2_PLUS_POSSESSIVE_INTERVAL   (1U<<5)  /* {n,m}+   */
458 460
#define ONIG_SYN_OP2_CCLASS_SET_OP              (1U<<6)  /* [...&&..[..]..] */
......
497 499
#define ONIG_SYN_ALLOW_MULTIPLEX_DEFINITION_NAME_CALL (1U<<10)  /* (?<x>)(?<x>)(?&x) */
498 500

  
499 501
/* syntax (behavior) in char class [...] */
500
#define ONIG_SYN_POSIX_BRACKET_ALWAYS_ALL_RANGE  (1U<<19) /* (?a) doesn't affect POSIX brackets */
501 502
#define ONIG_SYN_NOT_NEWLINE_IN_NEGATIVE_CC      (1U<<20) /* [^...] */
502 503
#define ONIG_SYN_BACKSLASH_ESCAPE_IN_CC          (1U<<21) /* [..\w..] etc.. */
503 504
#define ONIG_SYN_ALLOW_EMPTY_RANGE_IN_CC         (1U<<22)
regint.h
370 370
#define IS_NOTEOL(option)         ((option) & ONIG_OPTION_NOTEOL)
371 371
#define IS_POSIX_REGION(option)   ((option) & ONIG_OPTION_POSIX_REGION)
372 372
#define IS_ASCII_RANGE(option)    ((option) & ONIG_OPTION_ASCII_RANGE)
373
#define IS_POSIX_BRACKET_ALL_RANGE(option)  ((option) & ONIG_OPTION_POSIX_BRACKET_ALL_RANGE)
374
#define IS_WORD_BOUND_ALL_RANGE(option)     ((option) & ONIG_OPTION_WORD_BOUND_ALL_RANGE)
373 375
#define IS_NEWLINE_CRLF(option)   ((option) & ONIG_OPTION_NEWLINE_CRLF)
374 376

  
375 377
/* OP_SET_OPTION is required for these options.
regparse.c
63 63
      ONIG_SYN_FIXED_INTERVAL_IS_GREEDY_ONLY |
64 64
      ONIG_SYN_WARN_CC_OP_NOT_ESCAPED |
65 65
      ONIG_SYN_WARN_CC_DUP |
66
      ONIG_SYN_WARN_REDUNDANT_NESTED_REPEAT |
67
      ONIG_SYN_POSIX_BRACKET_ALWAYS_ALL_RANGE )
68
  , ONIG_OPTION_ASCII_RANGE
66
      ONIG_SYN_WARN_REDUNDANT_NESTED_REPEAT )
67
  , ( ONIG_OPTION_ASCII_RANGE | ONIG_OPTION_POSIX_BRACKET_ALL_RANGE |
68
      ONIG_OPTION_WORD_BOUND_ALL_RANGE )
69 69
  ,
70 70
  {
71 71
      (OnigCodePoint )'\\'                       /* esc */
......
3429 3429
      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_B_WORD_BOUND)) break;
3430 3430
      tok->type = TK_ANCHOR;
3431 3431
      tok->u.anchor.subtype = ANCHOR_WORD_BOUND;
3432
      tok->u.anchor.ascii_range = IS_ASCII_RANGE(env->option);
3432
      tok->u.anchor.ascii_range = IS_ASCII_RANGE(env->option)
3433
		&& ! IS_WORD_BOUND_ALL_RANGE(env->option);
3433 3434
      break;
3434 3435

  
3435 3436
    case 'B':
3436 3437
      if (! IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_B_WORD_BOUND)) break;
3437 3438
      tok->type = TK_ANCHOR;
3438 3439
      tok->u.anchor.subtype = ANCHOR_NOT_WORD_BOUND;
3439
      tok->u.anchor.ascii_range = IS_ASCII_RANGE(env->option);
3440
      tok->u.anchor.ascii_range = IS_ASCII_RANGE(env->option)
3441
		&& ! IS_WORD_BOUND_ALL_RANGE(env->option);
3440 3442
      break;
3441 3443

  
3442 3444
#ifdef USE_WORD_BEGIN_END
......
4263 4265
	return ONIGERR_INVALID_POSIX_BRACKET_TYPE;
4264 4266

  
4265 4267
      r = add_ctype_to_cc(cc, pb->ctype, not,
4266
	    IS_SYNTAX_BV(env->syntax, ONIG_SYN_POSIX_BRACKET_ALWAYS_ALL_RANGE),
4268
	    IS_POSIX_BRACKET_ALL_RANGE(env->option),
4267 4269
	    env);
4268 4270
      if (r != 0) return r;
4269 4271

  
......
5032 5034
	ONOFF(option, ONIG_OPTION_EXTEND, 1);
5033 5035
	PFETCH(c);
5034 5036
      }
5037
#if 0
5038
      else if (IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_OPTION_RUBY)) {
5039
	/* d-imx */
5040
	ONOFF(option, ONIG_OPTION_ASCII_RANGE, 0);
5041
	ONOFF(option, ONIG_OPTION_POSIX_BRACKET_ALL_RANGE, 0);
5042
	ONOFF(option, ONIG_OPTION_WORD_BOUND_ALL_RANGE, 0);
5043
	ONOFF(option, ONIG_OPTION_IGNORECASE, 1);
5044
	ONOFF(option, ONIG_OPTION_MULTILINE,  1);
5045
	ONOFF(option, ONIG_OPTION_EXTEND, 1);
5046
	PFETCH(c);
5047
      }
5048
#endif
5035 5049
      else {
5036 5050
	return ONIGERR_UNDEFINED_GROUP_OPTION;
5037 5051
      }
......
5082 5096
	         IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_OPTION_RUBY)) &&
5083 5097
	        (neg == 0)) {
5084 5098
	      ONOFF(option, ONIG_OPTION_ASCII_RANGE, 0);
5099
	      ONOFF(option, ONIG_OPTION_POSIX_BRACKET_ALL_RANGE, 1);
5100
	      ONOFF(option, ONIG_OPTION_WORD_BOUND_ALL_RANGE, 1);
5085 5101
	    }
5086 5102
	    else
5087 5103
	      return ONIGERR_UNDEFINED_GROUP_OPTION;
......
5092 5108
	         IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_OPTION_RUBY)) &&
5093 5109
	        (neg == 0)) {
5094 5110
	      ONOFF(option, ONIG_OPTION_ASCII_RANGE, 1);
5111
	      ONOFF(option, ONIG_OPTION_POSIX_BRACKET_ALL_RANGE, 1);
5112
	      ONOFF(option, ONIG_OPTION_WORD_BOUND_ALL_RANGE, 1);
5113
	    }
5114
	    else
5115
	      return ONIGERR_UNDEFINED_GROUP_OPTION;
5116
	    break;
5117

  
5118
	  case 'd':
5119
	    if (IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_OPTION_PERL) &&
5120
	        (neg == 0)) {
5121
	      ONOFF(option, ONIG_OPTION_ASCII_RANGE, 1);
5122
	    }
5123
	    else if (IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_OPTION_RUBY) &&
5124
	        (neg == 0)) {
5125
	      ONOFF(option, ONIG_OPTION_ASCII_RANGE, 0);
5126
	      ONOFF(option, ONIG_OPTION_POSIX_BRACKET_ALL_RANGE, 0);
5127
	      ONOFF(option, ONIG_OPTION_WORD_BOUND_ALL_RANGE, 0);
5095 5128
	    }
5096 5129
	    else
5097 5130
	      return ONIGERR_UNDEFINED_GROUP_OPTION;
5098 5131
	    break;
5099 5132

  
5100
	  case 'd': case 'l':
5133
	  case 'l':
5101 5134
	    if (IS_SYNTAX_OP2(env->syntax, ONIG_SYN_OP2_OPTION_PERL) && (neg == 0)) {
5102 5135
	      ONOFF(option, ONIG_OPTION_ASCII_RANGE, 1);
5103 5136
	    }
5104
-