1
0
Fork 0

mini cleanup

This commit is contained in:
Jan Steemann 2014-10-27 22:47:36 +01:00
parent 7452c70a3b
commit ccf7e4f131
4 changed files with 33 additions and 29 deletions

View File

@ -61,7 +61,7 @@ ConsoleThread::ConsoleThread (ApplicationServer* applicationServer,
: Thread("console"), : Thread("console"),
_applicationServer(applicationServer), _applicationServer(applicationServer),
_applicationV8(applicationV8), _applicationV8(applicationV8),
_context(0), _context(nullptr),
_vocbase(vocbase), _vocbase(vocbase),
_done(0), _done(0),
_userAborted(false) { _userAborted(false) {
@ -151,13 +151,13 @@ void ConsoleThread::inner () {
char* input = console.prompt("arangod> "); char* input = console.prompt("arangod> ");
if (_userAborted) { if (_userAborted) {
if (input != 0) { if (input != nullptr) {
TRI_FreeString(TRI_UNKNOWN_MEM_ZONE, input); TRI_FreeString(TRI_UNKNOWN_MEM_ZONE, input);
} }
throw "user aborted"; throw "user aborted";
} }
if (input == 0) { if (input == nullptr) {
_userAborted = true; _userAborted = true;
// this will be caught by "run" // this will be caught by "run"

View File

@ -111,25 +111,29 @@ Thread::Thread (std::string const& name)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Thread::~Thread () { Thread::~Thread () {
int res;
if (_running != 0) { if (_running != 0) {
if (! isSilent()) { if (! isSilent()) {
LOG_WARNING("forcefully shutting down thread '%s'", _name.c_str()); LOG_WARNING("forcefully shutting down thread '%s'", _name.c_str());
} }
res = TRI_StopThread(&_thread); int res = TRI_StopThread(&_thread);
if (res != TRI_ERROR_NO_ERROR) { if (res != TRI_ERROR_NO_ERROR) {
LOG_WARNING("unable to stop thread '%s': %s", _name.c_str(), TRI_errno_string(res)); errno = res;
TRI_set_errno(TRI_ERROR_SYS_ERROR);
LOG_WARNING("unable to stop thread '%s': %s", _name.c_str(), TRI_last_error());
} }
} }
if (! _joined) { if (! _joined) {
res = TRI_DetachThread(&_thread); int res = TRI_DetachThread(&_thread);
if (res != TRI_ERROR_NO_ERROR) { if (res != TRI_ERROR_NO_ERROR) {
LOG_WARNING("unable to detach thread '%s': %s", _name.c_str(), TRI_errno_string(res)); errno = res;
TRI_set_errno(TRI_ERROR_SYS_ERROR);
LOG_WARNING("unable to detach thread '%s': %s", _name.c_str(), TRI_last_error());
} }
} }
} }
@ -236,9 +240,12 @@ int Thread::shutdown () {
int res = TRI_StopThread(&_thread); int res = TRI_StopThread(&_thread);
if (res != TRI_ERROR_NO_ERROR) { if (res != TRI_ERROR_NO_ERROR) {
errno = res;
TRI_set_errno(TRI_ERROR_SYS_ERROR);
LOG_WARNING("unable to stop thread '%s': %s", LOG_WARNING("unable to stop thread '%s': %s",
_name.c_str(), _name.c_str(),
TRI_errno_string(res)); TRI_last_error());
} }
} }

View File

@ -142,7 +142,6 @@ void LineEditor::sortAlternatives (vector<string>& completions) {
void LineEditor::prepareShell () { void LineEditor::prepareShell () {
if (! _shellImpl) { if (! _shellImpl) {
initializeShell(); initializeShell();
// assert _shellImpl != 0;
} }
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------

View File

@ -46,7 +46,6 @@ using namespace std;
using namespace triagens; using namespace triagens;
namespace { namespace {
Completer* COMPLETER; Completer* COMPLETER;
static char WordBreakCharacters[] = { static char WordBreakCharacters[] = {
@ -74,7 +73,6 @@ namespace {
} }
} }
static char** AttemptedCompletion (char const* text, int start, int end) { static char** AttemptedCompletion (char const* text, int start, int end) {
char** result; char** result;
@ -110,7 +108,8 @@ namespace {
/// @brief constructs a new editor /// @brief constructs a new editor
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
ReadlineShell::ReadlineShell(std::string const& history, Completer *completer) ReadlineShell::ReadlineShell (std::string const& history,
Completer* completer)
: ShellImplementation(history, completer) { : ShellImplementation(history, completer) {
COMPLETER = completer; COMPLETER = completer;
@ -136,7 +135,6 @@ ReadlineShell::ReadlineShell(std::string const& history, Completer *completer)
bool ReadlineShell::open (bool autoComplete) { bool ReadlineShell::open (bool autoComplete) {
if (autoComplete) { if (autoComplete) {
// issue #289: do not append a space after completion // issue #289: do not append a space after completion
rl_completion_append_character = '\0'; rl_completion_append_character = '\0';
@ -168,7 +166,6 @@ bool ReadlineShell::open(bool autoComplete) {
stifle_history(1000); stifle_history(1000);
_state = STATE_OPENED; _state = STATE_OPENED;
return read_history(historyPath().c_str()) == 0; return read_history(historyPath().c_str()) == 0;
} }
@ -261,6 +258,7 @@ bool ReadlineShell::writeHistory() {
char * ReadlineShell::getLine (char const * input) { char * ReadlineShell::getLine (char const * input) {
return readline(input); return readline(input);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// --SECTION-- END-OF-FILE // --SECTION-- END-OF-FILE
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------