mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[bootloader] Fix exam mode with Epsilon 19 and add support for Epsilon 20 (#302)
* [bootloader] Fix exam mode on Epsilon 19 * [bootloader] Fix comment indentation * [bootloader] Restore comment indentation (even if GitHub tell that it isn't indented properly) * [bootloader] Turn tabulations into spaces * [bootloader] Mark Epsilon 19 as "safe to boot" * [bootloader] Fix Epsilon 20 boot * [bootloader] Chang version to 1.0.2
This commit is contained in:
@@ -1,10 +1,26 @@
|
||||
#include <bootloader/utility.h>
|
||||
#include <string.h>
|
||||
|
||||
// This function takes a pointer to a string (version) and the size of the
|
||||
// string (versionSize) and returns an integer representing the version.
|
||||
// Example: "1.2.3" will return 10203.
|
||||
// "1.0.1-dev" will return 10001.
|
||||
int Utility::versionSum(const char * version, int length) {
|
||||
int sum = 0;
|
||||
for (int i = 0; i < length; i++) {
|
||||
sum += version[i] * (strlen(version) * 100 - i * 10);
|
||||
int currentNumber = 0;
|
||||
// List of numbers that are allowed in a version
|
||||
const char * allowedNumbers = "0123456789";
|
||||
for (int i = 0; i < length; i++) {
|
||||
if (version[i] == '.') {
|
||||
sum = sum * 100 + currentNumber;
|
||||
currentNumber = 0;
|
||||
} else if (strchr(allowedNumbers, version[i]) != nullptr) {
|
||||
currentNumber = currentNumber * 10 + (version[i] - '0');
|
||||
} else {
|
||||
// We found a character that is not a number or a dot, so we stop
|
||||
break;
|
||||
}
|
||||
}
|
||||
sum = sum * 100 + currentNumber;
|
||||
return sum;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user