Commit 76f7aecf authored by Yukihiro Matsumoto's avatar Yukihiro Matsumoto

use ENABLE/DISABLE instead of INCLUDE for configuration macro names

parent 4aa9111f
...@@ -8,8 +8,21 @@ ...@@ -8,8 +8,21 @@
#define MRUBYCONF_H #define MRUBYCONF_H
#include <stdint.h> #include <stdint.h>
/* configuration options: */
/* add -DMRB_USE_FLOAT to use float instead of double for floating point numbers */
#undef MRB_USE_FLOAT #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 #ifdef MRB_USE_FLOAT
typedef float mrb_float; typedef float mrb_float;
#else #else
...@@ -20,34 +33,19 @@ typedef double mrb_float; ...@@ -20,34 +33,19 @@ typedef double mrb_float;
typedef int mrb_int; typedef int mrb_int;
typedef intptr_t mrb_sym; typedef intptr_t mrb_sym;
//#define PARSER_DUMP /* print out parser state */ /* define ENABLE_XXXX from DISABLE_XXX */
#undef PARSER_DUMP /* do not print out parser state */ #ifndef DISABLE_REGEXP
#define ENABLE_REGEXP
//#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 */
#endif #endif
#ifndef DISABLE_KERNEL_SPRINTF
#define INCLUDE_KERNEL_SPRINTF /* not use Kernel.sprintf method */ #define ENABLE_KERNEL_SPRINTF
//#undef INCLUDE_KERNEL_SPRINTF /* not use Kernel.sprintf method */ #endif
#ifndef DISABLE_MATH
#define INCLUDE_MATH /* use (non ISO) Math module */ #define ENABLE_MATH
//#undef INCLUDE_MATH /* not use (non ISO) Math module */ #endif
#ifndef DISABLE_TIME
#define INCLUDE_TIME /* use Time module */ #define ENABLE_TIME
//#undef INCLUDE_TIME /* not use Time module */
#ifdef MRUBY_DEBUG_BUILD
# define PARSER_DUMP
#endif #endif
#undef HAVE_UNISTD_H /* WINDOWS */
#define HAVE_UNISTD_H /* LINUX */
#ifndef FALSE #ifndef FALSE
# define FALSE 0 # define FALSE 0
......
...@@ -40,14 +40,7 @@ mrb_class(mrb_state *mrb, mrb_value v) ...@@ -40,14 +40,7 @@ mrb_class(mrb_state *mrb, mrb_value v)
case MRB_TT_FLOAT: case MRB_TT_FLOAT:
return mrb->float_class; return mrb->float_class;
#ifdef INCLUDE_REGEXP #ifdef ENABLE_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
case MRB_TT_REGEX: case MRB_TT_REGEX:
case MRB_TT_MATCH: case MRB_TT_MATCH:
mrb_raise(mrb, E_TYPE_ERROR, "type mismatch: %s given", mrb_raise(mrb, E_TYPE_ERROR, "type mismatch: %s given",
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "mruby/dump.h" #include "mruby/dump.h"
#include "mruby/string.h" #include "mruby/string.h"
#ifdef INCLUDE_REGEXP #ifdef ENABLE_REGEXP
#include "re.h" #include "re.h"
#endif #endif
#include "mruby/irep.h" #include "mruby/irep.h"
...@@ -237,7 +237,7 @@ get_pool_block_size(mrb_state *mrb, mrb_irep *irep, int type) ...@@ -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); nlen = str_dump_len(RSTRING_PTR(str), RSTRING_LEN(str), type);
size += nlen; size += nlen;
break; break;
#ifdef INCLUDE_REGEXP #ifdef ENABLE_REGEXP
case MRB_TT_REGEX: case MRB_TT_REGEX:
str = mrb_reg_to_s(mrb, irep->pool[pool_no]); str = mrb_reg_to_s(mrb, irep->pool[pool_no]);
nlen = str_dump_len(RSTRING_PTR(str), RSTRING_LEN(str), type); 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) ...@@ -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); str_dump(RSTRING_PTR(str), char_buf, RSTRING_LEN(str), type);
break; break;
#ifdef INCLUDE_REGEXP #ifdef ENABLE_REGEXP
case MRB_TT_REGEX: case MRB_TT_REGEX:
str = mrb_reg_to_s(mrb, irep->pool[pool_no]); str = mrb_reg_to_s(mrb, irep->pool[pool_no]);
nlen = str_dump_len(RSTRING_PTR(str), RSTRING_LEN(str), type); nlen = str_dump_len(RSTRING_PTR(str), RSTRING_LEN(str), type);
......
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
*/ */
#ifdef INCLUDE_REGEXP #ifdef ENABLE_REGEXP
#include "re.h" #include "re.h"
#endif #endif
...@@ -92,7 +92,7 @@ typedef struct { ...@@ -92,7 +92,7 @@ typedef struct {
struct RRange range; struct RRange range;
struct RStruct structdata; struct RStruct structdata;
struct RProc procdata; struct RProc procdata;
#ifdef INCLUDE_REGEXP #ifdef ENABLE_REGEXP
struct RMatch match; struct RMatch match;
struct RRegexp regexp; struct RRegexp regexp;
#endif #endif
...@@ -412,7 +412,7 @@ gc_mark_children(mrb_state *mrb, struct RBasic *obj) ...@@ -412,7 +412,7 @@ gc_mark_children(mrb_state *mrb, struct RBasic *obj)
} }
break; break;
#ifdef INCLUDE_REGEXP #ifdef ENABLE_REGEXP
case MRB_TT_MATCH: case MRB_TT_MATCH:
{ {
struct RMatch *m = (struct RMatch*)obj; struct RMatch *m = (struct RMatch*)obj;
...@@ -611,7 +611,7 @@ gc_gray_mark(mrb_state *mrb, struct RBasic *obj) ...@@ -611,7 +611,7 @@ gc_gray_mark(mrb_state *mrb, struct RBasic *obj)
children+=2; children+=2;
break; break;
#ifdef INCLUDE_REGEXP #ifdef ENABLE_REGEXP
case MRB_TT_MATCH: case MRB_TT_MATCH:
children+=2; children+=2;
break; break;
......
...@@ -51,15 +51,15 @@ mrb_init_core(mrb_state *mrb) ...@@ -51,15 +51,15 @@ mrb_init_core(mrb_state *mrb)
mrb_init_range(mrb); mrb_init_range(mrb);
mrb_init_struct(mrb); mrb_init_struct(mrb);
mrb_init_gc(mrb); mrb_init_gc(mrb);
#ifdef INCLUDE_REGEXP #ifdef ENABLE_REGEXP
mrb_init_regexp(mrb); mrb_init_regexp(mrb);
#endif #endif
mrb_init_exception(mrb); mrb_init_exception(mrb);
mrb_init_print(mrb); mrb_init_print(mrb);
#ifdef INCLUDE_TIME #ifdef ENABLE_TIME
mrb_init_time(mrb); mrb_init_time(mrb);
#endif #endif
#ifdef INCLUDE_MATH #ifdef ENABLE_MATH
mrb_init_math(mrb); mrb_init_math(mrb);
#endif #endif
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "mruby/dump.h" #include "mruby/dump.h"
#include "mruby/string.h" #include "mruby/string.h"
#ifdef INCLUDE_REGEXP #ifdef ENABLE_REGEXP
#include "re.h" #include "re.h"
#endif #endif
#include "mruby/irep.h" #include "mruby/irep.h"
...@@ -418,7 +418,7 @@ read_rite_irep_record(mrb_state *mrb, unsigned char *src, mrb_irep *irep, uint32 ...@@ -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); irep->pool[i] = mrb_str_new(mrb, buf, pdl);
break; break;
#ifdef INCLUDE_REGEXP #ifdef ENABLE_REGEXP
case MRB_TT_REGEX: case MRB_TT_REGEX:
str = mrb_str_new(mrb, buf, pdl); str = mrb_str_new(mrb, buf, pdl);
irep->pool[i] = mrb_reg_quote(mrb, str); irep->pool[i] = mrb_reg_quote(mrb, str);
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include "mruby.h" #include "mruby.h"
#ifdef INCLUDE_MATH #ifdef ENABLE_MATH
#include <math.h> #include <math.h>
#define domain_error(msg) \ #define domain_error(msg) \
...@@ -681,4 +681,4 @@ mrb_init_math(mrb_state *mrb) ...@@ -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, "erf", math_erf, ARGS_REQ(1));
mrb_define_module_function(mrb, mrb_math, "erfc", math_erfc, 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) ...@@ -4776,9 +4776,6 @@ mrb_compile_file(mrb_state * mrb, FILE *f)
if (!p) return -1; if (!p) return -1;
if (!p->tree) return -1; if (!p->tree) return -1;
if (p->nerr) return -1; if (p->nerr) return -1;
#ifdef PARSER_DUMP
parser_dump(mrb, p->tree, 0);
#endif
n = mrb_generate_code(mrb, p->tree); n = mrb_generate_code(mrb, p->tree);
mrb_pool_close(p->pool); mrb_pool_close(p->pool);
...@@ -4795,9 +4792,6 @@ mrb_compile_nstring(mrb_state *mrb, char *s, size_t len) ...@@ -4795,9 +4792,6 @@ mrb_compile_nstring(mrb_state *mrb, char *s, size_t len)
if (!p) return -1; if (!p) return -1;
if (!p->tree) return -1; if (!p->tree) return -1;
if (p->nerr) return -1; if (p->nerr) return -1;
#ifdef PARSER_DUMP
parser_dump(mrb, p->tree, 0);
#endif
n = mrb_generate_code(mrb, p->tree); n = mrb_generate_code(mrb, p->tree);
mrb_pool_close(p->pool); mrb_pool_close(p->pool);
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#include "regint.h" #include "regint.h"
#include "mruby/class.h" #include "mruby/class.h"
#include "error.h" #include "error.h"
#ifdef INCLUDE_REGEXP #ifdef ENABLE_REGEXP
#define REGEX_CLASS (mrb_class_obj_get(mrb, "Regexp")) #define REGEX_CLASS (mrb_class_obj_get(mrb, "Regexp"))
#define MATCH_CLASS (mrb_class_obj_get(mrb, "MatchData")) #define MATCH_CLASS (mrb_class_obj_get(mrb, "MatchData"))
...@@ -2318,7 +2318,7 @@ mrb_backref_set(mrb_state *mrb, mrb_value val) ...@@ -2318,7 +2318,7 @@ mrb_backref_set(mrb_state *mrb, mrb_value val)
{ {
vm_svar_set(mrb, 1, val); vm_svar_set(mrb, 1, val);
} }
#endif //INCLUDE_REGEXP #endif //ENABLE_REGEXP
#ifdef INCLUDE_ENCODING #ifdef INCLUDE_ENCODING
static inline long static inline long
...@@ -2421,7 +2421,7 @@ mrb_memsearch(mrb_state *mrb, const void *x0, int m, const void *y0, int n, mrb_ ...@@ -2421,7 +2421,7 @@ mrb_memsearch(mrb_state *mrb, const void *x0, int m, const void *y0, int n, mrb_
} }
#endif //INCLUDE_ENCODING #endif //INCLUDE_ENCODING
#ifdef INCLUDE_REGEXP #ifdef ENABLE_REGEXP
mrb_value mrb_value
mrb_reg_init_str(mrb_state *mrb, mrb_value re, mrb_value s, int options) 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, ...@@ -2469,7 +2469,7 @@ re_adjust_startpos(struct re_pattern_buffer *bufp, const char *string, int size,
}*/ }*/
return startpos; return startpos;
} }
#endif //INCLUDE_REGEXP #endif //ENABLE_REGEXP
#ifdef INCLUDE_ENCODING #ifdef INCLUDE_ENCODING
static const unsigned char mbctab_ascii[] = { static const unsigned char mbctab_ascii[] = {
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#include "mruby.h" #include "mruby.h"
#include <string.h> #include <string.h>
#include "regparse.h" #include "regparse.h"
#ifdef INCLUDE_REGEXP #ifdef ENABLE_REGEXP
OnigCaseFoldType OnigDefaultCaseFoldFlag = ONIGENC_CASE_FOLD_MIN; OnigCaseFoldType OnigDefaultCaseFoldFlag = ONIGENC_CASE_FOLD_MIN;
...@@ -5628,7 +5628,7 @@ onig_end(void) ...@@ -5628,7 +5628,7 @@ onig_end(void)
THREAD_SYSTEM_END; THREAD_SYSTEM_END;
return 0; return 0;
} }
#endif //INCLUDE_REGEXP #endif //ENABLE_REGEXP
#ifdef INCLUDE_ENCODING #ifdef INCLUDE_ENCODING
extern int extern int
...@@ -5653,7 +5653,7 @@ onig_is_in_code_range(const UChar* p, OnigCodePoint code) ...@@ -5653,7 +5653,7 @@ onig_is_in_code_range(const UChar* p, OnigCodePoint code)
} }
#endif //INCLUDE_ENCODING #endif //INCLUDE_ENCODING
#ifdef INCLUDE_REGEXP #ifdef ENABLE_REGEXP
extern int extern int
onig_is_code_in_cc_len(int elen, OnigCodePoint code, CClassNode* cc) onig_is_code_in_cc_len(int elen, OnigCodePoint code, CClassNode* cc)
{ {
...@@ -6285,4 +6285,4 @@ print_tree(FILE* f, Node* node) ...@@ -6285,4 +6285,4 @@ print_tree(FILE* f, Node* node)
print_indent_tree(f, node, 0); print_indent_tree(f, node, 0);
} }
#endif #endif
#endif //INCLUDE_REGEXP #endif //ENABLE_REGEXP
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
*/ */
#include "mruby.h" #include "mruby.h"
#ifdef INCLUDE_REGEXP #ifdef ENABLE_REGEXP
#include <string.h> #include <string.h>
#include "regint.h" #include "regint.h"
#include <stdio.h> /* for vsnprintf() */ #include <stdio.h> /* for vsnprintf() */
...@@ -372,4 +372,4 @@ onig_snprintf_with_pattern(UChar buf[], int bufsize, OnigEncoding enc, ...@@ -372,4 +372,4 @@ onig_snprintf_with_pattern(UChar buf[], int bufsize, OnigEncoding enc,
pat, pat_end, fmt, args); pat, pat_end, fmt, args);
va_end(args); va_end(args);
} }
#endif //INCLUDE_REGEXP #endif //ENABLE_REGEXP
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
*/ */
#include "mruby.h" #include "mruby.h"
#ifdef INCLUDE_REGEXP #ifdef ENABLE_REGEXP
#include <string.h> #include <string.h>
#include "regint.h" #include "regint.h"
...@@ -3754,4 +3754,4 @@ onig_copy_encoding(OnigEncoding to, OnigEncoding from) ...@@ -3754,4 +3754,4 @@ onig_copy_encoding(OnigEncoding to, OnigEncoding from)
{ {
*to = *from; *to = *from;
} }
#endif //INCLUDE_REGEXP #endif //ENABLE_REGEXP
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#include <string.h> #include <string.h>
#include "regparse.h" #include "regparse.h"
#include <stdarg.h> #include <stdarg.h>
#ifdef INCLUDE_REGEXP #ifdef ENABLE_REGEXP
#define WARN_BUFSIZE 256 #define WARN_BUFSIZE 256
...@@ -298,7 +298,7 @@ strcat_capa_from_static(UChar* dest, UChar* dest_end, ...@@ -298,7 +298,7 @@ strcat_capa_from_static(UChar* dest, UChar* dest_end,
onig_strcpy(r + (dest_end - dest), src, src_end); onig_strcpy(r + (dest_end - dest), src, src_end);
return r; return r;
} }
#endif //INCLUDE_REGEXP #endif //ENABLE_REGEXP
#ifdef INCLUDE_ENCODING #ifdef INCLUDE_ENCODING
#ifdef USE_ST_LIBRARY #ifdef USE_ST_LIBRARY
...@@ -393,7 +393,7 @@ onig_st_insert_strend(hash_table_type* table, const UChar* str_key, ...@@ -393,7 +393,7 @@ onig_st_insert_strend(hash_table_type* table, const UChar* str_key,
#endif /* USE_ST_LIBRARY */ #endif /* USE_ST_LIBRARY */
#endif //INCLUDE_ENCODING #endif //INCLUDE_ENCODING
#ifdef INCLUDE_REGEXP #ifdef ENABLE_REGEXP
#ifdef USE_NAMED_GROUP #ifdef USE_NAMED_GROUP
#define INIT_NAME_BACKREFS_ALLOC_NUM 8 #define INIT_NAME_BACKREFS_ALLOC_NUM 8
...@@ -5597,4 +5597,4 @@ onig_scan_env_set_error_string(ScanEnv* env, int ecode ARG_UNUSED, ...@@ -5597,4 +5597,4 @@ onig_scan_env_set_error_string(ScanEnv* env, int ecode ARG_UNUSED,
env->error = arg; env->error = arg;
env->error_end = arg_end; env->error_end = arg_end;
} }
#endif //INCLUDE_REGEXP #endif //ENABLE_REGEXP
This diff is collapsed.
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include <stdarg.h> #include <stdarg.h>
//#include "defines.h" //#include "defines.h"
#ifdef INCLUDE_REGEXP #ifdef ENABLE_REGEXP
#include "encoding.h" #include "encoding.h"
#endif #endif
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include "mruby.h" #include "mruby.h"
#ifdef INCLUDE_TIME #ifdef ENABLE_TIME
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <time.h> #include <time.h>
...@@ -744,4 +744,3 @@ mrb_init_time(mrb_state *mrb) ...@@ -744,4 +744,3 @@ mrb_init_time(mrb_state *mrb)
*/ */
} }
#endif #endif
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include "error.h" #include "error.h"
#include "mruby/array.h" #include "mruby/array.h"
#ifdef INCLUDE_REGEXP #ifdef ENABLE_REGEXP
#include "re.h" #include "re.h"
#include "st.h" #include "st.h"
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment