:: commit a014d0758c9cd869dd83033482fe714acfc07fe8

mintsuki <mintsuki@protonmail.com> — 2024-08-01 04:27

parents: bf94d9b285

config: Change syntax to use colon instead of equals for options

diff --git a/common/lib/config.c b/common/lib/config.c
index 6c292d36..b59eb2cc 100644
--- a/common/lib/config.c
+++ b/common/lib/config.c
@@ -464,12 +464,15 @@ char *config_get_value(const char *config, size_t index, const char *key) {
     size_t key_len = strlen(key);
 
     for (size_t i = 0; config[i]; i++) {
-        if (!strncmp(&config[i], key, key_len) && config[i + key_len] == '=') {
+        if (!strncmp(&config[i], key, key_len) && config[i + key_len] == ':') {
             if (i && config[i - 1] != SEPARATOR)
                 continue;
             if (index--)
                 continue;
             i += key_len + 1;
+            while (config[i] == ' ') {
+                i++;
+            }
             size_t value_len;
             for (value_len = 0;
                  config[i + value_len] != SEPARATOR && config[i + value_len];
diff --git a/common/menu.c b/common/menu.c
index be2a0256..4ded8efa 100644
--- a/common/menu.c
+++ b/common/menu.c
@@ -128,12 +128,12 @@ static int validate_line(const char *buffer) {
     char keybuf[64];
     size_t i;
     for (i = 0; buffer[i] && i < 64; i++) {
-        if (buffer[i] == '=') goto found_equals;
+        if (buffer[i] == ':') goto found_equals;
         keybuf[i] = buffer[i];
     }
 fail:
     if (i < 64) keybuf[i] = 0;
-    if (keybuf[0] == '\n' || (!keybuf[0] && buffer[0] != '=')) return TOK_KEY; // blank line is valid
+    if (keybuf[0] == '\n' || (!keybuf[0] && buffer[0] != ':')) return TOK_KEY; // blank line is valid
     invalid_syntax = true;
     return TOK_BADKEY;
 found_equals:
@@ -296,7 +296,7 @@ refresh:
         }
 
         // switch to token type 1 if equals sign
-        if (token_type == TOK_KEY && buffer[i] == '=') token_type = TOK_EQUALS;
+        if (token_type == TOK_KEY && buffer[i] == ':') token_type = TOK_EQUALS;
 
         if (buffer[i] != 0 && line_offset % line_size == line_size - 1) {
             if (current_line <  window_offset + window_size
diff --git a/test/limine.cfg b/test/limine.cfg
index 7d6e904a..3888aa8a 100644
--- a/test/limine.cfg
+++ b/test/limine.cfg
@@ -2,57 +2,57 @@
 ${TEST_KERNEL}=boot:///boot/test.elf
 ${WALLPAPER_PATH}=boot:///boot/bg.jpg
 
-DEFAULT_ENTRY=1
-TIMEOUT=3
-VERBOSE=yes
+DEFAULT_ENTRY: 1
+TIMEOUT: 3
+VERBOSE: yes
 
 # Terminal related settings
-TERM_WALLPAPER=${WALLPAPER_PATH}
-TERM_BACKDROP=008080
+TERM_WALLPAPER: ${WALLPAPER_PATH}
+TERM_BACKDROP: 008080
 
 :Limine Test
-    COMMENT=Test of the Limine boot protocol. ${ARCH}
+    COMMENT: Test of the Limine boot protocol. ${ARCH}
 
-    PROTOCOL=limine
-    KERNEL_PATH=${TEST_KERNEL}
-    KERNEL_CMDLINE=This is an example kernel command line.
+    PROTOCOL: limine
+    KERNEL_PATH: ${TEST_KERNEL}
+    KERNEL_CMDLINE: This is an example kernel command line.
 
-    MODULE_PATH=${WALLPAPER_PATH}
-    MODULE_CMDLINE=This is the first module.
+    MODULE_PATH: ${WALLPAPER_PATH}
+    MODULE_CMDLINE: This is the first module.
 
-    MODULE_PATH=boot:///boot/bg.jpg
+    MODULE_PATH: boot:///boot/bg.jpg
 
 :Multiboot2 Test
-    COMMENT=Test of the multiboot2 boot protocol.
+    COMMENT: Test of the multiboot2 boot protocol.
 
-    PROTOCOL=multiboot2
-    KERNEL_PATH=boot:///boot/multiboot2.elf
-    KERNEL_CMDLINE=This is an example kernel command line.
+    PROTOCOL: multiboot2
+    KERNEL_PATH: boot:///boot/multiboot2.elf
+    KERNEL_CMDLINE: This is an example kernel command line.
 
-    MODULE_PATH=boot:///boot/bg.jpg
-    MODULE_STRING=This is the first module.
+    MODULE_PATH: boot:///boot/bg.jpg
+    MODULE_STRING: This is the first module.
 
 :EFI Chainloading
-    COMMENT=Test EFI image chainloading.
+    COMMENT: Test EFI image chainloading.
 
-    PROTOCOL=efi_chainload
-    IMAGE_PATH=boot:///EFI/BOOT/BOOTX64.EFI
+    PROTOCOL: efi_chainload
+    IMAGE_PATH: boot:///EFI/BOOT/BOOTX64.EFI
 
 :BIOS Chainloading
-    COMMENT=Test BIOS chainloading.
+    COMMENT: Test BIOS chainloading.
 
-    PROTOCOL=bios_chainload
-    DRIVE=1
+    PROTOCOL: bios_chainload
+    DRIVE: 1
 
 :+Legacy
-    COMMENT=Directory containing legacy entries.
+    COMMENT: Directory containing legacy entries.
 
     ::Multiboot1 Test
-        COMMENT=Test of the multiboot1 boot protocol.
+        COMMENT: Test of the multiboot1 boot protocol.
 
-        PROTOCOL=multiboot1
-        KERNEL_PATH=boot:///boot/multiboot.elf
-        KERNEL_CMDLINE=This is an example kernel command line.
+        PROTOCOL: multiboot1
+        KERNEL_PATH: boot:///boot/multiboot.elf
+        KERNEL_CMDLINE: This is an example kernel command line.
 
-        MODULE_PATH=boot:///boot/bg.jpg
-        MODULE_STRING=This is the first module.
+        MODULE_PATH: boot:///boot/bg.jpg
+        MODULE_STRING: This is the first module.
tab: 248 wrap: offon