@@ -1161,6 +1161,44 @@ static void expandExpression(QCString &expr,QCString *rest,int pos)
1161
1161
}
1162
1162
}
1163
1163
1164
+ /*! @brief Process string or character literal.
1165
+ *
1166
+ * \a inputStr should point to the start of a string or character literal.
1167
+ * the routine will return a pointer to just after the end of the literal
1168
+ * the character making up the literal will be added to \a result.
1169
+ */
1170
+ const char *processUntilMatchingTerminator (const char *inputStr,QCString &result)
1171
+ {
1172
+ if (inputStr==0 ) return inputStr;
1173
+ char term = *inputStr; // capture start character of the literal
1174
+ if (term==0 || (term!=' \' ' && term!=' "' )) return inputStr; // not a valid literal
1175
+ char c=term;
1176
+ // output start character
1177
+ result+=c;
1178
+ inputStr++;
1179
+ while ((c=*inputStr)) // while inside the literal
1180
+ {
1181
+ if (c==term) // found end marker of the literal
1182
+ {
1183
+ // output end character and stop
1184
+ result+=c;
1185
+ inputStr++;
1186
+ break ;
1187
+ }
1188
+ else if (c==' \\ ' ) // escaped character, process next character
1189
+ // as well without checking for end marker.
1190
+ {
1191
+ result+=c;
1192
+ inputStr++;
1193
+ c=*inputStr;
1194
+ if (c==0 ) break ; // unexpected end of string after escape character
1195
+ }
1196
+ result+=c;
1197
+ inputStr++;
1198
+ }
1199
+ return inputStr;
1200
+ }
1201
+
1164
1202
/*! replaces all occurrences of @@@@ in \a s by @@
1165
1203
* and removes all occurrences of @@E.
1166
1204
* All identifiers found are replaced by 0L
@@ -1196,17 +1234,7 @@ QCString removeIdsAndMarkers(const char *s)
1196
1234
}
1197
1235
else if (c==' \' ' ) // quoted character
1198
1236
{
1199
- result+=c;
1200
- p++;
1201
- char pc=c;
1202
- while ((c=*p) && (c!=' \' ' || pc==' \\ ' ))
1203
- {
1204
- result+=c;
1205
- pc=c;
1206
- p++;
1207
- }
1208
- result+=c;
1209
- p++;
1237
+ p = processUntilMatchingTerminator (p,result);
1210
1238
}
1211
1239
else if (c==' d' && !inNum) // identifier starting with a `d'
1212
1240
{
@@ -1334,30 +1362,8 @@ QCString removeMarkers(const char *s)
1334
1362
}
1335
1363
break ;
1336
1364
case ' "' : // skip string literals
1337
- {
1338
- result+=c;
1339
- char pc=c;
1340
- c=*++p;
1341
- while (*p && (c!=' "' || pc==' \\ ' )) // no end quote
1342
- {
1343
- result+=c;
1344
- c=*++p;
1345
- }
1346
- if (*p) result+=c,p++;
1347
- }
1348
- break ;
1349
1365
case ' \' ' : // skip char literals
1350
- {
1351
- result+=c;
1352
- char pc=c;
1353
- c=*++p;
1354
- while (*p && (c!=' \' ' || pc==' \\ ' )) // no end quote
1355
- {
1356
- result+=c;
1357
- c=*++p;
1358
- }
1359
- if (*p) result+=c,p++;
1360
- }
1366
+ p = processUntilMatchingTerminator (p,result);
1361
1367
break ;
1362
1368
default :
1363
1369
{
0 commit comments