Semver fixes, misc fixes

This commit is contained in:
Vojtech Kral 2018-04-11 17:07:27 +02:00
parent 12b3132b1a
commit b030791384
8 changed files with 35 additions and 33 deletions

View File

@ -5,7 +5,7 @@
name = Bar Baz
# Configuration version of this file. Config file will only be installed, if the config_version differs.
# This means, the server may force the Slic3r configuration to be downgraded.
config_version = 0.1
config_version = 0.1.0
# Where to get the updates from?
config_update_url = https://example.com

View File

@ -5,7 +5,7 @@
name = Foo Bar
# Configuration version of this file. Config file will only be installed, if the config_version differs.
# This means, the server may force the Slic3r configuration to be downgraded.
config_version = 0.1
config_version = 0.1.0
# Where to get the updates from?
config_update_url = https://example.com

View File

@ -615,3 +615,21 @@ semver_numeric (semver_t *x) {
return num;
}
static char *semver_strdup(const char *src) {
if (src == NULL) return NULL;
size_t len = strlen(src) + 1;
char *res = malloc(len);
return res != NULL ? (char *) memcpy(res, src, len) : NULL;
}
semver_t
semver_copy(const semver_t *ver) {
semver_t res = *ver;
if (ver->metadata != NULL) {
res.metadata = strdup(ver->metadata);
}
if (ver->prerelease != NULL) {
res.prerelease = strdup(ver->prerelease);
}
}

View File

@ -98,6 +98,9 @@ semver_is_valid (const char *s);
int
semver_clean (char *s);
semver_t
semver_copy(const semver_t *ver);
#ifdef __cplusplus
}
#endif

View File

@ -56,7 +56,7 @@ AboutDialog::AboutDialog()
// version
{
std::string version_string = _(L("Version ")) + std::string(SLIC3R_VERSION);
auto version_string = _(L("Version ")) + std::string(SLIC3R_VERSION);
wxStaticText* version = new wxStaticText(this, wxID_ANY, version_string.c_str(), wxDefaultPosition, wxDefaultSize);
wxFont version_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
#ifdef __WXMSW__

View File

@ -352,11 +352,11 @@ void add_config_menu(wxMenuBar *menu, int event_preferences_changed, int event_l
// A different naming convention is used for the Wizard on Windows vs. OSX & GTK.
#if WIN32
std::string config_wizard_menu = _(L("Configuration Wizard"));
std::string config_wizard_tooltip = _(L("Run configuration wizard"));
auto config_wizard_menu = _(L("Configuration Wizard"));
auto config_wizard_tooltip = _(L("Run configuration wizard"));
#else
std::string config_wizard_menu = _(L("Configuration Assistant"));
std::string config_wizard_tooltip = _(L("Run configuration Assistant"));
auto config_wizard_menu = _(L("Configuration Assistant"));
auto config_wizard_tooltip = _(L("Run configuration Assistant"));
#endif
// Cmd+, is standard on OS X - what about other operating systems?
local_menu->Append(config_id_base + ConfigMenuWizard, config_wizard_menu + "\u2026", config_wizard_tooltip);

View File

@ -43,11 +43,7 @@ public:
}
}
static const Semver zero()
{
static semver_t ver = { 0, 0, 0, nullptr, nullptr };
return Semver(ver);
}
static const Semver zero() { return Semver(semver_zero()); }
static const Semver inf()
{
@ -61,37 +57,21 @@ public:
return Semver(ver);
}
Semver(Semver &&other) : ver(other.ver)
{
other.ver.major = other.ver.minor = other.ver.patch = 0;
other.ver.metadata = other.ver.prerelease = nullptr;
}
Semver(const Semver &other) : ver(other.ver)
{
if (other.ver.metadata != nullptr)
ver.metadata = strdup(other.ver.metadata);
if (other.ver.prerelease != nullptr)
ver.prerelease = strdup(other.ver.prerelease);
}
Semver(Semver &&other) : ver(other.ver) { other.ver = semver_zero(); }
Semver(const Semver &other) : ver(::semver_copy(&other.ver)) {}
Semver &operator=(Semver &&other)
{
::semver_free(&ver);
ver = other.ver;
other.ver.major = other.ver.minor = other.ver.patch = 0;
other.ver.metadata = other.ver.prerelease = nullptr;
other.ver = semver_zero();
return *this;
}
Semver &operator=(const Semver &other)
{
::semver_free(&ver);
ver = other.ver;
if (other.ver.metadata != nullptr)
ver.metadata = strdup(other.ver.metadata);
if (other.ver.prerelease != nullptr)
ver.prerelease = strdup(other.ver.prerelease);
ver = ::semver_copy(&other.ver);
return *this;
}

View File

@ -71,7 +71,8 @@ time_t get_current_time_utc()
tm.tm_isdst = -1;
return mktime(&tm);
#else
return gmtime();
const time_t current_local = time(nullptr);
return mktime(gmtime(&current_local));
#endif
}