mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Cleanup: Removed redundant processing of OS name
This commit is contained in:
parent
bfefd247c4
commit
549b970e49
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 <Nibbler.h>
|
||||||
#include <ISO8601.h>
|
#include <ISO8601.h>
|
||||||
#include <text.h>
|
#include <text.h>
|
||||||
|
#include <util.h>
|
||||||
#include <i18n.h>
|
#include <i18n.h>
|
||||||
|
|
||||||
extern Context context;
|
extern Context context;
|
||||||
|
@ -58,14 +59,14 @@ bool getDOM (const std::string& name, Variant& value)
|
||||||
if (name == "")
|
if (name == "")
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
int len = name.length ();
|
auto len = name.length ();
|
||||||
Nibbler n (name);
|
Nibbler n (name);
|
||||||
|
|
||||||
// rc. --> context.config
|
// rc. --> context.config
|
||||||
if (len > 3 &&
|
if (len > 3 &&
|
||||||
! name.compare (0, 3, "rc.", 3))
|
! name.compare (0, 3, "rc.", 3))
|
||||||
{
|
{
|
||||||
std::string key = name.substr (3);
|
auto key = name.substr (3);
|
||||||
auto c = context.config.find (key);
|
auto c = context.config.find (key);
|
||||||
if (c != context.config.end ())
|
if (c != context.config.end ())
|
||||||
{
|
{
|
||||||
|
@ -117,8 +118,6 @@ bool getDOM (const std::string& name, Variant& value)
|
||||||
throw format (STRING_DOM_UNREC, name);
|
throw format (STRING_DOM_UNREC, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO stats.<name>
|
|
||||||
|
|
||||||
// system. --> Implement locally.
|
// system. --> Implement locally.
|
||||||
if (len > 7 &&
|
if (len > 7 &&
|
||||||
! name.compare (0, 7, "system.", 7))
|
! name.compare (0, 7, "system.", 7))
|
||||||
|
@ -133,29 +132,7 @@ bool getDOM (const std::string& name, Variant& value)
|
||||||
// OS type.
|
// OS type.
|
||||||
else if (name == "system.os")
|
else if (name == "system.os")
|
||||||
{
|
{
|
||||||
#if defined (DARWIN)
|
value = Variant (osName ());
|
||||||
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
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -79,31 +79,7 @@ int CmdDiagnostics::execute (std::string& output)
|
||||||
<< bold.colorize (PACKAGE_STRING)
|
<< bold.colorize (PACKAGE_STRING)
|
||||||
<< "\n";
|
<< "\n";
|
||||||
|
|
||||||
out << " " << STRING_CMD_DIAG_PLATFORM << ": "
|
out << " " << STRING_CMD_DIAG_PLATFORM << ": " << osName ()
|
||||||
<<
|
|
||||||
#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
|
|
||||||
<< "\n\n";
|
<< "\n\n";
|
||||||
|
|
||||||
// Compiler.
|
// Compiler.
|
||||||
|
|
27
src/util.cpp
27
src/util.cpp
|
@ -484,4 +484,31 @@ time_t timegm (struct tm *tm)
|
||||||
#endif
|
#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);
|
time_t timegm (struct tm *tm);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
std::string osName ();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue