#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 }
559 if(
e->ntype == NODE_STRING){
560 if(candidate == 0x1b || candidate == 0x07){
561 a->
state =
e->trie[candidate];
563 }
564 e = esctrie_from_idx(a, a->
state);
565 if(
e->ntype == NODE_FUNCTION){
567 return 2;
568 }
570 }
571 return 0;
572 }
573 if((a->
state =
e->trie[candidate]) == 0){
574 if(esctrie_idx(a,
e) == a->
escapes){
575 memset(ni, 0, sizeof(*ni));
578 return 1;
579 }
580 loginfo(
"unexpected transition on %u[%u]",
581 esctrie_idx(a,
e), candidate);
582 return -1;
583 }
584 e = esctrie_from_idx(a, a->
state);
585
587 case NODE_NUMERIC:
588 break;
589 case NODE_STRING:
591 break;
592 case NODE_SPECIAL:
594 memcpy(ni, &
e->ni,
sizeof(*ni));
595 return 1;
596 }
597 break;
598 case NODE_FUNCTION:
600 return 2;
601 }
603 break;
604 }
605 return 0;
606}