Simplification in parsePreRelease

This commit is contained in:
Nathan Fisher 2024-02-12 19:09:13 -05:00
parent e4fe1c5740
commit 2de5098f34

View file

@ -160,16 +160,19 @@ int parsePreRelease(PreRelease *pr, char *s) {
vp = s + 5; vp = s + 5;
if (parseU12NonZero(vp, &val) != 0) if (parseU12NonZero(vp, &val) != 0)
return 1; return 1;
pr->alpha = (uint16_t)val;
} else if (strncasecmp(s, "beta", 4) == 0) { } else if (strncasecmp(s, "beta", 4) == 0) {
tag = Beta; tag = Beta;
vp = s + 4; vp = s + 4;
if (parseU12NonZero(vp, &val) != 0) if (parseU12NonZero(vp, &val) != 0)
return 1; return 1;
pr->beta = (uint16_t)val;
} else if (strncasecmp(s, "rc", 2) == 0) { } else if (strncasecmp(s, "rc", 2) == 0) {
tag = ReleaseCandidate; tag = ReleaseCandidate;
vp = s + 2; vp = s + 2;
if (parseU12NonZero(vp, &val) != 0) if (parseU12NonZero(vp, &val) != 0)
return 1; return 1;
pr->rc = (uint16_t)val;
} else if (strncasecmp(s, "git_", 4) == 0) { } else if (strncasecmp(s, "git_", 4) == 0) {
tag = GitRev; tag = GitRev;
vp = s + 4; vp = s + 4;
@ -177,20 +180,6 @@ int parsePreRelease(PreRelease *pr, char *s) {
return 1; return 1;
} }
pr->tag = tag; 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; return 0;
} }