|
1 | 1 | /*****************************************************************************
|
2 | 2 | *
|
3 |
| - * |
4 |
| - * |
5 |
| - * Copyright (C) 1997-2015 by Dimitri van Heesch. |
| 3 | + * Copyright (C) 1997-2021 by Dimitri van Heesch. |
6 | 4 | *
|
7 | 5 | * Permission to use, copy, modify, and distribute this software and its
|
8 | 6 | * documentation under the terms of the GNU General Public License is hereby
|
|
31 | 29 | #include <algorithm>
|
32 | 30 | #include <vector>
|
33 | 31 | #include <utility>
|
| 32 | +#include <regex> |
34 | 33 |
|
35 | 34 | #include <stdio.h>
|
36 | 35 | #include <stdlib.h>
|
37 | 36 | #include <assert.h>
|
38 | 37 | #include <ctype.h>
|
39 | 38 |
|
40 |
| -#include <qregexp.h> |
41 | 39 | #include <qfile.h>
|
42 | 40 |
|
43 | 41 | #include "scanner.h"
|
@@ -3741,9 +3739,9 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP})
|
3741 | 3739 | }
|
3742 | 3740 | else
|
3743 | 3741 | {
|
3744 |
| - static QRegExp re("@[0-9]+$"); |
| 3742 | + static std::regex re("@[0-9]+$"); |
3745 | 3743 | if (!yyextra->isTypedef && yyextra->memspecEntry &&
|
3746 |
| - yyextra->memspecEntry->name.find(re)==-1) // not typedef or anonymous type (see bug691071) |
| 3744 | + !std::regex_search(yyextra->memspecEntry->name.str(),re)) // not typedef or anonymous type (see bug691071) |
3747 | 3745 | {
|
3748 | 3746 | // enabled the next two lines for bug 623424
|
3749 | 3747 | yyextra->current->doc.resize(0);
|
@@ -4833,10 +4831,16 @@ OPERATOR "operator"{B}*({ARITHOP}|{ASSIGNOP}|{LOGICOP}|{BITOP})
|
4833 | 4831 | yyextra->current->fileName = yyextra->yyFileName;
|
4834 | 4832 | yyextra->current->startLine = yyextra->yyBegLineNr;
|
4835 | 4833 | yyextra->current->startColumn = yyextra->yyBegColNr;
|
4836 |
| - static QRegExp re("([^)]*[*&][^)]*)"); // (...*...) |
| 4834 | + static std::regex re("\\([^)]*[*&][^]*\\)"); |
| 4835 | + std::smatch match; |
| 4836 | + std::string type = yyextra->current->type.str(); |
| 4837 | + int ti=-1; |
| 4838 | + if (std::regex_search(type,match,re)) |
| 4839 | + { |
| 4840 | + ti = (int)match.position(); |
| 4841 | + } |
4837 | 4842 | int ts=yyextra->current->type.find('<');
|
4838 | 4843 | int te=yyextra->current->type.findRev('>');
|
4839 |
| - int ti=yyextra->current->type.find(re,0); |
4840 | 4844 |
|
4841 | 4845 | // bug677315: A<int(void *, char *)> get(); is not a function pointer
|
4842 | 4846 | bool isFunction = ti==-1 || // not a (...*...) pattern
|
@@ -6891,28 +6895,29 @@ static void splitKnRArg(yyscan_t yyscanner,QCString &oldStyleArgPtr,QCString &ol
|
6891 | 6895 | int si = yyextra->current->args.length();
|
6892 | 6896 | if (yyextra->oldStyleArgType.isEmpty()) // new argument
|
6893 | 6897 | {
|
6894 |
| - static QRegExp re("([^)]*)"); |
6895 |
| - int bi1 = yyextra->current->args.findRev(re); |
6896 |
| - int bi2 = bi1!=-1 ? yyextra->current->args.findRev(re,bi1-1) : -1; |
| 6898 | + static std::regex re("(\\([^)]*\\))[[:space:]]*(\\([^)]*\\))?"); |
| 6899 | + std::string args = yyextra->current->args.str(); |
| 6900 | + std::smatch matches; |
| 6901 | + std::regex_search(args,matches,re); |
6897 | 6902 | char c;
|
6898 |
| - if (bi1!=-1 && bi2!=-1) // found something like "int (*func)(int arg)" |
| 6903 | + if (matches.length()==3 && !matches[2].str().empty()) // found something like "int (*func)(int arg)" |
6899 | 6904 | {
|
6900 |
| - int s=bi2+1; |
| 6905 | + size_t s = matches.position()+1; // keep opening ( |
6901 | 6906 | yyextra->oldStyleArgType = yyextra->current->args.left(s);
|
6902 |
| - int i=s; |
| 6907 | + int i=(int)s; |
6903 | 6908 | while (i<si && ((c=yyextra->current->args.at(i))=='*' || isspace((uchar)c))) i++;
|
6904 | 6909 | yyextra->oldStyleArgType += yyextra->current->args.mid(s,i-s);
|
6905 | 6910 | s=i;
|
6906 | 6911 | while (i<si && isId(yyextra->current->args.at(i))) i++;
|
6907 | 6912 | oldStyleArgName = yyextra->current->args.mid(s,i-s);
|
6908 | 6913 | yyextra->oldStyleArgType+=yyextra->current->args.mid(i);
|
6909 | 6914 | }
|
6910 |
| - else if (bi1!=-1) // redundant braces like in "int (*var)" |
| 6915 | + else if (matches.length()==3) // redundant braces like in "int (*var)" |
6911 | 6916 | {
|
6912 |
| - int s=bi1; |
| 6917 | + size_t s = matches.position(); // strip opening ( |
6913 | 6918 | yyextra->oldStyleArgType = yyextra->current->args.left(s);
|
6914 | 6919 | s++;
|
6915 |
| - int i=s+1; |
| 6920 | + int i=(int)s+1; |
6916 | 6921 | while (i<si && ((c=yyextra->current->args.at(i))=='*' || isspace((uchar)c))) i++;
|
6917 | 6922 | yyextra->oldStyleArgType += yyextra->current->args.mid(s,i-s);
|
6918 | 6923 | s=i;
|
|
0 commit comments