Branch Coverage

CDB_File.xs
Criterion Covered Total %
branch 218 318 68.5


line true false branch
173 2 297 if(c->is_utf8)
176 0 299 if (cdb_read(c, buf, len, cdb_datapos(c)) == -1)
189 0 277 if(c->is_utf8)
206 0 285 if (newpos < len) {
217 43 14 if (!head || (head->num >= CDB_HPLIST)) {
0 43 if (!head || (head->num >= CDB_HPLIST)) {
227 0 57 if (posplus(c, 8) == -1)
229 0 57 if (posplus(c, keylen) == -1)
231 0 57 if (posplus(c, datalen) == -1)
244 749 205 while (len) {
280 0 147 if(c->map == NULL) croak("Called cdb_map_addr on a system without mmap");
282 147 0 if ((pos > c->size) || (c->size - pos < len)) {
0 147 if ((pos > c->size) || (c->size - pos < len)) {
293 2182 1 if (c->map) {
294 2182 0 if ((pos > c->size) || (c->size - pos < len)) {
0 2182 if ((pos > c->size) || (c->size - pos < len)) {
303 0 1 if (PerlIO_seek(c->fh, pos, SEEK_SET) == -1) return -1;
304 1 0 while (len > 0) {
308 0 1 while ((r == -1) && (errno == EINTR));
0 0 while ((r == -1) && (errno == EINTR));
309 0 1 if (r == -1) return -1;
310 1 0 if (r == 0) {
323 0 470 if( left->is_utf8 != right->is_utf8 ) {
324 0 0 if(left->is_utf8)
331 469 1 return (left->len == right->len) && memEQ(left->pv, right->pv, right->len);
467 2 return (left->len == right->len) && memEQ(left->pv, right->pv, right->len);
383 148 18 if (!c->loop) {
384 0 148 if(to_find->hash != 0) /* hash cache (except when the value is 0) */
390 1 147 if (cdb_read(c,buf,8,(u << 3) & 2047) == -1)
393 7 140 if (!c->hslots)
403 158 0 while (c->loop < c->hslots) {
404 0 158 if (cdb_read(c,buf,8,c->kpos) == -1)
407 11 147 if (!pos)
411 118 29 if (c->kpos == c->hpos + (c->hslots << 3))
414 147 0 if (u == c->khash) {
415 0 147 if (cdb_read(c,buf,8,pos) == -1)
418 147 0 if (next_key_len == to_find->len) {
448 548 7 if (c->curkey_allocated >= len && c->curkey_allocated < CDB_MAX_BUFFER_LEN) return;
548 0 if (c->curkey_allocated >= len && c->curkey_allocated < CDB_MAX_BUFFER_LEN) return;
451 7 0 if(len < CDB_MAX_BUFFER_LEN && c->curkey_allocated > CDB_MAX_BUFFER_LEN) {
0 7 if(len < CDB_MAX_BUFFER_LEN && c->curkey_allocated > CDB_MAX_BUFFER_LEN) {
458 0 7 if(c->curkey.pv)
472 0 56 if (cdb_read(c, buf, 4, 0) == -1)
484 409 47 if (c->curpos < c->end) {
485 0 409 if (cdb_read(c, buf, 8, c->curpos) == -1)
491 0 409 if (cdb_read(c, c->curkey.pv, klen, c->curpos + 8) == -1)
502 0 401 if (cdb_read(c, buf, 8, c->curpos) == -1)
510 31 11 if (c->end != 0) {
574 3 15 if(strlen(option_key) == 4 && strnEQ("utf8", option_key, 4) && is_utf8 )
3 0 if(strlen(option_key) == 4 && strnEQ("utf8", option_key, 4) && is_utf8 )
1 2 if(strlen(option_key) == 4 && strnEQ("utf8", option_key, 4) && is_utf8 )
585 1 17 if (!f)
593 17 0 if (fstat(fd, &st) == 0) {
594 17 0 if (st.st_size <= 0xffffffff) {
598 16 1 if (x != (char *)-1) {
620 1 174 if (!SvOK(k)) {
1 0 if (!SvOK(k)) {
1 0 if (!SvOK(k)) {
624 2 172 to_find.pv = this->is_utf8 ? SvPVutf8(k, to_find.len) : SvPV(k, to_find.len);
1 1 to_find.pv = this->is_utf8 ? SvPVutf8(k, to_find.len) : SvPV(k, to_find.len);
172 0 to_find.pv = this->is_utf8 ? SvPVutf8(k, to_find.len) : SvPV(k, to_find.len);
626 2 172 to_find.is_utf8 = this->is_utf8 && SvUTF8(k);
2 0 to_find.is_utf8 = this->is_utf8 && SvUTF8(k);
629 159 15 if (this->end && cdb_key_eq(&this->curkey, &to_find)) {
156 3 if (this->end && cdb_key_eq(&this->curkey, &to_find)) {
630 0 156 if (cdb_read(this, buf, 8, this->curpos) == -1)
634 126 30 if (this->fetch_advance) {
636 13 113 if (!iter_key(this)) {
645 16 2 if ((found != 0) && (found != 1)) readerror();
1 15 if ((found != 0) && (found != 1)) readerror();
648 171 2 if (found) {
674 110 12 while(iter_key(this)) {
677 110 0 if ((found != 0) && (found != 1))
0 110 if ((found != 0) && (found != 1))
685 0 110 if (! hv_store_ent(RETVAL, keysv, keyvalue, 0)) {
709 0 12 if (!SvOK(k)) {
0 0 if (!SvOK(k)) {
0 0 if (!SvOK(k)) {
716 0 12 to_find.pv = this->is_utf8 ? SvPVutf8(k, to_find.len) : SvPV(k, to_find.len);
0 0 to_find.pv = this->is_utf8 ? SvPVutf8(k, to_find.len) : SvPV(k, to_find.len);
11 1 to_find.pv = this->is_utf8 ? SvPVutf8(k, to_find.len) : SvPV(k, to_find.len);
722 18 12 if ((found != 0) && (found != 1))
0 18 if ((found != 0) && (found != 1))
724 12 18 if (!found)
745 1 8 if (!SvOK(k)) {
1 0 if (!SvOK(k)) {
1 0 if (!SvOK(k)) {
749 0 8 to_find.pv = this->is_utf8 ? SvPVutf8(k, to_find.len) : SvPV(k, to_find.len);
0 0 to_find.pv = this->is_utf8 ? SvPVutf8(k, to_find.len) : SvPV(k, to_find.len);
8 0 to_find.pv = this->is_utf8 ? SvPVutf8(k, to_find.len) : SvPV(k, to_find.len);
754 4 4 if (RETVAL != 0 && RETVAL != 1)
0 4 if (RETVAL != 0 && RETVAL != 1)
768 18 0 if (sv_isobject(db) && (SvTYPE(SvRV(db)) == SVt_PVMG) ) {
17 1 if (sv_isobject(db) && (SvTYPE(SvRV(db)) == SVt_PVMG) ) {
769 17 0 this = (cdb*)SvIV(SvRV(db));
771 7 10 if (this->curkey.pv)
776 16 1 if (this->map) {
791 21 3 if (iter_key(this)) {
808 0 165 if (!SvOK(k)) {
0 0 if (!SvOK(k)) {
0 0 if (!SvOK(k)) {
812 0 165 to_find.pv = this->is_utf8 ? SvPVutf8(k, to_find.len) : SvPV(k, to_find.len);
0 0 to_find.pv = this->is_utf8 ? SvPVutf8(k, to_find.len) : SvPV(k, to_find.len);
165 0 to_find.pv = this->is_utf8 ? SvPVutf8(k, to_find.len) : SvPV(k, to_find.len);
818 164 1 if (this->end == 0 || !cdb_key_eq(&this->curkey, &to_find))
0 164 if (this->end == 0 || !cdb_key_eq(&this->curkey, &to_find))
821 146 19 if (iter_key(this)) {
846 5 12 if(strlen(option_key) == 4 && strnEQ("utf8", option_key, 4) && is_utf8 )
5 0 if(strlen(option_key) == 4 && strnEQ("utf8", option_key, 4) && is_utf8 )
2 3 if(strlen(option_key) == 4 && strnEQ("utf8", option_key, 4) && is_utf8 )
857 1 16 if (!cdbmake->f) XSRETURN_UNDEF;
859 0 16 if (cdb_make_start(cdbmake) < 0) XSRETURN_UNDEF;
884 16 0 if (sv_isobject(sv) && (SvTYPE(SvRV(sv)) == SVt_PVMG) ) {
16 0 if (sv_isobject(sv) && (SvTYPE(SvRV(sv)) == SVt_PVMG) ) {
885 16 0 this = (cdb_make*)SvIV(SvRV(sv));
886 0 16 if(this->f) {
908 57 50 for (x = 1; x < items; x += 2) {
912 1 56 if(!SvOK(k)) {
1 0 if(!SvOK(k)) {
1 0 if(!SvOK(k)) {
917 2 55 if(!SvOK(v)) {
2 0 if(!SvOK(v)) {
2 0 if(!SvOK(v)) {
922 5 52 kp = is_utf8 ? SvPVutf8(k, klen) : SvPV(k, klen);
1 4 kp = is_utf8 ? SvPVutf8(k, klen) : SvPV(k, klen);
41 11 kp = is_utf8 ? SvPVutf8(k, klen) : SvPV(k, klen);
923 5 52 vp = is_utf8 ? SvPVutf8(v, vlen) : SvPV(v, vlen);
1 4 vp = is_utf8 ? SvPVutf8(v, vlen) : SvPV(v, vlen);
48 4 vp = is_utf8 ? SvPVutf8(v, vlen) : SvPV(v, vlen);
928 0 57 if (PerlIO_write(this->f, packbuf, 8) < 8)
932 0 57 if (PerlIO_write(this->f, kp, klen) < klen)
934 0 57 if (PerlIO_write(this->f, vp, vlen) < vlen)
937 0 57 if (cdb_make_addend(this, klen, vlen, h) == -1)
954 4096 16 for (i = 0; i < 256; ++i)
957 14 16 for (x = this->head; x; x = x->next) {
959 57 14 while (i--) {
965 4096 16 for (i = 0; i < 256; ++i) {
967 14 4082 if (u > memsize)
974 0 16 if (memsize > u) {
979 0 16 New(0xCDB, this->split, memsize, struct cdb_hp);
984 4096 16 for (i = 0; i < 256; ++i) {
990 14 16 for (x = this->head; x; x = x->next) {
992 57 14 while (i--) {
996 0 14 if (prev)
1001 14 2 if (prev)
1004 4096 16 for (i = 0; i < 256; ++i) {
1011 114 4096 for (u = 0; u < len; ++u) {
1016 57 4096 for (u = 0; u < count; ++u) {
1018 3 57 while (this->hash[where].p) {
1019 2 1 if (++where == len)
1026 114 4096 for (u = 0; u < len; ++u) {
1030 0 114 if (PerlIO_write(this->f, buf, 8) == -1)
1033 0 114 if (posplus(this, 8) == -1)
1040 0 16 if (PerlIO_flush(this->f) == EOF) writeerror();
1043 0 16 if (PerlIO_write(this->f, this->final, sizeof this->final) < sizeof this->final)
1046 0 16 if (PerlIO_flush(this->f) == EOF)
1049 0 16 if (fsync(PerlIO_fileno(this->f)) == -1)
1052 0 16 if (PerlIO_close(this->f) == EOF)
1056 0 16 if (rename(this->fntemp, this->fn)) {