@@ -64,6 +64,9 @@ struct actionSpec {
64
64
const char * name ; /* for ACTION_FIND */
65
65
bool canonicalizing ;
66
66
struct canonWorkArea canon ;
67
+ ptrArray * tagEntryArray ;
68
+ void (* walkerfn ) (const tagEntry * , void * );
69
+ void * dataForWalkerFn ;
67
70
};
68
71
69
72
static const char * ProgramName ;
@@ -183,9 +186,7 @@ static void walkTags (tagFile *const file, tagEntry *first_entry,
183
186
void (* actionfn ) (const tagEntry * , void * ), void * data ,
184
187
struct actionSpec * actionSpec )
185
188
{
186
- ptrArray * a = NULL ;
187
- if (Sorter )
188
- a = ptrArrayNew ((ptrArrayDeleteFunc )freeCopiedTag );
189
+ ptrArray * a = actionSpec -> tagEntryArray ;
189
190
190
191
do
191
192
{
@@ -233,14 +234,8 @@ static void walkTags (tagFile *const file, tagEntry *first_entry,
233
234
234
235
if (a )
235
236
{
236
- ptrArraySort (a , compareTagEntry );
237
- size_t count = ptrArrayCount (a );
238
- for (unsigned int i = 0 ; i < count ; i ++ )
239
- {
240
- tagEntry * e = ptrArrayItem (a , i );
241
- (* actionfn ) (e , data );
242
- }
243
- ptrArrayDelete (a );
237
+ actionSpec -> walkerfn = actionfn ;
238
+ actionSpec -> dataForWalkerFn = data ;
244
239
}
245
240
}
246
241
#else
@@ -774,6 +769,9 @@ extern int main (int argc, char **argv)
774
769
.ptags = false,
775
770
/* .absoluteOnly = false, */
776
771
},
772
+ .tagEntryArray = NULL ,
773
+ .walkerfn = NULL ,
774
+ .dataForWalkerFn = NULL ,
777
775
};
778
776
779
777
memset (& printOpts , 0 , sizeof (printOpts ));
@@ -1106,7 +1104,14 @@ extern int main (int argc, char **argv)
1106
1104
break ;
1107
1105
}
1108
1106
1109
- for (unsigned int i = 0 ; i < ptrArrayCount (inputSpecs ); i ++ )
1107
+ unsigned int count = ptrArrayCount (inputSpecs );
1108
+ /* TODO: if Sorter == NULL but if count > 1 && sort is set to true in !_TAG_FILE_SORT,
1109
+ * we have to sort as if !_TAG_FILE_SORT is true.
1110
+ * Sorter must be build here. */
1111
+ if (Sorter || count > 1 )
1112
+ actionSpec .tagEntryArray = ptrArrayNew ((ptrArrayDeleteFunc )freeCopiedTag );
1113
+
1114
+ for (unsigned int i = 0 ; i < count ; i ++ )
1110
1115
{
1111
1116
struct inputSpec * inputSpec = ptrArrayItem (inputSpecs , i );
1112
1117
@@ -1137,6 +1142,19 @@ extern int main (int argc, char **argv)
1137
1142
}
1138
1143
}
1139
1144
1145
+ if (actionSpec .tagEntryArray )
1146
+ {
1147
+ if (Sorter )
1148
+ ptrArraySort (actionSpec .tagEntryArray , compareTagEntry );
1149
+ size_t count = ptrArrayCount (actionSpec .tagEntryArray );
1150
+ for (unsigned int i = 0 ; i < count ; i ++ )
1151
+ {
1152
+ tagEntry * e = ptrArrayItem (actionSpec .tagEntryArray , i );
1153
+ actionSpec .walkerfn (e , actionSpec .dataForWalkerFn );
1154
+ }
1155
+ ptrArrayDelete (actionSpec .tagEntryArray );
1156
+ }
1157
+
1140
1158
out :
1141
1159
ptrArrayDelete (inputSpecs );
1142
1160
0 commit comments