mirror of
https://github.com/gechandesu/os_release.git
synced 2026-06-23 07:28:00 +03:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a50f83be68 | |||
| 8e51234ca9 |
+4
-5
@@ -1,7 +1,6 @@
|
|||||||
module os_release
|
module os_release
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import strings
|
|
||||||
|
|
||||||
// options contains list of default os-release, initrd-release, extension-release options.
|
// options contains list of default os-release, initrd-release, extension-release options.
|
||||||
pub const options = ['NAME', 'ID', 'ID_LIKE', 'PRETTY_NAME', 'CPE_NAME', 'VARIANT', 'VARIANT_ID',
|
pub const options = ['NAME', 'ID', 'ID_LIKE', 'PRETTY_NAME', 'CPE_NAME', 'VARIANT', 'VARIANT_ID',
|
||||||
@@ -53,17 +52,17 @@ pub fn parse(content string) map[string]string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn unescape(s string) string {
|
fn unescape(s string) string {
|
||||||
mut ret := strings.new_builder(128)
|
mut ret := []u8{cap: 128}
|
||||||
for i := 0; i < s.len; i++ {
|
for i := 0; i < s.len; i++ {
|
||||||
if (i == 0 || i == s.len - 1) && s[i] in [`"`, `'`] {
|
if (i == 0 || i == s.len - 1) && s[i] in [`"`, `'`] {
|
||||||
continue // trim leading and trailing quotes
|
continue // trim leading and trailing quotes
|
||||||
}
|
}
|
||||||
if s[i] == `\\` && i + 1 < s.len {
|
if s[i] == `\\` && i + 1 < s.len {
|
||||||
ret.write_byte(s[i + 1])
|
ret << s[i + 1]
|
||||||
i++
|
i++
|
||||||
} else {
|
} else {
|
||||||
ret.write_byte(s[i])
|
ret << s[i]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret.str()
|
return ret.bytestr()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
Module {
|
Module {
|
||||||
name: 'os_release'
|
name: 'os_release'
|
||||||
description: 'Freedesktop OS Release Parser'
|
description: 'freedesktop.org os-release parser'
|
||||||
version: '1.0.0'
|
version: '1.0.1'
|
||||||
license: 'Unlicense'
|
license: 'Unlicense'
|
||||||
dependencies: []
|
dependencies: []
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user