From: Michael D. Lowis Date: Thu, 7 Nov 2019 02:22:57 +0000 (-0500) Subject: minor tweak to parsing to allow spaces in regexes. Correct parsing should be reevaluated X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=ec02865243c429586299bd1febf6ba793fd8063f;p=projs%2Ftide.git minor tweak to parsing to allow spaces in regexes. Correct parsing should be reevaluated --- 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));