| 1 |
|
| #include "EXTERN.h" |
| 2 |
|
| #include "perl.h" |
| 3 |
|
| #include "XSUB.h" |
| 4 |
|
| |
| 5 |
|
| #include "ppport.h" |
| 6 |
|
| |
| 7 |
|
| #include "readtags.h" |
| 8 |
|
| #include "tagEntry_to_HV.h" |
| 9 |
|
| |
| 10 |
|
| typedef struct { |
| 11 |
|
| tagFile* file; |
| 12 |
|
| tagFileInfo* fileInfo; |
| 13 |
|
| tagEntry* entryBuffer; |
| 14 |
|
| } myTagFile; |
| 15 |
|
| |
| 16 |
|
| |
| 17 |
|
| |
| 18 |
|
| /*tagResult |
| 19 |
|
| tagsSetSortType(file, type) |
| 20 |
|
| tagFile * file |
| 21 |
|
| sortType type |
| 22 |
|
| */ |
| 23 |
|
| |
| 24 |
|
| MODULE = Parse::ExuberantCTags PACKAGE = Parse::ExuberantCTags |
| 25 |
|
| PROTOTYPES: DISABLE |
| 26 |
|
| |
| 27 |
|
| myTagFile* |
| 28 |
|
| new(CLASS, path) |
| 29 |
|
| char* CLASS |
| 30 |
|
| char* path |
| 31 |
|
| PREINIT: |
| 32 |
|
| tagFile* theFile; |
| 33 |
|
| tagFileInfo* theInfo; |
| 34 |
|
| CODE: |
| 35 |
2 |
| theInfo = (tagFileInfo*)safemalloc( sizeof(tagFileInfo) ); |
| 36 |
2 |
▶ | if( theInfo == NULL ){ |
Branch: 1 branch
| Branch | True | False | Total |
| if( theInfo == NULL ){ |
0 |
2 |
2 |
|
| 37 |
0 |
| warn("unable to malloc tagFileInfo"); |
| 38 |
0 |
| XSRETURN_UNDEF; |
| 39 |
|
| } |
| 40 |
|
| |
| 41 |
2 |
| theFile = tagsOpen(path, theInfo); |
| 42 |
2 |
▶ | if (theFile == NULL) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (theFile == NULL) { |
1 |
1 |
2 |
|
| 43 |
1 |
| safefree(theInfo); |
| 44 |
1 |
| XSRETURN_UNDEF; |
| 45 |
|
| } |
| 46 |
|
| |
| 47 |
1 |
▶ | if (theInfo->status.opened == 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (theInfo->status.opened == 0) { |
0 |
1 |
1 |
|
| 48 |
0 |
| safefree(theFile); |
| 49 |
0 |
| safefree(theInfo); |
| 50 |
0 |
| XSRETURN_UNDEF; |
| 51 |
|
| } |
| 52 |
|
| |
| 53 |
1 |
| RETVAL = (myTagFile*)safemalloc( sizeof(myTagFile) ); |
| 54 |
1 |
▶ | if( RETVAL == NULL ){ |
Branch: 1 branch
| Branch | True | False | Total |
| if( RETVAL == NULL ){ |
0 |
1 |
1 |
|
| 55 |
0 |
| warn("unable to malloc myTagFile"); |
| 56 |
0 |
| tagsClose(theFile); |
| 57 |
0 |
| safefree(theInfo); |
| 58 |
0 |
| XSRETURN_UNDEF; |
| 59 |
|
| } |
| 60 |
|
| |
| 61 |
1 |
| RETVAL->entryBuffer = (tagEntry*)safemalloc( sizeof(tagEntry) ); |
| 62 |
1 |
▶ | if( RETVAL == NULL ){ |
Branch: 1 branch
| Branch | True | False | Total |
| if( RETVAL == NULL ){ |
0 |
1 |
1 |
|
| 63 |
0 |
| warn("unable to malloc tagEntry"); |
| 64 |
0 |
| tagsClose(theFile); |
| 65 |
0 |
| safefree(theInfo); |
| 66 |
0 |
| safefree(RETVAL); |
| 67 |
0 |
| XSRETURN_UNDEF; |
| 68 |
|
| } |
| 69 |
1 |
| RETVAL->file = theFile; |
| 70 |
1 |
| RETVAL->fileInfo = theInfo; |
| 71 |
|
| OUTPUT: |
| 72 |
|
| RETVAL |
| 73 |
|
| |
| 74 |
|
| |
| 75 |
|
| void |
| 76 |
|
| DESTROY(self) |
| 77 |
|
| myTagFile* self |
| 78 |
|
| CODE: |
| 79 |
1 |
▶ | if (self->file != NULL) |
Branch: 1 branch
| Branch | True | False | Total |
| if (self->file != NULL) |
1 |
0 |
1 |
|
| 80 |
1 |
| tagsClose(self->file); |
| 81 |
1 |
| safefree(self->fileInfo); |
| 82 |
1 |
| safefree(self->entryBuffer); |
| 83 |
1 |
| safefree(self); |
| 84 |
|
| |
| 85 |
|
| |
| 86 |
|
| SV* |
| 87 |
|
| firstTag(self) |
| 88 |
|
| myTagFile* self |
| 89 |
|
| PREINIT: |
| 90 |
|
| HV* result; |
| 91 |
|
| CODE: |
| 92 |
2 |
▶ | if (self->file == NULL) |
Branch: 1 branch
| Branch | True | False | Total |
| if (self->file == NULL) |
0 |
2 |
2 |
|
| 93 |
0 |
| XSRETURN_UNDEF; |
| 94 |
2 |
▶ | if (tagsFirst(self->file, self->entryBuffer) == TagFailure) |
Branch: 1 branch
| Branch | True | False | Total |
| if (tagsFirst(self->file, self->entryBuffer) == TagFailure) |
0 |
2 |
2 |
|
| 95 |
0 |
| XSRETURN_UNDEF; |
| 96 |
2 |
| result = tagEntry_to_HV(self->entryBuffer); |
| 97 |
2 |
| RETVAL = newRV_noinc((SV*) result); |
| 98 |
|
| OUTPUT: |
| 99 |
|
| RETVAL |
| 100 |
|
| |
| 101 |
|
| |
| 102 |
|
| SV* |
| 103 |
|
| nextTag(self) |
| 104 |
|
| myTagFile* self |
| 105 |
|
| PREINIT: |
| 106 |
|
| HV* result; |
| 107 |
|
| CODE: |
| 108 |
4 |
▶ | if (self->file == NULL) |
Branch: 1 branch
| Branch | True | False | Total |
| if (self->file == NULL) |
0 |
4 |
4 |
|
| 109 |
0 |
| XSRETURN_UNDEF; |
| 110 |
4 |
▶ | if (tagsNext(self->file, self->entryBuffer) == TagFailure) |
Branch: 1 branch
| Branch | True | False | Total |
| if (tagsNext(self->file, self->entryBuffer) == TagFailure) |
1 |
3 |
4 |
|
| 111 |
1 |
| XSRETURN_UNDEF; |
| 112 |
3 |
| result = tagEntry_to_HV(self->entryBuffer); |
| 113 |
3 |
| RETVAL = newRV_noinc((SV*) result); |
| 114 |
|
| OUTPUT: |
| 115 |
|
| RETVAL |
| 116 |
|
| |
| 117 |
|
| |
| 118 |
|
| SV* |
| 119 |
|
| findTag(self, name, ...) |
| 120 |
|
| myTagFile* self |
| 121 |
|
| char* name |
| 122 |
|
| PREINIT: |
| 123 |
9 |
| int options = TAG_FULLMATCH | TAG_OBSERVECASE; |
| 124 |
|
| unsigned int i; |
| 125 |
|
| SV* sv; |
| 126 |
|
| HV* result; |
| 127 |
|
| CODE: |
| 128 |
9 |
▶ | if ( (items % 2) == 1 ) |
Branch: 1 branch
| Branch | True | False | Total |
| if ( (items % 2) == 1 ) |
0 |
9 |
9 |
|
| 129 |
0 |
| croak("Syntax: ->findTag('tagname', [option => value, ...])"); |
| 130 |
|
| |
| 131 |
9 |
▶ | if (self->file == NULL) |
Branch: 1 branch
| Branch | True | False | Total |
| if (self->file == NULL) |
0 |
9 |
9 |
|
| 132 |
0 |
| XSRETURN_UNDEF; |
| 133 |
|
| |
| 134 |
9 |
▶ | if (items > 2) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (items > 2) { |
5 |
4 |
9 |
|
| 135 |
12 |
▶ | for (i = 2; i < (unsigned int)items; i += 2) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 2; i < (unsigned int)items; i += 2) { |
7 |
5 |
12 |
|
| 136 |
7 |
| sv = ST(i); |
| 137 |
7 |
▶ | if ( SvOK(sv) ) { |
Branch: 1 branch
| Branch | True | False | Total |
| if ( SvOK(sv) ) { |
7 |
0 |
7 |
|
| 138 |
7 |
▶ | if ( strEQ(SvPV_nolen(sv), "partial") && SvTRUE(ST(i+1)) ) |
Branch: 2 branches
| Branch | True | False | Total |
| if ( strEQ(SvPV_nolen(sv), "partial") && SvTRUE(ST(i+1)) ) |
3 |
4 |
7 |
| if ( strEQ(SvPV_nolen(sv), "partial") && SvTRUE(ST(i+1)) ) |
3 |
0 |
3 |
|
| 139 |
3 |
| options |= TAG_PARTIALMATCH; |
| 140 |
4 |
▶ | else if ( strEQ(SvPV_nolen(sv), "ignore_case") && SvTRUE(ST(i+1)) ) |
Branch: 2 branches
| Branch | True | False | Total |
| else if ( strEQ(SvPV_nolen(sv), "ignore_case") && SvTRUE(ST(i+1)) ) |
4 |
0 |
4 |
| else if ( strEQ(SvPV_nolen(sv), "ignore_case") && SvTRUE(ST(i+1)) ) |
4 |
0 |
4 |
|
| 141 |
4 |
| options |= TAG_IGNORECASE; |
| 142 |
|
| } |
| 143 |
|
| } |
| 144 |
|
| } /* end if optional args */ |
| 145 |
9 |
▶ | if (tagsFind(self->file, self->entryBuffer, name, options) == TagFailure) |
Branch: 1 branch
| Branch | True | False | Total |
| if (tagsFind(self->file, self->entryBuffer, name, options) == TagFailure) |
3 |
6 |
9 |
|
| 146 |
3 |
| XSRETURN_UNDEF; |
| 147 |
6 |
| result = tagEntry_to_HV(self->entryBuffer); |
| 148 |
6 |
| RETVAL = newRV_noinc((SV*) result); |
| 149 |
|
| OUTPUT: |
| 150 |
|
| RETVAL |
| 151 |
|
| |
| 152 |
|
| |
| 153 |
|
| |
| 154 |
|
| SV* |
| 155 |
|
| findNextTag(self) |
| 156 |
|
| myTagFile* self |
| 157 |
|
| PREINIT: |
| 158 |
|
| HV* result; |
| 159 |
|
| CODE: |
| 160 |
2 |
▶ | if (self->file == NULL) |
Branch: 1 branch
| Branch | True | False | Total |
| if (self->file == NULL) |
0 |
2 |
2 |
|
| 161 |
0 |
| XSRETURN_UNDEF; |
| 162 |
2 |
▶ | if (tagsFindNext(self->file, self->entryBuffer) == TagFailure) |
Branch: 1 branch
| Branch | True | False | Total |
| if (tagsFindNext(self->file, self->entryBuffer) == TagFailure) |
1 |
1 |
2 |
|
| 163 |
1 |
| XSRETURN_UNDEF; |
| 164 |
1 |
| result = tagEntry_to_HV(self->entryBuffer); |
| 165 |
1 |
| RETVAL = newRV_noinc((SV*) result); |
| 166 |
|
| OUTPUT: |
| 167 |
|
| RETVAL |
| 168 |
|
| |
| 169 |
|
| |