mirror of
https://github.com/vishapoberon/compiler.git
synced 2026-07-10 01:53:32 +00:00
fixing os name parsing from /etc/os-release for single-quoted values
gentoo (and possibly others) write ID='gentoo' with single quotes in /etc/os-release. ParseOsRelease was only stripping double quotes and using ascii comparison to find the end of the value, which caused single quotes to be embedded in the os string, producing invalid oberon like os* = ''gentoo''. stripping both quote styles at start and stopping at either kind at end. works for unquoted values (raspbian, devuan) and double-quoted values too.
This commit is contained in:
parent
851aadcaf4
commit
f6f4c904fa
1 changed files with 2 additions and 2 deletions
|
|
@ -74,9 +74,9 @@ void ParseOsRelease(FILE *fd) {
|
||||||
while (fgets(osrelease, sizeof(osrelease), fd) != NULL) {
|
while (fgets(osrelease, sizeof(osrelease), fd) != NULL) {
|
||||||
if (strncasecmp(osrelease, "id=", 3) == 0) {
|
if (strncasecmp(osrelease, "id=", 3) == 0) {
|
||||||
int i=3;
|
int i=3;
|
||||||
while (osrelease[i] == '"') {i++;}
|
while (osrelease[i] == '"' || osrelease[i] == '\'') {i++;}
|
||||||
int j=i;
|
int j=i;
|
||||||
while (osrelease[j] > '"') {j++;}
|
while (osrelease[j] != 0 && osrelease[j] != '\n' && osrelease[j] != '"' && osrelease[j] != '\'') {j++;}
|
||||||
if (j>i) {
|
if (j>i) {
|
||||||
osrelease[j] = 0;
|
osrelease[j] = 0;
|
||||||
os = osrelease + i;
|
os = osrelease + i;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue