mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* re.c (rb_reg_expr_str): need to escape if the coderage is invalid.
* error.c, include/ruby/intern.h (rb_compile_error_with_enc): new function to raise syntax error, with source encoding'ed message. * parse.y (compile_error): use above function. [ruby-core:33951] (#4217) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30412 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
8af7ed6036
commit
90d5bcf910
4 changed files with 33 additions and 7 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
Tue Dec 28 18:36:38 2010 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||
|
||||
* re.c (rb_reg_expr_str): need to escape if the coderage is invalid.
|
||||
|
||||
* error.c, include/ruby/intern.h (rb_compile_error_with_enc): new
|
||||
function to raise syntax error, with source encoding'ed message.
|
||||
|
||||
* parse.y (compile_error): use above function.
|
||||
[ruby-core:33951] (#4217)
|
||||
|
||||
Tue Dec 28 07:37:38 2010 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* ruby.c: parenthesize macro arguments.
|
||||
|
|
23
error.c
23
error.c
|
@ -88,7 +88,19 @@ compile_snprintf(char *buf, long len, const char *file, int line, const char *fm
|
|||
}
|
||||
}
|
||||
|
||||
static void err_append(const char*);
|
||||
static void err_append(const char*, rb_encoding *);
|
||||
|
||||
void
|
||||
rb_compile_error_with_enc(const char *file, int line, void *enc, const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
char buf[BUFSIZ];
|
||||
|
||||
va_start(args, fmt);
|
||||
compile_snprintf(buf, BUFSIZ, file, line, fmt, args);
|
||||
va_end(args);
|
||||
err_append(buf, (rb_encoding *)enc);
|
||||
}
|
||||
|
||||
void
|
||||
rb_compile_error(const char *file, int line, const char *fmt, ...)
|
||||
|
@ -99,7 +111,7 @@ rb_compile_error(const char *file, int line, const char *fmt, ...)
|
|||
va_start(args, fmt);
|
||||
compile_snprintf(buf, BUFSIZ, file, line, fmt, args);
|
||||
va_end(args);
|
||||
err_append(buf);
|
||||
err_append(buf, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -111,7 +123,7 @@ rb_compile_error_append(const char *fmt, ...)
|
|||
va_start(args, fmt);
|
||||
vsnprintf(buf, BUFSIZ, fmt, args);
|
||||
va_end(args);
|
||||
err_append(buf);
|
||||
err_append(buf, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1644,14 +1656,15 @@ Init_syserr(void)
|
|||
}
|
||||
|
||||
static void
|
||||
err_append(const char *s)
|
||||
err_append(const char *s, rb_encoding *enc)
|
||||
{
|
||||
rb_thread_t *th = GET_THREAD();
|
||||
VALUE err = th->errinfo;
|
||||
|
||||
if (th->mild_compile_error) {
|
||||
if (!RTEST(err)) {
|
||||
err = rb_exc_new2(rb_eSyntaxError, s);
|
||||
err = rb_exc_new3(rb_eSyntaxError,
|
||||
rb_enc_str_new(s, strlen(s), enc));
|
||||
th->errinfo = err;
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -209,6 +209,7 @@ PRINTF_ARGS(NORETURN(void rb_loaderror(const char*, ...)), 1, 2);
|
|||
PRINTF_ARGS(NORETURN(void rb_name_error(ID, const char*, ...)), 2, 3);
|
||||
NORETURN(void rb_invalid_str(const char*, const char*));
|
||||
PRINTF_ARGS(void rb_compile_error(const char*, int, const char*, ...), 3, 4);
|
||||
PRINTF_ARGS(void rb_compile_error_with_enc(const char*, int, void *, const char*, ...), 4, 5);
|
||||
PRINTF_ARGS(void rb_compile_error_append(const char*, ...), 1, 2);
|
||||
NORETURN(void rb_load_fail(const char*));
|
||||
NORETURN(void rb_error_frozen(const char*));
|
||||
|
|
6
parse.y
6
parse.y
|
@ -308,6 +308,7 @@ static int parser_yyerror(struct parser_params*, const char*);
|
|||
#define ruby__end__seen (parser->parser_ruby__end__seen)
|
||||
#define ruby_sourceline (parser->parser_ruby_sourceline)
|
||||
#define ruby_sourcefile (parser->parser_ruby_sourcefile)
|
||||
#define current_enc (parser->enc)
|
||||
#define yydebug (parser->parser_yydebug)
|
||||
#ifdef RIPPER
|
||||
#else
|
||||
|
@ -586,8 +587,9 @@ static void ripper_compile_error(struct parser_params*, const char *fmt, ...);
|
|||
# define compile_error ripper_compile_error
|
||||
# define PARSER_ARG parser,
|
||||
#else
|
||||
# define compile_error parser->nerr++,rb_compile_error
|
||||
# define PARSER_ARG ruby_sourcefile, ruby_sourceline,
|
||||
# define rb_compile_error rb_compile_error_with_enc
|
||||
# define compile_error parser->nerr++,rb_compile_error_with_enc
|
||||
# define PARSER_ARG ruby_sourcefile, ruby_sourceline, current_enc,
|
||||
#endif
|
||||
|
||||
/* Older versions of Yacc set YYMAXDEPTH to a very low value by default (150,
|
||||
|
|
Loading…
Reference in a new issue