diff --git a/deploy/brandelf.c b/deploy/brandelf.c index 530297bbf..863136f9c 100644 --- a/deploy/brandelf.c +++ b/deploy/brandelf.c @@ -28,11 +28,7 @@ */ #include -//NOTE: commented out to make it compile on linux -// __FBSDID("$FreeBSD: src/usr.bin/brandelf/brandelf.c,v 1.25.22.2 2012/03/16 03:22:37 eadler Exp $"); - #include -//NOTE: changed path to make it compile on linux #include #include #include @@ -51,7 +47,7 @@ struct ELFtypes { const char *str; int value; }; -/* XXX - any more types? */ + static struct ELFtypes elftypes[] = { { "FreeBSD", ELFOSABI_FREEBSD }, { "Linux", ELFOSABI_LINUX }, @@ -59,10 +55,8 @@ static struct ELFtypes elftypes[] = { { "SVR4", ELFOSABI_SYSV } }; -int -main(int argc, char **argv) +int main(int argc, char **argv) { - const char *strtype = "FreeBSD"; int type = ELFOSABI_FREEBSD; int retval = 0; @@ -86,7 +80,7 @@ main(int argc, char **argv) listed = 1; break; case 'v': - /* does nothing */ + /* do nothing */ break; case 't': if (force) @@ -163,16 +157,14 @@ main(int argc, char **argv) return retval; } -static void -usage(void) +static void usage(void) { (void)fprintf(stderr, "usage: brandelf [-lv] [-f ELF_ABI_number] [-t string] file ...\n"); exit(1); } -static const char * -iselftype(int etype) +static const char * iselftype(int etype) { size_t elfwalk; @@ -184,8 +176,7 @@ iselftype(int etype) return 0; } -static int -elftype(const char *elfstrtype) +static int elftype(const char *elfstrtype) { size_t elfwalk; @@ -197,8 +188,7 @@ elftype(const char *elfstrtype) return -1; } -static void -printelftypes(void) +static void printelftypes(void) { size_t elfwalk; diff --git a/src/bootstrap.js b/src/bootstrap.js index 56b93c201..ae28a6067 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -5,6 +5,7 @@ Copyright (C) 2011 James Roe Copyright (C) 2011 execjosh, http://execjosh.blogspot.com Copyright (C) 2012 James M. Greene + Copyright (c) 2018 pixiuPL Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -94,7 +95,6 @@ phantom.defaultErrorHandler = function (message, stack) { }; phantom.onError = phantom.defaultErrorHandler; - phantom.callback = function (callback) { var ret = phantom.createCallback(); ret.called.connect(function (args) { @@ -310,7 +310,6 @@ phantom.callback = function (callback) { } cache[filename] = module; module._load(); - return module.exports; }; diff --git a/src/callback.cpp b/src/callback.cpp index 7baf6ceae..3969590b5 100644 --- a/src/callback.cpp +++ b/src/callback.cpp @@ -28,12 +28,13 @@ */ #include - #include "callback.h" Callback::Callback(QObject* parent) : QObject(parent) { + // No action here? + // TODO Implement some type of action } QVariant Callback::call(const QVariantList& arguments) diff --git a/src/callback.h b/src/callback.h index 32521b32f..a22f2ea17 100644 --- a/src/callback.h +++ b/src/callback.h @@ -35,14 +35,11 @@ class Callback : public QObject { Q_OBJECT - Q_PROPERTY(QVariant returnValue READ returnValue WRITE setReturnValue) public: Callback(QObject* parent); - QVariant call(const QVariantList& arguments); - QVariant returnValue() const; void setReturnValue(const QVariant& returnValue); diff --git a/src/childprocess.cpp b/src/childprocess.cpp index f62537c72..ac221b208 100644 --- a/src/childprocess.cpp +++ b/src/childprocess.cpp @@ -33,9 +33,7 @@ // ChildProcessContext // -ChildProcessContext::ChildProcessContext(QObject* parent) - : QObject(parent) - , m_proc(this) +ChildProcessContext::ChildProcessContext(QObject* parent) : QObject(parent), m_proc(this) { connect(&m_proc, SIGNAL(readyReadStandardOutput()), this, SLOT(_readyReadStandardOutput())); connect(&m_proc, SIGNAL(readyReadStandardError()), this, SLOT(_readyReadStandardError())); @@ -44,23 +42,17 @@ ChildProcessContext::ChildProcessContext(QObject* parent) } ChildProcessContext::~ChildProcessContext() = default; - -// public: - qint64 ChildProcessContext::pid() const { Q_PID pid = m_proc.pid(); - -#if !defined(Q_OS_WIN) && !defined(Q_OS_WINCE) return pid; -#else +// TODO Investigate... return pid->dwProcessId; #endif } void ChildProcessContext::kill(const QString& signal) { - // TODO: it would be nice to be able to handle more signals if ("SIGKILL" == signal) { m_proc.kill(); } else { @@ -80,8 +72,7 @@ void ChildProcessContext::_setEncoding(const QString& encoding) bool ChildProcessContext::_start(const QString& cmd, const QStringList& args) { m_proc.start(cmd, args); - // TODO: Is there a better way to do this??? - return m_proc.waitForStarted(1000); + return m_proc.waitForStarted(1000); } qint64 ChildProcessContext::_write(const QString &chunk, const QString &encoding) @@ -100,7 +91,6 @@ qint64 ChildProcessContext::_write(const QString &chunk, const QString &encoding } qint64 bytesWritten = m_proc.write(codec->fromUnicode(chunk)); - return bytesWritten; } @@ -126,14 +116,12 @@ void ChildProcessContext::_readyReadStandardError() void ChildProcessContext::_finished(const int exitCode, const QProcess::ExitStatus exitStatus) { Q_UNUSED(exitStatus) - emit exit(exitCode); } void ChildProcessContext::_error(const QProcess::ProcessError error) { Q_UNUSED(error) - emit exit(m_proc.exitCode()); } diff --git a/src/childprocess.h b/src/childprocess.h index 0ab502b67..29e2e1834 100644 --- a/src/childprocess.h +++ b/src/childprocess.h @@ -31,11 +31,7 @@ #include #include - -#ifdef Q_OS_WIN #include -#endif - #include "encoding.h" /** @@ -43,8 +39,8 @@ */ class ChildProcessContext : public QObject { - Q_OBJECT - Q_PROPERTY(qint64 pid READ pid) + Q_OBJECT; + Q_PROPERTY(qint64 pid READ pid); public: explicit ChildProcessContext(QObject* parent = Q_NULLPTR); @@ -52,10 +48,8 @@ class ChildProcessContext : public QObject qint64 pid() const; Q_INVOKABLE void kill(const QString& signal = "SIGTERM"); - Q_INVOKABLE void _setEncoding(const QString& encoding); Q_INVOKABLE bool _start(const QString& cmd, const QStringList& args); - Q_INVOKABLE qint64 _write(const QString &chunk, const QString &encoding); Q_INVOKABLE void _close(); diff --git a/src/crashdump.cpp b/src/crashdump.cpp index 73063a5c9..a33a70ffd 100644 --- a/src/crashdump.cpp +++ b/src/crashdump.cpp @@ -32,20 +32,13 @@ #include #include #include - #include - -#if defined(Q_OS_WIN) #include -#else #include #include -#endif - #include "crashdump.h" -void -print_crash_message() +void print_crash_message() { fputs("PhantomJS has crashed. Please read the bug reporting guide at\n" " and file a bug report.\n", @@ -53,8 +46,6 @@ print_crash_message() fflush(stderr); } -#if defined(Q_OS_WIN) - static LONG WINAPI unhandled_exception_filter(LPEXCEPTION_POINTERS ptrs) { fprintf(stderr, "Fatal Windows exception, code 0x%08x.\n", @@ -63,13 +54,7 @@ static LONG WINAPI unhandled_exception_filter(LPEXCEPTION_POINTERS ptrs) return EXCEPTION_EXECUTE_HANDLER; } -#if _MSC_VER >= 1400 -static void -invalid_parameter_handler(const wchar_t* expression, - const wchar_t* function, - const wchar_t* file, - unsigned int line, - uintptr_t /*reserved*/) +static void invalid_parameter_handler(const wchar_t* expression, const wchar_t* function, const wchar_t* file, unsigned int line, uintptr_t ) { // The parameters all have the value NULL unless a debug version of the CRT library is used // https://msdn.microsoft.com/en-us/library/a9yf33zb(v=VS.80).aspx @@ -135,8 +120,7 @@ init_crash_handler_os() #else // not Windows; Unix assumed -static void -handle_fatal_signal(int signo) +static void handle_fatal_signal(int signo) { // It would be nice to print the offending signal name here, but // strsignal() isn't reliably available. Instead we let the shell do it. @@ -144,8 +128,7 @@ handle_fatal_signal(int signo) raise(signo); } -static void -init_crash_handler_os() +static void init_crash_handler_os() { const char* offender; @@ -196,8 +179,7 @@ init_crash_handler_os() #endif // not Windows -void -init_crash_handler() +void init_crash_handler() { // Qt, QtWebkit, and PhantomJS mostly don't make use of C++ exceptions, // so in the rare cases where an exception does get thrown, it will diff --git a/src/crashdump.h b/src/crashdump.h index a2167c4e8..b5435871b 100644 --- a/src/crashdump.h +++ b/src/crashdump.h @@ -28,10 +28,9 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef CRASHDUMP_H #define CRASHDUMP_H extern void print_crash_message(); extern void init_crash_handler(); -#endif // CRASHDUMP_H + diff --git a/src/custompage.cpp b/src/custompage.cpp index 4fa38fffc..d89a36944 100644 --- a/src/custompage.cpp +++ b/src/custompage.cpp @@ -31,25 +31,20 @@ #include "custompage.h" -CustomPage::CustomPage(WebPage* parent) - : QWebPage(parent) - , m_webPage(parent) +CustomPage::CustomPage(WebPage* parent) : QWebPage(parent), m_webPage(parent) { m_userAgent = QWebPage::userAgentForUrl(QUrl()); setForwardUnsupportedContent(true); - connect(this, &QWebPage::consoleMessageReceived, this, &CustomPage::onConsoleMessageReceived); } bool CustomPage::extension(Extension extension, const ExtensionOption* option, ExtensionReturn* output) { Q_UNUSED(option); - if (extension == ChooseMultipleFilesExtension) { static_cast(output)->fileNames = m_uploadFiles; return true; } - return false; } @@ -61,7 +56,6 @@ void CustomPage::setCookieJar(CookieJar* cookieJar) bool CustomPage::shouldInterruptJavaScript() { m_webPage->javascriptInterrupt(); - if (m_webPage->m_shouldInterruptJs) { // reset our flag m_webPage->m_shouldInterruptJs = false; diff --git a/src/custompage.h b/src/custompage.h index 84ffa379c..439cb5e1c 100644 --- a/src/custompage.h +++ b/src/custompage.h @@ -29,25 +29,17 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#pragma once - #include - #include "phantom.h" #include "webpage.h" -/** -* @class CustomPage -*/ class CustomPage : public QWebPage { Q_OBJECT -public: - CustomPage(WebPage* parent = Q_NULLPTR); +public: CustomPage(WebPage* parent = Q_NULLPTR); bool extension(Extension extension, const ExtensionOption* option, ExtensionReturn* output) Q_DECL_OVERRIDE; - void setCookieJar(CookieJar* cookieJar); void setUserAgent(QString userAgent); QString userAgent() const; diff --git a/src/encoding.cpp b/src/encoding.cpp index 0620aab28..e0396fc65 100644 --- a/src/encoding.cpp +++ b/src/encoding.cpp @@ -38,7 +38,6 @@ Encoding::Encoding() if (!codec) { codec = QTextCodec::codecForLocale(); } - m_codec = codec; } @@ -64,7 +63,6 @@ QByteArray Encoding::encode(const QString& string) const QString Encoding::getName() const { - // TODO Is it safe to assume UTF-8 here? return QString::fromUtf8(getCodec()->name()); } @@ -81,8 +79,7 @@ void Encoding::setEncoding(const QString& encoding) const Encoding Encoding::UTF8 = Encoding("UTF-8"); -// private: -QTextCodec* Encoding::getCodec() const +private: QTextCodec* Encoding::getCodec() const { QTextCodec* codec = m_codec; diff --git a/src/encoding.h b/src/encoding.h index b32bfb73f..47aad99ac 100644 --- a/src/encoding.h +++ b/src/encoding.h @@ -28,8 +28,6 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#pragma once - #include class Encoding @@ -38,15 +36,11 @@ class Encoding Encoding(); Encoding(const QString& encoding); ~Encoding(); - QString decode(const QByteArray& bytes) const; QByteArray encode(const QString& string) const; - QString getName() const; void setEncoding(const QString& encoding); - QTextCodec* getCodec() const; - static const Encoding UTF8; private: diff --git a/src/env.cpp b/src/env.cpp index 127a20c34..4b954b29e 100644 --- a/src/env.cpp +++ b/src/env.cpp @@ -31,7 +31,6 @@ #include #include #include - #include "env.h" static Env* env_instance = Q_NULLPTR; @@ -41,7 +40,6 @@ Env* Env::instance() if (!env_instance) { env_instance = new Env(); } - return env_instance; } diff --git a/src/env.h b/src/env.h index 614ba1a4b..92feb6562 100644 --- a/src/env.h +++ b/src/env.h @@ -27,8 +27,6 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#pragma once - #include #include @@ -43,6 +41,5 @@ class Env : public QObject private: Env(); - QVariantMap m_map; }; diff --git a/src/filesystem.cpp b/src/filesystem.cpp index 6c6288be1..4d854f9f1 100644 --- a/src/filesystem.cpp +++ b/src/filesystem.cpp @@ -34,7 +34,6 @@ #include #include #include - #include "filesystem.h" // File @@ -234,8 +233,7 @@ bool File::setEncoding(const QString& encoding) // "Binary" mode doesn't use/need text codecs if (!m_fileStream) { - // TODO: Should we switch to "text" mode? - return false; + return false; } // Since there can be multiple names for the same codec (i.e., "utf8" and @@ -270,21 +268,18 @@ QString File::getEncoding() const return encoding; } -// private: - -bool File::_isUnbuffered() const +private bool File::_isUnbuffered() const { return m_file->openMode() & QIODevice::Unbuffered; } // FileSystem -// public: -FileSystem::FileSystem(QObject* parent) +public: FileSystem::FileSystem(QObject* parent) : QObject(parent) { } -// public slots: +public slots: // Attributes int FileSystem::_size(const QString& path) const diff --git a/src/filesystem.h b/src/filesystem.h index 6fce90c51..84cd642ff 100644 --- a/src/filesystem.h +++ b/src/filesystem.h @@ -27,8 +27,6 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#pragma once - #include #include #include @@ -54,22 +52,17 @@ public Q_SLOTS: QString read(const QVariant& n = -1); bool write(const QString& data); bool isTTY(); - bool seek(const qint64 pos); - QString readLine(); bool writeLine(const QString& data); - bool atEnd() const; void flush(); void close(); - QString getEncoding() const; bool setEncoding(const QString& encoding); private: bool _isUnbuffered() const; - QFile* m_file; QTextStream* m_fileStream; };