summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlbert Astals Cid <aacid@kde.org>2018-01-08 22:55:00 +0100
committerAlbert Astals Cid <aacid@kde.org>2018-01-08 22:55:00 +0100
commite428033c2d7efbbbf89bb2f84c8998521ac7ef8e (patch)
tree546f48df418659224c4500adc01fcddb4d9384a9 /test
parent2e47887616155dee566083e1aac9adab69aa4386 (diff)
Run clang-tidy with modernize nullptr
Also add two enum values in the qt5 frontend to representate no flags Also mark glib/gtk/cairo system includes so that gcc doesn't report the issues in those headers
Diffstat (limited to 'test')
-rw-r--r--test/CMakeLists.txt5
-rw-r--r--test/gtk-test.cc28
-rw-r--r--test/pdf-fullrewrite.cc14
-rw-r--r--test/pdf-inspector.cc22
-rw-r--r--test/perf-test.cc66
5 files changed, 69 insertions, 66 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 5bae1c7b..b6c1df29 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -17,7 +17,10 @@ endif ()
if (GTK_FOUND)
- add_definitions(${GTK3_CFLAGS})
+ include_directories(
+ SYSTEM
+ ${GTK3_INCLUDE_DIRS}
+ )
include_directories(
${CMAKE_SOURCE_DIR}/glib
diff --git a/test/gtk-test.cc b/test/gtk-test.cc
index 6f5e6216..de633481 100644
--- a/test/gtk-test.cc
+++ b/test/gtk-test.cc
@@ -24,16 +24,16 @@
static int page = 0;
static gboolean cairo_output = FALSE;
static gboolean splash_output = FALSE;
-static const char **file_arguments = NULL;
+static const char **file_arguments = nullptr;
static const GOptionEntry options[] = {
- { "cairo", 'c', 0, G_OPTION_ARG_NONE, &cairo_output, "Cairo Output Device", NULL},
- { "splash", 's', 0, G_OPTION_ARG_NONE, &splash_output, "Splash Output Device", NULL},
+ { "cairo", 'c', 0, G_OPTION_ARG_NONE, &cairo_output, "Cairo Output Device", nullptr},
+ { "splash", 's', 0, G_OPTION_ARG_NONE, &splash_output, "Splash Output Device", nullptr},
{ "page", 'p', 0, G_OPTION_ARG_INT, &page, "Page number", "PAGE" },
- { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &file_arguments, NULL, "PDF-FILES…" },
- { NULL }
+ { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &file_arguments, nullptr, "PDF-FILES…" },
+ { nullptr }
};
-static GList *view_list = NULL;
+static GList *view_list = nullptr;
//------------------------------------------------------------------------
@@ -115,8 +115,8 @@ GDKSplashOutputDev::~GDKSplashOutputDev() {
}
void GDKSplashOutputDev::clear() {
- startDoc(NULL);
- startPage(0, NULL, NULL);
+ startDoc(nullptr);
+ startPage(0, nullptr, nullptr);
}
void GDKSplashOutputDev::endPage() {
@@ -147,7 +147,7 @@ void GDKSplashOutputDev::redraw(int srcX, int srcY,
pixbuf = gdk_pixbuf_new_from_data (getBitmap()->getDataPtr() + srcY * gdk_rowstride + srcX * 3,
GDK_COLORSPACE_RGB, FALSE, 8,
width, height, gdk_rowstride,
- NULL, NULL);
+ nullptr, nullptr);
gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0);
cairo_paint (cr);
@@ -302,7 +302,7 @@ view_new (PopplerDocument *doc)
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
view->drawing_area = gtk_drawing_area_new ();
- sw = gtk_scrolled_window_new (NULL, NULL);
+ sw = gtk_scrolled_window_new (nullptr, nullptr);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
@@ -366,9 +366,9 @@ main (int argc, char *argv [])
return -1;
}
- ctx = g_option_context_new (NULL);
+ ctx = g_option_context_new (nullptr);
g_option_context_add_main_entries (ctx, options, "main");
- g_option_context_parse (ctx, &argc, &argv, NULL);
+ g_option_context_parse (ctx, &argc, &argv, nullptr);
g_option_context_free (ctx);
gtk_init (&argc, &argv);
@@ -379,10 +379,10 @@ main (int argc, char *argv [])
View *view;
GFile *file;
PopplerDocument *doc;
- GError *error = NULL;
+ GError *error = nullptr;
file = g_file_new_for_commandline_arg (file_arguments[i]);
- doc = poppler_document_new_from_gfile (file, NULL, NULL, &error);
+ doc = poppler_document_new_from_gfile (file, nullptr, nullptr, &error);
if (!doc) {
gchar *uri;
diff --git a/test/pdf-fullrewrite.cc b/test/pdf-fullrewrite.cc
index 1f8fcc4c..9dbff7cc 100644
--- a/test/pdf-fullrewrite.cc
+++ b/test/pdf-fullrewrite.cc
@@ -41,17 +41,17 @@ static const ArgDesc argDesc[] = {
"print usage information"},
{"-?", argFlag, &printHelp, 0,
"print usage information"},
- {NULL}
+ {nullptr}
};
int main (int argc, char *argv[])
{
- PDFDoc *doc = NULL;
- PDFDoc *docOut = NULL;
- GooString *inputName = NULL;
- GooString *outputName = NULL;
- GooString *ownerPW = NULL;
- GooString *userPW = NULL;
+ PDFDoc *doc = nullptr;
+ PDFDoc *docOut = nullptr;
+ GooString *inputName = nullptr;
+ GooString *outputName = nullptr;
+ GooString *ownerPW = nullptr;
+ GooString *userPW = nullptr;
int res = 0;
// parse args
diff --git a/test/pdf-inspector.cc b/test/pdf-inspector.cc
index 4775bc9f..d672add1 100644
--- a/test/pdf-inspector.cc
+++ b/test/pdf-inspector.cc
@@ -69,7 +69,7 @@ private:
PdfInspector::PdfInspector(void)
{
GtkWidget *widget;
- GError* error = NULL;
+ GError* error = nullptr;
builder = gtk_builder_new ();
@@ -129,12 +129,12 @@ PdfInspector::PdfInspector(void)
column = gtk_tree_view_get_column (GTK_TREE_VIEW (widget), i);
gtk_tree_view_column_set_sort_column_id (column, i);
}
- doc = NULL;
+ doc = nullptr;
output = new CairoOutputDev();
output->setPrinting (gFalse);
// set up initial widgets
- load (NULL);
+ load (nullptr);
}
void
@@ -165,7 +165,7 @@ PdfInspector::on_selection_changed (GtkTreeSelection *selection, PdfInspector *i
size_t i;
GtkTreeModel *model;
GtkTreeIter iter;
- gchar *op = NULL;
+ gchar *op = nullptr;
label = GTK_WIDGET (gtk_builder_get_object (inspector->builder, "description_label"));
gtk_label_set_markup (GTK_LABEL (label), "<i>No Description</i>");
@@ -178,7 +178,7 @@ PdfInspector::on_selection_changed (GtkTreeSelection *selection, PdfInspector *i
}
- if (op == NULL)
+ if (op == nullptr)
return;
for (i = 0; i < G_N_ELEMENTS (op_mapping); i++)
@@ -237,7 +237,7 @@ PdfInspector::analyze_page (int page)
output->setCairo (cr);
cairo_destroy (cr);
doc->displayPage (output, page + 1, 72, 72, 0, gFalse, gTrue, gFalse);
- output->setCairo (NULL);
+ output->setCairo (nullptr);
// Total time;
text = g_strdup_printf ("%g", timer.getElapsed ());
@@ -273,10 +273,10 @@ PdfInspector::load(const char *file_name)
GtkWidget *label;
// kill the old PDF file
- if (doc != NULL)
+ if (doc != nullptr)
{
delete doc;
- doc = NULL;
+ doc = nullptr;
}
// load the new file
@@ -285,14 +285,14 @@ PdfInspector::load(const char *file_name)
GooString *filename_g;
filename_g = new GooString (file_name);
- doc = new PDFDoc(filename_g, 0, 0);
+ doc = new PDFDoc(filename_g, nullptr, nullptr);
}
if (doc && !doc->isOk())
{
this->error_dialog ("Failed to load file.");
delete doc;
- doc = NULL;
+ doc = nullptr;
}
spin = GTK_WIDGET (gtk_builder_get_object (builder, "pdf_spin"));
@@ -339,7 +339,7 @@ PdfInspector::run()
int
main (int argc, char *argv [])
{
- const char *file_name = NULL;
+ const char *file_name = nullptr;
PdfInspector *inspector;
gtk_init (&argc, &argv);
diff --git a/test/perf-test.cc b/test/perf-test.cc
index 7710655e..c73eed08 100644
--- a/test/perf-test.cc
+++ b/test/perf-test.cc
@@ -118,7 +118,7 @@ typedef struct StrList {
- names of a file with a list of PDF files
- names of directories with PDF files
*/
-static StrList *gArgsListRoot = NULL;
+static StrList *gArgsListRoot = nullptr;
/* Names of all command-line switches we recognize */
#define TIMINGS_ARG "-timings"
@@ -143,13 +143,13 @@ static int gResolutionY = 0;
/* If NULL, we output the log info to stdout. If not NULL, should be a name
of the file to which we output log info.
Controled by -out command-line argument. */
-static char * gOutFileName = NULL;
+static char * gOutFileName = nullptr;
/* FILE * correspondig to gOutFileName or stdout if gOutFileName is NULL or
was invalid name */
-static FILE * gOutFile = NULL;
+static FILE * gOutFile = nullptr;
/* FILE * correspondig to gOutFileName or stderr if gOutFileName is NULL or
was invalid name */
-static FILE * gErrFile = NULL;
+static FILE * gErrFile = nullptr;
/* If True and a directory is given as a command-line argument, we'll process
pdf files in sub-directories as well.
@@ -235,7 +235,7 @@ static char *str_cat4(const char *str1, const char *str2, const char *str3, cons
str = (char*)zmalloc(str1_len + str2_len + str3_len + str4_len + 1);
if (!str)
- return NULL;
+ return nullptr;
tmp = str;
if (str1) {
@@ -258,7 +258,7 @@ static char *str_cat4(const char *str1, const char *str2, const char *str3, cons
static char *str_dup(const char *str)
{
- return str_cat4(str, NULL, NULL, NULL);
+ return str_cat4(str, nullptr, nullptr, nullptr);
}
static bool str_eq(const char *str1, const char *str2)
@@ -404,10 +404,10 @@ static void SplashColorsInit(void)
}
PdfEnginePoppler::PdfEnginePoppler() :
- _fileName(0)
+ _fileName(nullptr)
, _pageCount(INVALID_PAGE_NO)
- , _pdfDoc(NULL)
- , _outputDev(NULL)
+ , _pdfDoc(nullptr)
+ , _outputDev(nullptr)
{
}
@@ -425,7 +425,7 @@ bool PdfEnginePoppler::load(const char *fileName)
GooString *fileNameStr = new GooString(fileName);
if (!fileNameStr) return false;
- _pdfDoc = new PDFDoc(fileNameStr, NULL, NULL, (void*)NULL);
+ _pdfDoc = new PDFDoc(fileNameStr, nullptr, nullptr, (void*)nullptr);
if (!_pdfDoc->isOk()) {
return false;
}
@@ -446,7 +446,7 @@ SplashOutputDev * PdfEnginePoppler::outputDevice() {
SplashBitmap *PdfEnginePoppler::renderBitmap(int pageNo, double zoomReal, int rotation)
{
assert(outputDevice());
- if (!outputDevice()) return NULL;
+ if (!outputDevice()) return nullptr;
double hDPI = (double)PDF_FILE_DPI * zoomReal * 0.01;
double vDPI = (double)PDF_FILE_DPI * zoomReal * 0.01;
@@ -454,7 +454,7 @@ SplashBitmap *PdfEnginePoppler::renderBitmap(int pageNo, double zoomReal, int ro
GBool crop = gTrue;
GBool doLinks = gTrue;
_pdfDoc->displayPage(_outputDev, pageNo, hDPI, vDPI, rotation, useMediaBox,
- crop, doLinks, NULL, NULL);
+ crop, doLinks, nullptr, nullptr);
SplashBitmap* bmp = _outputDev->takeBitmap();
return bmp;
@@ -525,7 +525,7 @@ static FindFileState *find_file_open(const char *path, const char *pattern)
s = (FindFileState*)malloc(sizeof(FindFileState));
if (!s)
- return NULL;
+ return nullptr;
strcpy_s(s->path, sizeof(s->path), path);
strcpy_s(s->dirpath, sizeof(s->path), path);
#ifdef _WIN32
@@ -536,7 +536,7 @@ static FindFileState *find_file_open(const char *path, const char *pattern)
#ifdef _WIN32
s->dir = INVALID_HANDLE_VALUE;
#else
- s->dir = NULL;
+ s->dir = nullptr;
#endif
return s;
}
@@ -600,16 +600,16 @@ CheckFile:
const char *p;
char *q;
- if (s->dir == NULL)
+ if (s->dir == nullptr)
goto redo;
for (;;) {
dirent = readdir(s->dir);
- if (dirent == NULL) {
+ if (dirent == nullptr) {
redo:
if (s->dir) {
closedir(s->dir);
- s->dir = NULL;
+ s->dir = nullptr;
}
p = s->bufptr;
if (*p == '\0')
@@ -705,13 +705,13 @@ static StrList* StrList_RemoveHead(StrList **root)
StrList *tmp;
assert(root);
if (!root)
- return NULL;
+ return nullptr;
if (!*root)
- return NULL;
+ return nullptr;
tmp = *root;
*root = tmp->next;
- tmp->next = NULL;
+ tmp->next = nullptr;
return tmp;
}
@@ -736,7 +736,7 @@ static void StrList_Destroy(StrList **root)
StrList_FreeElement(cur);
cur = next;
}
- *root = NULL;
+ *root = nullptr;
}
static void my_error(void *, ErrorCategory, Goffset pos, char *msg) {
@@ -827,9 +827,9 @@ static bool ShowPreview(void)
static void RenderPdfAsText(const char *fileName)
{
- GooString * fileNameStr = NULL;
- PDFDoc * pdfDoc = NULL;
- GooString * txt = NULL;
+ GooString * fileNameStr = nullptr;
+ PDFDoc * pdfDoc = nullptr;
+ GooString * txt = nullptr;
int pageCount;
double timeInMs;
@@ -839,7 +839,7 @@ static void RenderPdfAsText(const char *fileName)
LogInfo("started: %s\n", fileName);
- TextOutputDev * textOut = new TextOutputDev(NULL, gTrue, 0, gFalse, gFalse);
+ TextOutputDev * textOut = new TextOutputDev(nullptr, gTrue, 0, gFalse, gFalse);
if (!textOut->isOk()) {
delete textOut;
return;
@@ -851,7 +851,7 @@ static void RenderPdfAsText(const char *fileName)
if (!fileNameStr)
goto Exit;
- pdfDoc = new PDFDoc(fileNameStr, NULL, NULL, NULL);
+ pdfDoc = new PDFDoc(fileNameStr, nullptr, nullptr, nullptr);
if (!pdfDoc->isOk()) {
error(errIO, -1, "RenderPdfFile(): failed to open PDF file {0:s}\n", fileName);
goto Exit;
@@ -881,7 +881,7 @@ static void RenderPdfAsText(const char *fileName)
LogInfo("page %d: %.2f ms\n", curPage, timeInMs);
printf("%s\n", txt->getCString());
delete txt;
- txt = NULL;
+ txt = nullptr;
}
Exit:
@@ -898,8 +898,8 @@ Exit:
static void RenderPdf(const char *fileName)
{
- const char * fileNameSplash = NULL;
- PdfEnginePoppler * engineSplash = NULL;
+ const char * fileNameSplash = nullptr;
+ PdfEnginePoppler * engineSplash = nullptr;
int pageCount;
double timeInMs;
@@ -932,7 +932,7 @@ static void RenderPdf(const char *fileName)
if ((gPageNo != PAGE_NO_NOT_GIVEN) && (gPageNo != curPage))
continue;
- SplashBitmap *bmpSplash = NULL;
+ SplashBitmap *bmpSplash = nullptr;
GooTimer msTimer;
bmpSplash = engineSplash->renderBitmap(curPage, 100.0, 0);
@@ -1179,7 +1179,7 @@ static void RenderDirectory(char *path)
{
FindFileState * ffs;
char filename[MAX_FILENAME_SIZE];
- StrList * dirList = NULL;
+ StrList * dirList = nullptr;
StrList * el;
StrList_Insert(&dirList, path);
@@ -1230,7 +1230,7 @@ static void RenderCmdLineArg(char *cmdLineArg)
int main(int argc, char **argv)
{
- setErrorCallback(my_error, NULL);
+ setErrorCallback(my_error, nullptr);
ParseCommandLine(argc, argv);
if (0 == StrList_Len(&gArgsListRoot))
PrintUsageAndExit(argc, argv);
@@ -1242,7 +1242,7 @@ int main(int argc, char **argv)
return 1;
globalParams->setErrQuiet(gFalse);
- FILE * outFile = NULL;
+ FILE * outFile = nullptr;
if (gOutFileName) {
outFile = fopen(gOutFileName, "wb");
if (!outFile) {