#include "automaton.h"
#include "internal.h"
Go to the source code of this file.
◆ esctrie
◆ esctrie_id()
uint32_t esctrie_id |
( |
const esctrie * |
e | ) |
|
◆ input_free_esctrie()
Definition at line 81 of file automaton.c.
81 {
84 for(
unsigned i = 0 ; i < a->
poolused ; ++i){
86 }
90}
struct esctrie * nodepool
◆ inputctx_add_cflow()
Definition at line 502 of file automaton.c.
502 {
503 esctrie* eptr = insert_path(a, seq);
505 return -1;
506 }
509 return esctrie_make_function(eptr, fxn);
510}
◆ inputctx_add_input_escape()
int inputctx_add_input_escape |
( |
automaton * |
a, |
|
|
const char * |
esc, |
|
|
uint32_t |
special, |
|
|
unsigned |
modifiers |
|
) |
| |
Definition at line 513 of file automaton.c.
514 {
515 if(esc[0] !=
NCKEY_ESC || strlen(esc) < 2){
516 logerror(
"not an escape (0x%x)", special);
517 return -1;
518 }
519 esctrie* eptr = insert_path(a, esc + 1);
521 return -1;
522 }
523
524
526 if(eptr->
ni.
id != special){
527 logwarn(
"already added escape (got 0x%x, wanted 0x%x)", eptr->
ni.
id, special);
528 }
529 }else{
530 eptr->
ni.
id = special;
537 logdebug(
"added 0x%08x to %u", special, esctrie_idx(a, eptr));
538 }
539 return 0;
540}
#define logerror(fmt,...)
#define logdebug(fmt,...)
◆ walk_automaton()
Definition at line 546 of file automaton.c.
547 {
548 if(candidate >= 0x80){
549 logerror(
"eight-bit char %u in control sequence", candidate);
550 return -1;
551 }
553
554 if(candidate == 0x1b && !a->
instring){
557 return 0;
558 }
560 return -1;
561 }
562 if(
e->ntype == NODE_STRING){
563 if(candidate == 0x1b || candidate == 0x07){
564 a->
state =
e->trie[candidate];
566 }
567 e = esctrie_from_idx(a, a->
state);
568 if(
e->ntype == NODE_FUNCTION){
570 return 2;
571 }
573 }
574 return 0;
575 }
577 if((a->
state =
e->trie[candidate]) == 0){
578 if(esctrie_idx(a,
e) == a->
escapes){
579 memset(ni, 0, sizeof(*ni));
582 return 1;
583 }
584 loginfo(
"unexpected transition on %u[%u]",
585 esctrie_idx(a,
e), candidate);
586 return -1;
587 }
588 e = esctrie_from_idx(a, a->
state);
589
591 case NODE_NUMERIC:
592 break;
593 case NODE_STRING:
595 break;
596 case NODE_SPECIAL:
598 memcpy(ni, &
e->ni,
sizeof(*ni));
599 return 1;
600 }
601 break;
602 case NODE_FUNCTION:
604 return 2;
605 }
607 break;
608 }
609 return 0;
610}