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 name = Bar Baz
# Configuration version of this file. Config file will only be installed, if the config_version differs. # 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. # 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? # Where to get the updates from?
config_update_url = https://example.com config_update_url = https://example.com

View file

@ -5,7 +5,7 @@
name = Foo Bar name = Foo Bar
# Configuration version of this file. Config file will only be installed, if the config_version differs. # 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. # 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? # Where to get the updates from?
config_update_url = https://example.com config_update_url = https://example.com

View file

@ -615,3 +615,21 @@ semver_numeric (semver_t *x) {
return num; 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 int
semver_clean (char *s); semver_clean (char *s);
semver_t
semver_copy(const semver_t *ver);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View file

@ -56,7 +56,7 @@ AboutDialog::AboutDialog()
// version // 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); wxStaticText* version = new wxStaticText(this, wxID_ANY, version_string.c_str(), wxDefaultPosition, wxDefaultSize);
wxFont version_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); wxFont version_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
#ifdef __WXMSW__ #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. // A different naming convention is used for the Wizard on Windows vs. OSX & GTK.
#if WIN32 #if WIN32
std::string config_wizard_menu = _(L("Configuration Wizard")); auto config_wizard_menu = _(L("Configuration Wizard"));
std::string config_wizard_tooltip = _(L("Run configuration wizard")); auto config_wizard_tooltip = _(L("Run configuration wizard"));
#else #else
std::string config_wizard_menu = _(L("Configuration Assistant")); auto config_wizard_menu = _(L("Configuration Assistant"));
std::string config_wizard_tooltip = _(L("Run configuration Assistant")); auto config_wizard_tooltip = _(L("Run configuration Assistant"));
#endif #endif
// Cmd+, is standard on OS X - what about other operating systems? // 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); 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 const Semver zero() { return Semver(semver_zero()); }
{
static semver_t ver = { 0, 0, 0, nullptr, nullptr };
return Semver(ver);
}
static const Semver inf() static const Semver inf()
{ {
@ -61,37 +57,21 @@ public:
return Semver(ver); return Semver(ver);
} }
Semver(Semver &&other) : ver(other.ver) Semver(Semver &&other) : ver(other.ver) { other.ver = semver_zero(); }
{ Semver(const Semver &other) : ver(::semver_copy(&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 &operator=(Semver &&other) Semver &operator=(Semver &&other)
{ {
::semver_free(&ver); ::semver_free(&ver);
ver = other.ver; ver = other.ver;
other.ver.major = other.ver.minor = other.ver.patch = 0; other.ver = semver_zero();
other.ver.metadata = other.ver.prerelease = nullptr;
return *this; return *this;
} }
Semver &operator=(const Semver &other) Semver &operator=(const Semver &other)
{ {
::semver_free(&ver); ::semver_free(&ver);
ver = other.ver; ver = ::semver_copy(&other.ver);
if (other.ver.metadata != nullptr)
ver.metadata = strdup(other.ver.metadata);
if (other.ver.prerelease != nullptr)
ver.prerelease = strdup(other.ver.prerelease);
return *this; return *this;
} }

View file

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