[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-ed] [Patch] Remove arbitrary 80-character prompt limitation

From: Tim Chase
Subject: [Bug-ed] [Patch] Remove arbitrary 80-character prompt limitation
Date: Mon, 15 Apr 2019 10:16:47 -0500

Currently GNU ed(1) has a hard-coded limit of 80-characters in

  static char prompt_str[80] = "*";

However, this silently truncates if you create a prompt longer than
80 characters:

  ed -p"$(tput sc; tput home; seq $(( $COLUMNS / 10 )) | xargs printf %10i ; 
tput rc)" file.txt

The above maintains a ruler at the top of the screen and works in BSD
ed(1) but fails in GNU ed(1) because the resulting prompt is longer
than 80 chars.  GNU ed(1) silently truncates with strncpy() which can
truncate in the middle of ANSI escape sequences (or allow them to set
attributes but then be unable to unset them).

The attached diff dynamically allocates the prompt at run-time.  In
theory, it's just pointing at a constant/known string from argv so
these should be able to use `const * char` but ap_argument's .data
element doesn't seem to point directly to the const argv string but
rather a (non-const) copy of it.

Consider the patch released under whatever OSI-approved license you
need (WTFPL, BSD, MIT, Apache, GPL v2 or v3 or AGPL).


Attachment: allow_arbitrary_length_prompt.diff
Description: Text Data

reply via email to

[Prev in Thread] Current Thread [Next in Thread]