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
|
||||
|
||||
import os
|
||||
import strings
|
||||
|
||||
// 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',
|
||||
@@ -53,17 +52,17 @@ pub fn parse(content string) map[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++ {
|
||||
if (i == 0 || i == s.len - 1) && s[i] in [`"`, `'`] {
|
||||
continue // trim leading and trailing quotes
|
||||
}
|
||||
if s[i] == `\\` && i + 1 < s.len {
|
||||
ret.write_byte(s[i + 1])
|
||||
ret << s[i + 1]
|
||||
i++
|
||||
} else {
|
||||
ret.write_byte(s[i])
|
||||
ret << s[i]
|
||||
}
|
||||
}
|
||||
return ret.str()
|
||||
return ret.bytestr()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user