Simplification in parsePreRelease
This commit is contained in:
parent
e4fe1c5740
commit
2de5098f34
1 changed files with 3 additions and 14 deletions
17
semver.c
17
semver.c
|
@ -160,16 +160,19 @@ int parsePreRelease(PreRelease *pr, char *s) {
|
|||
vp = s + 5;
|
||||
if (parseU12NonZero(vp, &val) != 0)
|
||||
return 1;
|
||||
pr->alpha = (uint16_t)val;
|
||||
} else if (strncasecmp(s, "beta", 4) == 0) {
|
||||
tag = Beta;
|
||||
vp = s + 4;
|
||||
if (parseU12NonZero(vp, &val) != 0)
|
||||
return 1;
|
||||
pr->beta = (uint16_t)val;
|
||||
} else if (strncasecmp(s, "rc", 2) == 0) {
|
||||
tag = ReleaseCandidate;
|
||||
vp = s + 2;
|
||||
if (parseU12NonZero(vp, &val) != 0)
|
||||
return 1;
|
||||
pr->rc = (uint16_t)val;
|
||||
} else if (strncasecmp(s, "git_", 4) == 0) {
|
||||
tag = GitRev;
|
||||
vp = s + 4;
|
||||
|
@ -177,20 +180,6 @@ int parsePreRelease(PreRelease *pr, char *s) {
|
|||
return 1;
|
||||
}
|
||||
pr->tag = tag;
|
||||
switch (tag) {
|
||||
case Alpha:
|
||||
pr->alpha = (uint16_t)val;
|
||||
break;
|
||||
case Beta:
|
||||
pr->beta = (uint16_t)val;
|
||||
break;
|
||||
case ReleaseCandidate:
|
||||
pr->rc = (uint16_t)val;
|
||||
break;
|
||||
case GitRev:
|
||||
break;
|
||||
default: return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue