mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Cleanup: Removed redundant processing of OS name
This commit is contained in:
parent
88bd2fc9e2
commit
abefdd506c
4 changed files with 34 additions and 52 deletions
31
src/DOM.cpp
31
src/DOM.cpp
|
@ -34,6 +34,7 @@
|
|||
#include <Nibbler.h>
|
||||
#include <ISO8601.h>
|
||||
#include <text.h>
|
||||
#include <util.h>
|
||||
#include <i18n.h>
|
||||
|
||||
extern Context context;
|
||||
|
@ -58,14 +59,14 @@ bool getDOM (const std::string& name, Variant& value)
|
|||
if (name == "")
|
||||
return false;
|
||||
|
||||
int len = name.length ();
|
||||
auto len = name.length ();
|
||||
Nibbler n (name);
|
||||
|
||||
// rc. --> context.config
|
||||
if (len > 3 &&
|
||||
! name.compare (0, 3, "rc.", 3))
|
||||
{
|
||||
std::string key = name.substr (3);
|
||||
auto key = name.substr (3);
|
||||
auto c = context.config.find (key);
|
||||
if (c != context.config.end ())
|
||||
{
|
||||
|
@ -117,8 +118,6 @@ bool getDOM (const std::string& name, Variant& value)
|
|||
throw format (STRING_DOM_UNREC, name);
|
||||
}
|
||||
|
||||
// TODO stats.<name>
|
||||
|
||||
// system. --> Implement locally.
|
||||
if (len > 7 &&
|
||||
! name.compare (0, 7, "system.", 7))
|
||||
|
@ -133,29 +132,7 @@ bool getDOM (const std::string& name, Variant& value)
|
|||
// OS type.
|
||||
else if (name == "system.os")
|
||||
{
|
||||
#if defined (DARWIN)
|
||||
value = Variant ("Darwin");
|
||||
#elif defined (SOLARIS)
|
||||
value = Variant ("Solaris");
|
||||
#elif defined (CYGWIN)
|
||||
value = Variant ("Cygwin");
|
||||
#elif defined (HAIKU)
|
||||
value = Variant ("Haiku");
|
||||
#elif defined (OPENBSD)
|
||||
value = Variant ("OpenBSD");
|
||||
#elif defined (FREEBSD)
|
||||
value = Variant ("FreeBSD");
|
||||
#elif defined (NETBSD)
|
||||
value = Variant ("NetBSD");
|
||||
#elif defined (LINUX)
|
||||
value = Variant ("Linux");
|
||||
#elif defined (KFREEBSD)
|
||||
value = Variant ("GNU/kFreeBSD");
|
||||
#elif defined (GNUHURD)
|
||||
value = Variant ("GNU/Hurd");
|
||||
#else
|
||||
value = Variant (STRING_DOM_UNKNOWN);
|
||||
#endif
|
||||
value = Variant (osName ());
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -79,31 +79,7 @@ int CmdDiagnostics::execute (std::string& output)
|
|||
<< bold.colorize (PACKAGE_STRING)
|
||||
<< "\n";
|
||||
|
||||
out << " " << STRING_CMD_DIAG_PLATFORM << ": "
|
||||
<<
|
||||
#if defined (DARWIN)
|
||||
"Darwin"
|
||||
#elif defined (SOLARIS)
|
||||
"Solaris"
|
||||
#elif defined (CYGWIN)
|
||||
"Cygwin"
|
||||
#elif defined (HAIKU)
|
||||
"Haiku"
|
||||
#elif defined (OPENBSD)
|
||||
"OpenBSD"
|
||||
#elif defined (FREEBSD)
|
||||
"FreeBSD"
|
||||
#elif defined (NETBSD)
|
||||
"NetBSD"
|
||||
#elif defined (LINUX)
|
||||
"Linux"
|
||||
#elif defined (KFREEBSD)
|
||||
"GNU/kFreeBSD"
|
||||
#elif defined (GNUHURD)
|
||||
"GNU/Hurd"
|
||||
#else
|
||||
STRING_CMD_DIAG_UNKNOWN
|
||||
#endif
|
||||
out << " " << STRING_CMD_DIAG_PLATFORM << ": " << osName ()
|
||||
<< "\n\n";
|
||||
|
||||
// Compiler.
|
||||
|
|
27
src/util.cpp
27
src/util.cpp
|
@ -484,4 +484,31 @@ time_t timegm (struct tm *tm)
|
|||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string osName ()
|
||||
{
|
||||
#if defined (DARWIN)
|
||||
return "Darwin";
|
||||
#elif defined (SOLARIS)
|
||||
return "Solaris";
|
||||
#elif defined (CYGWIN)
|
||||
return "Cygwin";
|
||||
#elif defined (HAIKU)
|
||||
return "Haiku";
|
||||
#elif defined (OPENBSD)
|
||||
return "OpenBSD";
|
||||
#elif defined (FREEBSD)
|
||||
return "FreeBSD";
|
||||
#elif defined (NETBSD)
|
||||
return "NetBSD";
|
||||
#elif defined (LINUX)
|
||||
return "Linux";
|
||||
#elif defined (KFREEBSD)
|
||||
return "GNU/kFreeBSD";
|
||||
#elif defined (GNUHURD)
|
||||
return "GNU/Hurd";
|
||||
#else
|
||||
return STRING_DOM_UNKNOWN;
|
||||
#endif
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -65,5 +65,7 @@ const std::vector <std::string> extractParents (
|
|||
time_t timegm (struct tm *tm);
|
||||
#endif
|
||||
|
||||
std::string osName ();
|
||||
|
||||
#endif
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue