Re: [PATCH 10/12] setterm: use string constant rather than #define

Karel Zak
2014-05-12T12:07:59Z

On Sun, May 11, 2014 at 08:26:47PM +0100, Sami Kerola wrote:
> -/* Control sequences. */
> -#define ESC "\033"
> -
> /* Static variables. */
>
> /* Option flags. Set if the option is to be invoked. */
> @@ -796,6 +793,8 @@ static char *ti_entry(const char *name) {
>
> static void
> perform_sequence(int vcterm) {
> + static const char *ESC = "\033";

Sorry, but this is really premature optimization, \033 is just one char.

> /* vcterm: Set if terminal is a virtual console. */
>
> int result;
> @@ -822,25 +821,25 @@ perform_sequence(int vcterm) {
> /* -linewrap [on|off]. Vc only (vt102) */
> if (opt_linewrap && vcterm) {
> if (opt_li_on)
> - printf("\033[?7h");
> + printf("%s[?7h", ESC);

fputs("\033[?7h", stdout);

is the right, simple and fast way.

Fixed and merged.

Karel

--
Karel Zak <kzak@redhat.com>