Changeset View
Changeset View
Standalone View
Standalone View
fish/fish.cpp
Show All 24 Lines | |||||
25 | */ | 25 | */ | ||
26 | 26 | | |||
27 | #include "fish.h" | 27 | #include "fish.h" | ||
28 | 28 | | |||
29 | #include <config-runtime.h> | 29 | #include <config-runtime.h> | ||
30 | #include <config-fish.h> | 30 | #include <config-fish.h> | ||
31 | #include <QFile> | 31 | #include <QFile> | ||
32 | #include <QDateTime> | 32 | #include <QDateTime> | ||
33 | #include <QRegExp> | 33 | #include <QRegularExpression> | ||
34 | #include <QCoreApplication> | 34 | #include <QCoreApplication> | ||
35 | #include <QDebug> | 35 | #include <QDebug> | ||
36 | #include <QStandardPaths> | 36 | #include <QStandardPaths> | ||
37 | #include <QMimeType> | 37 | #include <QMimeType> | ||
38 | #include <QMimeDatabase> | 38 | #include <QMimeDatabase> | ||
39 | 39 | | |||
40 | #include <stdlib.h> | 40 | #include <stdlib.h> | ||
41 | #include <sys/resource.h> | 41 | #include <sys/resource.h> | ||
▲ Show 20 Lines • Show All 740 Lines • ▼ Show 20 Line(s) | |||||
782 | bool fishProtocol::sendCommand(fish_command_type cmd, ...) { | 782 | bool fishProtocol::sendCommand(fish_command_type cmd, ...) { | ||
783 | const fish_info &info = fishInfo[cmd]; | 783 | const fish_info &info = fishInfo[cmd]; | ||
784 | myDebug( << "queuing: cmd="<< cmd << "['" << info.command << "'](" << info.params <<"), alt=['" << info.alt << "'], lines=" << info.lines); | 784 | myDebug( << "queuing: cmd="<< cmd << "['" << info.command << "'](" << info.params <<"), alt=['" << info.alt << "'], lines=" << info.lines); | ||
785 | 785 | | |||
786 | va_list list; | 786 | va_list list; | ||
787 | va_start(list, cmd); | 787 | va_start(list, cmd); | ||
788 | QString realCmd = info.command; | 788 | QString realCmd = info.command; | ||
789 | QString realAlt = info.alt; | 789 | QString realAlt = info.alt; | ||
790 | static QRegExp rx("[][\\\\\n $`#!()*?{}~&<>;'\"%^@|\t]"); | 790 | static const QRegularExpression rx("[][\\\\\n $`#!()*?{}~&<>;'\"%^@|\t]"); | ||
791 | for (int i = 0; i < info.params; i++) { | 791 | for (int i = 0; i < info.params; i++) { | ||
792 | QString arg(va_arg(list, const char *)); | 792 | QString arg(va_arg(list, const char *)); | ||
793 | int pos = -2; | 793 | int pos = -2; | ||
794 | while ((pos = rx.indexIn(arg,pos+2)) >= 0) { | 794 | while ((pos = arg.indexOf(rx, pos + 2)) >= 0) { | ||
795 | arg.replace(pos,0,QString("\\")); | 795 | arg.replace(pos,0,QString("\\")); | ||
796 | } | 796 | } | ||
797 | //myDebug( << "arg " << i << ": " << arg); | 797 | //myDebug( << "arg " << i << ": " << arg); | ||
798 | realCmd.append(" ").append(arg); | 798 | realCmd.append(" ").append(arg); | ||
799 | realAlt.replace(QRegExp('%'+QString::number(i+1)),arg); | 799 | realAlt.replace(QRegularExpression(QLatin1Char('%') + QString::number(i + 1)), arg); | ||
800 | } | 800 | } | ||
801 | QString s("#"); | 801 | QString s("#"); | ||
802 | s.append(realCmd).append("\n ").append(realAlt).append(" 2>&1;echo '### 000'\n"); | 802 | s.append(realCmd).append("\n ").append(realAlt).append(" 2>&1;echo '### 000'\n"); | ||
803 | if (realCmd == "FISH") | 803 | if (realCmd == "FISH") | ||
804 | s.prepend(" "); | 804 | s.prepend(" "); | ||
805 | commandList.append(s); | 805 | commandList.append(s); | ||
806 | commandCodes.append(cmd); | 806 | commandCodes.append(cmd); | ||
807 | va_end(list); | 807 | va_end(list); | ||
▲ Show 20 Lines • Show All 906 Lines • Show Last 20 Lines |