modified configuration file and parser
This commit is contained in:
parent
300b82bc5e
commit
435bbfbab8
@ -1,13 +1,11 @@
|
|||||||
# This is a comment
|
# This is a comment
|
||||||
|
|
||||||
# these are valid entries
|
# these are valid entries
|
||||||
keymap = it
|
KEY_ALT + KEY_S = "xset s on"
|
||||||
layout = qwerty
|
KEY_LEFTMETA = 'rofi -show drun'
|
||||||
|
KEY_LEFTMETA + KEY_L = '/home/ale/scripts/lock.sh'
|
||||||
|
|
||||||
I dont care about whitespaces = true
|
I dont care about whitespaces = true
|
||||||
# will be translated to Idontcareaboutwhitespaces=true
|
# will be translated to Idontcareaboutwhitespaces=true
|
||||||
or tabs = true
|
or tabs = true
|
||||||
# is: ortabs=true
|
# is: ortabs=true
|
||||||
|
|
||||||
# I can define strings
|
|
||||||
identifier = "keyboard 0"
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
CC = gcc
|
CC = gcc
|
||||||
CFLAGS = -Wall -Werror -pedantic -O2
|
CFLAGS = -Wall -Werror -pedantic
|
||||||
|
|
||||||
parse: parse.c
|
parse: parse.c
|
||||||
|
|
||||||
|
@ -3,6 +3,9 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#define ANSI_COLOR_RED "\x1b[31m"
|
||||||
|
#define ANSI_COLOR_RESET "\x1b[0m"
|
||||||
|
|
||||||
int main(int argc, char const *argv[])
|
int main(int argc, char const *argv[])
|
||||||
{
|
{
|
||||||
if (argc < 2)
|
if (argc < 2)
|
||||||
@ -19,11 +22,20 @@ int main(int argc, char const *argv[])
|
|||||||
if (linelen < 2)
|
if (linelen < 2)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
printf("%s\n", line);
|
printf(ANSI_COLOR_RED "%s\n" ANSI_COLOR_RESET, line);
|
||||||
// remove white spaces
|
/* remove white spaces */
|
||||||
|
int inquotes = 0;
|
||||||
|
int inapos = 0;
|
||||||
for (size_t i = 0; i < linelen; i++) {
|
for (size_t i = 0; i < linelen; i++) {
|
||||||
if (isblank(line[i]))
|
if (line[i] == '"' && !inapos)
|
||||||
|
inquotes = !inquotes;
|
||||||
|
if (line[i] == '\'' && !inquotes)
|
||||||
|
inapos = !inapos;
|
||||||
|
|
||||||
|
if (isblank(line[i]) && !(inquotes || inapos)) {
|
||||||
memmove(&line[i], &line[i + 1], linelen - i);
|
memmove(&line[i], &line[i + 1], linelen - i);
|
||||||
|
i -= i ? 1 : 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (line[0] == '#')
|
if (line[0] == '#')
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
Reference in New Issue
Block a user