mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
use ENABLE/DISABLE instead of INCLUDE for configuration macro names
This commit is contained in:
+24
-26
@@ -8,8 +8,21 @@
|
||||
#define MRUBYCONF_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/* configuration options: */
|
||||
/* add -DMRB_USE_FLOAT to use float instead of double for floating point numbers */
|
||||
#undef MRB_USE_FLOAT
|
||||
|
||||
/* -DDISABLE_XXXX to change to drop the feature */
|
||||
#define DISABLE_REGEXP /* regular expression classes */
|
||||
#undef DISABLE_KERNEL_SPRINTF /* Kernel.sprintf method */
|
||||
#undef DISABLE_MATH /* Math functions */
|
||||
#undef DISABLE_TIME /* Time class */
|
||||
|
||||
#undef HAVE_UNISTD_H /* WINDOWS */
|
||||
#define HAVE_UNISTD_H /* LINUX */
|
||||
/* end of configuration */
|
||||
|
||||
#ifdef MRB_USE_FLOAT
|
||||
typedef float mrb_float;
|
||||
#else
|
||||
@@ -20,34 +33,19 @@ typedef double mrb_float;
|
||||
typedef int mrb_int;
|
||||
typedef intptr_t mrb_sym;
|
||||
|
||||
//#define PARSER_DUMP /* print out parser state */
|
||||
#undef PARSER_DUMP /* do not print out parser state */
|
||||
|
||||
//#define INCLUDE_ENCODING /* use UTF-8 encoding classes */
|
||||
#undef INCLUDE_ENCODING /* not use encoding classes (ascii only) */
|
||||
|
||||
//#define INCLUDE_REGEXP /* use regular expression classes */
|
||||
#undef INCLUDE_REGEXP /* not use regular expression classes */
|
||||
|
||||
#ifdef INCLUDE_REGEXP
|
||||
# define INCLUDE_ENCODING /* Regexp depends Encoding */
|
||||
/* define ENABLE_XXXX from DISABLE_XXX */
|
||||
#ifndef DISABLE_REGEXP
|
||||
#define ENABLE_REGEXP
|
||||
#endif
|
||||
|
||||
#define INCLUDE_KERNEL_SPRINTF /* not use Kernel.sprintf method */
|
||||
//#undef INCLUDE_KERNEL_SPRINTF /* not use Kernel.sprintf method */
|
||||
|
||||
#define INCLUDE_MATH /* use (non ISO) Math module */
|
||||
//#undef INCLUDE_MATH /* not use (non ISO) Math module */
|
||||
|
||||
#define INCLUDE_TIME /* use Time module */
|
||||
//#undef INCLUDE_TIME /* not use Time module */
|
||||
|
||||
#ifdef MRUBY_DEBUG_BUILD
|
||||
# define PARSER_DUMP
|
||||
#ifndef DISABLE_KERNEL_SPRINTF
|
||||
#define ENABLE_KERNEL_SPRINTF
|
||||
#endif
|
||||
#ifndef DISABLE_MATH
|
||||
#define ENABLE_MATH
|
||||
#endif
|
||||
#ifndef DISABLE_TIME
|
||||
#define ENABLE_TIME
|
||||
#endif
|
||||
|
||||
#undef HAVE_UNISTD_H /* WINDOWS */
|
||||
#define HAVE_UNISTD_H /* LINUX */
|
||||
|
||||
#ifndef FALSE
|
||||
# define FALSE 0
|
||||
|
||||
@@ -40,14 +40,7 @@ mrb_class(mrb_state *mrb, mrb_value v)
|
||||
case MRB_TT_FLOAT:
|
||||
return mrb->float_class;
|
||||
|
||||
#ifdef INCLUDE_REGEXP
|
||||
// case MRB_TT_REGEX:
|
||||
// return mrb->regex_class;
|
||||
// case MRB_TT_MATCH:
|
||||
// return mrb->match_class;
|
||||
// case MRB_TT_DATA:
|
||||
// return mrb->encode_class;
|
||||
#else
|
||||
#ifdef ENABLE_REGEXP
|
||||
case MRB_TT_REGEX:
|
||||
case MRB_TT_MATCH:
|
||||
mrb_raise(mrb, E_TYPE_ERROR, "type mismatch: %s given",
|
||||
|
||||
+3
-3
@@ -8,7 +8,7 @@
|
||||
#include "mruby/dump.h"
|
||||
|
||||
#include "mruby/string.h"
|
||||
#ifdef INCLUDE_REGEXP
|
||||
#ifdef ENABLE_REGEXP
|
||||
#include "re.h"
|
||||
#endif
|
||||
#include "mruby/irep.h"
|
||||
@@ -237,7 +237,7 @@ get_pool_block_size(mrb_state *mrb, mrb_irep *irep, int type)
|
||||
nlen = str_dump_len(RSTRING_PTR(str), RSTRING_LEN(str), type);
|
||||
size += nlen;
|
||||
break;
|
||||
#ifdef INCLUDE_REGEXP
|
||||
#ifdef ENABLE_REGEXP
|
||||
case MRB_TT_REGEX:
|
||||
str = mrb_reg_to_s(mrb, irep->pool[pool_no]);
|
||||
nlen = str_dump_len(RSTRING_PTR(str), RSTRING_LEN(str), type);
|
||||
@@ -365,7 +365,7 @@ write_pool_block(mrb_state *mrb, mrb_irep *irep, char *buf, int type)
|
||||
str_dump(RSTRING_PTR(str), char_buf, RSTRING_LEN(str), type);
|
||||
break;
|
||||
|
||||
#ifdef INCLUDE_REGEXP
|
||||
#ifdef ENABLE_REGEXP
|
||||
case MRB_TT_REGEX:
|
||||
str = mrb_reg_to_s(mrb, irep->pool[pool_no]);
|
||||
nlen = str_dump_len(RSTRING_PTR(str), RSTRING_LEN(str), type);
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
|
||||
*/
|
||||
|
||||
#ifdef INCLUDE_REGEXP
|
||||
#ifdef ENABLE_REGEXP
|
||||
#include "re.h"
|
||||
#endif
|
||||
|
||||
@@ -92,7 +92,7 @@ typedef struct {
|
||||
struct RRange range;
|
||||
struct RStruct structdata;
|
||||
struct RProc procdata;
|
||||
#ifdef INCLUDE_REGEXP
|
||||
#ifdef ENABLE_REGEXP
|
||||
struct RMatch match;
|
||||
struct RRegexp regexp;
|
||||
#endif
|
||||
@@ -412,7 +412,7 @@ gc_mark_children(mrb_state *mrb, struct RBasic *obj)
|
||||
}
|
||||
break;
|
||||
|
||||
#ifdef INCLUDE_REGEXP
|
||||
#ifdef ENABLE_REGEXP
|
||||
case MRB_TT_MATCH:
|
||||
{
|
||||
struct RMatch *m = (struct RMatch*)obj;
|
||||
@@ -611,7 +611,7 @@ gc_gray_mark(mrb_state *mrb, struct RBasic *obj)
|
||||
children+=2;
|
||||
break;
|
||||
|
||||
#ifdef INCLUDE_REGEXP
|
||||
#ifdef ENABLE_REGEXP
|
||||
case MRB_TT_MATCH:
|
||||
children+=2;
|
||||
break;
|
||||
|
||||
+3
-3
@@ -51,15 +51,15 @@ mrb_init_core(mrb_state *mrb)
|
||||
mrb_init_range(mrb);
|
||||
mrb_init_struct(mrb);
|
||||
mrb_init_gc(mrb);
|
||||
#ifdef INCLUDE_REGEXP
|
||||
#ifdef ENABLE_REGEXP
|
||||
mrb_init_regexp(mrb);
|
||||
#endif
|
||||
mrb_init_exception(mrb);
|
||||
mrb_init_print(mrb);
|
||||
#ifdef INCLUDE_TIME
|
||||
#ifdef ENABLE_TIME
|
||||
mrb_init_time(mrb);
|
||||
#endif
|
||||
#ifdef INCLUDE_MATH
|
||||
#ifdef ENABLE_MATH
|
||||
mrb_init_math(mrb);
|
||||
#endif
|
||||
|
||||
|
||||
+2
-2
@@ -8,7 +8,7 @@
|
||||
#include "mruby/dump.h"
|
||||
|
||||
#include "mruby/string.h"
|
||||
#ifdef INCLUDE_REGEXP
|
||||
#ifdef ENABLE_REGEXP
|
||||
#include "re.h"
|
||||
#endif
|
||||
#include "mruby/irep.h"
|
||||
@@ -418,7 +418,7 @@ read_rite_irep_record(mrb_state *mrb, unsigned char *src, mrb_irep *irep, uint32
|
||||
irep->pool[i] = mrb_str_new(mrb, buf, pdl);
|
||||
break;
|
||||
|
||||
#ifdef INCLUDE_REGEXP
|
||||
#ifdef ENABLE_REGEXP
|
||||
case MRB_TT_REGEX:
|
||||
str = mrb_str_new(mrb, buf, pdl);
|
||||
irep->pool[i] = mrb_reg_quote(mrb, str);
|
||||
|
||||
+2
-2
@@ -6,7 +6,7 @@
|
||||
|
||||
#include "mruby.h"
|
||||
|
||||
#ifdef INCLUDE_MATH
|
||||
#ifdef ENABLE_MATH
|
||||
#include <math.h>
|
||||
|
||||
#define domain_error(msg) \
|
||||
@@ -681,4 +681,4 @@ mrb_init_math(mrb_state *mrb)
|
||||
mrb_define_module_function(mrb, mrb_math, "erf", math_erf, ARGS_REQ(1));
|
||||
mrb_define_module_function(mrb, mrb_math, "erfc", math_erfc, ARGS_REQ(1));
|
||||
}
|
||||
#endif /* INCLUDE_MATH */
|
||||
#endif /* ENABLE_MATH */
|
||||
|
||||
@@ -4776,9 +4776,6 @@ mrb_compile_file(mrb_state * mrb, FILE *f)
|
||||
if (!p) return -1;
|
||||
if (!p->tree) return -1;
|
||||
if (p->nerr) return -1;
|
||||
#ifdef PARSER_DUMP
|
||||
parser_dump(mrb, p->tree, 0);
|
||||
#endif
|
||||
n = mrb_generate_code(mrb, p->tree);
|
||||
mrb_pool_close(p->pool);
|
||||
|
||||
@@ -4795,9 +4792,6 @@ mrb_compile_nstring(mrb_state *mrb, char *s, size_t len)
|
||||
if (!p) return -1;
|
||||
if (!p->tree) return -1;
|
||||
if (p->nerr) return -1;
|
||||
#ifdef PARSER_DUMP
|
||||
parser_dump(mrb, p->tree, 0);
|
||||
#endif
|
||||
n = mrb_generate_code(mrb, p->tree);
|
||||
mrb_pool_close(p->pool);
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
#include "regint.h"
|
||||
#include "mruby/class.h"
|
||||
#include "error.h"
|
||||
#ifdef INCLUDE_REGEXP
|
||||
#ifdef ENABLE_REGEXP
|
||||
|
||||
#define REGEX_CLASS (mrb_class_obj_get(mrb, "Regexp"))
|
||||
#define MATCH_CLASS (mrb_class_obj_get(mrb, "MatchData"))
|
||||
@@ -2318,7 +2318,7 @@ mrb_backref_set(mrb_state *mrb, mrb_value val)
|
||||
{
|
||||
vm_svar_set(mrb, 1, val);
|
||||
}
|
||||
#endif //INCLUDE_REGEXP
|
||||
#endif //ENABLE_REGEXP
|
||||
|
||||
#ifdef INCLUDE_ENCODING
|
||||
static inline long
|
||||
@@ -2421,7 +2421,7 @@ mrb_memsearch(mrb_state *mrb, const void *x0, int m, const void *y0, int n, mrb_
|
||||
}
|
||||
#endif //INCLUDE_ENCODING
|
||||
|
||||
#ifdef INCLUDE_REGEXP
|
||||
#ifdef ENABLE_REGEXP
|
||||
mrb_value
|
||||
mrb_reg_init_str(mrb_state *mrb, mrb_value re, mrb_value s, int options)
|
||||
{
|
||||
@@ -2469,7 +2469,7 @@ re_adjust_startpos(struct re_pattern_buffer *bufp, const char *string, int size,
|
||||
}*/
|
||||
return startpos;
|
||||
}
|
||||
#endif //INCLUDE_REGEXP
|
||||
#endif //ENABLE_REGEXP
|
||||
|
||||
#ifdef INCLUDE_ENCODING
|
||||
static const unsigned char mbctab_ascii[] = {
|
||||
|
||||
+4
-4
@@ -30,7 +30,7 @@
|
||||
#include "mruby.h"
|
||||
#include <string.h>
|
||||
#include "regparse.h"
|
||||
#ifdef INCLUDE_REGEXP
|
||||
#ifdef ENABLE_REGEXP
|
||||
|
||||
OnigCaseFoldType OnigDefaultCaseFoldFlag = ONIGENC_CASE_FOLD_MIN;
|
||||
|
||||
@@ -5628,7 +5628,7 @@ onig_end(void)
|
||||
THREAD_SYSTEM_END;
|
||||
return 0;
|
||||
}
|
||||
#endif //INCLUDE_REGEXP
|
||||
#endif //ENABLE_REGEXP
|
||||
|
||||
#ifdef INCLUDE_ENCODING
|
||||
extern int
|
||||
@@ -5653,7 +5653,7 @@ onig_is_in_code_range(const UChar* p, OnigCodePoint code)
|
||||
}
|
||||
#endif //INCLUDE_ENCODING
|
||||
|
||||
#ifdef INCLUDE_REGEXP
|
||||
#ifdef ENABLE_REGEXP
|
||||
extern int
|
||||
onig_is_code_in_cc_len(int elen, OnigCodePoint code, CClassNode* cc)
|
||||
{
|
||||
@@ -6285,4 +6285,4 @@ print_tree(FILE* f, Node* node)
|
||||
print_indent_tree(f, node, 0);
|
||||
}
|
||||
#endif
|
||||
#endif //INCLUDE_REGEXP
|
||||
#endif //ENABLE_REGEXP
|
||||
|
||||
+2
-2
@@ -28,7 +28,7 @@
|
||||
*/
|
||||
|
||||
#include "mruby.h"
|
||||
#ifdef INCLUDE_REGEXP
|
||||
#ifdef ENABLE_REGEXP
|
||||
#include <string.h>
|
||||
#include "regint.h"
|
||||
#include <stdio.h> /* for vsnprintf() */
|
||||
@@ -372,4 +372,4 @@ onig_snprintf_with_pattern(UChar buf[], int bufsize, OnigEncoding enc,
|
||||
pat, pat_end, fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
#endif //INCLUDE_REGEXP
|
||||
#endif //ENABLE_REGEXP
|
||||
|
||||
+2
-2
@@ -28,7 +28,7 @@
|
||||
*/
|
||||
|
||||
#include "mruby.h"
|
||||
#ifdef INCLUDE_REGEXP
|
||||
#ifdef ENABLE_REGEXP
|
||||
#include <string.h>
|
||||
#include "regint.h"
|
||||
|
||||
@@ -3754,4 +3754,4 @@ onig_copy_encoding(OnigEncoding to, OnigEncoding from)
|
||||
{
|
||||
*to = *from;
|
||||
}
|
||||
#endif //INCLUDE_REGEXP
|
||||
#endif //ENABLE_REGEXP
|
||||
|
||||
+4
-4
@@ -32,7 +32,7 @@
|
||||
#include <string.h>
|
||||
#include "regparse.h"
|
||||
#include <stdarg.h>
|
||||
#ifdef INCLUDE_REGEXP
|
||||
#ifdef ENABLE_REGEXP
|
||||
|
||||
#define WARN_BUFSIZE 256
|
||||
|
||||
@@ -298,7 +298,7 @@ strcat_capa_from_static(UChar* dest, UChar* dest_end,
|
||||
onig_strcpy(r + (dest_end - dest), src, src_end);
|
||||
return r;
|
||||
}
|
||||
#endif //INCLUDE_REGEXP
|
||||
#endif //ENABLE_REGEXP
|
||||
|
||||
#ifdef INCLUDE_ENCODING
|
||||
#ifdef USE_ST_LIBRARY
|
||||
@@ -393,7 +393,7 @@ onig_st_insert_strend(hash_table_type* table, const UChar* str_key,
|
||||
#endif /* USE_ST_LIBRARY */
|
||||
#endif //INCLUDE_ENCODING
|
||||
|
||||
#ifdef INCLUDE_REGEXP
|
||||
#ifdef ENABLE_REGEXP
|
||||
#ifdef USE_NAMED_GROUP
|
||||
|
||||
#define INIT_NAME_BACKREFS_ALLOC_NUM 8
|
||||
@@ -5597,4 +5597,4 @@ onig_scan_env_set_error_string(ScanEnv* env, int ecode ARG_UNUSED,
|
||||
env->error = arg;
|
||||
env->error_end = arg_end;
|
||||
}
|
||||
#endif //INCLUDE_REGEXP
|
||||
#endif //ENABLE_REGEXP
|
||||
|
||||
+40
-40
@@ -17,10 +17,10 @@
|
||||
#include "mruby/variable.h"
|
||||
#include <stdio.h>
|
||||
#include "re.h"
|
||||
#ifdef INCLUDE_REGEXP
|
||||
#ifdef ENABLE_REGEXP
|
||||
#include "regex.h"
|
||||
#include "st.h"
|
||||
#endif //INCLUDE_REGEXP
|
||||
#endif //ENABLE_REGEXP
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
@@ -32,9 +32,9 @@
|
||||
|
||||
const char mrb_digitmap[] = "0123456789abcdefghijklmnopqrstuvwxyz";
|
||||
|
||||
#ifdef INCLUDE_REGEXP
|
||||
#ifdef ENABLE_REGEXP
|
||||
static mrb_value get_pat(mrb_state *mrb, mrb_value pat, mrb_int quote);
|
||||
#endif //INCLUDE_REGEXP
|
||||
#endif //ENABLE_REGEXP
|
||||
static mrb_value str_replace(mrb_state *mrb, struct RString *s1, struct RString *s2);
|
||||
static mrb_value mrb_str_subseq(mrb_state *mrb, mrb_value str, int beg, int len);
|
||||
|
||||
@@ -743,12 +743,12 @@ num_index:
|
||||
return str;
|
||||
|
||||
case MRB_TT_REGEX:
|
||||
#ifdef INCLUDE_REGEXP
|
||||
#ifdef ENABLE_REGEXP
|
||||
return mrb_str_subpat(mrb, str, indx, 0); //mrb_str_subpat(str, indx, INT2FIX(0));
|
||||
#else
|
||||
mrb_raise(mrb, E_TYPE_ERROR, "Regexp Class not supported");
|
||||
return mrb_nil_value();
|
||||
#endif //INCLUDE_REGEXP
|
||||
#endif //ENABLE_REGEXP
|
||||
|
||||
case MRB_TT_STRING:
|
||||
if (mrb_str_index(mrb, str, indx, 0) != -1)
|
||||
@@ -835,12 +835,12 @@ mrb_str_aref_m(mrb_state *mrb, mrb_value str)
|
||||
argc = mrb_get_args(mrb, "o|o", &a1, &a2);
|
||||
if (argc == 2) {
|
||||
if (mrb_type(a1) == MRB_TT_REGEX) {
|
||||
#ifdef INCLUDE_REGEXP
|
||||
#ifdef ENABLE_REGEXP
|
||||
return mrb_str_subpat(mrb, str, argv[0], mrb_fixnum(argv[1]));
|
||||
#else
|
||||
mrb_raise(mrb, E_TYPE_ERROR, "Regexp Class not supported");
|
||||
return mrb_nil_value();
|
||||
#endif //INCLUDE_REGEXP
|
||||
#endif //ENABLE_REGEXP
|
||||
}
|
||||
return mrb_str_substr(mrb, str, mrb_fixnum(a1), mrb_fixnum(a2));
|
||||
}
|
||||
@@ -1246,7 +1246,7 @@ mrb_str_buf_append(mrb_state *mrb, mrb_value str, mrb_value str2)
|
||||
return str;
|
||||
}
|
||||
|
||||
#ifdef INCLUDE_REGEXP
|
||||
#ifdef ENABLE_REGEXP
|
||||
static mrb_value
|
||||
str_gsub(mrb_state *mrb, mrb_value str, mrb_int bang)
|
||||
{
|
||||
@@ -1383,7 +1383,7 @@ mrb_str_gsub_bang(mrb_state *mrb, mrb_value self)
|
||||
str_modify(mrb, s);
|
||||
return str_gsub(mrb, s, 1);
|
||||
}
|
||||
#endif //INCLUDE_REGEXP
|
||||
#endif //ENABLE_REGEXP
|
||||
|
||||
mrb_int
|
||||
mrb_str_hash(mrb_state *mrb, mrb_value str)
|
||||
@@ -1506,7 +1506,7 @@ mrb_str_index_m(mrb_state *mrb, mrb_value str)
|
||||
|
||||
switch (mrb_type(sub)) {
|
||||
case MRB_TT_REGEX:
|
||||
#ifdef INCLUDE_REGEXP
|
||||
#ifdef ENABLE_REGEXP
|
||||
if (pos > RSTRING_LEN(str))
|
||||
return mrb_nil_value();
|
||||
pos = mrb_str_offset(mrb, str, pos);
|
||||
@@ -1514,7 +1514,7 @@ mrb_str_index_m(mrb_state *mrb, mrb_value str)
|
||||
pos = mrb_str_sublen(mrb, str, pos);
|
||||
#else
|
||||
mrb_raise(mrb, E_TYPE_ERROR, "Regexp Class not supported");
|
||||
#endif //INCLUDE_REGEXP
|
||||
#endif //ENABLE_REGEXP
|
||||
break;
|
||||
|
||||
case MRB_TT_FIXNUM: {
|
||||
@@ -1668,7 +1668,7 @@ mrb_check_string_type(mrb_state *mrb, mrb_value str)
|
||||
return mrb_check_convert_type(mrb, str, MRB_TT_STRING, "String", "to_str");
|
||||
}
|
||||
|
||||
#ifdef INCLUDE_REGEXP
|
||||
#ifdef ENABLE_REGEXP
|
||||
static mrb_value
|
||||
get_pat(mrb_state *mrb, mrb_value pat, mrb_int quote)
|
||||
{
|
||||
@@ -1696,7 +1696,7 @@ get_pat(mrb_state *mrb, mrb_value pat, mrb_int quote)
|
||||
|
||||
return mrb_reg_regcomp(mrb, pat);
|
||||
}
|
||||
#endif //INCLUDE_REGEXP
|
||||
#endif //ENABLE_REGEXP
|
||||
|
||||
/* 15.2.10.5.27 */
|
||||
/*
|
||||
@@ -1711,7 +1711,7 @@ get_pat(mrb_state *mrb, mrb_value pat, mrb_int quote)
|
||||
* 'hello'.match(/(.)\1/)[0] #=> "ll"
|
||||
* 'hello'.match('xx') #=> nil
|
||||
*/
|
||||
#ifdef INCLUDE_REGEXP
|
||||
#ifdef ENABLE_REGEXP
|
||||
static mrb_value
|
||||
mrb_str_match_m(mrb_state *mrb, mrb_value self)
|
||||
{
|
||||
@@ -1731,7 +1731,7 @@ mrb_str_match_m(mrb_state *mrb, mrb_value self)
|
||||
}
|
||||
return result;
|
||||
}
|
||||
#endif //INCLUDE_REGEXP
|
||||
#endif //ENABLE_REGEXP
|
||||
|
||||
/* ---------------------------------- */
|
||||
/* 15.2.10.5.29 */
|
||||
@@ -1883,11 +1883,11 @@ mrb_str_rindex_m(mrb_state *mrb, mrb_value str)
|
||||
pos += len;
|
||||
if (pos < 0) {
|
||||
if (mrb_type(sub) == MRB_TT_REGEX) {
|
||||
#ifdef INCLUDE_REGEXP
|
||||
#ifdef ENABLE_REGEXP
|
||||
mrb_backref_set(mrb, mrb_nil_value());
|
||||
#else
|
||||
mrb_raise(mrb, E_TYPE_ERROR, "Regexp Class not supported");
|
||||
#endif //INCLUDE_REGEXP
|
||||
#endif //ENABLE_REGEXP
|
||||
}
|
||||
return mrb_nil_value();
|
||||
}
|
||||
@@ -1904,7 +1904,7 @@ mrb_str_rindex_m(mrb_state *mrb, mrb_value str)
|
||||
|
||||
switch (mrb_type(sub)) {
|
||||
case MRB_TT_REGEX:
|
||||
#ifdef INCLUDE_REGEXP
|
||||
#ifdef ENABLE_REGEXP
|
||||
pos = mrb_str_offset(mrb, str, pos);
|
||||
if (!RREGEXP(sub)->ptr || RREGEXP_SRC_LEN(sub)) {
|
||||
pos = mrb_reg_search(mrb, sub, str, pos, 1);
|
||||
@@ -1913,7 +1913,7 @@ mrb_str_rindex_m(mrb_state *mrb, mrb_value str)
|
||||
if (pos >= 0) return mrb_fixnum_value(pos);
|
||||
#else
|
||||
mrb_raise(mrb, E_TYPE_ERROR, "Regexp Class not supported");
|
||||
#endif //INCLUDE_REGEXP
|
||||
#endif //ENABLE_REGEXP
|
||||
break;
|
||||
|
||||
case MRB_TT_FIXNUM: {
|
||||
@@ -1947,7 +1947,7 @@ mrb_str_rindex_m(mrb_state *mrb, mrb_value str)
|
||||
return mrb_nil_value();
|
||||
}
|
||||
|
||||
#ifdef INCLUDE_REGEXP
|
||||
#ifdef ENABLE_REGEXP
|
||||
static mrb_value
|
||||
scan_once(mrb_state *mrb, mrb_value str, mrb_value pat, mrb_int *start)
|
||||
{
|
||||
@@ -1986,7 +1986,7 @@ scan_once(mrb_state *mrb, mrb_value str, mrb_value pat, mrb_int *start)
|
||||
}
|
||||
return mrb_nil_value();
|
||||
}
|
||||
#endif //INCLUDE_REGEXP
|
||||
#endif //ENABLE_REGEXP
|
||||
|
||||
/* 15.2.10.5.32 */
|
||||
/*
|
||||
@@ -2019,7 +2019,7 @@ scan_once(mrb_state *mrb, mrb_value str, mrb_value pat, mrb_int *start)
|
||||
* <<cruel>> <<world>>
|
||||
* rceu lowlr
|
||||
*/
|
||||
#ifdef INCLUDE_REGEXP
|
||||
#ifdef ENABLE_REGEXP
|
||||
static mrb_value
|
||||
mrb_str_scan(mrb_state *mrb, mrb_value str)
|
||||
{
|
||||
@@ -2053,7 +2053,7 @@ mrb_str_scan(mrb_state *mrb, mrb_value str)
|
||||
mrb_backref_set(mrb, match);
|
||||
return str;
|
||||
}
|
||||
#endif //INCLUDE_REGEXP
|
||||
#endif //ENABLE_REGEXP
|
||||
|
||||
static const char isspacetable[256] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0,
|
||||
@@ -2146,28 +2146,28 @@ mrb_str_split_m(mrb_state *mrb, mrb_value str)
|
||||
//fs_set:
|
||||
if (mrb_type(spat) == MRB_TT_STRING) {
|
||||
split_type = string;
|
||||
#ifdef INCLUDE_REGEXP
|
||||
#ifdef ENABLE_REGEXP
|
||||
if (RSTRING_LEN(spat) == 0) {
|
||||
/* Special case - split into chars */
|
||||
spat = mrb_reg_regcomp(mrb, spat);
|
||||
split_type = regexp;
|
||||
}
|
||||
else {
|
||||
#endif //INCLUDE_REGEXP
|
||||
#endif //ENABLE_REGEXP
|
||||
if (RSTRING_LEN(spat) == 1 && RSTRING_PTR(spat)[0] == ' '){
|
||||
split_type = awk;
|
||||
}
|
||||
#ifdef INCLUDE_REGEXP
|
||||
#ifdef ENABLE_REGEXP
|
||||
}
|
||||
#endif //INCLUDE_REGEXP
|
||||
#endif //ENABLE_REGEXP
|
||||
}
|
||||
else {
|
||||
#ifdef INCLUDE_REGEXP
|
||||
#ifdef ENABLE_REGEXP
|
||||
spat = get_pat(mrb, spat, 1);
|
||||
split_type = regexp;
|
||||
#else
|
||||
mrb_raise(mrb, E_TYPE_ERROR, "Regexp Class not supported");
|
||||
#endif //INCLUDE_REGEXP
|
||||
#endif //ENABLE_REGEXP
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2230,7 +2230,7 @@ mrb_str_split_m(mrb_state *mrb, mrb_value str)
|
||||
beg = ptr - temp;
|
||||
}
|
||||
else {
|
||||
#ifdef INCLUDE_REGEXP
|
||||
#ifdef ENABLE_REGEXP
|
||||
char *ptr = RSTRING_PTR(str);
|
||||
long len = RSTRING_LEN(str);
|
||||
long start = beg;
|
||||
@@ -2276,7 +2276,7 @@ mrb_str_split_m(mrb_state *mrb, mrb_value str)
|
||||
}
|
||||
#else
|
||||
mrb_raise(mrb, E_TYPE_ERROR, "Regexp Class not supported");
|
||||
#endif //INCLUDE_REGEXP
|
||||
#endif //ENABLE_REGEXP
|
||||
}
|
||||
if (RSTRING_LEN(str) > 0 && (lim >= 0 || RSTRING_LEN(str) > beg || lim < 0)) {
|
||||
if (RSTRING_LEN(str) == beg)
|
||||
@@ -2314,14 +2314,14 @@ mrb_block_given_p()
|
||||
* returning <i>str</i>, or <code>nil</code> if no substitutions were
|
||||
* performed.
|
||||
*/
|
||||
#ifdef INCLUDE_REGEXP
|
||||
#ifdef ENABLE_REGEXP
|
||||
static mrb_value
|
||||
mrb_str_sub_bang(mrb_state *mrb, mrb_value str)
|
||||
{
|
||||
str_modify(mrb, str);
|
||||
return mrb_nil_value();
|
||||
}
|
||||
#endif //INCLUDE_REGEXP
|
||||
#endif //ENABLE_REGEXP
|
||||
|
||||
/* 15.2.10.5.36 */
|
||||
|
||||
@@ -2362,7 +2362,7 @@ mrb_str_sub_bang(mrb_state *mrb, mrb_value str)
|
||||
* #=> "Is /bin/bash your preferred shell?"
|
||||
*/
|
||||
|
||||
#ifdef INCLUDE_REGEXP
|
||||
#ifdef ENABLE_REGEXP
|
||||
static mrb_value
|
||||
mrb_str_sub(mrb_state *mrb, mrb_value self)
|
||||
{
|
||||
@@ -2371,7 +2371,7 @@ mrb_str_sub(mrb_state *mrb, mrb_value self)
|
||||
mrb_str_sub_bang(mrb, str);
|
||||
return str;
|
||||
}
|
||||
#endif //INCLUDE_REGEXP
|
||||
#endif //ENABLE_REGEXP
|
||||
|
||||
mrb_value
|
||||
mrb_cstr_to_inum(mrb_state *mrb, const char *str, int base, int badcheck)
|
||||
@@ -3030,7 +3030,7 @@ mrb_init_string(mrb_state *mrb)
|
||||
mrb_define_method(mrb, s, "each_line", mrb_str_each_line, ARGS_REQ(1)); /* 15.2.10.5.15 */
|
||||
mrb_define_method(mrb, s, "empty?", mrb_str_empty_p, ARGS_NONE()); /* 15.2.10.5.16 */
|
||||
mrb_define_method(mrb, s, "eql?", mrb_str_eql, ARGS_REQ(1)); /* 15.2.10.5.17 */
|
||||
#ifdef INCLUDE_REGEXP
|
||||
#ifdef ENABLE_REGEXP
|
||||
mrb_define_method(mrb, s, "gsub", mrb_str_gsub, ARGS_REQ(1)); /* 15.2.10.5.18 */
|
||||
mrb_define_method(mrb, s, "gsub!", mrb_str_gsub_bang, ARGS_REQ(1)); /* 15.2.10.5.19 */
|
||||
#endif
|
||||
@@ -3040,19 +3040,19 @@ mrb_init_string(mrb_state *mrb)
|
||||
mrb_define_method(mrb, s, "initialize", mrb_str_init, ARGS_REQ(1)); /* 15.2.10.5.23 */
|
||||
mrb_define_method(mrb, s, "initialize_copy", mrb_str_replace, ARGS_REQ(1)); /* 15.2.10.5.24 */
|
||||
mrb_define_method(mrb, s, "intern", mrb_str_intern, ARGS_NONE()); /* 15.2.10.5.25 */
|
||||
#ifdef INCLUDE_REGEXP
|
||||
#ifdef ENABLE_REGEXP
|
||||
mrb_define_method(mrb, s, "match", mrb_str_match_m, ARGS_REQ(1)); /* 15.2.10.5.27 */
|
||||
#endif
|
||||
mrb_define_method(mrb, s, "replace", mrb_str_replace, ARGS_REQ(1)); /* 15.2.10.5.28 */
|
||||
mrb_define_method(mrb, s, "reverse", mrb_str_reverse, ARGS_NONE()); /* 15.2.10.5.29 */
|
||||
mrb_define_method(mrb, s, "reverse!", mrb_str_reverse_bang, ARGS_NONE()); /* 15.2.10.5.30 */
|
||||
mrb_define_method(mrb, s, "rindex", mrb_str_rindex_m, ARGS_ANY()); /* 15.2.10.5.31 */
|
||||
#ifdef INCLUDE_REGEXP
|
||||
#ifdef ENABLE_REGEXP
|
||||
mrb_define_method(mrb, s, "scan", mrb_str_scan, ARGS_REQ(1)); /* 15.2.10.5.32 */
|
||||
#endif
|
||||
mrb_define_method(mrb, s, "slice", mrb_str_aref_m, ARGS_ANY()); /* 15.2.10.5.34 */
|
||||
mrb_define_method(mrb, s, "split", mrb_str_split_m, ARGS_ANY()); /* 15.2.10.5.35 */
|
||||
#ifdef INCLUDE_REGEXP
|
||||
#ifdef ENABLE_REGEXP
|
||||
mrb_define_method(mrb, s, "sub", mrb_str_sub, ARGS_REQ(1)); /* 15.2.10.5.36 */
|
||||
mrb_define_method(mrb, s, "sub!", mrb_str_sub_bang, ARGS_REQ(1)); /* 15.2.10.5.37 */
|
||||
#endif
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@
|
||||
#include <stdarg.h>
|
||||
//#include "defines.h"
|
||||
|
||||
#ifdef INCLUDE_REGEXP
|
||||
#ifdef ENABLE_REGEXP
|
||||
#include "encoding.h"
|
||||
#endif
|
||||
|
||||
|
||||
+1
-2
@@ -6,7 +6,7 @@
|
||||
|
||||
|
||||
#include "mruby.h"
|
||||
#ifdef INCLUDE_TIME
|
||||
#ifdef ENABLE_TIME
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
@@ -744,4 +744,3 @@ mrb_init_time(mrb_state *mrb)
|
||||
*/
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@
|
||||
#include "error.h"
|
||||
#include "mruby/array.h"
|
||||
|
||||
#ifdef INCLUDE_REGEXP
|
||||
#ifdef ENABLE_REGEXP
|
||||
#include "re.h"
|
||||
#include "st.h"
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user