summaryrefslogtreecommitdiff
path: root/data/vim/patches/8.1.0021
blob: 3106e3ea5b2db80ae5cbbb90603776f83fd9c2f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
To: vim_dev@googlegroups.com
Subject: Patch 8.1.0021
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 8.1.0021
Problem:    Clang warns for undefined behavior.
Solution:   Move #ifdef outside of sprintf() call.(suggestion by Michael
            Jarvis, closes #2956)
Files:	    src/term.c


*** ../vim-8.1.0020/src/term.c	2018-05-10 14:39:42.000000000 +0200
--- src/term.c	2018-05-23 20:26:41.770633594 +0200
***************
*** 2872,2885 ****
  #else
  	char *format = "%s%s%%dm";
  #endif
! 	sprintf(buf, format,
! 		i == 2 ?
  #if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS)
! 		s[1] == '|' ? IF_EB("\033|", ESC_STR "|") :
  #endif
! 		IF_EB("\033[", ESC_STR "[") : "\233",
! 		s[i] == '3' ? (n >= 16 ? "38;5;" : "9")
! 			    : (n >= 16 ? "48;5;" : "10"));
  	OUT_STR(tgoto(buf, 0, n >= 16 ? n : n - 8));
      }
      else
--- 2872,2886 ----
  #else
  	char *format = "%s%s%%dm";
  #endif
! 	char *lead = i == 2 ? (
  #if defined(FEAT_VTP) && defined(FEAT_TERMGUICOLORS)
! 		    s[1] == '|' ? IF_EB("\033|", ESC_STR "|") :
  #endif
! 		    IF_EB("\033[", ESC_STR "[")) : "\233";
! 	char *tail = s[i] == '3' ? (n >= 16 ? "38;5;" : "9")
! 				 : (n >= 16 ? "48;5;" : "10");
! 
! 	sprintf(buf, format, lead, tail);
  	OUT_STR(tgoto(buf, 0, n >= 16 ? n : n - 8));
      }
      else
*** ../vim-8.1.0020/src/version.c	2018-05-22 20:35:13.566009271 +0200
--- src/version.c	2018-05-23 20:30:12.982576453 +0200
***************
*** 763,764 ****
--- 763,766 ----
  {   /* Add new patch number below this line */
+ /**/
+     21,
  /**/

-- 
BEDEVERE:        And what do you burn, apart from witches?
FOURTH VILLAGER: ... Wood?
BEDEVERE:        So why do witches burn?
SECOND VILLAGER: (pianissimo) ... Because they're made of wood...?
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///