inpcom.c, introduce find_back_assignment()

This commit is contained in:
rlar 2017-03-31 19:04:41 +02:00
parent 5238f0b1cb
commit 511389ad10
2 changed files with 23 additions and 0 deletions

View File

@ -436,6 +436,27 @@ find_assignment(const char *str)
}
/*
* backward search for an assignment
* fixme, doesn't honour neither " nor ' quotes
*/
char *
find_back_assignment(const char *p, const char *start)
{
while (--p >= start) {
if (*p != '=')
continue;
// check for '!=', '<=', '>=', '=='
if (p <= start || !strchr("!<=>", p[-1]))
return (char *) p;
p--;
}
return NULL;
}
/*-------------------------------------------------------------------------
Read the entire input file and return a pointer to the first line of
the linked list of 'card' records in data. The pointer is stored in

View File

@ -216,6 +216,8 @@ extern struct line *inp_readall(FILE *fp, char *dir_name, bool comfile, bool int
extern FILE *inp_pathopen(char *name, char *mode);
extern char *search_identifier(char *str, const char *identifier, char *str_begin);
extern char *find_assignment(const char *s);
extern char *find_back_assignment(const char *s, const char *start);
extern struct line *line_nconc(struct line *head, struct line *rest);
extern struct line *line_reverse(struct line *head);