From a980e77e0a8b59883efd4631800f627ef82901c9 Mon Sep 17 00:00:00 2001 From: unK Date: Sat, 18 Oct 2008 16:07:56 +0200 Subject: [PATCH] check whether getenv returns NULL or not --- src/helpers.cpp | 4 +++- src/ncmpcpp.h | 3 +-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/helpers.cpp b/src/helpers.cpp index 5246c548..28019002 100644 --- a/src/helpers.cpp +++ b/src/helpers.cpp @@ -56,6 +56,8 @@ extern string UNKNOWN_ARTIST; extern string UNKNOWN_TITLE; extern string UNKNOWN_ALBUM; +const string term_type = getenv("TERM") ? getenv("TERM") : ""; + bool ConnectToMPD() { if (!Mpd->Connect()) @@ -265,7 +267,7 @@ bool SortSongsByTrack(Song *a, Song *b) void WindowTitle(const string &status) { - if (TERMINAL_TYPE != "linux" && Config.set_window_title) + if (term_type != "linux" && Config.set_window_title) std::cout << "\033]0;" << status << "\7"; } diff --git a/src/ncmpcpp.h b/src/ncmpcpp.h index 3c6c9782..4269821e 100644 --- a/src/ncmpcpp.h +++ b/src/ncmpcpp.h @@ -46,8 +46,7 @@ enum NcmpcppScreen const int ncmpcpp_window_timeout = 500; -const string home_folder = getenv("HOME"); -const string TERMINAL_TYPE = getenv("TERM"); +const string home_folder = getenv("HOME") ? getenv("HOME") : ""; const string search_mode_normal = "Match if tag contains searched phrase"; const string search_mode_strict = "Match only if both values are the same";