diff options
author | Evan Mallory <schmave@gmail.com> | 2016-09-17 13:29:09 -0400 |
---|---|---|
committer | Evan Mallory <schmave@gmail.com> | 2016-09-17 14:22:38 -0400 |
commit | c193cc3a5b4dbf39e19744cf4d30e616298eaa86 (patch) | |
tree | 5f837949c367f435d947833c6f52e37473357ee6 /src | |
parent | a3b573e1107729e743c96da8ed9272361ba6ae31 (diff) | |
download | fork-ledger-c193cc3a5b4dbf39e19744cf4d30e616298eaa86.tar.gz fork-ledger-c193cc3a5b4dbf39e19744cf4d30e616298eaa86.tar.bz2 fork-ledger-c193cc3a5b4dbf39e19744cf4d30e616298eaa86.zip |
Fix build under msys32; add Appveyor continuous build
* Appveyor is a continuous integration platform for Windows that is free for open source projects. See latest test build here: https://ci.appveyor.com/project/Evan/ledger/build/artifacts
* Changed WIN32 to _WIN32 because this article http://nadeausoftware.com/articles/2012/01/c_c_tip_how_use_compiler_predefined_macros_detect_operating_system claims that it is defined by the greatest number of compilers.
* Modified HAVE_ISATTY and other system defines so that system.hh compiles when cmake fails to find the relevant function.
* Add missing include in test/unit/t_value.cc
Almost all tests fail when you run them on msys32. I will address that in a future PR.
Diffstat (limited to 'src')
-rw-r--r-- | src/global.cc | 2 | ||||
-rw-r--r-- | src/main.cc | 2 | ||||
-rw-r--r-- | src/quotes.cc | 2 | ||||
-rw-r--r-- | src/report.cc | 6 | ||||
-rw-r--r-- | src/report.h | 3 | ||||
-rw-r--r-- | src/select.cc | 4 | ||||
-rw-r--r-- | src/stream.cc | 4 | ||||
-rw-r--r-- | src/strptime.cc | 4 | ||||
-rw-r--r-- | src/system.hh.in | 18 | ||||
-rw-r--r-- | src/times.cc | 2 | ||||
-rw-r--r-- | src/utils.cc | 4 | ||||
-rw-r--r-- | src/utils.h | 2 |
12 files changed, 27 insertions, 26 deletions
diff --git a/src/global.cc b/src/global.cc index 6edc69ca..a3f84409 100644 --- a/src/global.cc +++ b/src/global.cc @@ -451,7 +451,7 @@ expr_t::func_t global_scope_t::look_for_command(scope_t& scope, void global_scope_t::visit_man_page() const { -#ifndef WIN32 +#ifndef _WIN32 int pid = fork(); if (pid < 0) { throw std::logic_error(_("Failed to fork child process")); diff --git a/src/main.cc b/src/main.cc index 3a36280a..df1933f9 100644 --- a/src/main.cc +++ b/src/main.cc @@ -74,7 +74,7 @@ int main(int argc, char * argv[], char * envp[]) #endif std::signal(SIGINT, sigint_handler); -#ifndef WIN32 +#ifndef _WIN32 std::signal(SIGPIPE, sigpipe_handler); #endif diff --git a/src/quotes.cc b/src/quotes.cc index 2777974e..0dd9c4ed 100644 --- a/src/quotes.cc +++ b/src/quotes.cc @@ -62,7 +62,7 @@ commodity_quote_from_script(commodity_t& commodity, DEBUG("commodity.download", "invoking command: " << getquote_cmd); bool success = true; -#ifndef WIN32 +#ifndef _WIN32 if (FILE * fp = popen(getquote_cmd.c_str(), "r")) { if (std::feof(fp) || ! std::fgets(buf, 255, fp)) success = false; diff --git a/src/report.cc b/src/report.cc index 9e480ea5..78ccac51 100644 --- a/src/report.cc +++ b/src/report.cc @@ -57,7 +57,7 @@ void report_t::normalize_options(const string& verb) // Patch up some of the reporting options based on what kind of // command it was. -#if HAVE_ISATTY +#ifdef HAVE_ISATTY if (! HANDLED(force_color)) { if (! HANDLED(no_color) && isatty(STDOUT_FILENO)) HANDLER(color).on("?normalize"); @@ -181,14 +181,14 @@ void report_t::normalize_options(const string& verb) } long cols = 0; -#if HAVE_IOCTL +#ifdef HAVE_IOCTL struct winsize ws; #endif if (HANDLED(columns_)) cols = lexical_cast<long>(HANDLER(columns_).value); else if (const char * columns = std::getenv("COLUMNS")) cols = lexical_cast<long>(columns); -#if HAVE_IOCTL +#ifdef HAVE_IOCTL else if (ioctl(STDIN_FILENO, TIOCGWINSZ, &ws) != -1) cols = ws.ws_col; #endif diff --git a/src/report.h b/src/report.h index 0873e64f..cdff13ae 100644 --- a/src/report.h +++ b/src/report.h @@ -793,7 +793,8 @@ public: OPTION(report_t, output_); // -o -#if HAVE_ISATTY +// setenv() is not available on WIN32 +#if defined(HAVE_ISATTY) and !defined(_WIN32) OPTION__ (report_t, pager_, CTOR(report_t, pager_) { diff --git a/src/select.cc b/src/select.cc index 1c69b2bf..8e7786e6 100644 --- a/src/select.cc +++ b/src/select.cc @@ -145,14 +145,14 @@ value_t select_command(call_scope_t& args) string thus_far = ""; std::size_t cols = 0; -#if HAVE_IOCTL +#ifdef HAVE_IOCTL struct winsize ws; #endif if (report.HANDLED(columns_)) cols = lexical_cast<std::size_t>(report.HANDLER(columns_).value); else if (const char * columns_env = std::getenv("COLUMNS")) cols = lexical_cast<std::size_t>(columns_env); -#if HAVE_IOCTL +#ifdef HAVE_IOCTL else if (ioctl(STDIN_FILENO, TIOCGWINSZ, &ws) != -1) cols = ws.ws_col; #endif diff --git a/src/stream.cc b/src/stream.cc index 60b0dc55..0c3ed995 100644 --- a/src/stream.cc +++ b/src/stream.cc @@ -58,7 +58,7 @@ namespace { */ int do_fork(std::ostream ** os, const path& pager_path) { -#ifndef WIN32 +#ifndef _WIN32 int pfd[2]; int status = pipe(pfd); @@ -115,7 +115,7 @@ void output_stream_t::initialize(const optional<path>& output_file, void output_stream_t::close() { -#ifndef WIN32 +#ifndef _WIN32 if (os != &std::cout) { checked_delete(os); os = &std::cout; diff --git a/src/strptime.cc b/src/strptime.cc index b31954f4..b9d485d2 100644 --- a/src/strptime.cc +++ b/src/strptime.cc @@ -13,7 +13,7 @@ // limitations under the License. -#ifdef WIN32 +#ifdef _WIN32 // Implement strptime under windows #include "strptime.h" @@ -186,4 +186,4 @@ char* strptime(const char *buf, const char *fmt, struct tm *tm) { return _strptime(buf, fmt, tm); } -#endif // WIN32 +#endif // _WIN32 diff --git a/src/system.hh.in b/src/system.hh.in index 54bcf7a9..105436f6 100644 --- a/src/system.hh.in +++ b/src/system.hh.in @@ -60,12 +60,12 @@ #define HAVE_EDIT @HAVE_EDIT@ #define HAVE_GETTEXT @HAVE_GETTEXT@ -#define HAVE_ACCESS @HAVE_ACCESS@ -#define HAVE_REALPATH @HAVE_REALPATH@ -#define HAVE_GETPWUID @HAVE_GETPWUID@ -#define HAVE_GETPWNAM @HAVE_GETPWNAM@ -#define HAVE_IOCTL @HAVE_IOCTL@ -#define HAVE_ISATTY @HAVE_ISATTY@ +#cmakedefine HAVE_ACCESS +#cmakedefine HAVE_REALPATH +#cmakedefine HAVE_GETPWUID +#cmakedefine HAVE_GETPWNAM +#cmakedefine HAVE_IOCTL +#cmakedefine HAVE_ISATTY #define HAVE_UNIX_PIPES @HAVE_UNIX_PIPES@ @@ -144,16 +144,16 @@ typedef std::ostream::pos_type ostream_pos_type; #endif #include <sys/stat.h> -#if defined(WIN32) +#if defined(_WIN32) #include <io.h> #else #include <unistd.h> #endif -#if HAVE_GETPWUID || HAVE_GETPWNAM +#if defined(HAVE_GETPWUID) || defined(HAVE_GETPWNAM) #include <pwd.h> #endif -#if HAVE_IOCTL +#ifdef HAVE_IOCTL #include <sys/ioctl.h> #endif diff --git a/src/times.cc b/src/times.cc index 274abc83..01b89848 100644 --- a/src/times.cc +++ b/src/times.cc @@ -33,7 +33,7 @@ #include "times.h" -#ifdef WIN32 +#ifdef _WIN32 #include "strptime.h" #endif diff --git a/src/utils.cc b/src/utils.cc index 947f2408..fca9e6d4 100644 --- a/src/utils.cc +++ b/src/utils.cc @@ -807,7 +807,7 @@ path expand_path(const path& pathname) if (path_string.length() == 1 || pos == 1) { pfx = std::getenv("HOME"); -#if HAVE_GETPWUID +#ifdef HAVE_GETPWUID if (! pfx) { // Punt. We're trying to expand ~/, but HOME isn't set struct passwd * pw = getpwuid(getuid()); @@ -816,7 +816,7 @@ path expand_path(const path& pathname) } #endif } -#if HAVE_GETPWNAM +#ifdef HAVE_GETPWNAM else { string user(path_string, 1, pos == string::npos ? string::npos : pos - 1); diff --git a/src/utils.h b/src/utils.h index 42ea2ae9..d4a03a73 100644 --- a/src/utils.h +++ b/src/utils.h @@ -496,7 +496,7 @@ inline T& downcast(U& object) { path resolve_path(const path& pathname); -#if HAVE_REALPATH +#ifdef HAVE_REALPATH extern "C" char * realpath(const char *, char resolved_path[]); #endif |