xref: /OK3568_Linux_fs/buildroot/package/fbterm/0003-C++11-compliance.patch (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1lib/vterm_states: fix C++11 compliance
2
3In C++11, narrowing a type is no longer allowed in structure
4initializers:
5
6    struct foo { u16 u; };
7    foo f[] = { {0}, {-1} };
8
9results in the gcc-6 to whine out loudly, and fail:
10
11    error: narrowing conversion of ‘-1’ from ‘int’ to ‘u16 {aka short unsigned int}’ inside { } [-Wnarrowing]
12     };
13     ^
14
15Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
16
17diff -durN fbterm-1.7.0.orig/src/lib/vterm_states.cpp fbterm-1.7.0/src/lib/vterm_states.cpp
18--- fbterm-1.7.0.orig/src/lib/vterm_states.cpp	2010-10-06 06:23:08.000000000 +0200
19+++ fbterm-1.7.0/src/lib/vterm_states.cpp	2016-08-13 16:54:29.495451127 +0200
20@@ -22,6 +22,7 @@
21 #include "vterm.h"
22
23 #define ADDSAME(len) ((len) << 8)
24+#define ENDSEQ  { ((u16)-1) }
25
26 const VTerm::Sequence VTerm::control_sequences[] = {
27 	{ 0,	0,	ESkeep },
28@@ -39,14 +40,14 @@
29 	{ 0x1B, 0,	ESesc },
30 	{ 0x7F, 0,	ESkeep },
31 	{ 0x9B, 0,	ESsquare },
32-	{ -1}
33+	ENDSEQ
34 };
35
36 const VTerm::Sequence VTerm::escape_sequences[] = {
37 	{   0, 0, ESnormal },
38
39 	// ESnormal
40-	{ -1 },
41+	ENDSEQ,
42
43 	// ESesc
44 	{ '[', &VTerm::clear_param,	ESsquare },
45@@ -65,7 +66,7 @@
46 	{ '8', &VTerm::restore_cursor,	ESnormal },
47 	{ '>', &VTerm::keypad_numeric,	ESnormal },
48 	{ '=', &VTerm::keypad_application,	ESnormal },
49-	{ -1 },
50+	ENDSEQ,
51
52 	// ESsquare
53 	{ '[', 0,	ESfunckey },
54@@ -104,7 +105,7 @@
55 	{ '`', &VTerm::cursor_position_col,	ESnormal },
56 	{ ']', &VTerm::linux_specific, ESnormal },
57 	{ '}', &VTerm::fbterm_specific, ESnormal },
58-	{ -1 },
59+	ENDSEQ,
60
61 	// ESnonstd
62 	{ '0' | ADDSAME(9), &VTerm::set_palette,    ESkeep },
63@@ -112,25 +113,25 @@
64 	{ 'a' | ADDSAME(5), &VTerm::set_palette,    ESkeep },
65 	{ 'P', &VTerm::begin_set_palette, ESkeep },
66 	{ 'R', &VTerm::reset_palette, ESnormal },
67-	{ -1 },
68+	ENDSEQ,
69
70 	// ESpercent
71 	{ '@', &VTerm::clear_utf8,	ESnormal },
72 	{ 'G', &VTerm::set_utf8,	ESnormal },
73 	{ '8', &VTerm::set_utf8,	ESnormal },
74-	{ -1 },
75+	ENDSEQ,
76
77 	// EScharset
78 	{ '0', &VTerm::set_charset, ESnormal },
79 	{ 'B', &VTerm::set_charset, ESnormal },
80 	{ 'U', &VTerm::set_charset, ESnormal },
81 	{ 'K', &VTerm::set_charset, ESnormal },
82-	{ -1 },
83+	ENDSEQ,
84
85 	// EShash
86 	{ '8', &VTerm::screen_align,	ESnormal },
87-	{ -1 },
88+	ENDSEQ,
89
90 	// ESfunckey
91-	{ -1 },
92+	ENDSEQ,
93 };
94