ext/extzstd.c in extzstd-0.2 vs ext/extzstd.c in extzstd-0.3
- old
+ new
@@ -77,17 +77,19 @@
extzstd_make_errorf(ssize_t errcode, const char *fmt, ...)
{
VALUE e;
if (fmt && strlen(fmt) > 0) {
+ VALUE args[] = { SSIZET2NUM(errcode), Qnil };
va_list va;
va_start(va, fmt);
- VALUE mesg = rb_vsprintf(fmt, va);
+ args[1] = rb_vsprintf(fmt, va);
va_end(va);
- return AUX_FUNCALL(extzstd_eError, id_initialize, SSIZET2NUM(errcode), mesg);
+ return rb_class_new_instance(2, args, extzstd_eError);
} else {
- return AUX_FUNCALL(extzstd_eError, id_initialize, SSIZET2NUM(errcode));
+ VALUE args[] = { SSIZET2NUM(errcode) };
+ return rb_class_new_instance(1, args, extzstd_eError);
}
}
VALUE
extzstd_make_error(ssize_t errcode)
@@ -156,45 +158,47 @@
rb_define_const(mConstants, "ZSTD_LAZY", INT2NUM(ZSTD_lazy));
rb_define_const(mConstants, "ZSTD_LAZY2", INT2NUM(ZSTD_lazy2));
rb_define_const(mConstants, "ZSTD_BTLAZY2", INT2NUM(ZSTD_btlazy2));
rb_define_const(mConstants, "ZSTD_BTOPT", INT2NUM(ZSTD_btopt));
rb_define_const(mConstants, "ZSTD_BTULTRA", INT2NUM(ZSTD_btultra));
+ rb_define_const(mConstants, "ZSTD_BTULTRA2", INT2NUM(ZSTD_btultra2));
rb_define_const(mConstants, "ZSTD_WINDOWLOG_MAX", INT2NUM(ZSTD_WINDOWLOG_MAX));
rb_define_const(mConstants, "ZSTD_WINDOWLOG_MIN", INT2NUM(ZSTD_WINDOWLOG_MIN));
rb_define_const(mConstants, "ZSTD_HASHLOG_MAX", INT2NUM(ZSTD_HASHLOG_MAX));
rb_define_const(mConstants, "ZSTD_HASHLOG_MIN", INT2NUM(ZSTD_HASHLOG_MIN));
rb_define_const(mConstants, "ZSTD_CHAINLOG_MAX", INT2NUM(ZSTD_CHAINLOG_MAX));
rb_define_const(mConstants, "ZSTD_CHAINLOG_MIN", INT2NUM(ZSTD_CHAINLOG_MIN));
rb_define_const(mConstants, "ZSTD_HASHLOG3_MAX", INT2NUM(ZSTD_HASHLOG3_MAX));
rb_define_const(mConstants, "ZSTD_SEARCHLOG_MAX", INT2NUM(ZSTD_SEARCHLOG_MAX));
rb_define_const(mConstants, "ZSTD_SEARCHLOG_MIN", INT2NUM(ZSTD_SEARCHLOG_MIN));
- rb_define_const(mConstants, "ZSTD_SEARCHLENGTH_MAX", INT2NUM(ZSTD_SEARCHLENGTH_MAX));
- rb_define_const(mConstants, "ZSTD_SEARCHLENGTH_MIN", INT2NUM(ZSTD_SEARCHLENGTH_MIN));
- rb_define_const(mConstants, "ZSTD_TARGETLENGTH_MAX", INT2NUM(ZSTD_TARGETLENGTH_MAX));
- rb_define_const(mConstants, "ZSTD_TARGETLENGTH_MIN", INT2NUM(ZSTD_TARGETLENGTH_MIN));
+ //rb_define_const(mConstants, "ZSTD_SEARCHLENGTH_MAX", INT2NUM(ZSTD_SEARCHLENGTH_MAX));
+ //rb_define_const(mConstants, "ZSTD_SEARCHLENGTH_MIN", INT2NUM(ZSTD_SEARCHLENGTH_MIN));
+ //rb_define_const(mConstants, "ZSTD_TARGETLENGTH_MAX", INT2NUM(ZSTD_TARGETLENGTH_MAX));
+ //rb_define_const(mConstants, "ZSTD_TARGETLENGTH_MIN", INT2NUM(ZSTD_TARGETLENGTH_MIN));
rb_define_const(mConstants, "FAST", INT2NUM(ZSTD_fast));
rb_define_const(mConstants, "DFAST", INT2NUM(ZSTD_dfast));
rb_define_const(mConstants, "GREEDY", INT2NUM(ZSTD_greedy));
rb_define_const(mConstants, "LAZY", INT2NUM(ZSTD_lazy));
rb_define_const(mConstants, "LAZY2", INT2NUM(ZSTD_lazy2));
rb_define_const(mConstants, "BTLAZY2", INT2NUM(ZSTD_btlazy2));
rb_define_const(mConstants, "BTOPT", INT2NUM(ZSTD_btopt));
rb_define_const(mConstants, "BTULTRA", INT2NUM(ZSTD_btultra));
+ rb_define_const(mConstants, "BTULTRA2", INT2NUM(ZSTD_btultra2));
rb_define_const(mConstants, "WINDOWLOG_MAX", INT2NUM(ZSTD_WINDOWLOG_MAX));
rb_define_const(mConstants, "WINDOWLOG_MIN", INT2NUM(ZSTD_WINDOWLOG_MIN));
rb_define_const(mConstants, "HASHLOG_MAX", INT2NUM(ZSTD_HASHLOG_MAX));
rb_define_const(mConstants, "HASHLOG_MIN", INT2NUM(ZSTD_HASHLOG_MIN));
rb_define_const(mConstants, "CHAINLOG_MAX", INT2NUM(ZSTD_CHAINLOG_MAX));
rb_define_const(mConstants, "CHAINLOG_MIN", INT2NUM(ZSTD_CHAINLOG_MIN));
rb_define_const(mConstants, "HASHLOG3_MAX", INT2NUM(ZSTD_HASHLOG3_MAX));
rb_define_const(mConstants, "SEARCHLOG_MAX", INT2NUM(ZSTD_SEARCHLOG_MAX));
rb_define_const(mConstants, "SEARCHLOG_MIN", INT2NUM(ZSTD_SEARCHLOG_MIN));
- rb_define_const(mConstants, "SEARCHLENGTH_MAX", INT2NUM(ZSTD_SEARCHLENGTH_MAX));
- rb_define_const(mConstants, "SEARCHLENGTH_MIN", INT2NUM(ZSTD_SEARCHLENGTH_MIN));
- rb_define_const(mConstants, "TARGETLENGTH_MAX", INT2NUM(ZSTD_TARGETLENGTH_MAX));
- rb_define_const(mConstants, "TARGETLENGTH_MIN", INT2NUM(ZSTD_TARGETLENGTH_MIN));
+ //rb_define_const(mConstants, "SEARCHLENGTH_MAX", INT2NUM(ZSTD_SEARCHLENGTH_MAX));
+ //rb_define_const(mConstants, "SEARCHLENGTH_MIN", INT2NUM(ZSTD_SEARCHLENGTH_MIN));
+ //rb_define_const(mConstants, "TARGETLENGTH_MAX", INT2NUM(ZSTD_TARGETLENGTH_MAX));
+ //rb_define_const(mConstants, "TARGETLENGTH_MIN", INT2NUM(ZSTD_TARGETLENGTH_MIN));
}
/*
* class Zstd::EncodeParameter
*/
@@ -241,11 +245,11 @@
* [srcsize_hint = 0]
* [opts windowlog: nil]
* [opts contentlog: nil]
* [opts hashlog: nil]
* [opts searchlog: nil]
- * [opts searchlength: nil]
+ * [opts minmatch: nil]
* [opts targetlength: nil]
* [opts strategy: nil]
*/
static VALUE
params_init(int argc, VALUE argv[], VALUE v)
@@ -274,13 +278,16 @@
SETUP_PARAM(p->cParams.windowLog, opts, "windowlog", NUM2UINT);
SETUP_PARAM(p->cParams.chainLog, opts, "chainlog", NUM2UINT);
SETUP_PARAM(p->cParams.hashLog, opts, "hashlog", NUM2UINT);
SETUP_PARAM(p->cParams.searchLog, opts, "searchlog", NUM2UINT);
- SETUP_PARAM(p->cParams.searchLength, opts, "searchlength", NUM2UINT);
+ SETUP_PARAM(p->cParams.minMatch, opts, "minmatch", NUM2UINT);
SETUP_PARAM(p->cParams.targetLength, opts, "targetlength", NUM2UINT);
SETUP_PARAM(p->cParams.strategy, opts, "strategy", NUM2UINT);
+ SETUP_PARAM(p->fParams.contentSizeFlag, opts, "contentsize", RTEST);
+ SETUP_PARAM(p->fParams.checksumFlag, opts, "checksum", RTEST);
+ SETUP_PARAM(p->fParams.noDictIDFlag, opts, "nodictid", RTEST);
#undef SETUP_PARAM
}
return v;
}
@@ -320,11 +327,11 @@
//IMP_PARAMS(params_srcsize, params_set_srcsize, srcSize);
IMP_PARAMS(params_windowlog, params_set_windowlog, windowLog);
IMP_PARAMS(params_chainlog, params_set_chainlog, chainLog);
IMP_PARAMS(params_hashlog, params_set_hashlog, hashLog);
IMP_PARAMS(params_searchlog, params_set_searchlog, searchLog);
-IMP_PARAMS(params_searchlength, params_set_searchlength, searchLength);
+IMP_PARAMS(params_minmatch, params_set_minmatch, minMatch);
IMP_PARAMS(params_targetlength, params_set_targetlength, targetLength);
IMP_PARAMS(params_strategy, params_set_strategy, strategy);
#undef IMP_PARAMS
@@ -373,12 +380,12 @@
* Document-method: Zstd::Parameters#chainlog=
* Document-method: Zstd::Parameters#hashlog
* Document-method: Zstd::Parameters#hashlog=
* Document-method: Zstd::Parameters#searchlog
* Document-method: Zstd::Parameters#searchlog=
- * Document-method: Zstd::Parameters#searchlength
- * Document-method: Zstd::Parameters#searchlength=
+ * Document-method: Zstd::Parameters#minmatch
+ * Document-method: Zstd::Parameters#minmatch=
* Document-method: Zstd::Parameters#targetlength
* Document-method: Zstd::Parameters#targetlength=
* Document-method: Zstd::Parameters#strategy
* Document-method: Zstd::Parameters#strategy=
*
@@ -401,12 +408,12 @@
rb_define_method(extzstd_cParams, "chainlog=", RUBY_METHOD_FUNC(params_set_chainlog), 1);
rb_define_method(extzstd_cParams, "hashlog", RUBY_METHOD_FUNC(params_hashlog), 0);
rb_define_method(extzstd_cParams, "hashlog=", RUBY_METHOD_FUNC(params_set_hashlog), 1);
rb_define_method(extzstd_cParams, "searchlog", RUBY_METHOD_FUNC(params_searchlog), 0);
rb_define_method(extzstd_cParams, "searchlog=", RUBY_METHOD_FUNC(params_set_searchlog), 1);
- rb_define_method(extzstd_cParams, "searchlength", RUBY_METHOD_FUNC(params_searchlength), 0);
- rb_define_method(extzstd_cParams, "searchlength=", RUBY_METHOD_FUNC(params_set_searchlength), 1);
+ rb_define_method(extzstd_cParams, "minmatch", RUBY_METHOD_FUNC(params_minmatch), 0);
+ rb_define_method(extzstd_cParams, "minmatch=", RUBY_METHOD_FUNC(params_set_minmatch), 1);
rb_define_method(extzstd_cParams, "targetlength", RUBY_METHOD_FUNC(params_targetlength), 0);
rb_define_method(extzstd_cParams, "targetlength=", RUBY_METHOD_FUNC(params_set_targetlength), 1);
rb_define_method(extzstd_cParams, "strategy", RUBY_METHOD_FUNC(params_strategy), 0);
rb_define_method(extzstd_cParams, "strategy=", RUBY_METHOD_FUNC(params_set_strategy), 1);
@@ -430,10 +437,11 @@
{
rb_check_type(src, RUBY_T_STRING);
size_t capa = NUM2SIZET(dict_capacity);
VALUE dict = rb_str_buf_new(capa);
size_t srcsize = RSTRING_LEN(src);
- size_t s = ZDICT_trainFromBuffer(RSTRING_PTR(dict), capa, RSTRING_PTR(src), &srcsize, 1);
+ const ZDICT_legacy_params_t params = { 0 };
+ size_t s = ZDICT_trainFromBuffer_legacy(RSTRING_PTR(dict), capa, RSTRING_PTR(src), &srcsize, 1, params);
extzstd_check_error(s);
rb_str_set_len(dict, s);
return dict;
}