Skip to content
Snippets Groups Projects
Commit a6ab90b8 authored by Simon Rose's avatar Simon Rose
Browse files

Updated formatting to be more standard

parent dd5d5877
No related branches found
No related tags found
No related merge requests found
......@@ -20,6 +20,7 @@
* Fixed issue with module name checking which caused modules to fail to build on certain linux distributions
* Exact module version is fetched correctly at build-time to ensure that new releases do not affect upstream dependencies
* Issue involving priority between some test versions fixed
* `make patch` when there are no patch files will no longer return an error code.
## Other changes
* Removed `require` as a submodule and merged it into `e3-require`.
......
......@@ -823,18 +823,25 @@ static int compareDigit(int found, int requested, const char *name)
return MATCH;
}
static int compareNumericVersion(semver_t *sv_found, semver_t *sv_request, int already_matched) {
static int compareNumericVersion(semver_t *sv_found, semver_t *sv_request, int already_matched)
{
int match;
match = compareDigit(sv_found->major, sv_request->major, "major");
if (match != MATCH)
{
return match;
}
match = compareDigit(sv_found->minor, sv_request->minor, "minor");
if (match != MATCH)
{
return match;
}
match = compareDigit(sv_found->patch, sv_request->patch, "patch");
if (match != MATCH)
{
return match;
}
if (sv_request->build == -1)
{
......
......@@ -4,12 +4,14 @@
#include <stdio.h>
#include "version.h"
void cleanup_semver(semver_t *s) {
void cleanup_semver(semver_t *s)
{
free(s->version_str);
free(s);
}
static void init_semver(const char *version, semver_t *s) {
static void init_semver(const char *version, semver_t *s)
{
s->version_str = calloc(strlen(version) + 1, sizeof(char));
strcpy(s->version_str, version);
s->test_str = "";
......@@ -20,7 +22,8 @@ static void init_semver(const char *version, semver_t *s) {
s->build = -1;
}
static void fetch_part(char *version_str, regmatch_t *groups, unsigned int ix, int *part) {
static void fetch_part(char *version_str, const regmatch_t *groups, unsigned int ix, int *part)
{
char tmp;
tmp = version_str[groups[ix].rm_eo];
......@@ -29,7 +32,8 @@ static void fetch_part(char *version_str, regmatch_t *groups, unsigned int ix, i
version_str[groups[ix].rm_eo] = tmp;
}
int parse_semver(const char *version, semver_t *s) {
int parse_semver(const char *version, semver_t *s)
{
static const char* version_regex = "^(([0-9]+)\\.([0-9]+)\\.([0-9]+)(\\+([0-9]+))?)?(.*)$";
static const unsigned int max_regex_groups = 7 + 1;
static const unsigned int major_ix = 2;
......@@ -43,19 +47,23 @@ int parse_semver(const char *version, semver_t *s) {
init_semver(version, s);
if (s->version_str == NULL || s->version_str[0] == 0) {
if (s->version_str == NULL || s->version_str[0] == 0)
{
return 1;
}
if (regcomp(&compiled, version_regex, REG_EXTENDED)) {
if (regcomp(&compiled, version_regex, REG_EXTENDED))
{
return 1;
}
if (regexec(&compiled, s->version_str, max_regex_groups, groups, 0) == 0) {
if (regexec(&compiled, s->version_str, max_regex_groups, groups, 0) == 0)
{
fetch_part(s->version_str, groups, major_ix, &s->major);
fetch_part(s->version_str, groups, minor_ix, &s->minor);
fetch_part(s->version_str, groups, patch_ix, &s->patch);
if (groups[build_ix].rm_so != (size_t)-1) {
if (groups[build_ix].rm_so != (regoff_t)-1)
{
fetch_part(s->version_str, groups, build_ix, &s->build);
}
s->test_str = s->version_str + groups[test_ix].rm_so;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment