summaryrefslogtreecommitdiff
path: root/src/text.c
diff options
context:
space:
mode:
authorBerke Güzel <wenekar1@gmail.com>2026-10-15 12:38:37 +0300
committerBerke Güzel <wenekar1@gmail.com>2026-10-15 12:38:37 +0300
commit6cd9ab6f73994b68e8453c92a014d1a372af2a24 (patch)
tree742026e18d4f2210353efa15b1975610fc58f91b /src/text.c
parent86b1eed7dd946d6054eff37cdb7b4a784283e23b (diff)
parente47f9f20d68eda78a6621917a7e100ae333a1a53 (diff)
Merge branch 'wt/strict-input' into api-hardening
# Conflicts: # src/screen.c
Diffstat (limited to 'src/text.c')
-rw-r--r--src/text.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/text.c b/src/text.c
index 43c3ef5..a646195 100644
--- a/src/text.c
+++ b/src/text.c
@@ -190,10 +190,11 @@ static inline bool try_text_run(struct term *t, const char *buf, size_t len,
return wrote;
}
+/* The feed flags this build knows. term_feed() rejects any other bit. */
+#define TERM_FEED_KNOWN TERM_FEED_ONLCR
+
static void term_feed_inner(struct term *t, const char *buf, size_t len, unsigned flags)
{
- if (!t || !buf || len == 0)
- return;
t->transport_newline = (flags & TERM_FEED_ONLCR) != 0;
uint16_t cur_flags = term_current_flags(t);
@@ -366,13 +367,16 @@ static void term_feed_inner(struct term *t, const char *buf, size_t len, unsigne
}
}
-void term_feed(struct term *t, const char *buf, size_t len, unsigned flags)
+bool term_feed(struct term *t, const char *buf, size_t len, unsigned flags)
{
- if (!t || !buf || len == 0)
- return;
+ if (!t || (!buf && len > 0) || (flags & ~TERM_FEED_KNOWN))
+ return false;
+ if (len == 0)
+ return true;
term_write_begin(t);
term_feed_inner(t, buf, len, flags);
term_write_end(t);
+ return true;
}
void term_text_repeat(struct term *t, int count)