summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Spendrin <ps_ml@gmx.de>2015-12-16 01:05:58 (GMT)
committerPatrick Spendrin <ps_ml@gmx.de>2015-12-28 21:48:25 (GMT)
commitd0ecab47368288ec00318dccb6dfcd9fc79a8e8b (patch)
tree9d0071596ba5c4d65f9a697cb8478aac388625e8
parent9689a8eccd39469fa6c7ecd37b7ea12f8498f6e6 (diff)
Windows string fixes
This patch changes multiline QStringLiterals to QString::fromLatin1 as QStringLiterals doesn't understand multiline strings on windows. Also, strncasecmp is replaced by the portable qstrnicmp function provided by QByteArray header. REVIEW: 126379
-rw-r--r--generators/dvi/dviRenderer_prescan.cpp21
-rw-r--r--generators/dvi/psgs.cpp2
-rw-r--r--generators/dvi/special.cpp28
-rw-r--r--generators/epub/converter.cpp2
-rw-r--r--ui/latexrenderer.cpp2
-rw-r--r--ui/pageview.cpp2
6 files changed, 29 insertions, 28 deletions
diff --git a/generators/dvi/dviRenderer_prescan.cpp b/generators/dvi/dviRenderer_prescan.cpp
index 783c727..bce2185 100644
--- a/generators/dvi/dviRenderer_prescan.cpp
+++ b/generators/dvi/dviRenderer_prescan.cpp
@@ -22,6 +22,7 @@
#include <kprocess.h>
#include <QApplication>
+#include <QByteArray>
#include <QDir>
#include <QFileInfo>
#include <QImage>
@@ -44,7 +45,7 @@ void dviRenderer::prescan_embedPS(char *cp, quint8 *beginningOfSpecialCommand)
#endif
// Encapsulated Postscript File
- if (strncasecmp(cp, "PSfile=", 7) != 0)
+ if (qstrnicmp(cp, "PSfile=", 7) != 0)
return;
QString command(cp+7);
@@ -230,7 +231,7 @@ void dviRenderer::prescan_removePageSizeInfo(char *cp, quint8 *beginningOfSpecia
#endif
// Encapsulated Postscript File
- if (strncasecmp(cp, "papersize=", 10) != 0)
+ if (qstrnicmp(cp, "papersize=", 10) != 0)
return;
for (quint8 *ptr=beginningOfSpecialCommand; ptr<command_pointer; ptr++)
@@ -526,25 +527,25 @@ void dviRenderer::prescan_parseSpecials(char *cp, quint8 *)
// prescan phase, and NOT during rendering.
// PaperSize special
- if (strncasecmp(cp, "papersize", 9) == 0) {
+ if (qstrnicmp(cp, "papersize", 9) == 0) {
prescan_ParsePapersizeSpecial(special_command.mid(9));
return;
}
// color special for background color
- if (strncasecmp(cp, "background", 10) == 0) {
+ if (qstrnicmp(cp, "background", 10) == 0) {
prescan_ParseBackgroundSpecial(special_command.mid(10));
return;
}
// HTML anchor special
- if (strncasecmp(cp, "html:<A name=", 13) == 0) {
+ if (qstrnicmp(cp, "html:<A name=", 13) == 0) {
prescan_ParseHTMLAnchorSpecial(special_command.mid(14));
return;
}
// Postscript Header File
- if (strncasecmp(cp, "header=", 7) == 0) {
+ if (qstrnicmp(cp, "header=", 7) == 0) {
prescan_ParsePSHeaderSpecial(special_command.mid(7));
return;
}
@@ -562,19 +563,19 @@ void dviRenderer::prescan_parseSpecials(char *cp, quint8 *)
}
// PS-Postscript inclusion
- if (strncasecmp(cp, "ps:", 3) == 0) {
+ if (qstrnicmp(cp, "ps:", 3) == 0) {
prescan_ParsePSSpecial(special_command);
return;
}
// Encapsulated Postscript File
- if (strncasecmp(cp, "PSfile=", 7) == 0) {
+ if (qstrnicmp(cp, "PSfile=", 7) == 0) {
prescan_ParsePSFileSpecial(special_command.mid(7));
return;
}
// source special
- if (strncasecmp(cp, "src:", 4) == 0) {
+ if (qstrnicmp(cp, "src:", 4) == 0) {
prescan_ParseSourceSpecial(special_command.mid(4));
return;
}
@@ -583,7 +584,7 @@ void dviRenderer::prescan_parseSpecials(char *cp, quint8 *)
// both during rendering and during the pre-scan phase
// HTML anchor end
- if (strncasecmp(cp, "html:</A>", 9) == 0) {
+ if (qstrnicmp(cp, "html:</A>", 9) == 0) {
html_anchor_end();
return;
}
diff --git a/generators/dvi/psgs.cpp b/generators/dvi/psgs.cpp
index b1eedc4..466e642 100644
--- a/generators/dvi/psgs.cpp
+++ b/generators/dvi/psgs.cpp
@@ -255,7 +255,7 @@ void ghostscript_interface::gs_generate_graphics_file(const PageNumber& page, co
while(proc.canReadLine()) {
GSoutput = QString::fromLocal8Bit(proc.readLine());
if (GSoutput.contains(QStringLiteral("Unknown device"))) {
- qCDebug(OkularDviDebug) << QStringLiteral("The version of ghostview installed on this computer does not support "
+ qCDebug(OkularDviDebug) << QString::fromLatin1("The version of ghostview installed on this computer does not support "
"the '%1' ghostview device driver.").arg(*gsDevice) << endl;
knownDevices.erase(gsDevice);
gsDevice = knownDevices.begin();
diff --git a/generators/dvi/special.cpp b/generators/dvi/special.cpp
index 6a9fe69..522c017 100644
--- a/generators/dvi/special.cpp
+++ b/generators/dvi/special.cpp
@@ -20,13 +20,13 @@
#include <QMimeType>
#include <QMimeDatabase>
+#include <QByteArray>
#include <QFile>
#include <QFontDatabase>
#include <QImage>
#include <QPainter>
#include "debug_dvi.h"
-
void dviRenderer::printErrorMsgForSpecials(const QString& msg)
{
if (dviFile->errorCounter < 25) {
@@ -517,45 +517,45 @@ void dviRenderer::applicationDoSpecial(char *cp)
// and NOT during the prescan phase
// font color specials
- if (strncasecmp(cp, "color", 5) == 0) {
+ if (qstrnicmp(cp, "color", 5) == 0) {
color_special(special_command.mid(5));
return;
}
// HTML reference
- if (strncasecmp(cp, "html:<A href=", 13) == 0) {
+ if (qstrnicmp(cp, "html:<A href=", 13) == 0) {
html_href_special(special_command.mid(14));
return;
}
// HTML anchor end
- if (strncasecmp(cp, "html:</A>", 9) == 0) {
+ if (qstrnicmp(cp, "html:</A>", 9) == 0) {
html_anchor_end();
return;
}
// TPIC specials
- if (strncasecmp(cp, "pn", 2) == 0) {
+ if (qstrnicmp(cp, "pn", 2) == 0) {
TPIC_setPen_special(special_command.mid(2));
return;
}
- if (strncasecmp(cp, "pa ", 3) == 0) {
+ if (qstrnicmp(cp, "pa ", 3) == 0) {
TPIC_addPath_special(special_command.mid(3));
return;
}
- if (strncasecmp(cp, "fp", 2) == 0) {
+ if (qstrnicmp(cp, "fp", 2) == 0) {
TPIC_flushPath_special();
return;
}
// Encapsulated Postscript File
- if (strncasecmp(cp, "PSfile=", 7) == 0) {
+ if (qstrnicmp(cp, "PSfile=", 7) == 0) {
epsf_special(special_command.mid(7));
return;
}
// source special
- if (strncasecmp(cp, "src:", 4) == 0) {
+ if (qstrnicmp(cp, "src:", 4) == 0) {
source_special(special_command.mid(4));
return;
}
@@ -694,11 +694,11 @@ void dviRenderer::applicationDoSpecial(char *cp)
// unrecognized special commands.
if ((cp[0] == '!') ||
(cp[0] == '"') ||
- (strncasecmp(cp, "html:<A name=", 13) == 0) ||
- (strncasecmp(cp, "ps:", 3) == 0) ||
- (strncasecmp(cp, "papersize", 9) == 0) ||
- (strncasecmp(cp, "header", 6) == 0) ||
- (strncasecmp(cp, "background", 10) == 0) )
+ (qstrnicmp(cp, "html:<A name=", 13) == 0) ||
+ (qstrnicmp(cp, "ps:", 3) == 0) ||
+ (qstrnicmp(cp, "papersize", 9) == 0) ||
+ (qstrnicmp(cp, "header", 6) == 0) ||
+ (qstrnicmp(cp, "background", 10) == 0) )
return;
printErrorMsgForSpecials(i18n("The special command '%1' is not implemented.", special_command));
diff --git a/generators/epub/converter.cpp b/generators/epub/converter.cpp
index 16a6b5b..0f563fe 100644
--- a/generators/epub/converter.cpp
+++ b/generators/epub/converter.cpp
@@ -297,7 +297,7 @@ QTextDocument* Converter::convert( const QString &fileName )
QTextBlock before;
if(firstPage) {
// preHtml & postHtml make it possible to have a margin around the content of the page
- const QString preHtml = QStringLiteral("<html><head></head><body>"
+ const QString preHtml = QString::fromLatin1("<html><head></head><body>"
"<table style=\"-qt-table-type: root; margin-top:%1px; margin-bottom:%1px; margin-left:%1px; margin-right:%1px;\">"
"<tr>"
"<td style=\"border: none;\">").arg(mTextDocument->padding);
diff --git a/ui/latexrenderer.cpp b/ui/latexrenderer.cpp
index 8e42a9f..fbc93b6 100644
--- a/ui/latexrenderer.cpp
+++ b/ui/latexrenderer.cpp
@@ -191,7 +191,7 @@ LatexRenderer::Error LatexRenderer::handleLatex( QString& fileName, const QStrin
bool LatexRenderer::securityCheck( const QString &latexFormula )
{
- return !latexFormula.contains(QRegExp(QStringLiteral("\\\\(def|let|futurelet|newcommand|renewcommand|else|fi|write|input|include"
+ return !latexFormula.contains(QRegExp(QString::fromLatin1("\\\\(def|let|futurelet|newcommand|renewcommand|else|fi|write|input|include"
"|chardef|catcode|makeatletter|noexpand|toksdef|every|errhelp|errorstopmode|scrollmode|nonstopmode|batchmode"
"|read|csname|newhelp|relax|afterground|afterassignment|expandafter|noexpand|special|command|loop|repeat|toks"
"|output|line|mathcode|name|item|section|mbox|DeclareRobustCommand)[^a-zA-Z]")));
diff --git a/ui/pageview.cpp b/ui/pageview.cpp
index 13727e4..ee7aad1 100644
--- a/ui/pageview.cpp
+++ b/ui/pageview.cpp
@@ -2893,7 +2893,7 @@ void PageView::mouseReleaseEvent( QMouseEvent * e )
xs.append(1.0);
ys.prepend(0.0);
ys.append(1.0);
- selHtml = QStringLiteral("<html><head>"
+ selHtml = QString::fromLatin1("<html><head>"
"<meta content=\"text/html; charset=utf-8\" http-equiv=\"Content-Type\">"
"</head><body><table>");
for (int r=0; r+1<ys.length(); r++) {