]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Refactor: Use function str_endswith.
authorBruno Haible <bruno@clisp.org>
Fri, 3 Jan 2025 15:22:41 +0000 (16:22 +0100)
committerBruno Haible <bruno@clisp.org>
Wed, 8 Jan 2025 09:03:30 +0000 (10:03 +0100)
* libtextstyle/gnulib-local/lib/term-ostream.oo.c (term_ostream_create): Use
str_endswith.
* libtextstyle/gnulib-local/modules/term-ostream (Depends-on): Add
str_endswith.

libtextstyle/gnulib-local/lib/term-ostream.oo.c
libtextstyle/gnulib-local/modules/term-ostream

index a7b08bb70fe2be8cd54d55f02b18622495f98955..e296a4315f5c617581785cef58aa73f24ce1ff3b 100644 (file)
@@ -2677,14 +2677,11 @@ term_ostream_create (int fd, const char *filename, ttyctl_t tty_control)
             && (/* Recognize xterm-16color, xterm-88color, xterm-256color.  */
                 (strlen (term) >= 5 && memcmp (term, "xterm", 5) == 0)
                 || /* Recognize *-16color.  */
-                   (strlen (term) > 8
-                    && strcmp (term + strlen (term) - 8, "-16color") == 0)
+                   (strlen (term) > 8 && str_endswith (term, "-16color"))
                 || /* Recognize *-256color.  */
-                   (strlen (term) > 9
-                    && strcmp (term + strlen (term) - 9, "-256color") == 0)
+                   (strlen (term) > 9 && str_endswith (term, "-256color"))
                 || /* Recognize *-direct.  */
-                   (strlen (term) > 7
-                    && strcmp (term + strlen (term) - 7, "-direct") == 0))
+                   (strlen (term) > 7 && str_endswith (term, "-direct")))
             ? (/* Note: For recognizing cm_xtermrgb,
                   <https://github.com/termstandard/colors> recommends to test
                   getenv ("COLORTERM"), but it does not seem like a good idea.
index f63d01979d6b55521db73be049e19984c01474bf..09afac3a35b563de377e6865df3fd388549fa318 100644 (file)
@@ -19,6 +19,7 @@ get_ppid_of
 get_progname_of
 stdint-h
 str_startswith
+str_endswith
 terminfo-h
 xalloc
 xgethostname