Better handle blanks and comments in rc files. - sam - An updated version of th… | |
git clone git://vernunftzentrum.de/sam.git | |
Log | |
Files | |
Refs | |
LICENSE | |
--- | |
commit 1f4860ac9d58b65870094a6867a7b16c8f7c2f48 | |
parent e3c7cd4d198971a71e0cff17613c17248d58a76b | |
Author: Rob King <[email protected]> | |
Date: Fri, 23 Sep 2016 22:31:16 -0500 | |
Better handle blanks and comments in rc files. | |
Diffstat: | |
samterm/samrc.c | 38 +++++++++++++++++++------------ | |
1 file changed, 23 insertions(+), 15 deletions(-) | |
--- | |
diff --git a/samterm/samrc.c b/samterm/samrc.c | |
@@ -330,6 +330,12 @@ direxpandtabs(const char *s1, const char *s2, const char *… | |
return 0; | |
} | |
+static int | |
+dircomment(const char *s1, const char *s2, const char *s3, const char *s4, con… | |
+{ | |
+ return 0; | |
+} | |
+ | |
typedef struct Directive Directive; | |
struct Directive{ | |
const char *format; | |
@@ -338,20 +344,22 @@ struct Directive{ | |
}; | |
Directive directives[] ={ | |
- {" chord %5[Nn12345] %5[Nn12345] %99s %99s %1023[^\n]", 5, dirchord}, | |
- {" chord %5[Nn12345] %5[Nn12345] %99s %99s", 4, dirchord}, | |
- {" unchord %5[Nn12345] %5[Nn12345]", 2, dirunchor… | |
- {" bind %5[*camshNCAMSH12345] %99s raw 0x%4[0-9a-fA-F]", 3, dirraw}, | |
- {" bind %5[*camshNCAMSH12345] %99s raw %1s", 3, dirrawlit… | |
- {" bind %5[*camshNCAMSH12345] %99s command %99s %1023[^\n]", 4, dirbind}, | |
- {" bind %5[*camshNCAMSH12345] %99s command %99s", 3, dirbind}, | |
- {" unbind %5[*camshNCAMSH12345] %99s", 2, dirunbind… | |
- {" foreground %1023s", 1, dirforegr… | |
- {" background %1023s", 1, dirbackgr… | |
- {" border %1023s", 1, dirborder… | |
- {" font %1023s", 1, dirfont}, | |
- {" tabs %2[0-9]", 1, dirtabs}, | |
- {" expandtabs %99s", 1, direxpand… | |
+ {" chord %5[Nn12345] %5[Nn12345] %99s %99s %1023[^\n]", 5, dirchor… | |
+ {" chord %5[Nn12345] %5[Nn12345] %99s %99s", 4, dirchor… | |
+ {" unchord %5[Nn12345] %5[Nn12345]", 2, dirunch… | |
+ {" bind %5[*camshNCAMSH12345] %99s raw 0x%4[0-9a-fA-F]", 3, dirraw}, | |
+ {" bind %5[*camshNCAMSH12345] %99s raw %1s", 3, dirrawl… | |
+ {" bind %5[*camshNCAMSH12345] %99s command %99s %1023[^\n]", 4, dirbind… | |
+ {" bind %5[*camshNCAMSH12345] %99s command %99s", 3, dirbind… | |
+ {" unbind %5[*camshNCAMSH12345] %99s", 2, dirunbi… | |
+ {" foreground %1023s", 1, dirfore… | |
+ {" background %1023s", 1, dirback… | |
+ {" border %1023s", 1, dirbord… | |
+ {" font %1023s", 1, dirfont… | |
+ {" tabs %2[0-9]", 1, dirtabs… | |
+ {" expandtabs %99s", 1, direxpa… | |
+ {" %1[#]", 1, dircomm… | |
+ {" %1[^ ]", EOF, dircomm… | |
{NULL, 0, NULL} | |
}; | |
@@ -373,7 +381,7 @@ loadrcfile(FILE *f) | |
bool found = false; | |
ln++; | |
- if (r == 0 || l[0] == '\n' || l[0] == 0 || sscanf(l, " %1[#]", s1) == … | |
+ if (r == 0) | |
continue; | |
for (Directive *d = directives; d->format && !found; d++){ |