diff options
| author | 2018-08-30 10:30:07 +0200 | |
|---|---|---|
| committer | 2018-08-30 10:30:07 +0200 | |
| commit | e5a37ca38ef7b28695313e4b59f62c03d4801f2d (patch) | |
| tree | b7a5efe0cb56076bb83916c21567a75673b678da | |
| parent | cdaac5c82433b97ae17d0576b185a7fd689c89a9 (diff) | |
| download | OneRoll-e5a37ca38ef7b28695313e4b59f62c03d4801f2d.tar.gz OneRoll-e5a37ca38ef7b28695313e4b59f62c03d4801f2d.zip | |
protect comment from alias
| -rw-r--r-- | dicealias.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/dicealias.cpp b/dicealias.cpp index f514e9e..5730187 100644 --- a/dicealias.cpp +++ b/dicealias.cpp @@ -33,6 +33,7 @@ QString makeReplament(const QString& pattern, const QString& replacement, QStrin { auto hasVariable = cmd.contains("${"); auto hasQuote = cmd.contains("\""); + auto commentPos = cmd.lastIndexOf("#"); if(!hasQuote && !hasVariable) { @@ -75,7 +76,6 @@ QString makeReplament(const QString& pattern, const QString& replacement, QStrin pos = start; } } - pos= 0; while((pos = cmd.indexOf(pattern,pos)) && pos!=-1) { @@ -84,9 +84,13 @@ QString makeReplament(const QString& pattern, const QString& replacement, QStrin { if(!isInsidePair) isInsidePair = (pos > pair.first && pos < pair.second); + + if(commentPos >= 0 && pos > commentPos) + isInsidePair = true; } if(!isInsidePair) patternPosList.push_back(pos); + pos+=1; } |