@@ -5123,63 +5123,19 @@ QCString insertTemplateSpecifierInScope(const QCString &scope,const QCString &te
5123
5123
return result;
5124
5124
}
5125
5125
5126
- # if 0 // original version
5126
+
5127
5127
/* ! Strips the scope from a name. Examples: A::B will return A
5128
5128
* and A<T>::B<N::C<D> > will return A<T>.
5129
5129
*/
5130
5130
QCString stripScope (const char *name)
5131
- {
5132
- QCString result = name;
5133
- int l=result.length();
5134
- int p=l-1;
5135
- bool done;
5136
- int count;
5137
-
5138
- while (p>=0)
5139
- {
5140
- char c=result.at(p);
5141
- switch (c)
5142
- {
5143
- case ':':
5144
- //printf("stripScope(%s)=%s\n",name,result.right(l-p-1).data());
5145
- return result.right(l-p-1);
5146
- case '>':
5147
- count=1;
5148
- done=FALSE;
5149
- //printf("pos < = %d\n",p);
5150
- p--;
5151
- while (p>=0 && !done)
5152
- {
5153
- c=result.at(p--);
5154
- switch (c)
5155
- {
5156
- case '>': count++; break;
5157
- case '<': count--; if (count<=0) done=TRUE; break;
5158
- default:
5159
- //printf("c=%c count=%d\n",c,count);
5160
- break;
5161
- }
5162
- }
5163
- //printf("pos > = %d\n",p+1);
5164
- break;
5165
- default:
5166
- p--;
5167
- }
5168
- }
5169
- //printf("stripScope(%s)=%s\n",name,name);
5170
- return name;
5171
- }
5172
- #endif
5173
-
5174
- // new version by Davide Cesari which also works for Fortran
5175
- QCString stripScope (const char *name)
5176
5131
{
5177
5132
QCString result = name;
5178
5133
int l=result.length ();
5179
5134
int p;
5180
5135
bool done = FALSE ;
5181
5136
bool skipBracket=FALSE ; // if brackets do not match properly, ignore them altogether
5182
5137
int count=0 ;
5138
+ int round=0 ;
5183
5139
5184
5140
do
5185
5141
{
@@ -5192,7 +5148,10 @@ QCString stripScope(const char *name)
5192
5148
case ' :' :
5193
5149
// only exit in the case of ::
5194
5150
// printf("stripScope(%s)=%s\n",name,result.right(l-p-1).data());
5195
- if (p>0 && result.at (p-1 )==' :' ) return result.right (l-p-1 );
5151
+ if (p>0 && result.at (p-1 )==' :' && (count==0 || skipBracket))
5152
+ {
5153
+ return result.right (l-p-1 );
5154
+ }
5196
5155
p--;
5197
5156
break ;
5198
5157
case ' >' :
@@ -5216,20 +5175,29 @@ QCString stripScope(const char *name)
5216
5175
c=result.at (p--);
5217
5176
switch (c)
5218
5177
{
5219
- case ' >' :
5220
- count++;
5178
+ case ' )' :
5179
+ round++;
5180
+ break ;
5181
+ case ' (' :
5182
+ round--;
5183
+ break ;
5184
+ case ' >' : // ignore > inside (...) to support e.g. (sizeof(T)>0) inside template parameters
5185
+ if (round==0 ) count++;
5221
5186
break ;
5222
5187
case ' <' :
5223
- if (p> 0 )
5188
+ if (round== 0 )
5224
5189
{
5225
- if (result. at (p- 1 ) == ' < ' ) // skip << operator
5190
+ if (p> 0 )
5226
5191
{
5227
- p--;
5228
- break ;
5192
+ if (result.at (p-1 ) == ' <' ) // skip << operator
5193
+ {
5194
+ p--;
5195
+ break ;
5196
+ }
5229
5197
}
5198
+ count--;
5199
+ foundMatch = count==0 ;
5230
5200
}
5231
- count--;
5232
- foundMatch = count==0 ;
5233
5201
break ;
5234
5202
default :
5235
5203
// printf("c=%c count=%d\n",c,count);
@@ -5910,19 +5878,19 @@ QCString stripTemplateSpecifiersFromScope(const QCString &fullName,
5910
5878
{
5911
5879
// printf("1:result+=%s\n",fullName.mid(p,i-p).data());
5912
5880
int e=i+1 ;
5913
- bool done=FALSE ;
5914
5881
int count=1 ;
5915
- while (e<l && !done)
5882
+ int round=0 ;
5883
+ while (e<l && count>0 )
5916
5884
{
5917
5885
char c=fullName.at (e++);
5918
- if (c==' <' )
5919
- {
5920
- count++;
5921
- }
5922
- else if (c==' >' )
5886
+ switch (c)
5923
5887
{
5924
- count--;
5925
- done = count==0 ;
5888
+ case ' (' : round++; break ;
5889
+ case ' )' : if (round>0 ) round--; break ;
5890
+ case ' <' : if (round==0 ) count++; break ;
5891
+ case ' >' : if (round==0 ) count--; break ;
5892
+ default :
5893
+ break ;
5926
5894
}
5927
5895
}
5928
5896
int si= fullName.find (" ::" ,e);
0 commit comments