bug-ncurses
[Top][All Lists]
Advanced

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

[PATCH 11/34] Fix improperly escaped backslashes.


From: G. Branden Robinson
Subject: [PATCH 11/34] Fix improperly escaped backslashes.
Date: Fri, 6 Oct 2023 00:14:53 -0500

Use `\e` instead of `\\` to portably and robustly obtain a backslash in
the output.

groff_man_style(7):

       \e     Format the current escape character on the output; widely
              used in man pages to render a backslash glyph.  It works
              reliably as long as the “.ec” request is not used, which
              should never happen in man pages, and it is slightly more
              portable than the more explicit \(rs (“reverse solidus”)
              special character escape sequence.

`\\` does not behave as a naïve *roff user expects when employed in a
macro or string definition.  *roff is not C.

* man/curs_getcchar.3x:
* man/curs_getstr.3x:
* man/curs_mouse.3x:
* man/curs_terminfo.3x:
* man/scr_dump.5:
* man/term.5:
* man/terminfo.head:
* man/terminfo.tail:
* man/tic.1m:
* man/tput.1:
* man/user_caps.5: Do it.
---
 man/curs_getcchar.3x |  2 +-
 man/curs_getstr.3x   |  2 +-
 man/curs_mouse.3x    |  6 +++---
 man/curs_terminfo.3x |  2 +-
 man/scr_dump.5       | 38 ++++++++++++++++-----------------
 man/term.5           |  4 ++--
 man/terminfo.head    |  2 +-
 man/terminfo.tail    | 50 ++++++++++++++++++++++----------------------
 man/tic.1m           |  2 +-
 man/tput.1           |  2 +-
 man/user_caps.5      |  8 +++----
 11 files changed, 59 insertions(+), 59 deletions(-)

diff --git a/man/curs_getcchar.3x b/man/curs_getcchar.3x
index 94b87a52..68e1991a 100644
--- a/man/curs_getcchar.3x
+++ b/man/curs_getcchar.3x
@@ -102,7 +102,7 @@ .SS setcchar
 \fIcolor_pair\fP
 .bP
 The wide-character string pointed to by \fIwch\fP.
-The string must be L'\\0' terminated,
+The string must be L'\e0' terminated,
 contain at most one spacing character,
 which must be the first.
 .IP
diff --git a/man/curs_getstr.3x b/man/curs_getstr.3x
index f4c65f34..73dac1b9 100644
--- a/man/curs_getstr.3x
+++ b/man/curs_getstr.3x
@@ -272,7 +272,7 @@ .SH PORTABILITY
 it is not necessary with ncurses.
 .IP
 Since 1995, ncurses has provided signal handlers for INTR and QUIT
-(e.g., \fB^C\fP or \fB^\\\fP).
+(e.g., \fB^C\fP or \fB^\e\fP).
 With the \fBnoraw\fP and \fBcbreak\fP settings,
 those may catch a signal and stop the program,
 where other implementations allow one to enter those characters in the buffer.
diff --git a/man/curs_mouse.3x b/man/curs_mouse.3x
index 8f40045c..8e9dfba1 100644
--- a/man/curs_mouse.3x
+++ b/man/curs_mouse.3x
@@ -368,13 +368,13 @@ .SH PORTABILITY
 corresponds to private mode 1000 of xterm:
 .PP
 .RS 3
-\\E[?1000%?%p1%{1}%=%th%el%;
+\eE[?1000%?%p1%{1}%=%th%el%;
 .RE
 .PP
 The mouse driver also recognizes a newer xterm private mode 1006, e.g.,
 .PP
 .RS 3
-\\E[?1006;1000%?%p1%{1}%=%th%el%;
+\eE[?1006;1000%?%p1%{1}%=%th%el%;
 .RE
 .PP
 The \fIz\fP member in the event structure is not presently used.
@@ -395,7 +395,7 @@ .SH BUGS
 .PP
 Mouse events under xterm will not be detected correctly in a window with
 its keypad bit off, since they are interpreted as a variety of function key.
-Your terminfo description should have \fB\%kmous\fP set to \*(``\\E[M\*(''
+Your terminfo description should have \fB\%kmous\fP set to \*(``\eE[M\*(''
 (the beginning of the response from xterm for mouse clicks).
 Other values for \fB\%kmous\fP are permitted,
 but under the same assumption,
diff --git a/man/curs_terminfo.3x b/man/curs_terminfo.3x
index 978ec5ea..de4d3dd6 100644
--- a/man/curs_terminfo.3x
+++ b/man/curs_terminfo.3x
@@ -283,7 +283,7 @@ .SS Formatting Output
 it is interpreted by \fBtputs\fP.
 .bP
 The capability string is null-terminated.
-Use \*(``\\200\*('' where an ASCII NUL is needed in the output.
+Use \*(``\e200\*('' where an ASCII NUL is needed in the output.
 .PP
 \fBtiparm\fP is a newer form of \fBtparm\fP which uses \fI<stdarg.h>\fP
 rather than a fixed-parameter list.
diff --git a/man/scr_dump.5 b/man/scr_dump.5
index 38d503d1..fb0db23f 100644
--- a/man/scr_dump.5
+++ b/man/scr_dump.5
@@ -81,12 +81,12 @@ .SS ncurses6
 was unused by other applications.
 This 16-bit number was unused:
 .NS
-0x8888 (octal \*(``\\210\\210\*('')
+0x8888 (octal \*(``\e210\e210\*('')
 .NE
 .IP
 but to be more certain, this 32-bit number was chosen:
 .NS
-0x88888888 (octal \*(``\\210\\210\\210\\210\*('')
+0x88888888 (octal \*(``\e210\e210\e210\e210\*('')
 .NE
 .IP
 This is the pattern submitted to the maintainers of the \fBfile\fP program:
@@ -96,7 +96,7 @@ .SS ncurses6
 # making screen dumps "data".
 #
 # ncurses6 (2015) uses this format, ignoring byte-order
-0    string    \\210\\210\\210\\210ncurses    ncurses6 screen image
+0    string    \e210\e210\e210\e210ncurses    ncurses6 screen image
 #
 .NE
 .bP
@@ -248,7 +248,7 @@ .SS PDCurses
 followed by a one-byte version,
 e.g.,
 .NS
-       \*(``PDC\\001\*(''
+       \*(``PDC\e001\*(''
 .NE
 .SS NetBSD
 As of April 2017, NetBSD curses does
@@ -300,28 +300,28 @@ .SH EXAMPLE
 .PP
 When run using ncurses6, the output looks like this:
 .NS
-\\210\\210\\210\\210ncurses 6.0.20170415
+\e210\e210\e210\e210ncurses 6.0.20170415
 _cury=5
 _curx=11
 _maxy=9
 _maxx=19
 _flags=14
-_attrs=\\{REVERSE|C2}
+_attrs=\e{REVERSE|C2}
 flag=_idcok
 _delay=-1
 _regbottom=9
-_bkgrnd=\\{NORMAL|C1}\\s
+_bkgrnd=\e{NORMAL|C1}\es
 rows:
-1:\\{NORMAL|C1}\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s
-2:\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s
-3:\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s
-4:\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s
-5:\\s\\s\\s\\s\\s\\{BOLD}Hello\\{NORMAL}\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s
-6:\\s\\s\\s\\s\\s\\{REVERSE|C2}World!\\{NORMAL|C1}\\s\\s\\s\\s\\s\\s\\s\\s\\s
-7:\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s
-8:\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s
-9:\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s
-10:\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s\\s
+1:\e{NORMAL|C1}\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es
+2:\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es
+3:\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es
+4:\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es
+5:\es\es\es\es\es\e{BOLD}Hello\e{NORMAL}\es\es\es\es\es\es\es\es\es\es
+6:\es\es\es\es\es\e{REVERSE|C2}World!\e{NORMAL|C1}\es\es\es\es\es\es\es\es\es
+7:\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es
+8:\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es
+9:\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es
+10:\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es\es
 .NE
 .PP
 The first four octal escapes are actually nonprinting characters,
@@ -330,10 +330,10 @@ .SH EXAMPLE
 .bP
 The actual color pair values are not written to the file.
 .bP
-All characters are shown in printable form; spaces are \*(``\\s\*('' to
+All characters are shown in printable form; spaces are \*(``\es\*('' to
 ensure they are not overlooked.
 .bP
-Attributes are written in escaped curly braces, e.g., \*(``\\{BOLD}\*('',
+Attributes are written in escaped curly braces, e.g., \*(``\e{BOLD}\*('',
 and may include a color-pair (C1 or C2 in this example).
 .bP
 The parameters in the header are written out only if they are nonzero.
diff --git a/man/term.5 b/man/term.5
index e589d5ec..31697865 100644
--- a/man/term.5
+++ b/man/term.5
@@ -355,8 +355,8 @@ .SH EXAMPLE
 adm3a|lsi adm3a,
         am,
         cols#80, lines#24,
-        bel=\*^G, clear=\032$<1>, cr=\*^M, cub1=\*^H, cud1=\*^J,
-        cuf1=\*^L, cup=\\E=%p1%{32}%+%c%p2%{32}%+%c, cuu1=\*^K,
+        bel=\*^G, clear=\e032$<1>, cr=\*^M, cub1=\*^H, cud1=\*^J,
+        cuf1=\*^L, cup=\eE=%p1%{32}%+%c%p2%{32}%+%c, cuu1=\*^K,
         home=\*^\*^, ind=\*^J,
 .NE
 .PP
diff --git a/man/terminfo.head b/man/terminfo.head
index 6c7682bf..5e2b5c7a 100644
--- a/man/terminfo.head
+++ b/man/terminfo.head
@@ -85,7 +85,7 @@ consist of a sequence of fields:
 .bP
 Each field ends with a comma \*(``,\*(''
 (embedded commas may be
-escaped with a backslash or written as \*(``\\054\*('').
+escaped with a backslash or written as \*(``\e054\*('').
 .bP
 White space between fields is ignored.
 .bP
diff --git a/man/terminfo.tail b/man/terminfo.tail
index 435f6746..0cfb092a 100644
--- a/man/terminfo.tail
+++ b/man/terminfo.tail
@@ -88,33 +88,33 @@ of what a \fBterminfo\fP entry for a modern terminal 
typically looks like.
 \s-2ansi|ansi/pc-term compatible with color,
         am, mc5i, mir, msgr,
         colors#8, cols#80, it#8, lines#24, ncv#3, pairs#64,
-        acsc=+\\020\\,\\021-\\030.\*^Y0\\333\(ga\\004a\\261f\\370g\\361h\\260
-             j\\331k\\277l\\332m\\300n\\305o\*~p\\304q\\304r\\304s_t\\303
-             u\\264v\\301w\\302x\\263y\\363z\\362{\\343|\\330}\\234\*~\\376,
-        bel=\*^G, blink=\\E[5m, bold=\\E[1m, cbt=\\E[Z, clear=\\E[H\\E[J,
-        cr=\*^M, cub=\\E[%p1%dD, cub1=\\E[D, cud=\\E[%p1%dB, cud1=\\E[B,
-        cuf=\\E[%p1%dC, cuf1=\\E[C, cup=\\E[%i%p1%d;%p2%dH,
-        cuu=\\E[%p1%dA, cuu1=\\E[A, dch=\\E[%p1%dP, dch1=\\E[P,
-        dl=\\E[%p1%dM, dl1=\\E[M, ech=\\E[%p1%dX, ed=\\E[J, el=\\E[K,
-        el1=\\E[1K, home=\\E[H, hpa=\\E[%i%p1%dG, ht=\\E[I, hts=\\EH,
-        ich=\\E[%p1%d@, il=\\E[%p1%dL, il1=\\E[L, ind=\*^J,
-        indn=\\E[%p1%dS, invis=\\E[8m, kbs=\*^H, kcbt=\\E[Z, kcub1=\\E[D,
-        kcud1=\\E[B, kcuf1=\\E[C, kcuu1=\\E[A, khome=\\E[H, kich1=\\E[L,
-        mc4=\\E[4i, mc5=\\E[5i, nel=\\r\\E[S, op=\\E[39;49m,
-        rep=%p1%c\\E[%p2%{1}%-%db, rev=\\E[7m, rin=\\E[%p1%dT,
-        rmacs=\\E[10m, rmpch=\\E[10m, rmso=\\E[m, rmul=\\E[m,
-        s0ds=\\E(B, s1ds=\\E)B, s2ds=\\E*B, s3ds=\\E+B,
-        setab=\\E[4%p1%dm, setaf=\\E[3%p1%dm,
-        sgr=\\E[0;10%?%p1%t;7%;
+        acsc=+\e020\e,\e021-\e030.\*^Y0\e333\(ga\e004a\e261f\e370g\e361h\e260
+             j\e331k\e277l\e332m\e300n\e305o\*~p\e304q\e304r\e304s_t\e303
+             u\e264v\e301w\e302x\e263y\e363z\e362{\e343|\e330}\e234\*~\e376,
+        bel=\*^G, blink=\eE[5m, bold=\eE[1m, cbt=\eE[Z, clear=\eE[H\eE[J,
+        cr=\*^M, cub=\eE[%p1%dD, cub1=\eE[D, cud=\eE[%p1%dB, cud1=\eE[B,
+        cuf=\eE[%p1%dC, cuf1=\eE[C, cup=\eE[%i%p1%d;%p2%dH,
+        cuu=\eE[%p1%dA, cuu1=\eE[A, dch=\eE[%p1%dP, dch1=\eE[P,
+        dl=\eE[%p1%dM, dl1=\eE[M, ech=\eE[%p1%dX, ed=\eE[J, el=\eE[K,
+        el1=\eE[1K, home=\eE[H, hpa=\eE[%i%p1%dG, ht=\eE[I, hts=\eEH,
+        ich=\eE[%p1%d@, il=\eE[%p1%dL, il1=\eE[L, ind=\*^J,
+        indn=\eE[%p1%dS, invis=\eE[8m, kbs=\*^H, kcbt=\eE[Z, kcub1=\eE[D,
+        kcud1=\eE[B, kcuf1=\eE[C, kcuu1=\eE[A, khome=\eE[H, kich1=\eE[L,
+        mc4=\eE[4i, mc5=\eE[5i, nel=\er\eE[S, op=\eE[39;49m,
+        rep=%p1%c\eE[%p2%{1}%-%db, rev=\eE[7m, rin=\eE[%p1%dT,
+        rmacs=\eE[10m, rmpch=\eE[10m, rmso=\eE[m, rmul=\eE[m,
+        s0ds=\eE(B, s1ds=\eE)B, s2ds=\eE*B, s3ds=\eE+B,
+        setab=\eE[4%p1%dm, setaf=\eE[3%p1%dm,
+        sgr=\eE[0;10%?%p1%t;7%;
                    %?%p2%t;4%;
                    %?%p3%t;7%;
                    %?%p4%t;5%;
                    %?%p6%t;1%;
                    %?%p7%t;8%;
                    %?%p9%t;11%;m,
-        sgr0=\\E[0;10m, smacs=\\E[11m, smpch=\\E[11m, smso=\\E[7m,
-        smul=\\E[4m, tbc=\\E[3g, u6=\\E[%i%d;%dR, u7=\\E[6n,
-        u8=\\E[?%[;0123456789]c, u9=\\E[c, vpa=\\E[%i%p1%dd,
+        sgr0=\eE[0;10m, smacs=\eE[11m, smpch=\eE[11m, smso=\eE[7m,
+        smul=\eE[4m, tbc=\eE[3g, u6=\eE[%i%d;%dR, u7=\eE[6n,
+        u8=\eE[?%[;0123456789]c, u9=\eE[c, vpa=\eE[%i%p1%dd,
 .EE
 .PP
 Entries may continue onto multiple lines by placing white space at
@@ -1102,7 +1102,7 @@ though it is not commonly used in sgr
 because it protects characters on the screen from the host's erasures.
 The altcharset mode also is different in that it is either \*^O or \*^N,
 depending on whether it is off or on.
-If all modes are turned on, the resulting sequence is \\E[0;1;4;5;7;8m\*^N.
+If all modes are turned on, the resulting sequence is \eE[0;1;4;5;7;8m\*^N.
 .PP
 Some sequences are common to different modes.
 For example, ;7 is output when either p1 or p3 is true, that is, if
@@ -1117,7 +1117,7 @@ lb lb lb
 l  l  l .
 Sequence       When to Output  terminfo Translation
 _
-\\E[0  always  \\E[0
+\eE[0  always  \eE[0
 ;1     if p1 or p6     %?%p1%p6%|%t;1%;
 ;4     if p2   %?%p2%|%t;4%;
 ;5     if p4   %?%p4%|%t;5%;
@@ -1130,8 +1130,8 @@ m always  m
 Putting this all together into the sgr sequence gives:
 .PP
 .EX
-    sgr=\\E[0%?%p1%p6%|%t;1%;%?%p2%t;4%;%?%p4%t;5%;
-        %?%p1%p3%|%t;7%;%?%p7%t;8%;m%?%p9%t\\016%e\\017%;,
+    sgr=\eE[0%?%p1%p6%|%t;1%;%?%p2%t;4%;%?%p4%t;5%;
+        %?%p1%p3%|%t;7%;%?%p7%t;8%;m%?%p9%t\e016%e\e017%;,
 .EE
 .PP
 Remember that if you specify sgr, you must also specify sgr0.
diff --git a/man/tic.1m b/man/tic.1m
index dfcaa31e..324e4dba 100644
--- a/man/tic.1m
+++ b/man/tic.1m
@@ -236,7 +236,7 @@ .SS OPTIONS
 .TP
 \fB\-K\fP
 Suppress some longstanding ncurses extensions to termcap format,
-e.g., "\\s" for space.
+e.g., "\es" for space.
 .TP
 \fB\-L\fP
 Force source translation to terminfo format
diff --git a/man/tput.1 b/man/tput.1
index d9b736af..7d690e30 100644
--- a/man/tput.1
+++ b/man/tput.1
@@ -325,7 +325,7 @@ .SH EXAMPLES
 sequence, and \fBoffbold\fP, to end standout mode sequence,
 for the current terminal.
 This might be followed by a
-prompt: \fBecho "${bold}Please type in your name: ${offbold}\\c"\fP
+prompt: \fBecho "${bold}Please type in your name: ${offbold}\ec"\fP
 .TP 5
 \fB@TPUT@ hc\fP
 Set exit code to indicate if the current terminal is a hard copy terminal.
diff --git a/man/user_caps.5 b/man/user_caps.5
index 27c48f83..3020cbba 100644
--- a/man/user_caps.5
+++ b/man/user_caps.5
@@ -317,15 +317,15 @@ .SS Recognized capabilities
 .IP
 .nf
   xterm+x11mouse|X11 xterm mouse protocol,
-          kmous=\\E[M, XM=\\E[?1000%?%p1%{1}%=%th%el%;,
-          xm=\\E[M
+          kmous=\eE[M, XM=\eE[?1000%?%p1%{1}%=%th%el%;,
+          xm=\eE[M
              %?%p4%t%p3%e%{3}%;%'\ '%+%c
              %p2%'!'%+%c
              %p1%'!'%+%c,
 
   xterm+sm+1006|xterm SGR-mouse,
-          kmous=\\E[<, XM=\\E[?1006;1000%?%p1%{1}%=%th%el%;,
-          xm=\\E[<%i%p3%d;
+          kmous=\eE[<, XM=\eE[?1006;1000%?%p1%{1}%=%th%el%;,
+          xm=\eE[<%i%p3%d;
              %p1%d;
              %p2%d;
              %?%p4%tM%em%;,
-- 
2.30.2

Attachment: signature.asc
Description: PGP signature


reply via email to

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