mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-19 00:43:07 +02:00
Readline
- Made use of readline wordexp conditional upon the presence of wordexp.h, which is correct, but excludes certain BSDs.
This commit is contained in:
parent
b81891c78f
commit
cdc0c0a01a
4 changed files with 31 additions and 3 deletions
|
@ -1,6 +1,7 @@
|
||||||
cmake_minimum_required (VERSION 2.8)
|
cmake_minimum_required (VERSION 2.8)
|
||||||
set(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required
|
set(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required
|
||||||
|
|
||||||
|
include (CheckIncludeFiles)
|
||||||
include (CheckFunctionExists)
|
include (CheckFunctionExists)
|
||||||
include (CheckStructHasMember)
|
include (CheckStructHasMember)
|
||||||
|
|
||||||
|
@ -89,6 +90,8 @@ if (READLINE_FOUND)
|
||||||
set (TASK_LIBRARIES ${TASK_LIBRARIES} ${READLINE_LIBRARIES})
|
set (TASK_LIBRARIES ${TASK_LIBRARIES} ${READLINE_LIBRARIES})
|
||||||
endif (READLINE_FOUND)
|
endif (READLINE_FOUND)
|
||||||
|
|
||||||
|
check_include_files (wordexp.h HAVE_WORDEXP_H)
|
||||||
|
|
||||||
check_function_exists (timegm HAVE_TIMEGM)
|
check_function_exists (timegm HAVE_TIMEGM)
|
||||||
check_function_exists (get_current_dir_name HAVE_GET_CURRENT_DIR_NAME)
|
check_function_exists (get_current_dir_name HAVE_GET_CURRENT_DIR_NAME)
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,9 @@
|
||||||
/* Found uuid_unparse_lower in the uuid library */
|
/* Found uuid_unparse_lower in the uuid library */
|
||||||
#cmakedefine HAVE_UUID_UNPARSE_LOWER
|
#cmakedefine HAVE_UUID_UNPARSE_LOWER
|
||||||
|
|
||||||
|
/* Found wordexp.h in the libreadline library */
|
||||||
|
#cmakedefine HAVE_WORDEXP_H
|
||||||
|
|
||||||
/* Undefine this to eliminate the execute command */
|
/* Undefine this to eliminate the execute command */
|
||||||
#define HAVE_EXECUTE 1
|
#define HAVE_EXECUTE 1
|
||||||
|
|
||||||
|
|
|
@ -77,33 +77,49 @@ bool Readline::interactiveMode (const std::istream& in)
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Wordexp::Wordexp (const std::string &str)
|
Wordexp::Wordexp (const std::string &str)
|
||||||
{
|
{
|
||||||
std::string tmpStr(str);
|
_input = str;
|
||||||
escapeSpecialChars(tmpStr);
|
escapeSpecialChars(_input);
|
||||||
wordexp (tmpStr.c_str (), &_p, 0);
|
#ifdef HAVE_WORDEXP_H
|
||||||
|
wordexp (_input.c_str (), &_p, 0);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Wordexp::~Wordexp ()
|
Wordexp::~Wordexp ()
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_WORDEXP_H
|
||||||
wordfree (&_p);
|
wordfree (&_p);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int Wordexp::argc ()
|
int Wordexp::argc ()
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_WORDEXP_H
|
||||||
return _p.we_wordc;
|
return _p.we_wordc;
|
||||||
|
#else
|
||||||
|
return 1;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
char** Wordexp::argv ()
|
char** Wordexp::argv ()
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_WORDEXP_H
|
||||||
return _p.we_wordv;
|
return _p.we_wordv;
|
||||||
|
#else
|
||||||
|
return (char**)_input.c_str ();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
char* Wordexp::argv (int i)
|
char* Wordexp::argv (int i)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_WORDEXP_H
|
||||||
return _p.we_wordv[i];
|
return _p.we_wordv[i];
|
||||||
|
#else
|
||||||
|
return (char*)_input.c_str ();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -30,7 +30,9 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#ifdef HAVE_WORDEXP_H
|
||||||
#include <wordexp.h>
|
#include <wordexp.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
// Static class that offers a C++ API to readline C functions.
|
// Static class that offers a C++ API to readline C functions.
|
||||||
class Readline
|
class Readline
|
||||||
|
@ -61,7 +63,11 @@ public:
|
||||||
void escapeSpecialChars(std::string& str);
|
void escapeSpecialChars(std::string& str);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
#ifdef HAVE_WORDEXP_H
|
||||||
wordexp_t _p;
|
wordexp_t _p;
|
||||||
|
#else
|
||||||
|
std::string _input;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue