X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/59ecf21e36b2332f6adf2a568ef555283d8c119a..1375eb51603466b723ab7dd1ca4194ee5d662f75:/lunaix-os/hal/term/lcntls/lcntl.c?ds=inline diff --git a/lunaix-os/hal/term/lcntls/lcntl.c b/lunaix-os/hal/term/lcntls/lcntl.c index 4359830..aab02c0 100644 --- a/lunaix-os/hal/term/lcntls/lcntl.c +++ b/lunaix-os/hal/term/lcntls/lcntl.c @@ -21,25 +21,7 @@ raise_sig(struct term* at_term, struct linebuffer* lbuf, int sig) lbuf->sflags |= LSTATE_SIGRAISE; } -static inline int -lcntl_invoke_slaves(struct term* tdev, struct linebuffer* lbuf, char c) -{ - int allow_more = 0; - struct term_lcntl *lcntl, *n; - llist_for_each(lcntl, n, &tdev->lcntl_stack, lcntls) - { - allow_more = lcntl->process_and_put(tdev, lbuf, c); - if (!allow_more) { - break; - } - - line_flip(lbuf); - } - - return allow_more; -} - -static inline int optimize("ipa-cp-clone") +static inline int must_inline optimize("-fipa-cp-clone") lcntl_transform_seq(struct term* tdev, struct linebuffer* lbuf, bool out) { struct rbuffer* raw = lbuf->current; @@ -52,6 +34,9 @@ lcntl_transform_seq(struct term* tdev, struct linebuffer* lbuf, bool out) char c; bool should_flush = false; + int (*lcntl_slave_put)(struct term*, struct linebuffer*, char) = + tdev->lcntl->process_and_put; + #define EOL tdev->cc[_VEOL] #define EOF tdev->cc[_VEOF] #define ERASE tdev->cc[_VERASE] @@ -126,6 +111,8 @@ lcntl_transform_seq(struct term* tdev, struct linebuffer* lbuf, bool out) raise_sig(tdev, lbuf, SIGSTOP); } else if (c == ERASE) { rbuffer_erase(cooked); + } else if (c == KILL) { + // TODO shrink the rbuffer } else { goto keep; } @@ -145,18 +132,19 @@ lcntl_transform_seq(struct term* tdev, struct linebuffer* lbuf, bool out) } put_char: - allow_more = rbuffer_put(cooked, c); - } - - if (out || (_lf & _IEXTEN)) { - line_flip(lbuf); - lcntl_invoke_slaves(tdev, lbuf, c); + if (!out && (_lf & _IEXTEN) && lcntl_slave_put) { + allow_more = lcntl_slave_put(tdev, lbuf, c); + } else { + allow_more = rbuffer_put(cooked, c); + } } if (should_flush && !(_lf & _NOFLSH)) { term_flush(tdev); } + line_flip(lbuf); + return i; }