From dd26ee724a4c59f01a13379be4ef683dec54ed19 Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Fri, 24 Apr 2015 18:56:57 +0200 Subject: [PATCH] Fix tix-build honoring empty triplet variables. --- tix/tix-build.cpp | 4 ++-- tix/util.h | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/tix/tix-build.cpp b/tix/tix-build.cpp index ccf97615..83989f82 100644 --- a/tix/tix-build.cpp +++ b/tix/tix-build.cpp @@ -868,9 +868,9 @@ int main(int argc, char* argv[]) if ( !minfo.build && !(minfo.build = GetBuildTriplet()) ) error(1, errno, "unable to determine build, use --build or BUILD"); - if ( !minfo.host && !(minfo.host = strdup_null(getenv("HOST"))) ) + if ( !minfo.host && !(minfo.host = strdup_null_if_content(getenv("HOST"))) ) minfo.host = strdup(minfo.build); - if ( !minfo.target && !(minfo.target = strdup_null(getenv("TARGET"))) ) + if ( !minfo.target && !(minfo.target = strdup_null_if_content(getenv("TARGET"))) ) minfo.target = strdup(minfo.host); if ( minfo.prefix && !minfo.exec_prefix ) diff --git a/tix/util.h b/tix/util.h index 4bef3c38..843cbacf 100644 --- a/tix/util.h +++ b/tix/util.h @@ -75,6 +75,13 @@ char* strdup_null(const char* src) return src ? strdup(src) : NULL; } +char* strdup_null_if_content(const char* src) +{ + if ( src && !src[0] ) + return NULL; + return strdup_null(src); +} + const char* non_modify_basename(const char* path) { const char* last_slash = (char*) strrchr((char*) path, '/');