Trim rule

This commit is contained in:
Devine Lu Linvega 2024-04-04 20:19:57 -07:00
parent c7c5a20977
commit b7bdc5d8cb
2 changed files with 5 additions and 3 deletions

View File

@ -1,4 +1,4 @@
<> (?x dup) (?x ?x) <> (?x dup) (?x ?x)
<> (?x ?y swap) (?y ?x) <> (?x ?y swap) (?y ?x)
(A B swap) dup (A B swap) dup

View File

@ -116,9 +116,11 @@ print_rules(void)
static char * static char *
parse_rulefrag(FILE *f) parse_rulefrag(FILE *f)
{ {
int depth = 0; int depth = 0, trim = 0;
char c, *origin = dict_; char c, *origin = dict_;
while(f && fread(&c, 1, 1, f) && c && c != 0xa) { while(f && fread(&c, 1, 1, f) && c && c != 0xa) {
if(c == ' ' && !trim) continue;
trim = 1;
if(c == '(') { if(c == '(') {
depth++; depth++;
if(depth == 1) continue; if(depth == 1) continue;