version 1.16, 2021/03/25 17:31:21 |
version 1.17, 2021/03/25 20:25:31 |
|
|
static int doregex(char *, char *); |
static int doregex(char *, char *); |
static int parseexp(char *); |
static int parseexp(char *); |
static void clearexp(void); |
static void clearexp(void); |
|
static int addexp(char *, int, int, int, int); |
static int exitinterpreter(void); |
static int exitinterpreter(void); |
|
|
TAILQ_HEAD(exphead, expentry) ehead; |
TAILQ_HEAD(exphead, expentry) ehead; |
|
|
|
|
pctr = fndstart = expctr = fndend = inquote = 0; |
pctr = fndstart = expctr = fndend = inquote = 0; |
blkid = 1; |
blkid = 1; |
/* |
|
* Check for blocks of code with opening and closing (). |
|
* One block = (cmd p a r a m) |
|
* Two blocks = (cmd p a r a m s)(hola) |
|
* Two blocks = (cmd p a r (list a m s))(hola) |
|
* Only single line at moment, but more for multiline. |
|
*/ |
|
p = funstr; |
|
|
|
/* |
/* |
* Currently can't do () or (( at the moment, |
* Currently can't do () or (( at the moment, |
|
|
*/ |
*/ |
TAILQ_INIT(&ehead); |
TAILQ_INIT(&ehead); |
|
|
for (i = llen; i > 0; --i) { |
/* |
|
* Check for blocks of code with opening and closing (). |
|
* One block = (cmd p a r a m) |
|
* Two blocks = (cmd p a r a m s)(hola) |
|
* Two blocks = (cmd p a r (list a m s))(hola) |
|
* Only single line at moment, but more for multiline. |
|
*/ |
|
p = funstr; |
|
|
|
for (i = 0; i < llen; ++i) { |
if (*p == '(') { |
if (*p == '(') { |
if (fndstart == 1) { |
if (fndstart == 1) { |
if (endp == NULL) |
if (endp == NULL) |
*p = '\0'; |
*p = '\0'; |
else |
else |
*endp = '\0'; |
*endp = '\0'; |
e1->par2 = 1; |
|
if ((e1->exp = strndup(begp, BUFSIZE)) == |
ret = addexp(begp, 1, 1, blkid, ++expctr); |
NULL) { |
if (!ret) { |
cleanup(); |
cleanup(); |
return(dobeep_msg("strndup error")); |
return(ret); |
} |
} |
begp = NULL; |
begp = NULL; |
} |
} |
if ((e1 = malloc(sizeof(struct expentry))) == NULL) { |
fndstart = 0; |
cleanup(); |
|
return (dobeep_msg("malloc Error")); |
|
} |
|
TAILQ_INSERT_HEAD(&ehead, e1, eentry); |
|
e1->exp = NULL; |
|
e1->expctr = ++expctr; |
|
e1->blkid = blkid; |
|
e1->par1 = 1; |
|
fndstart = 1; |
|
fndend = 0; |
fndend = 0; |
endp = NULL; |
endp = NULL; |
pctr++; |
pctr++; |
|
|
return(dobeep_msg("Opening and closing quote "\ |
return(dobeep_msg("Opening and closing quote "\ |
"char error")); |
"char error")); |
} |
} |
if (endp == NULL) |
if (fndstart == 1) { |
*p = '\0'; |
if (endp == NULL) |
else |
*p = '\0'; |
*endp = '\0'; |
else |
if ((e1->exp = strndup(begp, BUFSIZE)) == NULL) { |
*endp = '\0'; |
cleanup(); |
|
return(dobeep_msg("strndup error")); |
ret = addexp(begp, 1, 2, blkid, ++expctr); |
|
if (!ret) { |
|
cleanup(); |
|
return(ret); |
|
} |
} |
} |
fndstart = 0; |
fndstart = 0; |
|
fndend = 0; |
|
begp = NULL; |
pctr--; |
pctr--; |
} else if (*p != ' ' && *p != '\t') { |
} else if (*p != ' ' && *p != '\t') { |
if (begp == NULL) |
if (fndstart == 0) { |
begp = p; |
fndstart = 1; |
|
if (begp == NULL) |
|
begp = p; |
|
} |
if (*p == '"') { |
if (*p == '"') { |
if (inquote == 0) |
if (inquote == 0) |
inquote = 1; |
inquote = 1; |
|
|
clearexp(); /* leave lists but remove expressions */ |
clearexp(); /* leave lists but remove expressions */ |
|
|
return (ret); |
return (ret); |
|
} |
|
|
|
|
|
static int |
|
addexp(char *begp, int par1, int par2, int blkid, int expctr) |
|
{ |
|
struct expentry *e1 = NULL; |
|
|
|
if ((e1 = malloc(sizeof(struct expentry))) == NULL) { |
|
cleanup(); |
|
return (dobeep_msg("malloc Error")); |
|
} |
|
TAILQ_INSERT_HEAD(&ehead, e1, eentry); |
|
if ((e1->exp = strndup(begp, BUFSIZE)) == NULL) { |
|
cleanup(); |
|
return(dobeep_msg("strndup error")); |
|
} |
|
e1->expctr = expctr; |
|
e1->blkid = blkid; |
|
/* need to think about these two */ |
|
e1->par1 = par1; |
|
e1->par2 = par2; |
|
|
|
return (TRUE); |
} |
} |
|
|
/* |
/* |