From ec02865243c429586299bd1febf6ba793fd8063f Mon Sep 17 00:00:00 2001 From: "Michael D. Lowis" Date: Wed, 6 Nov 2019 21:22:57 -0500 Subject: [PATCH] minor tweak to parsing to allow spaces in regexes. Correct parsing should be reevaluated --- config.h | 2 +- src/fetch.c | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/config.h b/config.h index 45f48cd..e322d5f 100644 --- a/config.h +++ b/config.h @@ -31,7 +31,7 @@ static char* SedCmd[] = { "sed", "-Ee", 0, 0 }; static char* FetchCmd[] = { "fetch", 0, 0 }; /* Default tag region text in editor windows */ -static char* TagString = "Del Put | Font Tabs Eol | x+ w+ !st | Find "; +static char* TagString = "Del Put Get | Font Tabs Eol | x+ w+ !st | Find "; /* List of font patterns available to the editor */ static char* Fonts[2] = { diff --git a/src/fetch.c b/src/fetch.c index 2f0aa90..e10f915 100644 --- a/src/fetch.c +++ b/src/fetch.c @@ -313,6 +313,21 @@ static char* nextfield(char** raw) return (field && *field ? field : NULL); } +static char* lastfield(char** raw) +{ + char* field = *raw; + /* skip whitespace */ + for (; *field && isspace(*field); field++); + + char* eof = field; + for (; *eof && *eof != '\n'; eof++); + *eof = '\0'; + *raw = eof + 1; + + return (field && *field ? field : NULL); +} + + static void parse_args1(int type, Rule* rule, char* args) { rule->type = type; @@ -328,7 +343,7 @@ static void parse_args2(int type, Rule* rule, char* args) { rule->type = type; rule->arg1 = nextfield(&args); - rule->arg2 = nextfield(&args); + rule->arg2 = lastfield(&args); if (!rule->arg1 || !rule->arg2) { printf("action '%s' requires two arguments\n", type2str(type)); -- 2.52.0