From 7c4122cc4b07937028681af484a3587780f06c61 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Peter=20K=C3=BCmmel?= Date: Fri, 16 Jul 2010 08:09:38 +0000 Subject: [PATCH] lyx sytle git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34912 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/support/Systemcall.cpp | 72 ++++++++++++++++----------------- src/support/SystemcallPrivate.h | 23 ++++++----- 2 files changed, 48 insertions(+), 47 deletions(-) diff --git a/src/support/Systemcall.cpp b/src/support/Systemcall.cpp index a42e7abef4..a328e367e1 100644 --- a/src/support/Systemcall.cpp +++ b/src/support/Systemcall.cpp @@ -243,17 +243,17 @@ int Systemcall::startscript(Starttype how, string const & what, bool process_eve SystemcallPrivate::SystemcallPrivate(const std::string& of) : process_(new QProcess), - outIndex_(0), - errIndex_(0), - outFile_(of), - terminalOutExists_(os::is_terminal(os::STDOUT)), - terminalErrExists_(os::is_terminal(os::STDERR)), - processEvents_(false) + out_index_(0), + err_index_(0), + out_file_(of), + terminal_out_exists_(os::is_terminal(os::STDOUT)), + terminal_err_exists_(os::is_terminal(os::STDERR)), + process_events_(false) { - if (!outFile_.empty()) { + if (!out_file_.empty()) { // Check whether we have to simply throw away the output. - if (outFile_ != os::nulldev()) - process_->setStandardOutputFile(toqstr(outFile_)); + if (out_file_ != os::nulldev()) + process_->setStandardOutputFile(toqstr(out_file_)); } connect(process_, SIGNAL(readyReadStandardOutput()), SLOT(stdOut())); @@ -277,7 +277,7 @@ void SystemcallPrivate::startProcess(const QString& cmd) void SystemcallPrivate::processEvents() { - if(processEvents_) { + if(process_events_) { QCoreApplication::processEvents(/*QEventLoop::ExcludeUserInputEvents*/); } } @@ -329,18 +329,18 @@ SystemcallPrivate::~SystemcallPrivate() { flush(); - if (outIndex_) { - outData_[outIndex_] = '\0'; - outIndex_ = 0; - if (terminalOutExists_) - cout << outData_; + if (out_index_) { + out_data_[out_index_] = '\0'; + out_index_ = 0; + if (terminal_out_exists_) + cout << out_data_; } cout.flush(); - if (errIndex_) { - errData_[errIndex_] = '\0'; - errIndex_ = 0; - if (terminalErrExists_) - cerr << errData_; + if (err_index_) { + err_data_[err_index_] = '\0'; + err_index_ = 0; + if (terminal_err_exists_) + cerr << err_data_; } cerr.flush(); @@ -357,12 +357,12 @@ void SystemcallPrivate::flush() QString data = QString::fromLocal8Bit(process_->readAllStandardOutput().data()); ProgressInterface::instance()->appendMessage(data); - if (!terminalOutExists_ && outFile_.empty()) + if (!terminal_out_exists_ && out_file_.empty()) cout << fromqstr(data); data = QString::fromLocal8Bit(process_->readAllStandardError().data()); ProgressInterface::instance()->appendError(data); - if (!terminalErrExists_) + if (!terminal_err_exists_) cerr << fromqstr(data); } } @@ -374,13 +374,13 @@ void SystemcallPrivate::stdOut() char c; process_->setReadChannel(QProcess::StandardOutput); while (process_->getChar(&c)) { - outData_[outIndex_++] = c; - if (c == '\n' || outIndex_ + 1 == bufferSize_) { - outData_[outIndex_] = '\0'; - outIndex_ = 0; - ProgressInterface::instance()->appendMessage(QString::fromLocal8Bit(outData_)); - if (terminalOutExists_) - cout << outData_; + out_data_[out_index_++] = c; + if (c == '\n' || out_index_ + 1 == max_buffer_size_) { + out_data_[out_index_] = '\0'; + out_index_ = 0; + ProgressInterface::instance()->appendMessage(QString::fromLocal8Bit(out_data_)); + if (terminal_out_exists_) + cout << out_data_; } } } @@ -393,13 +393,13 @@ void SystemcallPrivate::stdErr() char c; process_->setReadChannel(QProcess::StandardError); while (process_->getChar(&c)) { - errData_[errIndex_++] = c; - if (c == '\n' || errIndex_ + 1 == bufferSize_) { - errData_[errIndex_] = '\0'; - errIndex_ = 0; - ProgressInterface::instance()->appendError(QString::fromLocal8Bit(errData_)); - if (terminalErrExists_) - cerr << errData_; + err_data_[err_index_++] = c; + if (c == '\n' || err_index_ + 1 == max_buffer_size_) { + err_data_[err_index_] = '\0'; + err_index_ = 0; + ProgressInterface::instance()->appendError(QString::fromLocal8Bit(err_data_)); + if (terminal_err_exists_) + cerr << err_data_; } } } diff --git a/src/support/SystemcallPrivate.h b/src/support/SystemcallPrivate.h index 0b616dcd3c..958fae1e70 100644 --- a/src/support/SystemcallPrivate.h +++ b/src/support/SystemcallPrivate.h @@ -71,27 +71,28 @@ private: QProcess * process_; /// Index to the standard output buffer. - size_t outIndex_; + size_t out_index_; /// Index to the standard error buffer. - size_t errIndex_; + size_t err_index_; /// - std::string outFile_; + std::string out_file_; /// Size of buffers. - static size_t const bufferSize_ = 200; + static size_t const max_buffer_size_ = 200; /// Standard output buffer. - char outData_[bufferSize_]; + char out_data_[max_buffer_size_]; /// Standard error buffer. - char errData_[bufferSize_]; + char err_data_[max_buffer_size_]; - bool terminalErrExists_; - bool terminalOutExists_; + bool terminal_err_exists_; + bool terminal_out_exists_; + + QString cmd_; + bool process_events_; - bool processEvents_; void waitAndProcessEvents(); void processEvents(); - void killProcess(); - QString cmd_; + void killProcess(); }; -- 2.39.2