| 1 |
|
| #include "xh_config.h" |
| 2 |
|
| #include "xh_core.h" |
| 3 |
|
| |
| 4 |
|
| static void |
| 5 |
3077 |
| xh_assign_cb_mode(xh_opts_t *opts, SV *value) |
| 6 |
|
| { |
| 7 |
|
| xh_char_t *mode; |
| 8 |
|
| STRLEN len; |
| 9 |
|
| |
| 10 |
3077 |
▶ | if (!SvOK(value)) |
Branch: 1 branch
| Branch | True | False | Total |
| if (!SvOK(value)) |
0 |
3077 |
3077 |
|
| 11 |
0 |
| croak("Parameter 'cb_mode' is undefined"); |
| 12 |
|
| |
| 13 |
3077 |
| mode = XH_CHAR_CAST SvPV(value, len); |
| 14 |
3077 |
▶ | if (len == 4 && xh_strncmp(mode, XH_CHAR_CAST "node", 4) == 0) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (len == 4 && xh_strncmp(mode, XH_CHAR_CAST "node", 4) == 0) { |
3071 |
6 |
3077 |
| if (len == 4 && xh_strncmp(mode, XH_CHAR_CAST "node", 4) == 0) { |
3071 |
0 |
3071 |
|
| 15 |
3071 |
| opts->cb_mode = XH_CB_MODE_NODE; |
| 16 |
|
| } |
| 17 |
6 |
▶ | else if (len == 6 && xh_strncmp(mode, XH_CHAR_CAST "events", 6) == 0) { |
Branch: 2 branches
| Branch | True | False | Total |
| else if (len == 6 && xh_strncmp(mode, XH_CHAR_CAST "events", 6) == 0) { |
5 |
1 |
6 |
| else if (len == 6 && xh_strncmp(mode, XH_CHAR_CAST "events", 6) == 0) { |
5 |
0 |
5 |
|
| 18 |
5 |
| opts->cb_mode = XH_CB_MODE_EVENTS; |
| 19 |
|
| } |
| 20 |
|
| else { |
| 21 |
1 |
| croak("Invalid parameter value for 'cb_mode': %s", mode); |
| 22 |
|
| } |
| 23 |
3076 |
| } |
| 24 |
|
| |
| 25 |
|
| xh_bool_t |
| 26 |
3071 |
| xh_init_opts(xh_opts_t *opts) |
| 27 |
|
| { |
| 28 |
|
| xh_char_t method[XH_PARAM_LEN]; |
| 29 |
|
| xh_bool_t use_attr; |
| 30 |
|
| |
| 31 |
|
| XH_PARAM_READ_INIT |
| 32 |
|
| |
| 33 |
|
| /* native options */ |
| 34 |
6142 |
▶ | XH_PARAM_READ_STRING (opts->root, "XML::Hash::XS::root", XH_DEF_ROOT); |
Branch: 2 branches
| Branch | True | False | Total |
| XH_PARAM_READ_STRING (opts->root, "XML::Hash::XS::root", XH_DEF_ROOT); |
3071 |
0 |
3071 |
| XH_PARAM_READ_STRING (opts->root, "XML::Hash::XS::root", XH_DEF_ROOT); |
3071 |
0 |
3071 |
|
| 35 |
6142 |
▶ | XH_PARAM_READ_STRING (opts->version, "XML::Hash::XS::version", XH_DEF_VERSION); |
Branch: 2 branches
| Branch | True | False | Total |
| XH_PARAM_READ_STRING (opts->version, "XML::Hash::XS::version", XH_DEF_VERSION); |
3071 |
0 |
3071 |
| XH_PARAM_READ_STRING (opts->version, "XML::Hash::XS::version", XH_DEF_VERSION); |
3071 |
0 |
3071 |
|
| 36 |
6142 |
▶ | XH_PARAM_READ_STRING (opts->encoding, "XML::Hash::XS::encoding", XH_DEF_ENCODING); |
Branch: 2 branches
| Branch | True | False | Total |
| XH_PARAM_READ_STRING (opts->encoding, "XML::Hash::XS::encoding", XH_DEF_ENCODING); |
3071 |
0 |
3071 |
| XH_PARAM_READ_STRING (opts->encoding, "XML::Hash::XS::encoding", XH_DEF_ENCODING); |
3071 |
0 |
3071 |
|
| 37 |
3071 |
▶ | XH_PARAM_READ_INT (opts->indent, "XML::Hash::XS::indent", XH_DEF_INDENT); |
Branch: 1 branch
| Branch | True | False | Total |
| XH_PARAM_READ_INT (opts->indent, "XML::Hash::XS::indent", XH_DEF_INDENT); |
3071 |
0 |
3071 |
|
| 38 |
3071 |
▶ | XH_PARAM_READ_BOOL (opts->canonical, "XML::Hash::XS::canonical", XH_DEF_CANONICAL); |
Branch: 2 branches
| Branch | True | False | Total |
| XH_PARAM_READ_BOOL (opts->canonical, "XML::Hash::XS::canonical", XH_DEF_CANONICAL); |
3071 |
0 |
3071 |
| XH_PARAM_READ_BOOL (opts->canonical, "XML::Hash::XS::canonical", XH_DEF_CANONICAL); |
4 |
3067 |
3071 |
|
| 39 |
3075 |
▶ | XH_PARAM_READ_STRING (opts->content, "XML::Hash::XS::content", XH_DEF_CONTENT); |
Branch: 2 branches
| Branch | True | False | Total |
| XH_PARAM_READ_STRING (opts->content, "XML::Hash::XS::content", XH_DEF_CONTENT); |
3071 |
0 |
3071 |
| XH_PARAM_READ_STRING (opts->content, "XML::Hash::XS::content", XH_DEF_CONTENT); |
4 |
3067 |
3071 |
|
| 40 |
3071 |
▶ | XH_PARAM_READ_BOOL (opts->utf8, "XML::Hash::XS::utf8", XH_DEF_UTF8); |
Branch: 2 branches
| Branch | True | False | Total |
| XH_PARAM_READ_BOOL (opts->utf8, "XML::Hash::XS::utf8", XH_DEF_UTF8); |
3071 |
0 |
3071 |
| XH_PARAM_READ_BOOL (opts->utf8, "XML::Hash::XS::utf8", XH_DEF_UTF8); |
3071 |
0 |
3071 |
|
| 41 |
3071 |
▶ | XH_PARAM_READ_BOOL (opts->xml_decl, "XML::Hash::XS::xml_decl", XH_DEF_XML_DECL); |
Branch: 2 branches
| Branch | True | False | Total |
| XH_PARAM_READ_BOOL (opts->xml_decl, "XML::Hash::XS::xml_decl", XH_DEF_XML_DECL); |
3071 |
0 |
3071 |
| XH_PARAM_READ_BOOL (opts->xml_decl, "XML::Hash::XS::xml_decl", XH_DEF_XML_DECL); |
3068 |
3 |
3071 |
|
| 42 |
3071 |
▶ | XH_PARAM_READ_BOOL (opts->keep_root, "XML::Hash::XS::keep_root", XH_DEF_KEEP_ROOT); |
Branch: 2 branches
| Branch | True | False | Total |
| XH_PARAM_READ_BOOL (opts->keep_root, "XML::Hash::XS::keep_root", XH_DEF_KEEP_ROOT); |
3071 |
0 |
3071 |
| XH_PARAM_READ_BOOL (opts->keep_root, "XML::Hash::XS::keep_root", XH_DEF_KEEP_ROOT); |
3008 |
63 |
3071 |
|
| 43 |
|
| #ifdef XH_HAVE_DOM |
| 44 |
|
| XH_PARAM_READ_BOOL (opts->doc, "XML::Hash::XS::doc", XH_DEF_DOC); |
| 45 |
|
| #endif |
| 46 |
3071 |
▶ | XH_PARAM_READ_BOOL (use_attr, "XML::Hash::XS::use_attr", XH_DEF_USE_ATTR); |
Branch: 2 branches
| Branch | True | False | Total |
| XH_PARAM_READ_BOOL (use_attr, "XML::Hash::XS::use_attr", XH_DEF_USE_ATTR); |
3071 |
0 |
3071 |
| XH_PARAM_READ_BOOL (use_attr, "XML::Hash::XS::use_attr", XH_DEF_USE_ATTR); |
3 |
3068 |
3071 |
|
| 47 |
3071 |
▶ | XH_PARAM_READ_INT (opts->max_depth, "XML::Hash::XS::max_depth", XH_DEF_MAX_DEPTH); |
Branch: 1 branch
| Branch | True | False | Total |
| XH_PARAM_READ_INT (opts->max_depth, "XML::Hash::XS::max_depth", XH_DEF_MAX_DEPTH); |
3071 |
0 |
3071 |
|
| 48 |
3071 |
▶ | XH_PARAM_READ_INT (opts->buf_size, "XML::Hash::XS::buf_size", XH_DEF_BUF_SIZE); |
Branch: 1 branch
| Branch | True | False | Total |
| XH_PARAM_READ_INT (opts->buf_size, "XML::Hash::XS::buf_size", XH_DEF_BUF_SIZE); |
3071 |
0 |
3071 |
|
| 49 |
3071 |
▶ | XH_PARAM_READ_PATTERN(opts->force_array, "XML::Hash::XS::force_array", XH_DEF_FORCE_ARRAY); |
Branch: 1 branch
| Branch | True | False | Total |
| XH_PARAM_READ_PATTERN(opts->force_array, "XML::Hash::XS::force_array", XH_DEF_FORCE_ARRAY); |
3071 |
0 |
3071 |
|
| 50 |
3071 |
▶ | XH_PARAM_READ_BOOL (opts->force_content, "XML::Hash::XS::force_content", XH_DEF_FORCE_CONTENT); |
Branch: 2 branches
| Branch | True | False | Total |
| XH_PARAM_READ_BOOL (opts->force_content, "XML::Hash::XS::force_content", XH_DEF_FORCE_CONTENT); |
3071 |
0 |
3071 |
| XH_PARAM_READ_BOOL (opts->force_content, "XML::Hash::XS::force_content", XH_DEF_FORCE_CONTENT); |
0 |
3071 |
3071 |
|
| 51 |
3071 |
▶ | XH_PARAM_READ_BOOL (opts->merge_text, "XML::Hash::XS::merge_text", XH_DEF_MERGE_TEXT); |
Branch: 2 branches
| Branch | True | False | Total |
| XH_PARAM_READ_BOOL (opts->merge_text, "XML::Hash::XS::merge_text", XH_DEF_MERGE_TEXT); |
3071 |
0 |
3071 |
| XH_PARAM_READ_BOOL (opts->merge_text, "XML::Hash::XS::merge_text", XH_DEF_MERGE_TEXT); |
0 |
3071 |
3071 |
|
| 52 |
3071 |
▶ | if ( (sv = get_sv("XML::Hash::XS::cb_mode", 0)) != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( (sv = get_sv("XML::Hash::XS::cb_mode", 0)) != NULL ) { |
3071 |
0 |
3071 |
|
| 53 |
3071 |
| xh_assign_cb_mode(opts, sv); |
| 54 |
|
| } |
| 55 |
|
| else { |
| 56 |
0 |
| opts->cb_mode = XH_CB_MODE_NODE; |
| 57 |
|
| } |
| 58 |
|
| |
| 59 |
|
| /* XML::Hash::LX options */ |
| 60 |
6142 |
▶ | XH_PARAM_READ_STRING (opts->attr, "XML::Hash::XS::attr", XH_DEF_ATTR); |
Branch: 2 branches
| Branch | True | False | Total |
| XH_PARAM_READ_STRING (opts->attr, "XML::Hash::XS::attr", XH_DEF_ATTR); |
3071 |
0 |
3071 |
| XH_PARAM_READ_STRING (opts->attr, "XML::Hash::XS::attr", XH_DEF_ATTR); |
3071 |
0 |
3071 |
|
| 61 |
3071 |
| opts->attr_len = xh_strlen(opts->attr); |
| 62 |
6142 |
▶ | XH_PARAM_READ_STRING (opts->text, "XML::Hash::XS::text", XH_DEF_TEXT); |
Branch: 2 branches
| Branch | True | False | Total |
| XH_PARAM_READ_STRING (opts->text, "XML::Hash::XS::text", XH_DEF_TEXT); |
3071 |
0 |
3071 |
| XH_PARAM_READ_STRING (opts->text, "XML::Hash::XS::text", XH_DEF_TEXT); |
3071 |
0 |
3071 |
|
| 63 |
3071 |
▶ | XH_PARAM_READ_BOOL (opts->trim, "XML::Hash::XS::trim", XH_DEF_TRIM); |
Branch: 2 branches
| Branch | True | False | Total |
| XH_PARAM_READ_BOOL (opts->trim, "XML::Hash::XS::trim", XH_DEF_TRIM); |
3071 |
0 |
3071 |
| XH_PARAM_READ_BOOL (opts->trim, "XML::Hash::XS::trim", XH_DEF_TRIM); |
15 |
3056 |
3071 |
|
| 64 |
3071 |
▶ | XH_PARAM_READ_STRING (opts->cdata, "XML::Hash::XS::cdata", XH_DEF_CDATA); |
Branch: 2 branches
| Branch | True | False | Total |
| XH_PARAM_READ_STRING (opts->cdata, "XML::Hash::XS::cdata", XH_DEF_CDATA); |
3071 |
0 |
3071 |
| XH_PARAM_READ_STRING (opts->cdata, "XML::Hash::XS::cdata", XH_DEF_CDATA); |
0 |
3071 |
3071 |
|
| 65 |
3071 |
▶ | XH_PARAM_READ_STRING (opts->comm, "XML::Hash::XS::comm", XH_DEF_COMM); |
Branch: 2 branches
| Branch | True | False | Total |
| XH_PARAM_READ_STRING (opts->comm, "XML::Hash::XS::comm", XH_DEF_COMM); |
3071 |
0 |
3071 |
| XH_PARAM_READ_STRING (opts->comm, "XML::Hash::XS::comm", XH_DEF_COMM); |
0 |
3071 |
3071 |
|
| 66 |
|
| |
| 67 |
|
| /* method */ |
| 68 |
6142 |
▶ | XH_PARAM_READ_STRING (method, "XML::Hash::XS::method", XH_DEF_METHOD); |
Branch: 2 branches
| Branch | True | False | Total |
| XH_PARAM_READ_STRING (method, "XML::Hash::XS::method", XH_DEF_METHOD); |
3071 |
0 |
3071 |
| XH_PARAM_READ_STRING (method, "XML::Hash::XS::method", XH_DEF_METHOD); |
3071 |
0 |
3071 |
|
| 69 |
3071 |
▶ | if (xh_strcmp(method, XH_CHAR_CAST "LX") == 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (xh_strcmp(method, XH_CHAR_CAST "LX") == 0) { |
15 |
3056 |
3071 |
|
| 70 |
15 |
| opts->method = XH_METHOD_LX; |
| 71 |
|
| } |
| 72 |
3056 |
▶ | else if (use_attr) { |
Branch: 1 branch
| Branch | True | False | Total |
| else if (use_attr) { |
3 |
3053 |
3056 |
|
| 73 |
3 |
| opts->method = XH_METHOD_NATIVE_ATTR_MODE; |
| 74 |
|
| } |
| 75 |
|
| else { |
| 76 |
3053 |
| opts->method = XH_METHOD_NATIVE; |
| 77 |
|
| } |
| 78 |
|
| |
| 79 |
|
| /* output, NULL - to string */ |
| 80 |
3071 |
▶ | if ( (sv = get_sv("XML::Hash::XS::output", 0)) != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( (sv = get_sv("XML::Hash::XS::output", 0)) != NULL ) { |
3071 |
0 |
3071 |
|
| 81 |
3071 |
| xh_param_assign_output(&opts->output, sv); |
| 82 |
|
| } |
| 83 |
|
| else { |
| 84 |
0 |
| opts->output = XH_DEF_OUTPUT; |
| 85 |
|
| } |
| 86 |
3071 |
▶ | if ( (sv = get_sv("XML::Hash::XS::output_cb", 0)) != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( (sv = get_sv("XML::Hash::XS::output_cb", 0)) != NULL ) { |
3071 |
0 |
3071 |
|
| 87 |
3071 |
| xh_param_assign_cb(&opts->output_cb, "output_cb", sv); |
| 88 |
|
| } |
| 89 |
|
| |
| 90 |
|
| /* suppress empty */ |
| 91 |
3071 |
▶ | if ( (sv = get_sv("XML::Hash::XS::suppress_empty", 0)) != NULL ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( (sv = get_sv("XML::Hash::XS::suppress_empty", 0)) != NULL ) { |
3071 |
0 |
3071 |
|
| 92 |
3071 |
▶ | if ( SvOK(sv) ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( SvOK(sv) ) { |
3071 |
0 |
3071 |
|
| 93 |
3071 |
▶ | if (SvTYPE(sv) == SVt_IV) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvTYPE(sv) == SVt_IV) { |
3071 |
0 |
3071 |
|
| 94 |
3071 |
| opts->suppress_empty = SvIV(sv); |
| 95 |
|
| } |
| 96 |
|
| else { |
| 97 |
0 |
| opts->suppress_empty = XH_SUPPRESS_EMPTY_TO_STRING; |
| 98 |
|
| } |
| 99 |
|
| } |
| 100 |
|
| else { |
| 101 |
0 |
| opts->suppress_empty = XH_SUPPRESS_EMPTY_TO_UNDEF; |
| 102 |
|
| } |
| 103 |
|
| } |
| 104 |
|
| else { |
| 105 |
0 |
| opts->suppress_empty = XH_DEF_SUPPRESS_EMPTY; |
| 106 |
|
| } |
| 107 |
|
| |
| 108 |
3071 |
| return TRUE; |
| 109 |
|
| } |
| 110 |
|
| |
| 111 |
|
| xh_opts_t * |
| 112 |
9 |
| xh_create_opts(void) |
| 113 |
|
| { |
| 114 |
|
| xh_opts_t *opts; |
| 115 |
|
| |
| 116 |
9 |
▶ | if ((opts = malloc(sizeof(xh_opts_t))) == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ((opts = malloc(sizeof(xh_opts_t))) == NULL) { |
0 |
9 |
9 |
|
| 117 |
0 |
| return NULL; |
| 118 |
|
| } |
| 119 |
9 |
| memset(opts, 0, sizeof(xh_opts_t)); |
| 120 |
|
| |
| 121 |
9 |
▶ | if (! xh_init_opts(opts)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (! xh_init_opts(opts)) { |
0 |
9 |
9 |
|
| 122 |
0 |
| xh_destroy_opts(opts); |
| 123 |
0 |
| return NULL; |
| 124 |
|
| } |
| 125 |
|
| |
| 126 |
9 |
| return opts; |
| 127 |
|
| } |
| 128 |
|
| |
| 129 |
|
| void |
| 130 |
3084 |
| xh_destroy_opts(xh_opts_t *opts) |
| 131 |
|
| { |
| 132 |
3084 |
▶ | if (opts->force_array.expr != NULL) |
Branch: 1 branch
| Branch | True | False | Total |
| if (opts->force_array.expr != NULL) |
3 |
3081 |
3084 |
|
| 133 |
3 |
| SvREFCNT_dec(opts->force_array.expr); |
| 134 |
|
| |
| 135 |
3084 |
▶ | if (opts->filter.expr != NULL) |
Branch: 1 branch
| Branch | True | False | Total |
| if (opts->filter.expr != NULL) |
32 |
3052 |
3084 |
|
| 136 |
32 |
| SvREFCNT_dec(opts->filter.expr); |
| 137 |
|
| |
| 138 |
3084 |
▶ | if (opts->cb != NULL) |
Branch: 1 branch
| Branch | True | False | Total |
| if (opts->cb != NULL) |
23 |
3061 |
3084 |
|
| 139 |
23 |
| SvREFCNT_dec(opts->cb); |
| 140 |
|
| |
| 141 |
3084 |
▶ | if (opts->output != NULL) |
Branch: 1 branch
| Branch | True | False | Total |
| if (opts->output != NULL) |
6 |
3078 |
3084 |
|
| 142 |
6 |
| SvREFCNT_dec(opts->output); |
| 143 |
|
| |
| 144 |
3084 |
▶ | if (opts->output_cb != NULL) |
Branch: 1 branch
| Branch | True | False | Total |
| if (opts->output_cb != NULL) |
12 |
3072 |
3084 |
|
| 145 |
12 |
| SvREFCNT_dec(opts->output_cb); |
| 146 |
3084 |
| } |
| 147 |
|
| |
| 148 |
|
| void |
| 149 |
13 |
| xh_copy_opts(xh_opts_t *dst, xh_opts_t *src) |
| 150 |
|
| { |
| 151 |
13 |
| memcpy(dst, src, sizeof(xh_opts_t)); |
| 152 |
13 |
▶ | if (dst->force_array.expr != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (dst->force_array.expr != NULL) { |
1 |
12 |
13 |
|
| 153 |
1 |
| SvREFCNT_inc(dst->force_array.expr); |
| 154 |
|
| } |
| 155 |
13 |
▶ | if (dst->filter.expr != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (dst->filter.expr != NULL) { |
9 |
4 |
13 |
|
| 156 |
9 |
| SvREFCNT_inc(dst->filter.expr); |
| 157 |
|
| } |
| 158 |
13 |
▶ | if (dst->cb != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (dst->cb != NULL) { |
6 |
7 |
13 |
|
| 159 |
6 |
| SvREFCNT_inc(dst->cb); |
| 160 |
|
| } |
| 161 |
13 |
▶ | if (dst->output != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (dst->output != NULL) { |
1 |
12 |
13 |
|
| 162 |
1 |
| SvREFCNT_inc(dst->output); |
| 163 |
|
| } |
| 164 |
13 |
▶ | if (dst->output_cb != NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (dst->output_cb != NULL) { |
1 |
12 |
13 |
|
| 165 |
1 |
| SvREFCNT_inc(dst->output_cb); |
| 166 |
|
| } |
| 167 |
13 |
| } |
| 168 |
|
| |
| 169 |
|
| void |
| 170 |
515 |
| xh_parse_param(xh_opts_t *opts, xh_int_t first, I32 ax, I32 items) |
| 171 |
|
| { |
| 172 |
|
| xh_int_t i; |
| 173 |
|
| xh_char_t *p, *cv; |
| 174 |
|
| SV *v; |
| 175 |
|
| STRLEN len; |
| 176 |
515 |
| xh_int_t use_attr = -1; |
| 177 |
|
| |
| 178 |
515 |
▶ | if ((items - first) % 2 != 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ((items - first) % 2 != 0) { |
0 |
515 |
515 |
|
| 179 |
0 |
| croak("Odd number of parameters in new()"); |
| 180 |
|
| } |
| 181 |
|
| |
| 182 |
1123 |
▶ | for (i = first; i < items; i = i + 2) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = first; i < items; i = i + 2) { |
612 |
511 |
1123 |
|
| 183 |
612 |
| v = ST(i); |
| 184 |
612 |
▶ | if (!SvOK(v)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!SvOK(v)) { |
0 |
612 |
612 |
|
| 185 |
0 |
| croak("Parameter name is undefined"); |
| 186 |
|
| } |
| 187 |
|
| |
| 188 |
612 |
| p = XH_CHAR_CAST SvPV(v, len); |
| 189 |
612 |
| v = ST(i + 1); |
| 190 |
|
| |
| 191 |
612 |
| switch (len) { |
| 192 |
18 |
| case 2: |
| 193 |
18 |
▶ | if (xh_str_equal2(p, 'c', 'b')) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (xh_str_equal2(p, 'c', 'b')) { |
18 |
0 |
18 |
|
| 194 |
18 |
| xh_param_assign_cb(&opts->cb, "cb", v); |
| 195 |
18 |
| break; |
| 196 |
|
| } |
| 197 |
0 |
| goto error; |
| 198 |
|
| #ifdef XH_HAVE_DOM |
| 199 |
|
| case 3: |
| 200 |
|
| if (xh_str_equal3(p, 'd', 'o', 'c')) { |
| 201 |
|
| opts->doc = xh_param_assign_bool(v); |
| 202 |
|
| break; |
| 203 |
|
| } |
| 204 |
|
| goto error; |
| 205 |
|
| #endif |
| 206 |
38 |
| case 4: |
| 207 |
38 |
▶ | if (xh_str_equal4(p, 'a', 't', 't', 'r')) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (xh_str_equal4(p, 'a', 't', 't', 'r')) { |
1 |
37 |
38 |
|
| 208 |
1 |
| xh_param_assign_string(opts->attr, v); |
| 209 |
1 |
▶ | if (opts->attr[0] == '\0') { |
Branch: 1 branch
| Branch | True | False | Total |
| if (opts->attr[0] == '\0') { |
0 |
1 |
1 |
|
| 210 |
0 |
| opts->attr_len = 0; |
| 211 |
|
| } |
| 212 |
|
| else { |
| 213 |
1 |
| opts->attr_len = xh_strlen(opts->attr); |
| 214 |
|
| } |
| 215 |
1 |
| break; |
| 216 |
|
| } |
| 217 |
37 |
▶ | if (xh_str_equal4(p, 'c', 'o', 'm', 'm')) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (xh_str_equal4(p, 'c', 'o', 'm', 'm')) { |
2 |
35 |
37 |
|
| 218 |
2 |
| xh_param_assign_string(opts->comm, v); |
| 219 |
2 |
| break; |
| 220 |
|
| } |
| 221 |
35 |
▶ | if (xh_str_equal4(p, 'r', 'o', 'o', 't')) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (xh_str_equal4(p, 'r', 'o', 'o', 't')) { |
2 |
33 |
35 |
|
| 222 |
2 |
| xh_param_assign_string(opts->root, v); |
| 223 |
2 |
| break; |
| 224 |
|
| } |
| 225 |
33 |
▶ | if (xh_str_equal4(p, 't', 'r', 'i', 'm')) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (xh_str_equal4(p, 't', 'r', 'i', 'm')) { |
20 |
13 |
33 |
|
| 226 |
20 |
| opts->trim = xh_param_assign_bool(v); |
| 227 |
20 |
| break; |
| 228 |
|
| } |
| 229 |
13 |
▶ | if (xh_str_equal4(p, 't', 'e', 'x', 't')) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (xh_str_equal4(p, 't', 'e', 'x', 't')) { |
1 |
12 |
13 |
|
| 230 |
1 |
| xh_param_assign_string(opts->text, v); |
| 231 |
1 |
| break; |
| 232 |
|
| } |
| 233 |
12 |
▶ | if (xh_str_equal4(p, 'u', 't', 'f', '8')) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (xh_str_equal4(p, 'u', 't', 'f', '8')) { |
12 |
0 |
12 |
|
| 234 |
12 |
| opts->utf8 = xh_param_assign_bool(v); |
| 235 |
12 |
| break; |
| 236 |
|
| } |
| 237 |
0 |
| goto error; |
| 238 |
2 |
| case 5: |
| 239 |
2 |
▶ | if (xh_str_equal5(p, 'c', 'd', 'a', 't', 'a')) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (xh_str_equal5(p, 'c', 'd', 'a', 't', 'a')) { |
2 |
0 |
2 |
| if (xh_str_equal5(p, 'c', 'd', 'a', 't', 'a')) { |
2 |
0 |
2 |
|
| 240 |
2 |
| xh_param_assign_string(opts->cdata, v); |
| 241 |
2 |
| break; |
| 242 |
|
| } |
| 243 |
0 |
| goto error; |
| 244 |
31 |
| case 6: |
| 245 |
31 |
▶ | if (xh_str_equal6(p, 'i', 'n', 'd', 'e', 'n', 't')) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (xh_str_equal6(p, 'i', 'n', 'd', 'e', 'n', 't')) { |
3 |
28 |
31 |
| if (xh_str_equal6(p, 'i', 'n', 'd', 'e', 'n', 't')) { |
3 |
0 |
3 |
|
| 246 |
3 |
| xh_param_assign_int(p, &opts->indent, v); |
| 247 |
3 |
| break; |
| 248 |
|
| } |
| 249 |
28 |
▶ | if (xh_str_equal6(p, 'm', 'e', 't', 'h', 'o', 'd')) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (xh_str_equal6(p, 'm', 'e', 't', 'h', 'o', 'd')) { |
0 |
28 |
28 |
| if (xh_str_equal6(p, 'm', 'e', 't', 'h', 'o', 'd')) { |
0 |
0 |
0 |
|
| 250 |
0 |
▶ | if (!SvOK(v)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (!SvOK(v)) { |
0 |
0 |
0 |
|
| 251 |
0 |
| croak("Parameter '%s' is undefined", p); |
| 252 |
|
| } |
| 253 |
0 |
| cv = XH_CHAR_CAST SvPV(v, len); |
| 254 |
0 |
| switch (len) { |
| 255 |
0 |
| case 6: |
| 256 |
0 |
▶ | if (xh_str_equal6(cv, 'N', 'A', 'T', 'I', 'V', 'E')) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (xh_str_equal6(cv, 'N', 'A', 'T', 'I', 'V', 'E')) { |
0 |
0 |
0 |
| if (xh_str_equal6(cv, 'N', 'A', 'T', 'I', 'V', 'E')) { |
0 |
0 |
0 |
|
| 257 |
0 |
| opts->method = XH_METHOD_NATIVE; |
| 258 |
0 |
| break; |
| 259 |
|
| } |
| 260 |
0 |
| goto error_value; |
| 261 |
0 |
| case 2: |
| 262 |
0 |
▶ | if (cv[0] == 'L' && cv[1] == 'X') { |
Branch: 2 branches
| Branch | True | False | Total |
| if (cv[0] == 'L' && cv[1] == 'X') { |
0 |
0 |
0 |
| if (cv[0] == 'L' && cv[1] == 'X') { |
0 |
0 |
0 |
|
| 263 |
0 |
| opts->method = XH_METHOD_LX; |
| 264 |
0 |
| break; |
| 265 |
|
| } |
| 266 |
0 |
| goto error_value; |
| 267 |
0 |
| default: |
| 268 |
0 |
| goto error_value; |
| 269 |
|
| } |
| 270 |
0 |
| break; |
| 271 |
|
| } |
| 272 |
28 |
▶ | if (xh_str_equal6(p, 'o', 'u', 't', 'p', 'u', 't')) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (xh_str_equal6(p, 'o', 'u', 't', 'p', 'u', 't')) { |
4 |
24 |
28 |
| if (xh_str_equal6(p, 'o', 'u', 't', 'p', 'u', 't')) { |
4 |
0 |
4 |
|
| 273 |
4 |
| xh_param_assign_output(&opts->output, v); |
| 274 |
4 |
| break; |
| 275 |
|
| } |
| 276 |
24 |
▶ | if (xh_str_equal6(p, 'f', 'i', 'l', 't', 'e', 'r')) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (xh_str_equal6(p, 'f', 'i', 'l', 't', 'e', 'r')) { |
24 |
0 |
24 |
| if (xh_str_equal6(p, 'f', 'i', 'l', 't', 'e', 'r')) { |
24 |
0 |
24 |
|
| 277 |
24 |
| xh_param_assign_filter(&opts->filter, v); |
| 278 |
24 |
| break; |
| 279 |
|
| } |
| 280 |
0 |
| goto error; |
| 281 |
8 |
| case 7: |
| 282 |
8 |
▶ | if (xh_str_equal7(p, 'c', 'b', '_', 'm', 'o', 'd', 'e')) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (xh_str_equal7(p, 'c', 'b', '_', 'm', 'o', 'd', 'e')) { |
6 |
2 |
8 |
| if (xh_str_equal7(p, 'c', 'b', '_', 'm', 'o', 'd', 'e')) { |
6 |
0 |
6 |
|
| 283 |
6 |
| xh_assign_cb_mode(opts, v); |
| 284 |
5 |
| break; |
| 285 |
|
| } |
| 286 |
2 |
▶ | if (xh_str_equal7(p, 'c', 'o', 'n', 't', 'e', 'n', 't')) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (xh_str_equal7(p, 'c', 'o', 'n', 't', 'e', 'n', 't')) { |
2 |
0 |
2 |
| if (xh_str_equal7(p, 'c', 'o', 'n', 't', 'e', 'n', 't')) { |
2 |
0 |
2 |
|
| 287 |
2 |
| xh_param_assign_string(opts->content, v); |
| 288 |
2 |
| break; |
| 289 |
|
| } |
| 290 |
0 |
▶ | if (xh_str_equal7(p, 'v', 'e', 'r', 's', 'i', 'o', 'n')) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (xh_str_equal7(p, 'v', 'e', 'r', 's', 'i', 'o', 'n')) { |
0 |
0 |
0 |
| if (xh_str_equal7(p, 'v', 'e', 'r', 's', 'i', 'o', 'n')) { |
0 |
0 |
0 |
|
| 291 |
0 |
| xh_param_assign_string(opts->version, v); |
| 292 |
0 |
| break; |
| 293 |
|
| } |
| 294 |
0 |
| goto error; |
| 295 |
32 |
| case 8: |
| 296 |
32 |
▶ | if (xh_str_equal8(p, 'e', 'n', 'c', 'o', 'd', 'i', 'n', 'g')) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (xh_str_equal8(p, 'e', 'n', 'c', 'o', 'd', 'i', 'n', 'g')) { |
9 |
23 |
32 |
| if (xh_str_equal8(p, 'e', 'n', 'c', 'o', 'd', 'i', 'n', 'g')) { |
9 |
0 |
9 |
|
| 297 |
9 |
| xh_param_assign_string(opts->encoding, v); |
| 298 |
9 |
| break; |
| 299 |
|
| } |
| 300 |
23 |
▶ | if (xh_str_equal8(p, 'u', 's', 'e', '_', 'a', 't', 't', 'r')) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (xh_str_equal8(p, 'u', 's', 'e', '_', 'a', 't', 't', 'r')) { |
2 |
21 |
23 |
| if (xh_str_equal8(p, 'u', 's', 'e', '_', 'a', 't', 't', 'r')) { |
2 |
0 |
2 |
|
| 301 |
2 |
| use_attr = xh_param_assign_bool(v); |
| 302 |
2 |
| break; |
| 303 |
|
| } |
| 304 |
21 |
▶ | if (xh_str_equal8(p, 'x', 'm', 'l', '_', 'd', 'e', 'c', 'l')) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (xh_str_equal8(p, 'x', 'm', 'l', '_', 'd', 'e', 'c', 'l')) { |
8 |
13 |
21 |
| if (xh_str_equal8(p, 'x', 'm', 'l', '_', 'd', 'e', 'c', 'l')) { |
8 |
0 |
8 |
|
| 305 |
8 |
| opts->xml_decl = xh_param_assign_bool(v); |
| 306 |
8 |
| break; |
| 307 |
|
| } |
| 308 |
13 |
▶ | if (xh_str_equal8(p, 'b', 'u', 'f', '_', 's', 'i', 'z', 'e')) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (xh_str_equal8(p, 'b', 'u', 'f', '_', 's', 'i', 'z', 'e')) { |
13 |
0 |
13 |
| if (xh_str_equal8(p, 'b', 'u', 'f', '_', 's', 'i', 'z', 'e')) { |
13 |
0 |
13 |
|
| 309 |
13 |
| xh_param_assign_int(p, &opts->buf_size, v); |
| 310 |
13 |
| break; |
| 311 |
|
| } |
| 312 |
0 |
| goto error; |
| 313 |
466 |
| case 9: |
| 314 |
466 |
▶ | if (xh_str_equal9(p, 'o', 'u', 't', 'p', 'u', 't', '_', 'c', 'b')) { |
Branch: 3 branches
| Branch | True | False | Total |
| if (xh_str_equal9(p, 'o', 'u', 't', 'p', 'u', 't', '_', 'c', 'b')) { |
11 |
455 |
466 |
| if (xh_str_equal9(p, 'o', 'u', 't', 'p', 'u', 't', '_', 'c', 'b')) { |
11 |
0 |
11 |
| if (xh_str_equal9(p, 'o', 'u', 't', 'p', 'u', 't', '_', 'c', 'b')) { |
11 |
0 |
11 |
|
| 315 |
11 |
| xh_param_assign_cb(&opts->output_cb, "output_cb", v); |
| 316 |
10 |
| break; |
| 317 |
|
| } |
| 318 |
455 |
▶ | if (xh_str_equal9(p, 'c', 'a', 'n', 'o', 'n', 'i', 'c', 'a', 'l')) { |
Branch: 3 branches
| Branch | True | False | Total |
| if (xh_str_equal9(p, 'c', 'a', 'n', 'o', 'n', 'i', 'c', 'a', 'l')) { |
10 |
445 |
455 |
| if (xh_str_equal9(p, 'c', 'a', 'n', 'o', 'n', 'i', 'c', 'a', 'l')) { |
10 |
0 |
10 |
| if (xh_str_equal9(p, 'c', 'a', 'n', 'o', 'n', 'i', 'c', 'a', 'l')) { |
10 |
0 |
10 |
|
| 319 |
10 |
| opts->canonical = xh_param_assign_bool(v); |
| 320 |
10 |
| break; |
| 321 |
|
| } |
| 322 |
445 |
▶ | if (xh_str_equal9(p, 'm', 'a', 'x', '_', 'd', 'e', 'p', 't', 'h')) { |
Branch: 3 branches
| Branch | True | False | Total |
| if (xh_str_equal9(p, 'm', 'a', 'x', '_', 'd', 'e', 'p', 't', 'h')) { |
0 |
445 |
445 |
| if (xh_str_equal9(p, 'm', 'a', 'x', '_', 'd', 'e', 'p', 't', 'h')) { |
0 |
0 |
0 |
| if (xh_str_equal9(p, 'm', 'a', 'x', '_', 'd', 'e', 'p', 't', 'h')) { |
0 |
0 |
0 |
|
| 323 |
0 |
| xh_param_assign_int(p, &opts->max_depth, v); |
| 324 |
0 |
| break; |
| 325 |
|
| } |
| 326 |
445 |
▶ | if (xh_str_equal9(p, 'k', 'e', 'e', 'p', '_', 'r', 'o', 'o', 't')) { |
Branch: 3 branches
| Branch | True | False | Total |
| if (xh_str_equal9(p, 'k', 'e', 'e', 'p', '_', 'r', 'o', 'o', 't')) { |
445 |
0 |
445 |
| if (xh_str_equal9(p, 'k', 'e', 'e', 'p', '_', 'r', 'o', 'o', 't')) { |
445 |
0 |
445 |
| if (xh_str_equal9(p, 'k', 'e', 'e', 'p', '_', 'r', 'o', 'o', 't')) { |
445 |
0 |
445 |
|
| 327 |
445 |
| opts->keep_root = xh_param_assign_bool(v); |
| 328 |
445 |
| break; |
| 329 |
|
| } |
| 330 |
0 |
| goto error; |
| 331 |
3 |
| case 10: |
| 332 |
3 |
▶ | if (xh_str_equal10(p, 'm', 'e', 'r', 'g', 'e', '_', 't', 'e', 'x', 't')) { |
Branch: 3 branches
| Branch | True | False | Total |
| if (xh_str_equal10(p, 'm', 'e', 'r', 'g', 'e', '_', 't', 'e', 'x', 't')) { |
3 |
0 |
3 |
| if (xh_str_equal10(p, 'm', 'e', 'r', 'g', 'e', '_', 't', 'e', 'x', 't')) { |
3 |
0 |
3 |
| if (xh_str_equal10(p, 'm', 'e', 'r', 'g', 'e', '_', 't', 'e', 'x', 't')) { |
3 |
0 |
3 |
|
| 333 |
3 |
| opts->merge_text = xh_param_assign_bool(v); |
| 334 |
3 |
| break; |
| 335 |
|
| } |
| 336 |
0 |
| goto error; |
| 337 |
7 |
| case 11: |
| 338 |
7 |
▶ | if (xh_str_equal11(p, 'f', 'o', 'r', 'c', 'e', '_', 'a', 'r', 'r', 'a', 'y')) { |
Branch: 3 branches
| Branch | True | False | Total |
| if (xh_str_equal11(p, 'f', 'o', 'r', 'c', 'e', '_', 'a', 'r', 'r', 'a', 'y')) { |
7 |
0 |
7 |
| if (xh_str_equal11(p, 'f', 'o', 'r', 'c', 'e', '_', 'a', 'r', 'r', 'a', 'y')) { |
7 |
0 |
7 |
| if (xh_str_equal11(p, 'f', 'o', 'r', 'c', 'e', '_', 'a', 'r', 'r', 'a', 'y')) { |
7 |
0 |
7 |
|
| 339 |
7 |
| xh_param_assign_pattern(&opts->force_array, v); |
| 340 |
7 |
| break; |
| 341 |
|
| } |
| 342 |
0 |
| goto error; |
| 343 |
2 |
| case 13: |
| 344 |
2 |
▶ | if (xh_str_equal13(p, 'f', 'o', 'r', 'c', 'e', '_', 'c', 'o', 'n', 't', 'e', 'n', 't')) { |
Branch: 4 branches
| Branch | True | False | Total |
| if (xh_str_equal13(p, 'f', 'o', 'r', 'c', 'e', '_', 'c', 'o', 'n', 't', 'e', 'n', 't')) { |
2 |
0 |
2 |
| if (xh_str_equal13(p, 'f', 'o', 'r', 'c', 'e', '_', 'c', 'o', 'n', 't', 'e', 'n', 't')) { |
2 |
0 |
2 |
| if (xh_str_equal13(p, 'f', 'o', 'r', 'c', 'e', '_', 'c', 'o', 'n', 't', 'e', 'n', 't')) { |
2 |
0 |
2 |
| if (xh_str_equal13(p, 'f', 'o', 'r', 'c', 'e', '_', 'c', 'o', 'n', 't', 'e', 'n', 't')) { |
2 |
0 |
2 |
|
| 345 |
2 |
| opts->force_content = xh_param_assign_bool(v); |
| 346 |
2 |
| break; |
| 347 |
|
| } |
| 348 |
0 |
| goto error; |
| 349 |
3 |
| case 14: |
| 350 |
3 |
▶ | if (xh_str_equal14(p, 's', 'u', 'p', 'p', 'r', 'e', 's', 's', '_', 'e', 'm', 'p', 't', 'y')) { |
Branch: 4 branches
| Branch | True | False | Total |
| if (xh_str_equal14(p, 's', 'u', 'p', 'p', 'r', 'e', 's', 's', '_', 'e', 'm', 'p', 't', 'y')) { |
3 |
0 |
3 |
| if (xh_str_equal14(p, 's', 'u', 'p', 'p', 'r', 'e', 's', 's', '_', 'e', 'm', 'p', 't', 'y')) { |
3 |
0 |
3 |
| if (xh_str_equal14(p, 's', 'u', 'p', 'p', 'r', 'e', 's', 's', '_', 'e', 'm', 'p', 't', 'y')) { |
3 |
0 |
3 |
| if (xh_str_equal14(p, 's', 'u', 'p', 'p', 'r', 'e', 's', 's', '_', 'e', 'm', 'p', 't', 'y')) { |
3 |
0 |
3 |
|
| 351 |
3 |
▶ | if (SvOK(v)) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvOK(v)) { |
2 |
1 |
3 |
|
| 352 |
2 |
▶ | if (SvTYPE(v) == SVt_IV) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvTYPE(v) == SVt_IV) { |
1 |
1 |
2 |
|
| 353 |
1 |
| opts->suppress_empty = SvIV(v); |
| 354 |
|
| } |
| 355 |
|
| else { |
| 356 |
1 |
| opts->suppress_empty = XH_SUPPRESS_EMPTY_TO_STRING; |
| 357 |
|
| } |
| 358 |
|
| } |
| 359 |
|
| else { |
| 360 |
1 |
| opts->suppress_empty = XH_SUPPRESS_EMPTY_TO_UNDEF; |
| 361 |
|
| } |
| 362 |
3 |
| break; |
| 363 |
|
| } |
| 364 |
|
| default: |
| 365 |
2 |
| goto error; |
| 366 |
|
| } |
| 367 |
|
| } |
| 368 |
|
| |
| 369 |
511 |
▶ | if (use_attr != -1 && (opts->method == XH_METHOD_NATIVE || opts->method == XH_METHOD_NATIVE_ATTR_MODE)) { |
Branch: 3 branches
| Branch | True | False | Total |
| if (use_attr != -1 && (opts->method == XH_METHOD_NATIVE || opts->method == XH_METHOD_NATIVE_ATTR_MODE)) { |
2 |
509 |
511 |
| if (use_attr != -1 && (opts->method == XH_METHOD_NATIVE || opts->method == XH_METHOD_NATIVE_ATTR_MODE)) { |
0 |
2 |
2 |
| if (use_attr != -1 && (opts->method == XH_METHOD_NATIVE || opts->method == XH_METHOD_NATIVE_ATTR_MODE)) { |
0 |
0 |
0 |
|
| 370 |
2 |
▶ | if (use_attr == TRUE) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (use_attr == TRUE) { |
2 |
0 |
2 |
|
| 371 |
2 |
| opts->method = XH_METHOD_NATIVE_ATTR_MODE; |
| 372 |
|
| } |
| 373 |
|
| else { |
| 374 |
0 |
| opts->method = XH_METHOD_NATIVE; |
| 375 |
|
| } |
| 376 |
|
| } |
| 377 |
|
| |
| 378 |
511 |
▶ | if (opts->output != NULL && opts->output_cb != NULL) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (opts->output != NULL && opts->output_cb != NULL) { |
5 |
506 |
511 |
| if (opts->output != NULL && opts->output_cb != NULL) { |
1 |
4 |
5 |
|
| 379 |
1 |
| croak("Parameters 'output' and 'output_cb' are mutually exclusive"); |
| 380 |
|
| } |
| 381 |
|
| |
| 382 |
510 |
| return; |
| 383 |
|
| |
| 384 |
0 |
| error_value: |
| 385 |
0 |
| croak("Invalid parameter value for '%s': %s", p, cv); |
| 386 |
|
| return; |
| 387 |
|
| |
| 388 |
2 |
| error: |
| 389 |
2 |
| croak("Invalid parameter '%s'", p); |
| 390 |
|
| } |
| 391 |
|
| |
| 392 |
|
| void * |
| 393 |
148 |
| xh_get_obj_param(xh_int_t *nparam, I32 ax, I32 items, char *class) |
| 394 |
|
| { |
| 395 |
|
| SV *param; |
| 396 |
148 |
| void *obj = NULL; |
| 397 |
|
| |
| 398 |
148 |
▶ | if (*nparam >= items) |
Branch: 1 branch
| Branch | True | False | Total |
| if (*nparam >= items) |
0 |
148 |
148 |
|
| 399 |
0 |
| croak("Invalid parameters"); |
| 400 |
|
| |
| 401 |
148 |
| param = ST(*nparam); |
| 402 |
148 |
▶ | if ( sv_derived_from(param, class) ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( sv_derived_from(param, class) ) { |
13 |
135 |
148 |
|
| 403 |
13 |
▶ | if ( sv_isobject(param) ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( sv_isobject(param) ) { |
13 |
0 |
13 |
|
| 404 |
|
| /* reference to object */ |
| 405 |
13 |
| IV tmp = SvIV((SV *) SvRV(param)); |
| 406 |
13 |
| obj = INT2PTR(xh_opts_t *, tmp); |
| 407 |
|
| } |
| 408 |
13 |
| (*nparam)++; |
| 409 |
|
| } |
| 410 |
|
| |
| 411 |
148 |
| return obj; |
| 412 |
|
| } |
| 413 |
|
| |
| 414 |
|
| SV * |
| 415 |
58 |
| xh_get_hash_param(xh_int_t *nparam, I32 ax, I32 items) |
| 416 |
|
| { |
| 417 |
|
| SV *param; |
| 418 |
|
| |
| 419 |
58 |
▶ | if (*nparam >= items) |
Branch: 1 branch
| Branch | True | False | Total |
| if (*nparam >= items) |
0 |
58 |
58 |
|
| 420 |
0 |
| croak("Invalid parameters"); |
| 421 |
|
| |
| 422 |
58 |
| param = ST(*nparam); |
| 423 |
58 |
▶ | if (!SvROK(param) || SvTYPE(SvRV(param)) != SVt_PVHV) |
Branch: 2 branches
| Branch | True | False | Total |
| if (!SvROK(param) || SvTYPE(SvRV(param)) != SVt_PVHV) |
58 |
0 |
58 |
| if (!SvROK(param) || SvTYPE(SvRV(param)) != SVt_PVHV) |
0 |
58 |
58 |
|
| 424 |
0 |
| croak("Parameter is not hash reference"); |
| 425 |
|
| |
| 426 |
58 |
| (*nparam)++; |
| 427 |
|
| |
| 428 |
58 |
| return param; |
| 429 |
|
| } |
| 430 |
|
| |
| 431 |
|
| SV * |
| 432 |
90 |
| xh_get_str_param(xh_int_t *nparam, I32 ax, I32 items) |
| 433 |
|
| { |
| 434 |
|
| SV *param; |
| 435 |
|
| |
| 436 |
90 |
▶ | if (*nparam >= items) |
Branch: 1 branch
| Branch | True | False | Total |
| if (*nparam >= items) |
0 |
90 |
90 |
|
| 437 |
0 |
| croak("Invalid parameters"); |
| 438 |
|
| |
| 439 |
90 |
| param = ST(*nparam); |
| 440 |
90 |
▶ | if (SvROK(param)) |
Branch: 1 branch
| Branch | True | False | Total |
| if (SvROK(param)) |
3 |
87 |
90 |
|
| 441 |
3 |
| param = SvRV(param); |
| 442 |
|
| |
| 443 |
90 |
▶ | if (!SvOK(param)) |
Branch: 1 branch
| Branch | True | False | Total |
| if (!SvOK(param)) |
0 |
90 |
90 |
|
| 444 |
0 |
| croak("Invalid parameters"); |
| 445 |
|
| |
| 446 |
90 |
▶ | if (!SvPOK(param) && SvTYPE(param) != SVt_PVGV) |
Branch: 2 branches
| Branch | True | False | Total |
| if (!SvPOK(param) && SvTYPE(param) != SVt_PVGV) |
2 |
88 |
90 |
| if (!SvPOK(param) && SvTYPE(param) != SVt_PVGV) |
0 |
2 |
2 |
|
| 447 |
0 |
| croak("Invalid parameters"); |
| 448 |
|
| |
| 449 |
90 |
| (*nparam)++; |
| 450 |
|
| |
| 451 |
90 |
| return param; |
| 452 |
|
| } |
| 453 |
|
| |
| 454 |
|
| void |
| 455 |
3075 |
| xh_merge_opts(xh_opts_t *ctx_opts, xh_opts_t *opts, xh_int_t nparam, I32 ax, I32 items) |
| 456 |
|
| { |
| 457 |
3075 |
▶ | if (opts == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (opts == NULL) { |
3062 |
13 |
3075 |
|
| 458 |
|
| /* read global options */ |
| 459 |
3062 |
| xh_init_opts(ctx_opts); |
| 460 |
|
| } |
| 461 |
|
| else { |
| 462 |
|
| /* copy options from object */ |
| 463 |
13 |
| xh_copy_opts(ctx_opts, opts); |
| 464 |
|
| } |
| 465 |
3075 |
▶ | if (nparam < items) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (nparam < items) { |
506 |
2569 |
3075 |
|
| 466 |
506 |
| xh_parse_param(ctx_opts, nparam, ax, items); |
| 467 |
|
| } |
| 468 |
3072 |
▶ | if (ctx_opts->output != NULL && ctx_opts->output_cb != NULL) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (ctx_opts->output != NULL && ctx_opts->output_cb != NULL) { |
4 |
3068 |
3072 |
| if (ctx_opts->output != NULL && ctx_opts->output_cb != NULL) { |
0 |
4 |
4 |
|
| 469 |
0 |
| croak("Parameters 'output' and 'output_cb' are mutually exclusive"); |
| 470 |
|
| } |
| 471 |
3072 |
| } |