summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/versionstr.cc16
-rw-r--r--src/versionstr.h4
2 files changed, 13 insertions, 7 deletions
diff --git a/src/versionstr.cc b/src/versionstr.cc
index a46f221..be6913b 100644
--- a/src/versionstr.cc
+++ b/src/versionstr.cc
@@ -1,5 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set et sw=2 ts=2: */
/***************************************************************************
* versionstr.cc
*
@@ -31,6 +30,8 @@
#include <stdlib.h>
#include <stdio.h>
+#include <hugin.hpp>
+
// Workaround - major, minor and patch are defined as macros when using
// _GNU_SOURCES
#ifdef major
@@ -45,7 +46,6 @@
VersionStr::VersionStr(const std::string& v)
{
- memset(version, 0, sizeof(version));
set(v);
}
@@ -66,7 +66,9 @@ void VersionStr::set(const std::string& v)
{
if(idx > 2)
{
- throw "Version string is too long.";
+ version = {0, 0, 0};
+ ERR(version, "Version string is too long.");
+ return;
}
version[idx] = atoi(num.c_str());
idx++;
@@ -78,12 +80,16 @@ void VersionStr::set(const std::string& v)
}
else
{
- throw "Version string contains illegal character.";
+ version = {0, 0, 0};
+ ERR(version, "Version string contains illegal character.");
+ return;
}
}
if(idx > 2)
{
- throw "Version string is too long.";
+ version = {0, 0, 0};
+ ERR(version, "Version string is too long.");
+ return;
}
version[idx] = atoi(num.c_str());
}
diff --git a/src/versionstr.h b/src/versionstr.h
index 48eb40a..9fc2fcd 100644
--- a/src/versionstr.h
+++ b/src/versionstr.h
@@ -1,5 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set et sw=2 ts=2: */
/***************************************************************************
* versionstr.h
*
@@ -27,6 +26,7 @@
*/
#pragma once
+#include <array>
#include <string>
// Workaround - major, minor and patch are defined as macros when using
@@ -108,5 +108,5 @@ public:
private:
void set(const std::string& v);
- size_t version[3];
+ std::array<size_t, 3> version = {0, 0, 0};
};