From 91a0daae334d249375f07ec46f3e338d98f0449a Mon Sep 17 00:00:00 2001 From: "raveit65 (via Travis CI)" Date: Mon, 12 Feb 2024 23:20:07 +0000 Subject: Deploy mate-desktop/libmatekbd to github.com/mate-desktop/libmatekbd.git:gh-pages --- .../index.html | 130 ++ .../report-0255e3.html | 962 +++++++++++++ .../report-336c49.html | 962 +++++++++++++ .../report-33ad4b.html | 1481 ++++++++++++++++++++ .../report-37cb39.html | 962 +++++++++++++ .../report-3d6c4d.html | 1481 ++++++++++++++++++++ .../report-523ef4.html | 962 +++++++++++++ .../report-5ce420.html | 962 +++++++++++++ .../report-88f11a.html | 1481 ++++++++++++++++++++ .../report-c098bd.html | 962 +++++++++++++ .../report-f5e1ce.html | 1481 ++++++++++++++++++++ .../report-fb6164.html | 1408 +++++++++++++++++++ .../report-ff92e7.html | 962 +++++++++++++ .../scanview.css | 62 + .../sorttable.js | 492 +++++++ 15 files changed, 14750 insertions(+) create mode 100644 2023-10-28-125744-5647-1@b00c769a5abd_travis-test/index.html create mode 100644 2023-10-28-125744-5647-1@b00c769a5abd_travis-test/report-0255e3.html create mode 100644 2023-10-28-125744-5647-1@b00c769a5abd_travis-test/report-336c49.html create mode 100644 2023-10-28-125744-5647-1@b00c769a5abd_travis-test/report-33ad4b.html create mode 100644 2023-10-28-125744-5647-1@b00c769a5abd_travis-test/report-37cb39.html create mode 100644 2023-10-28-125744-5647-1@b00c769a5abd_travis-test/report-3d6c4d.html create mode 100644 2023-10-28-125744-5647-1@b00c769a5abd_travis-test/report-523ef4.html create mode 100644 2023-10-28-125744-5647-1@b00c769a5abd_travis-test/report-5ce420.html create mode 100644 2023-10-28-125744-5647-1@b00c769a5abd_travis-test/report-88f11a.html create mode 100644 2023-10-28-125744-5647-1@b00c769a5abd_travis-test/report-c098bd.html create mode 100644 2023-10-28-125744-5647-1@b00c769a5abd_travis-test/report-f5e1ce.html create mode 100644 2023-10-28-125744-5647-1@b00c769a5abd_travis-test/report-fb6164.html create mode 100644 2023-10-28-125744-5647-1@b00c769a5abd_travis-test/report-ff92e7.html create mode 100644 2023-10-28-125744-5647-1@b00c769a5abd_travis-test/scanview.css create mode 100644 2023-10-28-125744-5647-1@b00c769a5abd_travis-test/sorttable.js (limited to '2023-10-28-125744-5647-1@b00c769a5abd_travis-test') diff --git a/2023-10-28-125744-5647-1@b00c769a5abd_travis-test/index.html b/2023-10-28-125744-5647-1@b00c769a5abd_travis-test/index.html new file mode 100644 index 0000000..9c09868 --- /dev/null +++ b/2023-10-28-125744-5647-1@b00c769a5abd_travis-test/index.html @@ -0,0 +1,130 @@ + + +rootdir - scan-build results + + + + + + +

rootdir - scan-build results

+ + + + + + + +
User:root@f4798fb9e7b2
Working Directory:/rootdir
Command Line:make -j 2
Clang Version:clang version 16.0.6 (Fedora 16.0.6-3.fc38) +
Date:Sat Oct 28 12:57:44 2023
+

Bug Summary

+ + + + + + + +
Bug TypeQuantityDisplay?
All Bugs12
Security
Potential insecure memory buffer bounds restriction in call 'strcat'3
Potential insecure memory buffer bounds restriction in call 'strcpy'1
Unused code
Unreachable code8
+

Reports

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Bug GroupBug Type ▾FileFunction/MethodLinePath Length
SecurityPotential insecure memory buffer bounds restriction in call 'strcat'libmatekbd/matekbd-keyboard-config.cmatekbd_keyboard_config_merge_items1441View Report
SecurityPotential insecure memory buffer bounds restriction in call 'strcat'libmatekbd/matekbd-keyboard-config.cmatekbd_keyboard_config_merge_items1451View Report
SecurityPotential insecure memory buffer bounds restriction in call 'strcat'libmatekbd/matekbd-keyboard-config.cmatekbd_keyboard_config_merge_items1391View Report
SecurityPotential insecure memory buffer bounds restriction in call 'strcpy'libmatekbd/matekbd-keyboard-config.cmatekbd_keyboard_config_split_items1701View Report
Unused codeUnreachable codetest/matekbd-keyboard-drawing-test.cmain2231View Report
Unused codeUnreachable codetest/matekbd-keyboard-drawing-test.cmain2261View Report
Unused codeUnreachable codetest/matekbd-keyboard-drawing-test.cmain2461View Report
Unused codeUnreachable codetest/matekbd-keyboard-drawing-test.cmain1971View Report
Unused codeUnreachable codetest/matekbd-keyboard-drawing-test.cmain1921View Report
Unused codeUnreachable codetest/matekbd-keyboard-drawing-test.cmain1851View Report
Unused codeUnreachable codelibmatekbd/tmp-introspecthdajf3ov/Matekbd-1.0.cvalue_to_string1811View Report
Unused codeUnreachable codetest/matekbd-keyboard-drawing-test.cmain2541View Report
+ + diff --git a/2023-10-28-125744-5647-1@b00c769a5abd_travis-test/report-0255e3.html b/2023-10-28-125744-5647-1@b00c769a5abd_travis-test/report-0255e3.html new file mode 100644 index 0000000..4622f14 --- /dev/null +++ b/2023-10-28-125744-5647-1@b00c769a5abd_travis-test/report-0255e3.html @@ -0,0 +1,962 @@ + + + +matekbd-keyboard-drawing-test.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:test/matekbd-keyboard-drawing-test.c
Warning:line 223, column 3
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name matekbd-keyboard-drawing-test.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/test -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -I .. -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libxml2 -D MATELOCALEDIR="/usr/local/share/locale" -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-unused-parameter -fdebug-compilation-dir=/rootdir/test -ferror-limit 19 -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-28-125744-5647-1 -x c matekbd-keyboard-drawing-test.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * Copyright (C) 2006 Sergey V. Udaltsov <svu@gnome.org>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20#if HAVE_CONFIG_H1
21# include <config.h>
22#endif
23
24#include <gtk/gtk.h>
25#include <stdlib.h>
26#include <string.h>
27#include <glib.h>
28#include "libmatekbd/matekbd-keyboard-drawing.h"
29
30static gchar *groups = NULL((void*)0);
31static gchar *levels = NULL((void*)0);
32static gchar *symbols = NULL((void*)0);
33static gchar *keycodes = NULL((void*)0);
34static gchar *geometry = NULL((void*)0);
35
36static gboolean track_config = FALSE(0);
37static gboolean track_modifiers = FALSE(0);
38static gboolean program_version = FALSE(0);
39
40static const GOptionEntry options[] = {
41 {"groups", '\0', 0, G_OPTION_ARG_STRING, &groups,
42 "Keyboard groups to display, from 1-4. Up to four groups only may be "
43 "displayed. Examples: --groups=3 or --groups=1,2,1,2",
44 "group1[,group2[,group3[,group4]]]"},
45 {"levels", '\0', 0, G_OPTION_ARG_STRING, &levels,
46 "Keyboard shift levels to display, from 1-64. Up to four shift levels "
47 "only may be displayed. Examples: --levels=3 or --levels=1,2,1,2",
48 "level1[,level2[,level3[,level4]]]"},
49 {"symbols", '\0', 0, G_OPTION_ARG_STRING, &symbols,
50 "Symbols component of the keyboard. If you omit this option, it is "
51 "obtained from the X server; that is, the keyboard that is currently "
52 "configured is drawn. Examples: --symbols=us or "
53 "--symbols=us(pc104)+iso9995-3+group(switch)+ctrl(nocaps)", NULL((void*)0)},
54 {"keycodes", '\0', 0, G_OPTION_ARG_STRING, &keycodes,
55 "Keycodes component of the keyboard. If you omit this option, it is "
56 "obtained from the X server; that is, the keyboard that is currently"
57 " configured is drawn. Examples: --keycodes=xfree86+aliases(qwerty)",
58 NULL((void*)0)},
59 {"geometry", '\0', 0, G_OPTION_ARG_STRING, &geometry,
60 "Geometry xkb component. If you omit this option, it is obtained from the"
61 " X server; that is, the keyboard that is currently configured is drawn. "
62 "Example: --geometry=kinesis", NULL((void*)0)},
63 {"track-modifiers", '\0', 0, G_OPTION_ARG_NONE, &track_modifiers,
64 "Track the current modifiers", NULL((void*)0)},
65 {"track-config", '\0', 0, G_OPTION_ARG_NONE, &track_config,
66 "Track the server XKB configuration", NULL((void*)0)},
67 {"version", '\0', 0, G_OPTION_ARG_NONE, &program_version,
68 "Show current version", NULL((void*)0)},
69 {NULL((void*)0), 0, 0, G_OPTION_ARG_NONE, NULL((void*)0), NULL((void*)0), NULL((void*)0)},
70};
71
72static gboolean
73set_groups (gchar * groups_option,
74 MatekbdKeyboardDrawingGroupLevel * groupLevels)
75{
76 MatekbdKeyboardDrawingGroupLevel *pgl = groupLevels;
77 gint cntr, g;
78
79 groupLevels[0].group =
80 groupLevels[1].group =
81 groupLevels[2].group = groupLevels[3].group = -1;
82
83 if (groups_option == NULL((void*)0))
84 return TRUE(!(0));
85
86 for (cntr = 4; --cntr >= 0;) {
87 if (*groups_option == '\0')
88 return FALSE(0);
89
90 g = *groups_option - '1';
91 if (g < 0 || g >= 4)
92 return FALSE(0);
93
94 pgl->group = g;
95 /* printf ("group %d\n", pgl->group); */
96
97 groups_option++;
98 if (*groups_option == '\0')
99 return TRUE(!(0));
100 if (*groups_option != ',')
101 return FALSE(0);
102
103 groups_option++;
104 pgl++;
105 }
106
107 return TRUE(!(0));
108}
109
110static gboolean
111set_levels (gchar * levels_option,
112 MatekbdKeyboardDrawingGroupLevel * groupLevels)
113{
114 MatekbdKeyboardDrawingGroupLevel *pgl = groupLevels;
115 gint cntr, l;
116 gchar *p;
117
118 groupLevels[0].level =
119 groupLevels[1].level =
120 groupLevels[2].level = groupLevels[3].level = -1;
121
122 if (levels_option == NULL((void*)0))
123 return TRUE(!(0));
124
125 for (cntr = 4; --cntr >= 0;) {
126 if (*levels_option == '\0')
127 return FALSE(0);
128
129 l = (gint) strtol (levels_option, &p, 10) - 1;
130 if (l < 0 || l >= 64)
131 return FALSE(0);
132
133 pgl->level = l;
134 /* printf ("level %d\n", pgl->level); */
135
136 levels_option = p;
137 if (*levels_option == '\0')
138 return TRUE(!(0));
139 if (*levels_option != ',')
140 return FALSE(0);
141
142 levels_option++;
143 pgl++;
144 }
145
146 return TRUE(!(0));
147}
148
149static void
150bad_keycode (MatekbdKeyboardDrawing * drawing, guint keycode)
151{
152 g_warning
153 ("got keycode %u, which is not on your keyboard according to your configuration",
154 keycode);
155}
156
157gint
158main (gint argc, gchar ** argv)
159{
160 GtkWidget *window;
161 GtkWidget *matekbd_keyboard_drawing;
162 GdkScreen *screen;
163 GdkMonitor *monitor;
164 GdkRectangle rect;
165 GOptionContext *context;
166 GError *error = NULL((void*)0);
167
168 MatekbdKeyboardDrawingGroupLevel groupLevels[4] =
169 { {0, 0}, {1, 0}, {0, 1}, {1, 1} };
170 MatekbdKeyboardDrawingGroupLevel *pgroupLevels[4] =
171 { &groupLevels[0], &groupLevels[1], &groupLevels[2],
172 &groupLevels[3]
173 };
174
175 context = g_option_context_new ("kbdraw");
176 g_option_context_add_main_entries (context, options, NULL((void*)0));
177 if (!g_option_context_parse (context, &argc, &argv, &error)) {
178 g_message ("option parsing failed: %s", error->message);
179 g_option_context_free (context);
180 exit (EXIT_FAILURE1);
181 }
182 g_option_context_free (context);
183
184 if (program_version) {
185 g_print ("kbdraw %s\n", VERSION"1.27.1");
186 exit (0);
187 }
188
189 gtk_init (&argc, &argv);
190
191 if (!set_groups (groups, groupLevels)) {
192 g_printerr ("--groups: invalid argument\n");
193 exit (1);
194 }
195
196 if (!set_levels (levels, groupLevels)) {
197 g_printerr ("--levels: invalid argument\n");
198 exit (1);
199 }
200
201 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
202 g_signal_connect (G_OBJECT (window), "destroy",g_signal_connect_data ((((((GObject*) (void *) ((window))))))
, ("destroy"), (((GCallback) (gtk_main_quit))), (((void*)0)),
((void*)0), (GConnectFlags) 0)
203 G_CALLBACK (gtk_main_quit), NULL)g_signal_connect_data ((((((GObject*) (void *) ((window))))))
, ("destroy"), (((GCallback) (gtk_main_quit))), (((void*)0)),
((void*)0), (GConnectFlags) 0)
;
204
205 screen = gtk_window_get_screen (GTK_WINDOW (window)((((GtkWindow*) (void *) ((window))))));
206 monitor = gdk_display_get_monitor_at_point (gdk_screen_get_display (screen), 0, 0);
207 gdk_monitor_get_geometry (monitor, &rect);
208 gtk_window_set_default_size (GTK_WINDOW (window)((((GtkWindow*) (void *) ((window))))),
209 rect.width * 4 / 5,
210 rect.height * 1 / 2);
211
212 gtk_widget_show (window);
213
214 matekbd_keyboard_drawing = matekbd_keyboard_drawing_new ();
215 gtk_widget_show (matekbd_keyboard_drawing);
216 gtk_container_add (GTK_CONTAINER (window)((((GtkContainer*) (void *) ((window))))), matekbd_keyboard_drawing);
217
218 matekbd_keyboard_drawing_set_groups_levels (MATEKBD_KEYBOARD_DRAWING((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
219 (matekbd_keyboard_drawing)((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
,
220 pgroupLevels);
221
222 if (track_modifiers)
223 matekbd_keyboard_drawing_set_track_modifiers
This statement is never executed
224 (MATEKBD_KEYBOARD_DRAWING (matekbd_keyboard_drawing)((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
, TRUE(!(0)));
225 if (track_config)
226 matekbd_keyboard_drawing_set_track_config
227 (MATEKBD_KEYBOARD_DRAWING (matekbd_keyboard_drawing)((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
, TRUE(!(0)));
228 g_signal_connect (G_OBJECT (matekbd_keyboard_drawing), "bad-keycode",g_signal_connect_data ((((((GObject*) (void *) ((matekbd_keyboard_drawing
)))))), ("bad-keycode"), (((GCallback) (bad_keycode))), (((void
*)0)), ((void*)0), (GConnectFlags) 0)
229 G_CALLBACK (bad_keycode), NULL)g_signal_connect_data ((((((GObject*) (void *) ((matekbd_keyboard_drawing
)))))), ("bad-keycode"), (((GCallback) (bad_keycode))), (((void
*)0)), ((void*)0), (GConnectFlags) 0)
;
230
231 if (symbols || geometry || keycodes) {
232 XkbComponentNamesRec names;
233 gint success;
234
235 memset (&names, '\0', sizeof (names));
236
237 if (symbols)
238 names.symbols = symbols;
239 else
240 names.symbols = (gchar *)
241 matekbd_keyboard_drawing_get_symbols
242 (MATEKBD_KEYBOARD_DRAWING((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
243 (matekbd_keyboard_drawing)((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
);
244
245 if (keycodes)
246 names.keycodes = keycodes;
247 else
248 names.keycodes = (gchar *)
249 matekbd_keyboard_drawing_get_keycodes
250 (MATEKBD_KEYBOARD_DRAWING((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
251 (matekbd_keyboard_drawing)((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
);
252
253 if (geometry)
254 names.geometry = geometry;
255 else
256 names.geometry = (gchar *)
257 matekbd_keyboard_drawing_get_geometry
258 (MATEKBD_KEYBOARD_DRAWING((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
259 (matekbd_keyboard_drawing)((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
);
260
261 success =
262 matekbd_keyboard_drawing_set_keyboard
263 (MATEKBD_KEYBOARD_DRAWING (matekbd_keyboard_drawing)((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
,
264 &names);
265 if (!success) {
266 g_printerr
267 ("\nError loading new keyboard description with components:\n\n"
268 " keycodes: %s\n" " types: %s\n"
269 " compat: %s\n" " symbols: %s\n"
270 " geometry: %s\n\n", names.keycodes,
271 names.types, names.compat, names.symbols,
272 names.geometry);
273 exit (1);
274 }
275 }
276
277 gtk_widget_grab_focus (matekbd_keyboard_drawing);
278
279 gtk_main ();
280
281 return 0;
282}
diff --git a/2023-10-28-125744-5647-1@b00c769a5abd_travis-test/report-336c49.html b/2023-10-28-125744-5647-1@b00c769a5abd_travis-test/report-336c49.html new file mode 100644 index 0000000..231c40d --- /dev/null +++ b/2023-10-28-125744-5647-1@b00c769a5abd_travis-test/report-336c49.html @@ -0,0 +1,962 @@ + + + +matekbd-keyboard-drawing-test.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:test/matekbd-keyboard-drawing-test.c
Warning:line 226, column 3
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name matekbd-keyboard-drawing-test.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/test -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -I .. -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libxml2 -D MATELOCALEDIR="/usr/local/share/locale" -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-unused-parameter -fdebug-compilation-dir=/rootdir/test -ferror-limit 19 -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-28-125744-5647-1 -x c matekbd-keyboard-drawing-test.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * Copyright (C) 2006 Sergey V. Udaltsov <svu@gnome.org>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20#if HAVE_CONFIG_H1
21# include <config.h>
22#endif
23
24#include <gtk/gtk.h>
25#include <stdlib.h>
26#include <string.h>
27#include <glib.h>
28#include "libmatekbd/matekbd-keyboard-drawing.h"
29
30static gchar *groups = NULL((void*)0);
31static gchar *levels = NULL((void*)0);
32static gchar *symbols = NULL((void*)0);
33static gchar *keycodes = NULL((void*)0);
34static gchar *geometry = NULL((void*)0);
35
36static gboolean track_config = FALSE(0);
37static gboolean track_modifiers = FALSE(0);
38static gboolean program_version = FALSE(0);
39
40static const GOptionEntry options[] = {
41 {"groups", '\0', 0, G_OPTION_ARG_STRING, &groups,
42 "Keyboard groups to display, from 1-4. Up to four groups only may be "
43 "displayed. Examples: --groups=3 or --groups=1,2,1,2",
44 "group1[,group2[,group3[,group4]]]"},
45 {"levels", '\0', 0, G_OPTION_ARG_STRING, &levels,
46 "Keyboard shift levels to display, from 1-64. Up to four shift levels "
47 "only may be displayed. Examples: --levels=3 or --levels=1,2,1,2",
48 "level1[,level2[,level3[,level4]]]"},
49 {"symbols", '\0', 0, G_OPTION_ARG_STRING, &symbols,
50 "Symbols component of the keyboard. If you omit this option, it is "
51 "obtained from the X server; that is, the keyboard that is currently "
52 "configured is drawn. Examples: --symbols=us or "
53 "--symbols=us(pc104)+iso9995-3+group(switch)+ctrl(nocaps)", NULL((void*)0)},
54 {"keycodes", '\0', 0, G_OPTION_ARG_STRING, &keycodes,
55 "Keycodes component of the keyboard. If you omit this option, it is "
56 "obtained from the X server; that is, the keyboard that is currently"
57 " configured is drawn. Examples: --keycodes=xfree86+aliases(qwerty)",
58 NULL((void*)0)},
59 {"geometry", '\0', 0, G_OPTION_ARG_STRING, &geometry,
60 "Geometry xkb component. If you omit this option, it is obtained from the"
61 " X server; that is, the keyboard that is currently configured is drawn. "
62 "Example: --geometry=kinesis", NULL((void*)0)},
63 {"track-modifiers", '\0', 0, G_OPTION_ARG_NONE, &track_modifiers,
64 "Track the current modifiers", NULL((void*)0)},
65 {"track-config", '\0', 0, G_OPTION_ARG_NONE, &track_config,
66 "Track the server XKB configuration", NULL((void*)0)},
67 {"version", '\0', 0, G_OPTION_ARG_NONE, &program_version,
68 "Show current version", NULL((void*)0)},
69 {NULL((void*)0), 0, 0, G_OPTION_ARG_NONE, NULL((void*)0), NULL((void*)0), NULL((void*)0)},
70};
71
72static gboolean
73set_groups (gchar * groups_option,
74 MatekbdKeyboardDrawingGroupLevel * groupLevels)
75{
76 MatekbdKeyboardDrawingGroupLevel *pgl = groupLevels;
77 gint cntr, g;
78
79 groupLevels[0].group =
80 groupLevels[1].group =
81 groupLevels[2].group = groupLevels[3].group = -1;
82
83 if (groups_option == NULL((void*)0))
84 return TRUE(!(0));
85
86 for (cntr = 4; --cntr >= 0;) {
87 if (*groups_option == '\0')
88 return FALSE(0);
89
90 g = *groups_option - '1';
91 if (g < 0 || g >= 4)
92 return FALSE(0);
93
94 pgl->group = g;
95 /* printf ("group %d\n", pgl->group); */
96
97 groups_option++;
98 if (*groups_option == '\0')
99 return TRUE(!(0));
100 if (*groups_option != ',')
101 return FALSE(0);
102
103 groups_option++;
104 pgl++;
105 }
106
107 return TRUE(!(0));
108}
109
110static gboolean
111set_levels (gchar * levels_option,
112 MatekbdKeyboardDrawingGroupLevel * groupLevels)
113{
114 MatekbdKeyboardDrawingGroupLevel *pgl = groupLevels;
115 gint cntr, l;
116 gchar *p;
117
118 groupLevels[0].level =
119 groupLevels[1].level =
120 groupLevels[2].level = groupLevels[3].level = -1;
121
122 if (levels_option == NULL((void*)0))
123 return TRUE(!(0));
124
125 for (cntr = 4; --cntr >= 0;) {
126 if (*levels_option == '\0')
127 return FALSE(0);
128
129 l = (gint) strtol (levels_option, &p, 10) - 1;
130 if (l < 0 || l >= 64)
131 return FALSE(0);
132
133 pgl->level = l;
134 /* printf ("level %d\n", pgl->level); */
135
136 levels_option = p;
137 if (*levels_option == '\0')
138 return TRUE(!(0));
139 if (*levels_option != ',')
140 return FALSE(0);
141
142 levels_option++;
143 pgl++;
144 }
145
146 return TRUE(!(0));
147}
148
149static void
150bad_keycode (MatekbdKeyboardDrawing * drawing, guint keycode)
151{
152 g_warning
153 ("got keycode %u, which is not on your keyboard according to your configuration",
154 keycode);
155}
156
157gint
158main (gint argc, gchar ** argv)
159{
160 GtkWidget *window;
161 GtkWidget *matekbd_keyboard_drawing;
162 GdkScreen *screen;
163 GdkMonitor *monitor;
164 GdkRectangle rect;
165 GOptionContext *context;
166 GError *error = NULL((void*)0);
167
168 MatekbdKeyboardDrawingGroupLevel groupLevels[4] =
169 { {0, 0}, {1, 0}, {0, 1}, {1, 1} };
170 MatekbdKeyboardDrawingGroupLevel *pgroupLevels[4] =
171 { &groupLevels[0], &groupLevels[1], &groupLevels[2],
172 &groupLevels[3]
173 };
174
175 context = g_option_context_new ("kbdraw");
176 g_option_context_add_main_entries (context, options, NULL((void*)0));
177 if (!g_option_context_parse (context, &argc, &argv, &error)) {
178 g_message ("option parsing failed: %s", error->message);
179 g_option_context_free (context);
180 exit (EXIT_FAILURE1);
181 }
182 g_option_context_free (context);
183
184 if (program_version) {
185 g_print ("kbdraw %s\n", VERSION"1.27.1");
186 exit (0);
187 }
188
189 gtk_init (&argc, &argv);
190
191 if (!set_groups (groups, groupLevels)) {
192 g_printerr ("--groups: invalid argument\n");
193 exit (1);
194 }
195
196 if (!set_levels (levels, groupLevels)) {
197 g_printerr ("--levels: invalid argument\n");
198 exit (1);
199 }
200
201 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
202 g_signal_connect (G_OBJECT (window), "destroy",g_signal_connect_data ((((((GObject*) (void *) ((window))))))
, ("destroy"), (((GCallback) (gtk_main_quit))), (((void*)0)),
((void*)0), (GConnectFlags) 0)
203 G_CALLBACK (gtk_main_quit), NULL)g_signal_connect_data ((((((GObject*) (void *) ((window))))))
, ("destroy"), (((GCallback) (gtk_main_quit))), (((void*)0)),
((void*)0), (GConnectFlags) 0)
;
204
205 screen = gtk_window_get_screen (GTK_WINDOW (window)((((GtkWindow*) (void *) ((window))))));
206 monitor = gdk_display_get_monitor_at_point (gdk_screen_get_display (screen), 0, 0);
207 gdk_monitor_get_geometry (monitor, &rect);
208 gtk_window_set_default_size (GTK_WINDOW (window)((((GtkWindow*) (void *) ((window))))),
209 rect.width * 4 / 5,
210 rect.height * 1 / 2);
211
212 gtk_widget_show (window);
213
214 matekbd_keyboard_drawing = matekbd_keyboard_drawing_new ();
215 gtk_widget_show (matekbd_keyboard_drawing);
216 gtk_container_add (GTK_CONTAINER (window)((((GtkContainer*) (void *) ((window))))), matekbd_keyboard_drawing);
217
218 matekbd_keyboard_drawing_set_groups_levels (MATEKBD_KEYBOARD_DRAWING((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
219 (matekbd_keyboard_drawing)((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
,
220 pgroupLevels);
221
222 if (track_modifiers)
223 matekbd_keyboard_drawing_set_track_modifiers
224 (MATEKBD_KEYBOARD_DRAWING (matekbd_keyboard_drawing)((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
, TRUE(!(0)));
225 if (track_config)
226 matekbd_keyboard_drawing_set_track_config
This statement is never executed
227 (MATEKBD_KEYBOARD_DRAWING (matekbd_keyboard_drawing)((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
, TRUE(!(0)));
228 g_signal_connect (G_OBJECT (matekbd_keyboard_drawing), "bad-keycode",g_signal_connect_data ((((((GObject*) (void *) ((matekbd_keyboard_drawing
)))))), ("bad-keycode"), (((GCallback) (bad_keycode))), (((void
*)0)), ((void*)0), (GConnectFlags) 0)
229 G_CALLBACK (bad_keycode), NULL)g_signal_connect_data ((((((GObject*) (void *) ((matekbd_keyboard_drawing
)))))), ("bad-keycode"), (((GCallback) (bad_keycode))), (((void
*)0)), ((void*)0), (GConnectFlags) 0)
;
230
231 if (symbols || geometry || keycodes) {
232 XkbComponentNamesRec names;
233 gint success;
234
235 memset (&names, '\0', sizeof (names));
236
237 if (symbols)
238 names.symbols = symbols;
239 else
240 names.symbols = (gchar *)
241 matekbd_keyboard_drawing_get_symbols
242 (MATEKBD_KEYBOARD_DRAWING((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
243 (matekbd_keyboard_drawing)((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
);
244
245 if (keycodes)
246 names.keycodes = keycodes;
247 else
248 names.keycodes = (gchar *)
249 matekbd_keyboard_drawing_get_keycodes
250 (MATEKBD_KEYBOARD_DRAWING((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
251 (matekbd_keyboard_drawing)((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
);
252
253 if (geometry)
254 names.geometry = geometry;
255 else
256 names.geometry = (gchar *)
257 matekbd_keyboard_drawing_get_geometry
258 (MATEKBD_KEYBOARD_DRAWING((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
259 (matekbd_keyboard_drawing)((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
);
260
261 success =
262 matekbd_keyboard_drawing_set_keyboard
263 (MATEKBD_KEYBOARD_DRAWING (matekbd_keyboard_drawing)((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
,
264 &names);
265 if (!success) {
266 g_printerr
267 ("\nError loading new keyboard description with components:\n\n"
268 " keycodes: %s\n" " types: %s\n"
269 " compat: %s\n" " symbols: %s\n"
270 " geometry: %s\n\n", names.keycodes,
271 names.types, names.compat, names.symbols,
272 names.geometry);
273 exit (1);
274 }
275 }
276
277 gtk_widget_grab_focus (matekbd_keyboard_drawing);
278
279 gtk_main ();
280
281 return 0;
282}
diff --git a/2023-10-28-125744-5647-1@b00c769a5abd_travis-test/report-33ad4b.html b/2023-10-28-125744-5647-1@b00c769a5abd_travis-test/report-33ad4b.html new file mode 100644 index 0000000..48e99d2 --- /dev/null +++ b/2023-10-28-125744-5647-1@b00c769a5abd_travis-test/report-33ad4b.html @@ -0,0 +1,1481 @@ + + + +matekbd-keyboard-config.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:libmatekbd/matekbd-keyboard-config.c
Warning:line 144, column 3
Call to function 'strcat' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcat'. CWE-119
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name matekbd-keyboard-config.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/libmatekbd -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -I .. -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libxml2 -I ../intl -D G_LOG_DOMAIN="MateKbdIndicator" -D DATADIR="/usr/local/share" -D SYSCONFDIR="/usr/local/etc" -D LIBDIR="/usr/local/lib" -D PIC -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -fdebug-compilation-dir=/rootdir/libmatekbd -ferror-limit 19 -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-28-125744-5647-1 -x c matekbd-keyboard-config.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * Copyright (C) 2006 Sergey V. Udaltsov <svu@gnome.org>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20#include <config.h>
21
22#include <stdio.h>
23#include <string.h>
24#include <stdlib.h>
25#include <X11/keysym.h>
26
27#include <glib/gi18n-lib.h>
28
29#include <matekbd-keyboard-config.h>
30#include <matekbd-config-private.h>
31#include <matekbd-util.h>
32
33/*
34 * MatekbdKeyboardConfig
35 */
36#define MATEKBD_KEYBOARD_CONFIG_SCHEMA"org.mate.peripherals-keyboard-xkb" ".kbd" MATEKBD_CONFIG_SCHEMA"org.mate.peripherals-keyboard-xkb" ".kbd"
37
38#define GROUP_SWITCHERS_GROUP"grp" "grp"
39#define DEFAULT_GROUP_SWITCH"grp:shift_caps_toggle" "grp:shift_caps_toggle"
40
41const gchar MATEKBD_KEYBOARD_CONFIG_KEY_MODEL[] = "model";
42const gchar MATEKBD_KEYBOARD_CONFIG_KEY_LAYOUTS[] = "layouts";
43const gchar MATEKBD_KEYBOARD_CONFIG_KEY_OPTIONS[] = "options";
44
45const gchar *MATEKBD_KEYBOARD_CONFIG_ACTIVE[] = {
46 MATEKBD_KEYBOARD_CONFIG_KEY_MODEL,
47 MATEKBD_KEYBOARD_CONFIG_KEY_LAYOUTS,
48 MATEKBD_KEYBOARD_CONFIG_KEY_OPTIONS
49};
50
51/*
52 * static common functions
53 */
54
55static gboolean
56matekbd_strv_equal (gchar ** l1, gchar ** l2)
57{
58 if (l1 == l2)
59 return TRUE(!(0));
60 if (l1 == NULL((void*)0))
61 return g_strv_length (l2) == 0;
62 if (l2 == NULL((void*)0))
63 return g_strv_length (l1) == 0;
64
65 while ((*l1 != NULL((void*)0)) && (*l2 != NULL((void*)0))) {
66 if (*l1 != *l2) {
67 if (*l1 && *l2) {
68 if (g_ascii_strcasecmp (*l1, *l2))
69 return FALSE(0);
70 } else
71 return FALSE(0);
72 }
73
74 l1++;
75 l2++;
76 }
77 return (*l1 == NULL((void*)0)) && (*l2 == NULL((void*)0));
78}
79
80gboolean
81matekbd_keyboard_config_get_lv_descriptions (XklConfigRegistry *
82 config_registry,
83 const gchar * layout_name,
84 const gchar * variant_name,
85 gchar ** layout_short_descr,
86 gchar ** layout_descr,
87 gchar ** variant_short_descr,
88 gchar ** variant_descr)
89{
90 /* TODO make it not static */
91 static XklConfigItem *litem = NULL((void*)0);
92 static XklConfigItem *vitem = NULL((void*)0);
93
94 if (litem == NULL((void*)0))
95 litem = xkl_config_item_new ();
96 if (vitem == NULL((void*)0))
97 vitem = xkl_config_item_new ();
98
99 layout_name = g_strdup (layout_name)g_strdup_inline (layout_name);
100
101 g_snprintf (litem->name, sizeof litem->name, "%s", layout_name);
102 if (xkl_config_registry_find_layout (config_registry, litem)) {
103 *layout_short_descr = litem->short_description;
104 *layout_descr = litem->description;
105 } else
106 *layout_short_descr = *layout_descr = NULL((void*)0);
107
108 if (variant_name != NULL((void*)0)) {
109 variant_name = g_strdup (variant_name)g_strdup_inline (variant_name);
110 g_snprintf (vitem->name, sizeof vitem->name, "%s",
111 variant_name);
112 if (xkl_config_registry_find_variant
113 (config_registry, layout_name, vitem)) {
114 *variant_short_descr = vitem->short_description;
115 *variant_descr = vitem->description;
116 } else
117 *variant_short_descr = *variant_descr = NULL((void*)0);
118
119 g_free ((char *) variant_name);
120 } else
121 *variant_descr = NULL((void*)0);
122
123 g_free ((char *) layout_name);
124 return *layout_descr != NULL((void*)0);
125}
126
127/*
128 * extern common functions
129 */
130const gchar *
131matekbd_keyboard_config_merge_items (const gchar * parent,
132 const gchar * child)
133{
134 static gchar buffer[XKL_MAX_CI_NAME_LENGTH32 * 2 - 1];
135 *buffer = '\0';
136 if (parent != NULL((void*)0)) {
137 if (strlen (parent) >= XKL_MAX_CI_NAME_LENGTH32)
138 return NULL((void*)0);
139 strcat (buffer, parent);
140 }
141 if (child != NULL((void*)0) && *child != 0) {
142 if (strlen (child) >= XKL_MAX_CI_NAME_LENGTH32)
143 return NULL((void*)0);
144 strcat (buffer, "\t");
Call to function 'strcat' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcat'. CWE-119
145 strcat (buffer, child);
146 }
147 return buffer;
148}
149
150gboolean
151matekbd_keyboard_config_split_items (const gchar * merged, gchar ** parent,
152 gchar ** child)
153{
154 static gchar pbuffer[XKL_MAX_CI_NAME_LENGTH32];
155 static gchar cbuffer[XKL_MAX_CI_NAME_LENGTH32];
156 int plen;
157 const gchar *pos;
158 *parent = *child = NULL((void*)0);
159
160 if (merged == NULL((void*)0))
161 return FALSE(0);
162
163 pos = strchr (merged, '\t');
164 if (pos == NULL((void*)0)) {
165 plen = strlen (merged);
166 } else {
167 plen = pos - merged;
168 if (strlen (pos + 1) >= XKL_MAX_CI_NAME_LENGTH32)
169 return FALSE(0);
170 strcpy (*child = cbuffer, pos + 1);
171 }
172 if (plen >= XKL_MAX_CI_NAME_LENGTH32)
173 return FALSE(0);
174 memcpy (*parent = pbuffer, merged, plen);
175 pbuffer[plen] = '\0';
176 return TRUE(!(0));
177}
178
179/*
180 * static MatekbdKeyboardConfig functions
181 */
182static void
183matekbd_keyboard_config_copy_from_xkl_config (MatekbdKeyboardConfig * kbd_config,
184 XklConfigRec * pdata)
185{
186 char **p, **p1;
187 int i;
188 matekbd_keyboard_config_model_set (kbd_config, pdata->model);
189 xkl_debug (150, "Loaded Kbd model: [%s]\n", pdata->model)_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Loaded Kbd model: [%s]\n"
, pdata->model )
;
190
191 /* Layouts */
192 g_strfreev (kbd_config->layouts_variants);
193 kbd_config->layouts_variants = NULL((void*)0);
194 if (pdata->layouts != NULL((void*)0)) {
195 p = pdata->layouts;
196 p1 = pdata->variants;
197 kbd_config->layouts_variants =
198 g_new0 (gchar *, g_strv_length (pdata->layouts) + 1)(gchar * *) (__extension__ ({ gsize __n = (gsize) (g_strv_length
(pdata->layouts) + 1); gsize __s = sizeof (gchar *); gpointer
__p; if (__s == 1) __p = g_malloc0 (__n); else if (__builtin_constant_p
(__n) && (__s == 0 || __n <= (9223372036854775807L
*2UL+1UL) / __s)) __p = g_malloc0 (__n * __s); else __p = g_malloc0_n
(__n, __s); __p; }))
;
199 i = 0;
200 while (*p != NULL((void*)0)) {
201 const gchar *full_layout =
202 matekbd_keyboard_config_merge_items (*p, *p1);
203 xkl_debug (150,_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Loaded Kbd layout (with variant): [%s]\n"
, full_layout )
204 "Loaded Kbd layout (with variant): [%s]\n",_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Loaded Kbd layout (with variant): [%s]\n"
, full_layout )
205 full_layout)_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Loaded Kbd layout (with variant): [%s]\n"
, full_layout )
;
206 kbd_config->layouts_variants[i++] =
207 g_strdup (full_layout)g_strdup_inline (full_layout);
208 p++;
209 p1++;
210 }
211 }
212
213 /* Options */
214 g_strfreev (kbd_config->options);
215 kbd_config->options = NULL((void*)0);
216
217 if (pdata->options != NULL((void*)0)) {
218 p = pdata->options;
219 kbd_config->options =
220 g_new0 (gchar *, g_strv_length (pdata->options) + 1)(gchar * *) (__extension__ ({ gsize __n = (gsize) (g_strv_length
(pdata->options) + 1); gsize __s = sizeof (gchar *); gpointer
__p; if (__s == 1) __p = g_malloc0 (__n); else if (__builtin_constant_p
(__n) && (__s == 0 || __n <= (9223372036854775807L
*2UL+1UL) / __s)) __p = g_malloc0 (__n * __s); else __p = g_malloc0_n
(__n, __s); __p; }))
;
221 i = 0;
222 while (*p != NULL((void*)0)) {
223 char group[XKL_MAX_CI_NAME_LENGTH32];
224 char *option = *p;
225 char *delim =
226 (option != NULL((void*)0)) ? strchr (option, ':') : NULL((void*)0);
227 int len;
228 if ((delim != NULL((void*)0)) &&
229 ((len =
230 (delim - option)) <
231 XKL_MAX_CI_NAME_LENGTH32)) {
232 strncpy (group, option, len);
233 group[len] = 0;
234 xkl_debug (150,_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Loaded Kbd option: [%s][%s]\n"
, group, option )
235 "Loaded Kbd option: [%s][%s]\n",_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Loaded Kbd option: [%s][%s]\n"
, group, option )
236 group, option)_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Loaded Kbd option: [%s][%s]\n"
, group, option )
;
237 matekbd_keyboard_config_options_set
238 (kbd_config, i++, group, option);
239 }
240 p++;
241 }
242 }
243}
244
245static void
246matekbd_keyboard_config_copy_to_xkl_config (MatekbdKeyboardConfig * kbd_config,
247 XklConfigRec * pdata)
248{
249 int i;
250 int num_layouts, num_options;
251 pdata->model =
252 (kbd_config->model ==
253 NULL((void*)0)) ? NULL((void*)0) : g_strdup (kbd_config->model)g_strdup_inline (kbd_config->model);
254
255 num_layouts =
256 (kbd_config->layouts_variants ==
257 NULL((void*)0)) ? 0 : g_strv_length (kbd_config->layouts_variants);
258 num_options =
259 (kbd_config->options ==
260 NULL((void*)0)) ? 0 : g_strv_length (kbd_config->options);
261
262 xkl_debug (150, "Taking %d layouts\n", num_layouts)_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Taking %d layouts\n"
, num_layouts )
;
263 if (num_layouts != 0) {
264 gchar **the_layout_variant = kbd_config->layouts_variants;
265 char **p1 = pdata->layouts =
266 g_new0 (char *, num_layouts + 1)(char * *) (__extension__ ({ gsize __n = (gsize) (num_layouts
+ 1); gsize __s = sizeof (char *); gpointer __p; if (__s == 1
) __p = g_malloc0 (__n); else if (__builtin_constant_p (__n) &&
(__s == 0 || __n <= (9223372036854775807L *2UL+1UL) / __s
)) __p = g_malloc0 (__n * __s); else __p = g_malloc0_n (__n, __s
); __p; }))
;
267 char **p2 = pdata->variants =
268 g_new0 (char *, num_layouts + 1)(char * *) (__extension__ ({ gsize __n = (gsize) (num_layouts
+ 1); gsize __s = sizeof (char *); gpointer __p; if (__s == 1
) __p = g_malloc0 (__n); else if (__builtin_constant_p (__n) &&
(__s == 0 || __n <= (9223372036854775807L *2UL+1UL) / __s
)) __p = g_malloc0 (__n * __s); else __p = g_malloc0_n (__n, __s
); __p; }))
;
269 for (i = num_layouts; --i >= 0;) {
270 char *layout, *variant;
271 if (matekbd_keyboard_config_split_items
272 (*the_layout_variant, &layout, &variant)
273 && variant != NULL((void*)0)) {
274 *p1 =
275 (layout ==
276 NULL((void*)0)) ? g_strdup ("")g_strdup_inline ("") :
277 g_strdup (layout)g_strdup_inline (layout);
278 *p2 =
279 (variant ==
280 NULL((void*)0)) ? g_strdup ("")g_strdup_inline ("") :
281 g_strdup (variant)g_strdup_inline (variant);
282 } else {
283 *p1 =
284 (*the_layout_variant ==
285 NULL((void*)0)) ? g_strdup ("")g_strdup_inline ("") :
286 g_strdup (*the_layout_variant)g_strdup_inline (*the_layout_variant);
287 *p2 = g_strdup ("")g_strdup_inline ("");
288 }
289 xkl_debug (150, "Adding [%s]/%p and [%s]/%p\n",_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Adding [%s]/%p and [%s]/%p\n"
, *p1 ? *p1 : "(nil)", *p1, *p2 ? *p2 : "(nil)", *p2 )
290 *p1 ? *p1 : "(nil)", *p1,_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Adding [%s]/%p and [%s]/%p\n"
, *p1 ? *p1 : "(nil)", *p1, *p2 ? *p2 : "(nil)", *p2 )
291 *p2 ? *p2 : "(nil)", *p2)_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Adding [%s]/%p and [%s]/%p\n"
, *p1 ? *p1 : "(nil)", *p1, *p2 ? *p2 : "(nil)", *p2 )
;
292 p1++;
293 p2++;
294 the_layout_variant++;
295 }
296 }
297
298 if (num_options != 0) {
299 gchar **the_option = kbd_config->options;
300 char **p = pdata->options =
301 g_new0 (char *, num_options + 1)(char * *) (__extension__ ({ gsize __n = (gsize) (num_options
+ 1); gsize __s = sizeof (char *); gpointer __p; if (__s == 1
) __p = g_malloc0 (__n); else if (__builtin_constant_p (__n) &&
(__s == 0 || __n <= (9223372036854775807L *2UL+1UL) / __s
)) __p = g_malloc0 (__n * __s); else __p = g_malloc0_n (__n, __s
); __p; }))
;
302 for (i = num_options; --i >= 0;) {
303 char *group, *option;
304 if (matekbd_keyboard_config_split_items
305 (*the_option, &group, &option)
306 && option != NULL((void*)0))
307 *(p++) = g_strdup (option)g_strdup_inline (option);
308 else {
309 *(p++) = g_strdup ("")g_strdup_inline ("");
310 xkl_debug (150, "Could not split [%s]\n",_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Could not split [%s]\n"
, *the_option )
311 *the_option)_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Could not split [%s]\n"
, *the_option )
;
312 }
313 the_option++;
314 }
315 }
316}
317
318static void
319matekbd_keyboard_config_load_params (MatekbdKeyboardConfig * kbd_config,
320 const gchar * param_names[])
321{
322 gchar *pc;
323
324 pc = g_settings_get_string (kbd_config->settings, param_names[0]);
325 if (pc == NULL((void*)0)) {
326 matekbd_keyboard_config_model_set (kbd_config, NULL((void*)0));
327 } else {
328 matekbd_keyboard_config_model_set (kbd_config, pc);
329 g_free (pc);
330 }
331 xkl_debug (150, "Loaded Kbd model: [%s]\n",_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Loaded Kbd model: [%s]\n"
, kbd_config->model ? kbd_config->model : "(null)" )
332 kbd_config->model ? kbd_config->model : "(null)")_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Loaded Kbd model: [%s]\n"
, kbd_config->model ? kbd_config->model : "(null)" )
;
333
334 g_strfreev (kbd_config->layouts_variants);
335
336 kbd_config->layouts_variants =
337 g_settings_get_strv (kbd_config->settings, param_names[1]);
338
339 if (kbd_config->layouts_variants != NULL((void*)0)
340 && kbd_config->layouts_variants[0] == NULL((void*)0)) {
341 g_strfreev (kbd_config->layouts_variants);
342 kbd_config->layouts_variants = NULL((void*)0);
343 }
344
345 g_strfreev (kbd_config->options);
346
347 kbd_config->options =
348 g_settings_get_strv (kbd_config->settings, param_names[2]);
349
350 if (kbd_config->options != NULL((void*)0) && kbd_config->options[0] == NULL((void*)0)) {
351 g_strfreev (kbd_config->options);
352 kbd_config->options = NULL((void*)0);
353 }
354}
355
356static void
357matekbd_keyboard_config_save_params (MatekbdKeyboardConfig * kbd_config,
358 const gchar * param_names[])
359{
360 gchar **pl;
361
362 if (kbd_config->model)
363 g_settings_set_string (kbd_config->settings, param_names[0],
364 kbd_config->model);
365 else
366 g_settings_set_string (kbd_config->settings, param_names[0],
367 NULL((void*)0));
368 xkl_debug (150, "Saved Kbd model: [%s]\n",_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Saved Kbd model: [%s]\n"
, kbd_config->model ? kbd_config->model : "(null)" )
369 kbd_config->model ? kbd_config->model : "(null)")_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Saved Kbd model: [%s]\n"
, kbd_config->model ? kbd_config->model : "(null)" )
;
370
371 if (kbd_config->layouts_variants) {
372 pl = kbd_config->layouts_variants;
373 while (*pl != NULL((void*)0)) {
374 xkl_debug (150, "Saved Kbd layout: [%s]\n", *pl)_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Saved Kbd layout: [%s]\n"
, *pl )
;
375 pl++;
376 }
377 g_settings_set_strv (kbd_config->settings,
378 param_names[1],
379 (const gchar * const *)
380 kbd_config->layouts_variants);
381 } else {
382 xkl_debug (150, "Saved Kbd layouts: []\n")_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Saved Kbd layouts: []\n"
)
;
383 g_settings_set_strv (kbd_config->settings,
384 param_names[1], NULL((void*)0));
385 }
386
387 if (kbd_config->options) {
388 pl = kbd_config->options;
389 while (*pl != NULL((void*)0)) {
390 xkl_debug (150, "Saved Kbd option: [%s]\n", *pl)_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Saved Kbd option: [%s]\n"
, *pl )
;
391 pl++;
392 }
393 g_settings_set_strv (kbd_config->settings,
394 param_names[2],
395 (const gchar *
396 const *) kbd_config->options);
397 } else {
398 xkl_debug (150, "Saved Kbd options: []\n")_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Saved Kbd options: []\n"
)
;
399 g_settings_set_strv (kbd_config->settings,
400 param_names[2], NULL((void*)0));
401 }
402}
403
404/*
405 * extern MatekbdKeyboardConfig config functions
406 */
407void
408matekbd_keyboard_config_init (MatekbdKeyboardConfig * kbd_config,
409 XklEngine * engine)
410{
411 memset (kbd_config, 0, sizeof (*kbd_config));
412 kbd_config->settings = g_settings_new (MATEKBD_KEYBOARD_CONFIG_SCHEMA"org.mate.peripherals-keyboard-xkb" ".kbd");
413 kbd_config->engine = engine;
414}
415
416void
417matekbd_keyboard_config_term (MatekbdKeyboardConfig * kbd_config)
418{
419 matekbd_keyboard_config_model_set (kbd_config, NULL((void*)0));
420
421 g_strfreev (kbd_config->layouts_variants);
422 kbd_config->layouts_variants = NULL((void*)0);
423 g_strfreev (kbd_config->options);
424 kbd_config->options = NULL((void*)0);
425
426 g_object_unref (kbd_config->settings);
427 kbd_config->settings = NULL((void*)0);
428}
429
430void
431matekbd_keyboard_config_load_from_gsettings (MatekbdKeyboardConfig * kbd_config,
432 MatekbdKeyboardConfig *
433 kbd_config_default)
434{
435 matekbd_keyboard_config_load_params (kbd_config,
436 MATEKBD_KEYBOARD_CONFIG_ACTIVE);
437
438 if (kbd_config_default != NULL((void*)0)) {
439
440 if (kbd_config->model == NULL((void*)0))
441 kbd_config->model =
442 g_strdup (kbd_config_default->model)g_strdup_inline (kbd_config_default->model);
443
444 if (kbd_config->layouts_variants == NULL((void*)0)) {
445 kbd_config->layouts_variants =
446 g_strdupv
447 (kbd_config_default->layouts_variants);
448 }
449
450 if (kbd_config->options == NULL((void*)0)) {
451 kbd_config->options =
452 g_strdupv (kbd_config_default->options);
453 }
454 }
455}
456
457void
458matekbd_keyboard_config_load_from_x_current (MatekbdKeyboardConfig * kbd_config,
459 XklConfigRec * data)
460{
461 gboolean own_data = data == NULL((void*)0);
462 xkl_debug (150, "Copying config from X(current)\n")_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Copying config from X(current)\n"
)
;
463 if (own_data)
464 data = xkl_config_rec_new ();
465 if (xkl_config_rec_get_from_server (data, kbd_config->engine))
466 matekbd_keyboard_config_copy_from_xkl_config (kbd_config,
467 data);
468 else
469 xkl_debug (150,_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Could not load keyboard config from server: [%s]\n"
, xkl_get_last_error () )
470 "Could not load keyboard config from server: [%s]\n",_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Could not load keyboard config from server: [%s]\n"
, xkl_get_last_error () )
471 xkl_get_last_error ())_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Could not load keyboard config from server: [%s]\n"
, xkl_get_last_error () )
;
472 if (own_data)
473 g_object_unref (G_OBJECT (data)((((GObject*) (void *) ((data))))));
474}
475
476void
477matekbd_keyboard_config_load_from_x_initial (MatekbdKeyboardConfig * kbd_config,
478 XklConfigRec * data)
479{
480 gboolean own_data = data == NULL((void*)0);
481 xkl_debug (150, "Copying config from X(initial)\n")_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Copying config from X(initial)\n"
)
;
482 if (own_data)
483 data = xkl_config_rec_new ();
484 if (xkl_config_rec_get_from_backup (data, kbd_config->engine))
485 matekbd_keyboard_config_copy_from_xkl_config (kbd_config,
486 data);
487 else
488 xkl_debug (150,_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Could not load keyboard config from backup: [%s]\n"
, xkl_get_last_error () )
489 "Could not load keyboard config from backup: [%s]\n",_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Could not load keyboard config from backup: [%s]\n"
, xkl_get_last_error () )
490 xkl_get_last_error ())_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Could not load keyboard config from backup: [%s]\n"
, xkl_get_last_error () )
;
491 if (own_data)
492 g_object_unref (G_OBJECT (data)((((GObject*) (void *) ((data))))));
493}
494
495static gboolean
496matekbd_keyboard_config_options_equals (MatekbdKeyboardConfig * kbd_config1,
497 MatekbdKeyboardConfig * kbd_config2)
498{
499 int num_options, num_options2;
500
501 num_options =
502 (kbd_config1->options ==
503 NULL((void*)0)) ? 0 : g_strv_length (kbd_config1->options);
504 num_options2 =
505 (kbd_config2->options ==
506 NULL((void*)0)) ? 0 : g_strv_length (kbd_config2->options);
507
508 if (num_options != num_options2)
509 return False0;
510
511 if (num_options != 0) {
512 int i;
513 char *group1, *option1;
514
515 for (i = 0; i < num_options; i++) {
516 int j;
517 char *group2, *option2;
518 gboolean are_equal = FALSE(0);
519
520 if (!matekbd_keyboard_config_split_items
521 (kbd_config1->options[i], &group1, &option1))
522 continue;
523
524 option1 = g_strdup (option1)g_strdup_inline (option1);
525
526 for (j = 0; j < num_options && !are_equal; j++) {
527 if (matekbd_keyboard_config_split_items
528 (kbd_config2->options[j], &group2,
529 &option2)) {
530 are_equal =
531 strcmp (option1, option2) == 0;
532 }
533 }
534
535 g_free (option1);
536
537 if (!are_equal)
538 return False0;
539 }
540 }
541
542 return True1;
543}
544
545gboolean
546matekbd_keyboard_config_equals (MatekbdKeyboardConfig * kbd_config1,
547 MatekbdKeyboardConfig * kbd_config2)
548{
549 if (kbd_config1 == kbd_config2)
550 return True1;
551 if ((kbd_config1->model != kbd_config2->model) &&
552 (kbd_config1->model != NULL((void*)0)) &&
553 (kbd_config2->model != NULL((void*)0)) &&
554 g_ascii_strcasecmp (kbd_config1->model, kbd_config2->model))
555 return False0;
556 if (!matekbd_strv_equal (kbd_config1->layouts_variants,
557 kbd_config2->layouts_variants))
558 return False0;
559
560 if (!matekbd_keyboard_config_options_equals
561 (kbd_config1, kbd_config2))
562 return False0;
563
564 return True1;
565}
566
567void
568matekbd_keyboard_config_save_to_gsettings (MatekbdKeyboardConfig * kbd_config)
569{
570 g_settings_delay (kbd_config->settings);
571
572 matekbd_keyboard_config_save_params (kbd_config,
573 MATEKBD_KEYBOARD_CONFIG_ACTIVE);
574
575 g_settings_apply (kbd_config->settings);
576}
577
578void
579matekbd_keyboard_config_model_set (MatekbdKeyboardConfig * kbd_config,
580 const gchar * model_name)
581{
582 if (kbd_config->model != NULL((void*)0))
583 g_free (kbd_config->model);
584 kbd_config->model =
585 (model_name == NULL((void*)0)
586 || model_name[0] == '\0') ? NULL((void*)0) : g_strdup (model_name)g_strdup_inline (model_name);
587}
588
589void
590matekbd_keyboard_config_options_set (MatekbdKeyboardConfig * kbd_config,
591 gint idx,
592 const gchar * group_name,
593 const gchar * option_name)
594{
595 const gchar *merged;
596 if (group_name == NULL((void*)0) || option_name == NULL((void*)0))
597 return;
598 merged =
599 matekbd_keyboard_config_merge_items (group_name, option_name);
600 if (merged == NULL((void*)0))
601 return;
602 kbd_config->options[idx] = g_strdup (merged)g_strdup_inline (merged);
603}
604
605gboolean
606matekbd_keyboard_config_options_is_set (MatekbdKeyboardConfig * kbd_config,
607 const gchar * group_name,
608 const gchar * option_name)
609{
610 gchar **p = kbd_config->options;
611 const gchar *merged =
612 matekbd_keyboard_config_merge_items (group_name, option_name);
613 if (merged == NULL((void*)0))
614 return FALSE(0);
615
616 while (p && *p) {
617 if (!g_ascii_strcasecmp (merged, *p++))
618 return TRUE(!(0));
619 }
620 return FALSE(0);
621}
622
623gboolean
624matekbd_keyboard_config_activate (MatekbdKeyboardConfig * kbd_config)
625{
626 gboolean rv;
627 XklConfigRec *data = xkl_config_rec_new ();
628
629 matekbd_keyboard_config_copy_to_xkl_config (kbd_config, data);
630 rv = xkl_config_rec_activate (data, kbd_config->engine);
631 g_object_unref (G_OBJECT (data)((((GObject*) (void *) ((data))))));
632
633 return rv;
634}
635
636/**
637 * matekbd_keyboard_config_start_listen:
638 * @func: (scope notified): a function to call when settings are changed
639 */
640void
641matekbd_keyboard_config_start_listen (MatekbdKeyboardConfig * kbd_config,
642 GCallback func,
643 gpointer user_data)
644{
645 kbd_config->config_listener_id =
646 g_signal_connect (kbd_config->settings, "changed", func,g_signal_connect_data ((kbd_config->settings), ("changed")
, (func), (user_data), ((void*)0), (GConnectFlags) 0)
647 user_data)g_signal_connect_data ((kbd_config->settings), ("changed")
, (func), (user_data), ((void*)0), (GConnectFlags) 0)
;
648}
649
650void
651matekbd_keyboard_config_stop_listen (MatekbdKeyboardConfig * kbd_config)
652{
653#if GLIB_CHECK_VERSION(2,62,0)(2 > (2) || (2 == (2) && 76 > (62)) || (2 == (2
) && 76 == (62) && 5 >= (0)))
654 g_clear_signal_handler (&kbd_config->config_listener_id,do { gpointer const _instance = (kbd_config->settings); gulong
*const _handler_id_ptr = (&kbd_config->config_listener_id
); const gulong _handler_id = *_handler_id_ptr; if (_handler_id
> 0) { *_handler_id_ptr = 0; g_signal_handler_disconnect (
_instance, _handler_id); } } while (0)
655 kbd_config->settings)do { gpointer const _instance = (kbd_config->settings); gulong
*const _handler_id_ptr = (&kbd_config->config_listener_id
); const gulong _handler_id = *_handler_id_ptr; if (_handler_id
> 0) { *_handler_id_ptr = 0; g_signal_handler_disconnect (
_instance, _handler_id); } } while (0)
;
656#else
657 if (kbd_config->config_listener_id != 0) {
658 g_signal_handler_disconnect (kbd_config->settings,
659 kbd_config->config_listener_id);
660 kbd_config->config_listener_id = 0;
661 }
662#endif
663}
664
665gboolean
666matekbd_keyboard_config_get_descriptions (XklConfigRegistry * config_registry,
667 const gchar * name,
668 gchar ** layout_short_descr,
669 gchar ** layout_descr,
670 gchar ** variant_short_descr,
671 gchar ** variant_descr)
672{
673 char *layout_name = NULL((void*)0), *variant_name = NULL((void*)0);
674 if (!matekbd_keyboard_config_split_items
675 (name, &layout_name, &variant_name))
676 return FALSE(0);
677 return matekbd_keyboard_config_get_lv_descriptions (config_registry,
678 layout_name,
679 variant_name,
680 layout_short_descr,
681 layout_descr,
682 variant_short_descr,
683 variant_descr);
684}
685
686const gchar *
687matekbd_keyboard_config_format_full_layout (const gchar * layout_descr,
688 const gchar * variant_descr)
689{
690 static gchar full_descr[XKL_MAX_CI_DESC_LENGTH192 * 2];
691 if (variant_descr == NULL((void*)0) || variant_descr[0] == 0)
692 g_snprintf (full_descr, sizeof (full_descr), "%s",
693 layout_descr);
694 else
695 g_snprintf (full_descr, sizeof (full_descr), "%s %s",
696 layout_descr, variant_descr);
697 return full_descr;
698}
699
700gchar *
701matekbd_keyboard_config_to_string (const MatekbdKeyboardConfig * config)
702{
703 gchar *layouts = NULL((void*)0), *options = NULL((void*)0);
704 GString *buffer = g_string_new (NULL((void*)0));
705
706 gchar **iter;
707 gint count;
708 gchar *result;
709
710 if (config->layouts_variants) {
711 /* g_slist_length is "expensive", so we determinate the length on the fly */
712 for (iter = config->layouts_variants, count = 0; *iter;
713 iter++, ++count) {
714 if (buffer->len)
715 g_string_append (buffer, " ")(__builtin_constant_p (" ") ? __extension__ ({ const char * const
__val = (" "); g_string_append_len_inline (buffer, __val, (__builtin_expect
(__extension__ ({ int _g_boolean_var_18; if (__val != ((void
*)0)) _g_boolean_var_18 = 1; else _g_boolean_var_18 = 0; _g_boolean_var_18
; }), 1)) ? (gssize) strlen (((__val) + !(__val))) : (gssize)
-1); }) : g_string_append_len_inline (buffer, " ", (gssize) -
1))
;
716
717 g_string_append (buffer, *iter)(__builtin_constant_p (*iter) ? __extension__ ({ const char *
const __val = (*iter); g_string_append_len_inline (buffer, __val
, (__builtin_expect (__extension__ ({ int _g_boolean_var_19; if
(__val != ((void*)0)) _g_boolean_var_19 = 1; else _g_boolean_var_19
= 0; _g_boolean_var_19; }), 1)) ? (gssize) strlen (((__val) +
!(__val))) : (gssize) -1); }) : g_string_append_len_inline (
buffer, *iter, (gssize) -1))
;
718 }
719
720 /* Translators: The count is related to the number of options. The %s
721 * format specifier should not be modified, left "as is". */
722 layouts =
723 g_strdup_printf (ngettextdcngettext (((void*)0), "layout \"%s\"", "layouts \"%s\"", count
, 5)
724 ("layout \"%s\"", "layouts \"%s\"",dcngettext (((void*)0), "layout \"%s\"", "layouts \"%s\"", count
, 5)
725 count)dcngettext (((void*)0), "layout \"%s\"", "layouts \"%s\"", count
, 5)
, buffer->str);
726 g_string_truncate (buffer, 0)g_string_truncate_inline (buffer, 0);
727 }
728 if (config->options) {
729 /* g_slist_length is "expensive", so we determinate the length on the fly */
730 for (iter = config->options, count = 0; *iter;
731 iter++, ++count) {
732 if (buffer->len)
733 g_string_append (buffer, " ")(__builtin_constant_p (" ") ? __extension__ ({ const char * const
__val = (" "); g_string_append_len_inline (buffer, __val, (__builtin_expect
(__extension__ ({ int _g_boolean_var_20; if (__val != ((void
*)0)) _g_boolean_var_20 = 1; else _g_boolean_var_20 = 0; _g_boolean_var_20
; }), 1)) ? (gssize) strlen (((__val) + !(__val))) : (gssize)
-1); }) : g_string_append_len_inline (buffer, " ", (gssize) -
1))
;
734
735 g_string_append (buffer, *iter)(__builtin_constant_p (*iter) ? __extension__ ({ const char *
const __val = (*iter); g_string_append_len_inline (buffer, __val
, (__builtin_expect (__extension__ ({ int _g_boolean_var_21; if
(__val != ((void*)0)) _g_boolean_var_21 = 1; else _g_boolean_var_21
= 0; _g_boolean_var_21; }), 1)) ? (gssize) strlen (((__val) +
!(__val))) : (gssize) -1); }) : g_string_append_len_inline (
buffer, *iter, (gssize) -1))
;
736 }
737
738 /* Translators: The count is related to the number of options. The %s
739 * format specifier should not be modified, left "as is". */
740 options =
741 g_strdup_printf (ngettextdcngettext (((void*)0), "option \"%s\"", "options \"%s\"", count
, 5)
742 ("option \"%s\"", "options \"%s\"",dcngettext (((void*)0), "option \"%s\"", "options \"%s\"", count
, 5)
743 count)dcngettext (((void*)0), "option \"%s\"", "options \"%s\"", count
, 5)
, buffer->str);
744 g_string_truncate (buffer, 0)g_string_truncate_inline (buffer, 0);
745 }
746
747 g_string_free (buffer, TRUE)(__builtin_constant_p ((!(0))) ? (((!(0))) ? (g_string_free) (
(buffer), ((!(0)))) : g_string_free_and_steal (buffer)) : (g_string_free
) ((buffer), ((!(0)))))
;
748
749 result =
750 g_strdup_printf (_("model \"%s\", %s and %s")((char *) g_dgettext ("libmatekbd", "model \"%s\", %s and %s"
))
, config->model,
751 layouts ? layouts : _("no layout")((char *) g_dgettext ("libmatekbd", "no layout")),
752 options ? options : _("no options")((char *) g_dgettext ("libmatekbd", "no options")));
753
754 g_free (options);
755 g_free (layouts);
756
757 return result;
758}
759
760/**
761 * matekbd_keyboard_config_add_default_switch_option_if_necessary:
762 *
763 * Returns: (transfer full) (array zero-terminated=1): List of options
764 */
765gchar **
766matekbd_keyboard_config_add_default_switch_option_if_necessary (gchar **
767 layouts_list,
768 gchar **
769 options_list,
770 gboolean *was_appended)
771{
772 *was_appended = FALSE(0);
773 if (g_strv_length (layouts_list) >= 2) {
774 gboolean any_switcher = False0;
775 if (*options_list != NULL((void*)0)) {
776 gchar **option = options_list;
777 while (*option != NULL((void*)0)) {
778 char *g, *o;
779 if (matekbd_keyboard_config_split_items
780 (*option, &g, &o)) {
781 if (!g_ascii_strcasecmp
782 (g, GROUP_SWITCHERS_GROUP"grp")) {
783 any_switcher = True1;
784 break;
785 }
786 }
787 option++;
788 }
789 }
790 if (!any_switcher) {
791 const gchar *id =
792 matekbd_keyboard_config_merge_items
793 (GROUP_SWITCHERS_GROUP"grp",
794 DEFAULT_GROUP_SWITCH"grp:shift_caps_toggle");
795 options_list =
796 matekbd_strv_append (options_list, g_strdup (id)g_strdup_inline (id));
797 *was_appended = TRUE(!(0));
798 }
799 }
800 return options_list;
801}
diff --git a/2023-10-28-125744-5647-1@b00c769a5abd_travis-test/report-37cb39.html b/2023-10-28-125744-5647-1@b00c769a5abd_travis-test/report-37cb39.html new file mode 100644 index 0000000..aaa2060 --- /dev/null +++ b/2023-10-28-125744-5647-1@b00c769a5abd_travis-test/report-37cb39.html @@ -0,0 +1,962 @@ + + + +matekbd-keyboard-drawing-test.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:test/matekbd-keyboard-drawing-test.c
Warning:line 246, column 21
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name matekbd-keyboard-drawing-test.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/test -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -I .. -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libxml2 -D MATELOCALEDIR="/usr/local/share/locale" -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-unused-parameter -fdebug-compilation-dir=/rootdir/test -ferror-limit 19 -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-28-125744-5647-1 -x c matekbd-keyboard-drawing-test.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * Copyright (C) 2006 Sergey V. Udaltsov <svu@gnome.org>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20#if HAVE_CONFIG_H1
21# include <config.h>
22#endif
23
24#include <gtk/gtk.h>
25#include <stdlib.h>
26#include <string.h>
27#include <glib.h>
28#include "libmatekbd/matekbd-keyboard-drawing.h"
29
30static gchar *groups = NULL((void*)0);
31static gchar *levels = NULL((void*)0);
32static gchar *symbols = NULL((void*)0);
33static gchar *keycodes = NULL((void*)0);
34static gchar *geometry = NULL((void*)0);
35
36static gboolean track_config = FALSE(0);
37static gboolean track_modifiers = FALSE(0);
38static gboolean program_version = FALSE(0);
39
40static const GOptionEntry options[] = {
41 {"groups", '\0', 0, G_OPTION_ARG_STRING, &groups,
42 "Keyboard groups to display, from 1-4. Up to four groups only may be "
43 "displayed. Examples: --groups=3 or --groups=1,2,1,2",
44 "group1[,group2[,group3[,group4]]]"},
45 {"levels", '\0', 0, G_OPTION_ARG_STRING, &levels,
46 "Keyboard shift levels to display, from 1-64. Up to four shift levels "
47 "only may be displayed. Examples: --levels=3 or --levels=1,2,1,2",
48 "level1[,level2[,level3[,level4]]]"},
49 {"symbols", '\0', 0, G_OPTION_ARG_STRING, &symbols,
50 "Symbols component of the keyboard. If you omit this option, it is "
51 "obtained from the X server; that is, the keyboard that is currently "
52 "configured is drawn. Examples: --symbols=us or "
53 "--symbols=us(pc104)+iso9995-3+group(switch)+ctrl(nocaps)", NULL((void*)0)},
54 {"keycodes", '\0', 0, G_OPTION_ARG_STRING, &keycodes,
55 "Keycodes component of the keyboard. If you omit this option, it is "
56 "obtained from the X server; that is, the keyboard that is currently"
57 " configured is drawn. Examples: --keycodes=xfree86+aliases(qwerty)",
58 NULL((void*)0)},
59 {"geometry", '\0', 0, G_OPTION_ARG_STRING, &geometry,
60 "Geometry xkb component. If you omit this option, it is obtained from the"
61 " X server; that is, the keyboard that is currently configured is drawn. "
62 "Example: --geometry=kinesis", NULL((void*)0)},
63 {"track-modifiers", '\0', 0, G_OPTION_ARG_NONE, &track_modifiers,
64 "Track the current modifiers", NULL((void*)0)},
65 {"track-config", '\0', 0, G_OPTION_ARG_NONE, &track_config,
66 "Track the server XKB configuration", NULL((void*)0)},
67 {"version", '\0', 0, G_OPTION_ARG_NONE, &program_version,
68 "Show current version", NULL((void*)0)},
69 {NULL((void*)0), 0, 0, G_OPTION_ARG_NONE, NULL((void*)0), NULL((void*)0), NULL((void*)0)},
70};
71
72static gboolean
73set_groups (gchar * groups_option,
74 MatekbdKeyboardDrawingGroupLevel * groupLevels)
75{
76 MatekbdKeyboardDrawingGroupLevel *pgl = groupLevels;
77 gint cntr, g;
78
79 groupLevels[0].group =
80 groupLevels[1].group =
81 groupLevels[2].group = groupLevels[3].group = -1;
82
83 if (groups_option == NULL((void*)0))
84 return TRUE(!(0));
85
86 for (cntr = 4; --cntr >= 0;) {
87 if (*groups_option == '\0')
88 return FALSE(0);
89
90 g = *groups_option - '1';
91 if (g < 0 || g >= 4)
92 return FALSE(0);
93
94 pgl->group = g;
95 /* printf ("group %d\n", pgl->group); */
96
97 groups_option++;
98 if (*groups_option == '\0')
99 return TRUE(!(0));
100 if (*groups_option != ',')
101 return FALSE(0);
102
103 groups_option++;
104 pgl++;
105 }
106
107 return TRUE(!(0));
108}
109
110static gboolean
111set_levels (gchar * levels_option,
112 MatekbdKeyboardDrawingGroupLevel * groupLevels)
113{
114 MatekbdKeyboardDrawingGroupLevel *pgl = groupLevels;
115 gint cntr, l;
116 gchar *p;
117
118 groupLevels[0].level =
119 groupLevels[1].level =
120 groupLevels[2].level = groupLevels[3].level = -1;
121
122 if (levels_option == NULL((void*)0))
123 return TRUE(!(0));
124
125 for (cntr = 4; --cntr >= 0;) {
126 if (*levels_option == '\0')
127 return FALSE(0);
128
129 l = (gint) strtol (levels_option, &p, 10) - 1;
130 if (l < 0 || l >= 64)
131 return FALSE(0);
132
133 pgl->level = l;
134 /* printf ("level %d\n", pgl->level); */
135
136 levels_option = p;
137 if (*levels_option == '\0')
138 return TRUE(!(0));
139 if (*levels_option != ',')
140 return FALSE(0);
141
142 levels_option++;
143 pgl++;
144 }
145
146 return TRUE(!(0));
147}
148
149static void
150bad_keycode (MatekbdKeyboardDrawing * drawing, guint keycode)
151{
152 g_warning
153 ("got keycode %u, which is not on your keyboard according to your configuration",
154 keycode);
155}
156
157gint
158main (gint argc, gchar ** argv)
159{
160 GtkWidget *window;
161 GtkWidget *matekbd_keyboard_drawing;
162 GdkScreen *screen;
163 GdkMonitor *monitor;
164 GdkRectangle rect;
165 GOptionContext *context;
166 GError *error = NULL((void*)0);
167
168 MatekbdKeyboardDrawingGroupLevel groupLevels[4] =
169 { {0, 0}, {1, 0}, {0, 1}, {1, 1} };
170 MatekbdKeyboardDrawingGroupLevel *pgroupLevels[4] =
171 { &groupLevels[0], &groupLevels[1], &groupLevels[2],
172 &groupLevels[3]
173 };
174
175 context = g_option_context_new ("kbdraw");
176 g_option_context_add_main_entries (context, options, NULL((void*)0));
177 if (!g_option_context_parse (context, &argc, &argv, &error)) {
178 g_message ("option parsing failed: %s", error->message);
179 g_option_context_free (context);
180 exit (EXIT_FAILURE1);
181 }
182 g_option_context_free (context);
183
184 if (program_version) {
185 g_print ("kbdraw %s\n", VERSION"1.27.1");
186 exit (0);
187 }
188
189 gtk_init (&argc, &argv);
190
191 if (!set_groups (groups, groupLevels)) {
192 g_printerr ("--groups: invalid argument\n");
193 exit (1);
194 }
195
196 if (!set_levels (levels, groupLevels)) {
197 g_printerr ("--levels: invalid argument\n");
198 exit (1);
199 }
200
201 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
202 g_signal_connect (G_OBJECT (window), "destroy",g_signal_connect_data ((((((GObject*) (void *) ((window))))))
, ("destroy"), (((GCallback) (gtk_main_quit))), (((void*)0)),
((void*)0), (GConnectFlags) 0)
203 G_CALLBACK (gtk_main_quit), NULL)g_signal_connect_data ((((((GObject*) (void *) ((window))))))
, ("destroy"), (((GCallback) (gtk_main_quit))), (((void*)0)),
((void*)0), (GConnectFlags) 0)
;
204
205 screen = gtk_window_get_screen (GTK_WINDOW (window)((((GtkWindow*) (void *) ((window))))));
206 monitor = gdk_display_get_monitor_at_point (gdk_screen_get_display (screen), 0, 0);
207 gdk_monitor_get_geometry (monitor, &rect);
208 gtk_window_set_default_size (GTK_WINDOW (window)((((GtkWindow*) (void *) ((window))))),
209 rect.width * 4 / 5,
210 rect.height * 1 / 2);
211
212 gtk_widget_show (window);
213
214 matekbd_keyboard_drawing = matekbd_keyboard_drawing_new ();
215 gtk_widget_show (matekbd_keyboard_drawing);
216 gtk_container_add (GTK_CONTAINER (window)((((GtkContainer*) (void *) ((window))))), matekbd_keyboard_drawing);
217
218 matekbd_keyboard_drawing_set_groups_levels (MATEKBD_KEYBOARD_DRAWING((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
219 (matekbd_keyboard_drawing)((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
,
220 pgroupLevels);
221
222 if (track_modifiers)
223 matekbd_keyboard_drawing_set_track_modifiers
224 (MATEKBD_KEYBOARD_DRAWING (matekbd_keyboard_drawing)((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
, TRUE(!(0)));
225 if (track_config)
226 matekbd_keyboard_drawing_set_track_config
227 (MATEKBD_KEYBOARD_DRAWING (matekbd_keyboard_drawing)((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
, TRUE(!(0)));
228 g_signal_connect (G_OBJECT (matekbd_keyboard_drawing), "bad-keycode",g_signal_connect_data ((((((GObject*) (void *) ((matekbd_keyboard_drawing
)))))), ("bad-keycode"), (((GCallback) (bad_keycode))), (((void
*)0)), ((void*)0), (GConnectFlags) 0)
229 G_CALLBACK (bad_keycode), NULL)g_signal_connect_data ((((((GObject*) (void *) ((matekbd_keyboard_drawing
)))))), ("bad-keycode"), (((GCallback) (bad_keycode))), (((void
*)0)), ((void*)0), (GConnectFlags) 0)
;
230
231 if (symbols || geometry || keycodes) {
232 XkbComponentNamesRec names;
233 gint success;
234
235 memset (&names, '\0', sizeof (names));
236
237 if (symbols)
238 names.symbols = symbols;
239 else
240 names.symbols = (gchar *)
241 matekbd_keyboard_drawing_get_symbols
242 (MATEKBD_KEYBOARD_DRAWING((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
243 (matekbd_keyboard_drawing)((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
);
244
245 if (keycodes)
246 names.keycodes = keycodes;
This statement is never executed
247 else
248 names.keycodes = (gchar *)
249 matekbd_keyboard_drawing_get_keycodes
250 (MATEKBD_KEYBOARD_DRAWING((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
251 (matekbd_keyboard_drawing)((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
);
252
253 if (geometry)
254 names.geometry = geometry;
255 else
256 names.geometry = (gchar *)
257 matekbd_keyboard_drawing_get_geometry
258 (MATEKBD_KEYBOARD_DRAWING((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
259 (matekbd_keyboard_drawing)((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
);
260
261 success =
262 matekbd_keyboard_drawing_set_keyboard
263 (MATEKBD_KEYBOARD_DRAWING (matekbd_keyboard_drawing)((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
,
264 &names);
265 if (!success) {
266 g_printerr
267 ("\nError loading new keyboard description with components:\n\n"
268 " keycodes: %s\n" " types: %s\n"
269 " compat: %s\n" " symbols: %s\n"
270 " geometry: %s\n\n", names.keycodes,
271 names.types, names.compat, names.symbols,
272 names.geometry);
273 exit (1);
274 }
275 }
276
277 gtk_widget_grab_focus (matekbd_keyboard_drawing);
278
279 gtk_main ();
280
281 return 0;
282}
diff --git a/2023-10-28-125744-5647-1@b00c769a5abd_travis-test/report-3d6c4d.html b/2023-10-28-125744-5647-1@b00c769a5abd_travis-test/report-3d6c4d.html new file mode 100644 index 0000000..d02ea2a --- /dev/null +++ b/2023-10-28-125744-5647-1@b00c769a5abd_travis-test/report-3d6c4d.html @@ -0,0 +1,1481 @@ + + + +matekbd-keyboard-config.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:libmatekbd/matekbd-keyboard-config.c
Warning:line 170, column 3
Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name matekbd-keyboard-config.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/libmatekbd -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -I .. -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libxml2 -I ../intl -D G_LOG_DOMAIN="MateKbdIndicator" -D DATADIR="/usr/local/share" -D SYSCONFDIR="/usr/local/etc" -D LIBDIR="/usr/local/lib" -D PIC -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -fdebug-compilation-dir=/rootdir/libmatekbd -ferror-limit 19 -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-28-125744-5647-1 -x c matekbd-keyboard-config.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * Copyright (C) 2006 Sergey V. Udaltsov <svu@gnome.org>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20#include <config.h>
21
22#include <stdio.h>
23#include <string.h>
24#include <stdlib.h>
25#include <X11/keysym.h>
26
27#include <glib/gi18n-lib.h>
28
29#include <matekbd-keyboard-config.h>
30#include <matekbd-config-private.h>
31#include <matekbd-util.h>
32
33/*
34 * MatekbdKeyboardConfig
35 */
36#define MATEKBD_KEYBOARD_CONFIG_SCHEMA"org.mate.peripherals-keyboard-xkb" ".kbd" MATEKBD_CONFIG_SCHEMA"org.mate.peripherals-keyboard-xkb" ".kbd"
37
38#define GROUP_SWITCHERS_GROUP"grp" "grp"
39#define DEFAULT_GROUP_SWITCH"grp:shift_caps_toggle" "grp:shift_caps_toggle"
40
41const gchar MATEKBD_KEYBOARD_CONFIG_KEY_MODEL[] = "model";
42const gchar MATEKBD_KEYBOARD_CONFIG_KEY_LAYOUTS[] = "layouts";
43const gchar MATEKBD_KEYBOARD_CONFIG_KEY_OPTIONS[] = "options";
44
45const gchar *MATEKBD_KEYBOARD_CONFIG_ACTIVE[] = {
46 MATEKBD_KEYBOARD_CONFIG_KEY_MODEL,
47 MATEKBD_KEYBOARD_CONFIG_KEY_LAYOUTS,
48 MATEKBD_KEYBOARD_CONFIG_KEY_OPTIONS
49};
50
51/*
52 * static common functions
53 */
54
55static gboolean
56matekbd_strv_equal (gchar ** l1, gchar ** l2)
57{
58 if (l1 == l2)
59 return TRUE(!(0));
60 if (l1 == NULL((void*)0))
61 return g_strv_length (l2) == 0;
62 if (l2 == NULL((void*)0))
63 return g_strv_length (l1) == 0;
64
65 while ((*l1 != NULL((void*)0)) && (*l2 != NULL((void*)0))) {
66 if (*l1 != *l2) {
67 if (*l1 && *l2) {
68 if (g_ascii_strcasecmp (*l1, *l2))
69 return FALSE(0);
70 } else
71 return FALSE(0);
72 }
73
74 l1++;
75 l2++;
76 }
77 return (*l1 == NULL((void*)0)) && (*l2 == NULL((void*)0));
78}
79
80gboolean
81matekbd_keyboard_config_get_lv_descriptions (XklConfigRegistry *
82 config_registry,
83 const gchar * layout_name,
84 const gchar * variant_name,
85 gchar ** layout_short_descr,
86 gchar ** layout_descr,
87 gchar ** variant_short_descr,
88 gchar ** variant_descr)
89{
90 /* TODO make it not static */
91 static XklConfigItem *litem = NULL((void*)0);
92 static XklConfigItem *vitem = NULL((void*)0);
93
94 if (litem == NULL((void*)0))
95 litem = xkl_config_item_new ();
96 if (vitem == NULL((void*)0))
97 vitem = xkl_config_item_new ();
98
99 layout_name = g_strdup (layout_name)g_strdup_inline (layout_name);
100
101 g_snprintf (litem->name, sizeof litem->name, "%s", layout_name);
102 if (xkl_config_registry_find_layout (config_registry, litem)) {
103 *layout_short_descr = litem->short_description;
104 *layout_descr = litem->description;
105 } else
106 *layout_short_descr = *layout_descr = NULL((void*)0);
107
108 if (variant_name != NULL((void*)0)) {
109 variant_name = g_strdup (variant_name)g_strdup_inline (variant_name);
110 g_snprintf (vitem->name, sizeof vitem->name, "%s",
111 variant_name);
112 if (xkl_config_registry_find_variant
113 (config_registry, layout_name, vitem)) {
114 *variant_short_descr = vitem->short_description;
115 *variant_descr = vitem->description;
116 } else
117 *variant_short_descr = *variant_descr = NULL((void*)0);
118
119 g_free ((char *) variant_name);
120 } else
121 *variant_descr = NULL((void*)0);
122
123 g_free ((char *) layout_name);
124 return *layout_descr != NULL((void*)0);
125}
126
127/*
128 * extern common functions
129 */
130const gchar *
131matekbd_keyboard_config_merge_items (const gchar * parent,
132 const gchar * child)
133{
134 static gchar buffer[XKL_MAX_CI_NAME_LENGTH32 * 2 - 1];
135 *buffer = '\0';
136 if (parent != NULL((void*)0)) {
137 if (strlen (parent) >= XKL_MAX_CI_NAME_LENGTH32)
138 return NULL((void*)0);
139 strcat (buffer, parent);
140 }
141 if (child != NULL((void*)0) && *child != 0) {
142 if (strlen (child) >= XKL_MAX_CI_NAME_LENGTH32)
143 return NULL((void*)0);
144 strcat (buffer, "\t");
145 strcat (buffer, child);
146 }
147 return buffer;
148}
149
150gboolean
151matekbd_keyboard_config_split_items (const gchar * merged, gchar ** parent,
152 gchar ** child)
153{
154 static gchar pbuffer[XKL_MAX_CI_NAME_LENGTH32];
155 static gchar cbuffer[XKL_MAX_CI_NAME_LENGTH32];
156 int plen;
157 const gchar *pos;
158 *parent = *child = NULL((void*)0);
159
160 if (merged == NULL((void*)0))
161 return FALSE(0);
162
163 pos = strchr (merged, '\t');
164 if (pos == NULL((void*)0)) {
165 plen = strlen (merged);
166 } else {
167 plen = pos - merged;
168 if (strlen (pos + 1) >= XKL_MAX_CI_NAME_LENGTH32)
169 return FALSE(0);
170 strcpy (*child = cbuffer, pos + 1);
Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119
171 }
172 if (plen >= XKL_MAX_CI_NAME_LENGTH32)
173 return FALSE(0);
174 memcpy (*parent = pbuffer, merged, plen);
175 pbuffer[plen] = '\0';
176 return TRUE(!(0));
177}
178
179/*
180 * static MatekbdKeyboardConfig functions
181 */
182static void
183matekbd_keyboard_config_copy_from_xkl_config (MatekbdKeyboardConfig * kbd_config,
184 XklConfigRec * pdata)
185{
186 char **p, **p1;
187 int i;
188 matekbd_keyboard_config_model_set (kbd_config, pdata->model);
189 xkl_debug (150, "Loaded Kbd model: [%s]\n", pdata->model)_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Loaded Kbd model: [%s]\n"
, pdata->model )
;
190
191 /* Layouts */
192 g_strfreev (kbd_config->layouts_variants);
193 kbd_config->layouts_variants = NULL((void*)0);
194 if (pdata->layouts != NULL((void*)0)) {
195 p = pdata->layouts;
196 p1 = pdata->variants;
197 kbd_config->layouts_variants =
198 g_new0 (gchar *, g_strv_length (pdata->layouts) + 1)(gchar * *) (__extension__ ({ gsize __n = (gsize) (g_strv_length
(pdata->layouts) + 1); gsize __s = sizeof (gchar *); gpointer
__p; if (__s == 1) __p = g_malloc0 (__n); else if (__builtin_constant_p
(__n) && (__s == 0 || __n <= (9223372036854775807L
*2UL+1UL) / __s)) __p = g_malloc0 (__n * __s); else __p = g_malloc0_n
(__n, __s); __p; }))
;
199 i = 0;
200 while (*p != NULL((void*)0)) {
201 const gchar *full_layout =
202 matekbd_keyboard_config_merge_items (*p, *p1);
203 xkl_debug (150,_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Loaded Kbd layout (with variant): [%s]\n"
, full_layout )
204 "Loaded Kbd layout (with variant): [%s]\n",_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Loaded Kbd layout (with variant): [%s]\n"
, full_layout )
205 full_layout)_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Loaded Kbd layout (with variant): [%s]\n"
, full_layout )
;
206 kbd_config->layouts_variants[i++] =
207 g_strdup (full_layout)g_strdup_inline (full_layout);
208 p++;
209 p1++;
210 }
211 }
212
213 /* Options */
214 g_strfreev (kbd_config->options);
215 kbd_config->options = NULL((void*)0);
216
217 if (pdata->options != NULL((void*)0)) {
218 p = pdata->options;
219 kbd_config->options =
220 g_new0 (gchar *, g_strv_length (pdata->options) + 1)(gchar * *) (__extension__ ({ gsize __n = (gsize) (g_strv_length
(pdata->options) + 1); gsize __s = sizeof (gchar *); gpointer
__p; if (__s == 1) __p = g_malloc0 (__n); else if (__builtin_constant_p
(__n) && (__s == 0 || __n <= (9223372036854775807L
*2UL+1UL) / __s)) __p = g_malloc0 (__n * __s); else __p = g_malloc0_n
(__n, __s); __p; }))
;
221 i = 0;
222 while (*p != NULL((void*)0)) {
223 char group[XKL_MAX_CI_NAME_LENGTH32];
224 char *option = *p;
225 char *delim =
226 (option != NULL((void*)0)) ? strchr (option, ':') : NULL((void*)0);
227 int len;
228 if ((delim != NULL((void*)0)) &&
229 ((len =
230 (delim - option)) <
231 XKL_MAX_CI_NAME_LENGTH32)) {
232 strncpy (group, option, len);
233 group[len] = 0;
234 xkl_debug (150,_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Loaded Kbd option: [%s][%s]\n"
, group, option )
235 "Loaded Kbd option: [%s][%s]\n",_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Loaded Kbd option: [%s][%s]\n"
, group, option )
236 group, option)_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Loaded Kbd option: [%s][%s]\n"
, group, option )
;
237 matekbd_keyboard_config_options_set
238 (kbd_config, i++, group, option);
239 }
240 p++;
241 }
242 }
243}
244
245static void
246matekbd_keyboard_config_copy_to_xkl_config (MatekbdKeyboardConfig * kbd_config,
247 XklConfigRec * pdata)
248{
249 int i;
250 int num_layouts, num_options;
251 pdata->model =
252 (kbd_config->model ==
253 NULL((void*)0)) ? NULL((void*)0) : g_strdup (kbd_config->model)g_strdup_inline (kbd_config->model);
254
255 num_layouts =
256 (kbd_config->layouts_variants ==
257 NULL((void*)0)) ? 0 : g_strv_length (kbd_config->layouts_variants);
258 num_options =
259 (kbd_config->options ==
260 NULL((void*)0)) ? 0 : g_strv_length (kbd_config->options);
261
262 xkl_debug (150, "Taking %d layouts\n", num_layouts)_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Taking %d layouts\n"
, num_layouts )
;
263 if (num_layouts != 0) {
264 gchar **the_layout_variant = kbd_config->layouts_variants;
265 char **p1 = pdata->layouts =
266 g_new0 (char *, num_layouts + 1)(char * *) (__extension__ ({ gsize __n = (gsize) (num_layouts
+ 1); gsize __s = sizeof (char *); gpointer __p; if (__s == 1
) __p = g_malloc0 (__n); else if (__builtin_constant_p (__n) &&
(__s == 0 || __n <= (9223372036854775807L *2UL+1UL) / __s
)) __p = g_malloc0 (__n * __s); else __p = g_malloc0_n (__n, __s
); __p; }))
;
267 char **p2 = pdata->variants =
268 g_new0 (char *, num_layouts + 1)(char * *) (__extension__ ({ gsize __n = (gsize) (num_layouts
+ 1); gsize __s = sizeof (char *); gpointer __p; if (__s == 1
) __p = g_malloc0 (__n); else if (__builtin_constant_p (__n) &&
(__s == 0 || __n <= (9223372036854775807L *2UL+1UL) / __s
)) __p = g_malloc0 (__n * __s); else __p = g_malloc0_n (__n, __s
); __p; }))
;
269 for (i = num_layouts; --i >= 0;) {
270 char *layout, *variant;
271 if (matekbd_keyboard_config_split_items
272 (*the_layout_variant, &layout, &variant)
273 && variant != NULL((void*)0)) {
274 *p1 =
275 (layout ==
276 NULL((void*)0)) ? g_strdup ("")g_strdup_inline ("") :
277 g_strdup (layout)g_strdup_inline (layout);
278 *p2 =
279 (variant ==
280 NULL((void*)0)) ? g_strdup ("")g_strdup_inline ("") :
281 g_strdup (variant)g_strdup_inline (variant);
282 } else {
283 *p1 =
284 (*the_layout_variant ==
285 NULL((void*)0)) ? g_strdup ("")g_strdup_inline ("") :
286 g_strdup (*the_layout_variant)g_strdup_inline (*the_layout_variant);
287 *p2 = g_strdup ("")g_strdup_inline ("");
288 }
289 xkl_debug (150, "Adding [%s]/%p and [%s]/%p\n",_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Adding [%s]/%p and [%s]/%p\n"
, *p1 ? *p1 : "(nil)", *p1, *p2 ? *p2 : "(nil)", *p2 )
290 *p1 ? *p1 : "(nil)", *p1,_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Adding [%s]/%p and [%s]/%p\n"
, *p1 ? *p1 : "(nil)", *p1, *p2 ? *p2 : "(nil)", *p2 )
291 *p2 ? *p2 : "(nil)", *p2)_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Adding [%s]/%p and [%s]/%p\n"
, *p1 ? *p1 : "(nil)", *p1, *p2 ? *p2 : "(nil)", *p2 )
;
292 p1++;
293 p2++;
294 the_layout_variant++;
295 }
296 }
297
298 if (num_options != 0) {
299 gchar **the_option = kbd_config->options;
300 char **p = pdata->options =
301 g_new0 (char *, num_options + 1)(char * *) (__extension__ ({ gsize __n = (gsize) (num_options
+ 1); gsize __s = sizeof (char *); gpointer __p; if (__s == 1
) __p = g_malloc0 (__n); else if (__builtin_constant_p (__n) &&
(__s == 0 || __n <= (9223372036854775807L *2UL+1UL) / __s
)) __p = g_malloc0 (__n * __s); else __p = g_malloc0_n (__n, __s
); __p; }))
;
302 for (i = num_options; --i >= 0;) {
303 char *group, *option;
304 if (matekbd_keyboard_config_split_items
305 (*the_option, &group, &option)
306 && option != NULL((void*)0))
307 *(p++) = g_strdup (option)g_strdup_inline (option);
308 else {
309 *(p++) = g_strdup ("")g_strdup_inline ("");
310 xkl_debug (150, "Could not split [%s]\n",_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Could not split [%s]\n"
, *the_option )
311 *the_option)_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Could not split [%s]\n"
, *the_option )
;
312 }
313 the_option++;
314 }
315 }
316}
317
318static void
319matekbd_keyboard_config_load_params (MatekbdKeyboardConfig * kbd_config,
320 const gchar * param_names[])
321{
322 gchar *pc;
323
324 pc = g_settings_get_string (kbd_config->settings, param_names[0]);
325 if (pc == NULL((void*)0)) {
326 matekbd_keyboard_config_model_set (kbd_config, NULL((void*)0));
327 } else {
328 matekbd_keyboard_config_model_set (kbd_config, pc);
329 g_free (pc);
330 }
331 xkl_debug (150, "Loaded Kbd model: [%s]\n",_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Loaded Kbd model: [%s]\n"
, kbd_config->model ? kbd_config->model : "(null)" )
332 kbd_config->model ? kbd_config->model : "(null)")_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Loaded Kbd model: [%s]\n"
, kbd_config->model ? kbd_config->model : "(null)" )
;
333
334 g_strfreev (kbd_config->layouts_variants);
335
336 kbd_config->layouts_variants =
337 g_settings_get_strv (kbd_config->settings, param_names[1]);
338
339 if (kbd_config->layouts_variants != NULL((void*)0)
340 && kbd_config->layouts_variants[0] == NULL((void*)0)) {
341 g_strfreev (kbd_config->layouts_variants);
342 kbd_config->layouts_variants = NULL((void*)0);
343 }
344
345 g_strfreev (kbd_config->options);
346
347 kbd_config->options =
348 g_settings_get_strv (kbd_config->settings, param_names[2]);
349
350 if (kbd_config->options != NULL((void*)0) && kbd_config->options[0] == NULL((void*)0)) {
351 g_strfreev (kbd_config->options);
352 kbd_config->options = NULL((void*)0);
353 }
354}
355
356static void
357matekbd_keyboard_config_save_params (MatekbdKeyboardConfig * kbd_config,
358 const gchar * param_names[])
359{
360 gchar **pl;
361
362 if (kbd_config->model)
363 g_settings_set_string (kbd_config->settings, param_names[0],
364 kbd_config->model);
365 else
366 g_settings_set_string (kbd_config->settings, param_names[0],
367 NULL((void*)0));
368 xkl_debug (150, "Saved Kbd model: [%s]\n",_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Saved Kbd model: [%s]\n"
, kbd_config->model ? kbd_config->model : "(null)" )
369 kbd_config->model ? kbd_config->model : "(null)")_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Saved Kbd model: [%s]\n"
, kbd_config->model ? kbd_config->model : "(null)" )
;
370
371 if (kbd_config->layouts_variants) {
372 pl = kbd_config->layouts_variants;
373 while (*pl != NULL((void*)0)) {
374 xkl_debug (150, "Saved Kbd layout: [%s]\n", *pl)_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Saved Kbd layout: [%s]\n"
, *pl )
;
375 pl++;
376 }
377 g_settings_set_strv (kbd_config->settings,
378 param_names[1],
379 (const gchar * const *)
380 kbd_config->layouts_variants);
381 } else {
382 xkl_debug (150, "Saved Kbd layouts: []\n")_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Saved Kbd layouts: []\n"
)
;
383 g_settings_set_strv (kbd_config->settings,
384 param_names[1], NULL((void*)0));
385 }
386
387 if (kbd_config->options) {
388 pl = kbd_config->options;
389 while (*pl != NULL((void*)0)) {
390 xkl_debug (150, "Saved Kbd option: [%s]\n", *pl)_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Saved Kbd option: [%s]\n"
, *pl )
;
391 pl++;
392 }
393 g_settings_set_strv (kbd_config->settings,
394 param_names[2],
395 (const gchar *
396 const *) kbd_config->options);
397 } else {
398 xkl_debug (150, "Saved Kbd options: []\n")_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Saved Kbd options: []\n"
)
;
399 g_settings_set_strv (kbd_config->settings,
400 param_names[2], NULL((void*)0));
401 }
402}
403
404/*
405 * extern MatekbdKeyboardConfig config functions
406 */
407void
408matekbd_keyboard_config_init (MatekbdKeyboardConfig * kbd_config,
409 XklEngine * engine)
410{
411 memset (kbd_config, 0, sizeof (*kbd_config));
412 kbd_config->settings = g_settings_new (MATEKBD_KEYBOARD_CONFIG_SCHEMA"org.mate.peripherals-keyboard-xkb" ".kbd");
413 kbd_config->engine = engine;
414}
415
416void
417matekbd_keyboard_config_term (MatekbdKeyboardConfig * kbd_config)
418{
419 matekbd_keyboard_config_model_set (kbd_config, NULL((void*)0));
420
421 g_strfreev (kbd_config->layouts_variants);
422 kbd_config->layouts_variants = NULL((void*)0);
423 g_strfreev (kbd_config->options);
424 kbd_config->options = NULL((void*)0);
425
426 g_object_unref (kbd_config->settings);
427 kbd_config->settings = NULL((void*)0);
428}
429
430void
431matekbd_keyboard_config_load_from_gsettings (MatekbdKeyboardConfig * kbd_config,
432 MatekbdKeyboardConfig *
433 kbd_config_default)
434{
435 matekbd_keyboard_config_load_params (kbd_config,
436 MATEKBD_KEYBOARD_CONFIG_ACTIVE);
437
438 if (kbd_config_default != NULL((void*)0)) {
439
440 if (kbd_config->model == NULL((void*)0))
441 kbd_config->model =
442 g_strdup (kbd_config_default->model)g_strdup_inline (kbd_config_default->model);
443
444 if (kbd_config->layouts_variants == NULL((void*)0)) {
445 kbd_config->layouts_variants =
446 g_strdupv
447 (kbd_config_default->layouts_variants);
448 }
449
450 if (kbd_config->options == NULL((void*)0)) {
451 kbd_config->options =
452 g_strdupv (kbd_config_default->options);
453 }
454 }
455}
456
457void
458matekbd_keyboard_config_load_from_x_current (MatekbdKeyboardConfig * kbd_config,
459 XklConfigRec * data)
460{
461 gboolean own_data = data == NULL((void*)0);
462 xkl_debug (150, "Copying config from X(current)\n")_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Copying config from X(current)\n"
)
;
463 if (own_data)
464 data = xkl_config_rec_new ();
465 if (xkl_config_rec_get_from_server (data, kbd_config->engine))
466 matekbd_keyboard_config_copy_from_xkl_config (kbd_config,
467 data);
468 else
469 xkl_debug (150,_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Could not load keyboard config from server: [%s]\n"
, xkl_get_last_error () )
470 "Could not load keyboard config from server: [%s]\n",_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Could not load keyboard config from server: [%s]\n"
, xkl_get_last_error () )
471 xkl_get_last_error ())_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Could not load keyboard config from server: [%s]\n"
, xkl_get_last_error () )
;
472 if (own_data)
473 g_object_unref (G_OBJECT (data)((((GObject*) (void *) ((data))))));
474}
475
476void
477matekbd_keyboard_config_load_from_x_initial (MatekbdKeyboardConfig * kbd_config,
478 XklConfigRec * data)
479{
480 gboolean own_data = data == NULL((void*)0);
481 xkl_debug (150, "Copying config from X(initial)\n")_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Copying config from X(initial)\n"
)
;
482 if (own_data)
483 data = xkl_config_rec_new ();
484 if (xkl_config_rec_get_from_backup (data, kbd_config->engine))
485 matekbd_keyboard_config_copy_from_xkl_config (kbd_config,
486 data);
487 else
488 xkl_debug (150,_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Could not load keyboard config from backup: [%s]\n"
, xkl_get_last_error () )
489 "Could not load keyboard config from backup: [%s]\n",_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Could not load keyboard config from backup: [%s]\n"
, xkl_get_last_error () )
490 xkl_get_last_error ())_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Could not load keyboard config from backup: [%s]\n"
, xkl_get_last_error () )
;
491 if (own_data)
492 g_object_unref (G_OBJECT (data)((((GObject*) (void *) ((data))))));
493}
494
495static gboolean
496matekbd_keyboard_config_options_equals (MatekbdKeyboardConfig * kbd_config1,
497 MatekbdKeyboardConfig * kbd_config2)
498{
499 int num_options, num_options2;
500
501 num_options =
502 (kbd_config1->options ==
503 NULL((void*)0)) ? 0 : g_strv_length (kbd_config1->options);
504 num_options2 =
505 (kbd_config2->options ==
506 NULL((void*)0)) ? 0 : g_strv_length (kbd_config2->options);
507
508 if (num_options != num_options2)
509 return False0;
510
511 if (num_options != 0) {
512 int i;
513 char *group1, *option1;
514
515 for (i = 0; i < num_options; i++) {
516 int j;
517 char *group2, *option2;
518 gboolean are_equal = FALSE(0);
519
520 if (!matekbd_keyboard_config_split_items
521 (kbd_config1->options[i], &group1, &option1))
522 continue;
523
524 option1 = g_strdup (option1)g_strdup_inline (option1);
525
526 for (j = 0; j < num_options && !are_equal; j++) {
527 if (matekbd_keyboard_config_split_items
528 (kbd_config2->options[j], &group2,
529 &option2)) {
530 are_equal =
531 strcmp (option1, option2) == 0;
532 }
533 }
534
535 g_free (option1);
536
537 if (!are_equal)
538 return False0;
539 }
540 }
541
542 return True1;
543}
544
545gboolean
546matekbd_keyboard_config_equals (MatekbdKeyboardConfig * kbd_config1,
547 MatekbdKeyboardConfig * kbd_config2)
548{
549 if (kbd_config1 == kbd_config2)
550 return True1;
551 if ((kbd_config1->model != kbd_config2->model) &&
552 (kbd_config1->model != NULL((void*)0)) &&
553 (kbd_config2->model != NULL((void*)0)) &&
554 g_ascii_strcasecmp (kbd_config1->model, kbd_config2->model))
555 return False0;
556 if (!matekbd_strv_equal (kbd_config1->layouts_variants,
557 kbd_config2->layouts_variants))
558 return False0;
559
560 if (!matekbd_keyboard_config_options_equals
561 (kbd_config1, kbd_config2))
562 return False0;
563
564 return True1;
565}
566
567void
568matekbd_keyboard_config_save_to_gsettings (MatekbdKeyboardConfig * kbd_config)
569{
570 g_settings_delay (kbd_config->settings);
571
572 matekbd_keyboard_config_save_params (kbd_config,
573 MATEKBD_KEYBOARD_CONFIG_ACTIVE);
574
575 g_settings_apply (kbd_config->settings);
576}
577
578void
579matekbd_keyboard_config_model_set (MatekbdKeyboardConfig * kbd_config,
580 const gchar * model_name)
581{
582 if (kbd_config->model != NULL((void*)0))
583 g_free (kbd_config->model);
584 kbd_config->model =
585 (model_name == NULL((void*)0)
586 || model_name[0] == '\0') ? NULL((void*)0) : g_strdup (model_name)g_strdup_inline (model_name);
587}
588
589void
590matekbd_keyboard_config_options_set (MatekbdKeyboardConfig * kbd_config,
591 gint idx,
592 const gchar * group_name,
593 const gchar * option_name)
594{
595 const gchar *merged;
596 if (group_name == NULL((void*)0) || option_name == NULL((void*)0))
597 return;
598 merged =
599 matekbd_keyboard_config_merge_items (group_name, option_name);
600 if (merged == NULL((void*)0))
601 return;
602 kbd_config->options[idx] = g_strdup (merged)g_strdup_inline (merged);
603}
604
605gboolean
606matekbd_keyboard_config_options_is_set (MatekbdKeyboardConfig * kbd_config,
607 const gchar * group_name,
608 const gchar * option_name)
609{
610 gchar **p = kbd_config->options;
611 const gchar *merged =
612 matekbd_keyboard_config_merge_items (group_name, option_name);
613 if (merged == NULL((void*)0))
614 return FALSE(0);
615
616 while (p && *p) {
617 if (!g_ascii_strcasecmp (merged, *p++))
618 return TRUE(!(0));
619 }
620 return FALSE(0);
621}
622
623gboolean
624matekbd_keyboard_config_activate (MatekbdKeyboardConfig * kbd_config)
625{
626 gboolean rv;
627 XklConfigRec *data = xkl_config_rec_new ();
628
629 matekbd_keyboard_config_copy_to_xkl_config (kbd_config, data);
630 rv = xkl_config_rec_activate (data, kbd_config->engine);
631 g_object_unref (G_OBJECT (data)((((GObject*) (void *) ((data))))));
632
633 return rv;
634}
635
636/**
637 * matekbd_keyboard_config_start_listen:
638 * @func: (scope notified): a function to call when settings are changed
639 */
640void
641matekbd_keyboard_config_start_listen (MatekbdKeyboardConfig * kbd_config,
642 GCallback func,
643 gpointer user_data)
644{
645 kbd_config->config_listener_id =
646 g_signal_connect (kbd_config->settings, "changed", func,g_signal_connect_data ((kbd_config->settings), ("changed")
, (func), (user_data), ((void*)0), (GConnectFlags) 0)
647 user_data)g_signal_connect_data ((kbd_config->settings), ("changed")
, (func), (user_data), ((void*)0), (GConnectFlags) 0)
;
648}
649
650void
651matekbd_keyboard_config_stop_listen (MatekbdKeyboardConfig * kbd_config)
652{
653#if GLIB_CHECK_VERSION(2,62,0)(2 > (2) || (2 == (2) && 76 > (62)) || (2 == (2
) && 76 == (62) && 5 >= (0)))
654 g_clear_signal_handler (&kbd_config->config_listener_id,do { gpointer const _instance = (kbd_config->settings); gulong
*const _handler_id_ptr = (&kbd_config->config_listener_id
); const gulong _handler_id = *_handler_id_ptr; if (_handler_id
> 0) { *_handler_id_ptr = 0; g_signal_handler_disconnect (
_instance, _handler_id); } } while (0)
655 kbd_config->settings)do { gpointer const _instance = (kbd_config->settings); gulong
*const _handler_id_ptr = (&kbd_config->config_listener_id
); const gulong _handler_id = *_handler_id_ptr; if (_handler_id
> 0) { *_handler_id_ptr = 0; g_signal_handler_disconnect (
_instance, _handler_id); } } while (0)
;
656#else
657 if (kbd_config->config_listener_id != 0) {
658 g_signal_handler_disconnect (kbd_config->settings,
659 kbd_config->config_listener_id);
660 kbd_config->config_listener_id = 0;
661 }
662#endif
663}
664
665gboolean
666matekbd_keyboard_config_get_descriptions (XklConfigRegistry * config_registry,
667 const gchar * name,
668 gchar ** layout_short_descr,
669 gchar ** layout_descr,
670 gchar ** variant_short_descr,
671 gchar ** variant_descr)
672{
673 char *layout_name = NULL((void*)0), *variant_name = NULL((void*)0);
674 if (!matekbd_keyboard_config_split_items
675 (name, &layout_name, &variant_name))
676 return FALSE(0);
677 return matekbd_keyboard_config_get_lv_descriptions (config_registry,
678 layout_name,
679 variant_name,
680 layout_short_descr,
681 layout_descr,
682 variant_short_descr,
683 variant_descr);
684}
685
686const gchar *
687matekbd_keyboard_config_format_full_layout (const gchar * layout_descr,
688 const gchar * variant_descr)
689{
690 static gchar full_descr[XKL_MAX_CI_DESC_LENGTH192 * 2];
691 if (variant_descr == NULL((void*)0) || variant_descr[0] == 0)
692 g_snprintf (full_descr, sizeof (full_descr), "%s",
693 layout_descr);
694 else
695 g_snprintf (full_descr, sizeof (full_descr), "%s %s",
696 layout_descr, variant_descr);
697 return full_descr;
698}
699
700gchar *
701matekbd_keyboard_config_to_string (const MatekbdKeyboardConfig * config)
702{
703 gchar *layouts = NULL((void*)0), *options = NULL((void*)0);
704 GString *buffer = g_string_new (NULL((void*)0));
705
706 gchar **iter;
707 gint count;
708 gchar *result;
709
710 if (config->layouts_variants) {
711 /* g_slist_length is "expensive", so we determinate the length on the fly */
712 for (iter = config->layouts_variants, count = 0; *iter;
713 iter++, ++count) {
714 if (buffer->len)
715 g_string_append (buffer, " ")(__builtin_constant_p (" ") ? __extension__ ({ const char * const
__val = (" "); g_string_append_len_inline (buffer, __val, (__builtin_expect
(__extension__ ({ int _g_boolean_var_26; if (__val != ((void
*)0)) _g_boolean_var_26 = 1; else _g_boolean_var_26 = 0; _g_boolean_var_26
; }), 1)) ? (gssize) strlen (((__val) + !(__val))) : (gssize)
-1); }) : g_string_append_len_inline (buffer, " ", (gssize) -
1))
;
716
717 g_string_append (buffer, *iter)(__builtin_constant_p (*iter) ? __extension__ ({ const char *
const __val = (*iter); g_string_append_len_inline (buffer, __val
, (__builtin_expect (__extension__ ({ int _g_boolean_var_27; if
(__val != ((void*)0)) _g_boolean_var_27 = 1; else _g_boolean_var_27
= 0; _g_boolean_var_27; }), 1)) ? (gssize) strlen (((__val) +
!(__val))) : (gssize) -1); }) : g_string_append_len_inline (
buffer, *iter, (gssize) -1))
;
718 }
719
720 /* Translators: The count is related to the number of options. The %s
721 * format specifier should not be modified, left "as is". */
722 layouts =
723 g_strdup_printf (ngettextdcngettext (((void*)0), "layout \"%s\"", "layouts \"%s\"", count
, 5)
724 ("layout \"%s\"", "layouts \"%s\"",dcngettext (((void*)0), "layout \"%s\"", "layouts \"%s\"", count
, 5)
725 count)dcngettext (((void*)0), "layout \"%s\"", "layouts \"%s\"", count
, 5)
, buffer->str);
726 g_string_truncate (buffer, 0)g_string_truncate_inline (buffer, 0);
727 }
728 if (config->options) {
729 /* g_slist_length is "expensive", so we determinate the length on the fly */
730 for (iter = config->options, count = 0; *iter;
731 iter++, ++count) {
732 if (buffer->len)
733 g_string_append (buffer, " ")(__builtin_constant_p (" ") ? __extension__ ({ const char * const
__val = (" "); g_string_append_len_inline (buffer, __val, (__builtin_expect
(__extension__ ({ int _g_boolean_var_28; if (__val != ((void
*)0)) _g_boolean_var_28 = 1; else _g_boolean_var_28 = 0; _g_boolean_var_28
; }), 1)) ? (gssize) strlen (((__val) + !(__val))) : (gssize)
-1); }) : g_string_append_len_inline (buffer, " ", (gssize) -
1))
;
734
735 g_string_append (buffer, *iter)(__builtin_constant_p (*iter) ? __extension__ ({ const char *
const __val = (*iter); g_string_append_len_inline (buffer, __val
, (__builtin_expect (__extension__ ({ int _g_boolean_var_29; if
(__val != ((void*)0)) _g_boolean_var_29 = 1; else _g_boolean_var_29
= 0; _g_boolean_var_29; }), 1)) ? (gssize) strlen (((__val) +
!(__val))) : (gssize) -1); }) : g_string_append_len_inline (
buffer, *iter, (gssize) -1))
;
736 }
737
738 /* Translators: The count is related to the number of options. The %s
739 * format specifier should not be modified, left "as is". */
740 options =
741 g_strdup_printf (ngettextdcngettext (((void*)0), "option \"%s\"", "options \"%s\"", count
, 5)
742 ("option \"%s\"", "options \"%s\"",dcngettext (((void*)0), "option \"%s\"", "options \"%s\"", count
, 5)
743 count)dcngettext (((void*)0), "option \"%s\"", "options \"%s\"", count
, 5)
, buffer->str);
744 g_string_truncate (buffer, 0)g_string_truncate_inline (buffer, 0);
745 }
746
747 g_string_free (buffer, TRUE)(__builtin_constant_p ((!(0))) ? (((!(0))) ? (g_string_free) (
(buffer), ((!(0)))) : g_string_free_and_steal (buffer)) : (g_string_free
) ((buffer), ((!(0)))))
;
748
749 result =
750 g_strdup_printf (_("model \"%s\", %s and %s")((char *) g_dgettext ("libmatekbd", "model \"%s\", %s and %s"
))
, config->model,
751 layouts ? layouts : _("no layout")((char *) g_dgettext ("libmatekbd", "no layout")),
752 options ? options : _("no options")((char *) g_dgettext ("libmatekbd", "no options")));
753
754 g_free (options);
755 g_free (layouts);
756
757 return result;
758}
759
760/**
761 * matekbd_keyboard_config_add_default_switch_option_if_necessary:
762 *
763 * Returns: (transfer full) (array zero-terminated=1): List of options
764 */
765gchar **
766matekbd_keyboard_config_add_default_switch_option_if_necessary (gchar **
767 layouts_list,
768 gchar **
769 options_list,
770 gboolean *was_appended)
771{
772 *was_appended = FALSE(0);
773 if (g_strv_length (layouts_list) >= 2) {
774 gboolean any_switcher = False0;
775 if (*options_list != NULL((void*)0)) {
776 gchar **option = options_list;
777 while (*option != NULL((void*)0)) {
778 char *g, *o;
779 if (matekbd_keyboard_config_split_items
780 (*option, &g, &o)) {
781 if (!g_ascii_strcasecmp
782 (g, GROUP_SWITCHERS_GROUP"grp")) {
783 any_switcher = True1;
784 break;
785 }
786 }
787 option++;
788 }
789 }
790 if (!any_switcher) {
791 const gchar *id =
792 matekbd_keyboard_config_merge_items
793 (GROUP_SWITCHERS_GROUP"grp",
794 DEFAULT_GROUP_SWITCH"grp:shift_caps_toggle");
795 options_list =
796 matekbd_strv_append (options_list, g_strdup (id)g_strdup_inline (id));
797 *was_appended = TRUE(!(0));
798 }
799 }
800 return options_list;
801}
diff --git a/2023-10-28-125744-5647-1@b00c769a5abd_travis-test/report-523ef4.html b/2023-10-28-125744-5647-1@b00c769a5abd_travis-test/report-523ef4.html new file mode 100644 index 0000000..6e93d13 --- /dev/null +++ b/2023-10-28-125744-5647-1@b00c769a5abd_travis-test/report-523ef4.html @@ -0,0 +1,962 @@ + + + +matekbd-keyboard-drawing-test.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:test/matekbd-keyboard-drawing-test.c
Warning:line 197, column 3
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name matekbd-keyboard-drawing-test.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/test -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -I .. -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libxml2 -D MATELOCALEDIR="/usr/local/share/locale" -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-unused-parameter -fdebug-compilation-dir=/rootdir/test -ferror-limit 19 -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-28-125744-5647-1 -x c matekbd-keyboard-drawing-test.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * Copyright (C) 2006 Sergey V. Udaltsov <svu@gnome.org>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20#if HAVE_CONFIG_H1
21# include <config.h>
22#endif
23
24#include <gtk/gtk.h>
25#include <stdlib.h>
26#include <string.h>
27#include <glib.h>
28#include "libmatekbd/matekbd-keyboard-drawing.h"
29
30static gchar *groups = NULL((void*)0);
31static gchar *levels = NULL((void*)0);
32static gchar *symbols = NULL((void*)0);
33static gchar *keycodes = NULL((void*)0);
34static gchar *geometry = NULL((void*)0);
35
36static gboolean track_config = FALSE(0);
37static gboolean track_modifiers = FALSE(0);
38static gboolean program_version = FALSE(0);
39
40static const GOptionEntry options[] = {
41 {"groups", '\0', 0, G_OPTION_ARG_STRING, &groups,
42 "Keyboard groups to display, from 1-4. Up to four groups only may be "
43 "displayed. Examples: --groups=3 or --groups=1,2,1,2",
44 "group1[,group2[,group3[,group4]]]"},
45 {"levels", '\0', 0, G_OPTION_ARG_STRING, &levels,
46 "Keyboard shift levels to display, from 1-64. Up to four shift levels "
47 "only may be displayed. Examples: --levels=3 or --levels=1,2,1,2",
48 "level1[,level2[,level3[,level4]]]"},
49 {"symbols", '\0', 0, G_OPTION_ARG_STRING, &symbols,
50 "Symbols component of the keyboard. If you omit this option, it is "
51 "obtained from the X server; that is, the keyboard that is currently "
52 "configured is drawn. Examples: --symbols=us or "
53 "--symbols=us(pc104)+iso9995-3+group(switch)+ctrl(nocaps)", NULL((void*)0)},
54 {"keycodes", '\0', 0, G_OPTION_ARG_STRING, &keycodes,
55 "Keycodes component of the keyboard. If you omit this option, it is "
56 "obtained from the X server; that is, the keyboard that is currently"
57 " configured is drawn. Examples: --keycodes=xfree86+aliases(qwerty)",
58 NULL((void*)0)},
59 {"geometry", '\0', 0, G_OPTION_ARG_STRING, &geometry,
60 "Geometry xkb component. If you omit this option, it is obtained from the"
61 " X server; that is, the keyboard that is currently configured is drawn. "
62 "Example: --geometry=kinesis", NULL((void*)0)},
63 {"track-modifiers", '\0', 0, G_OPTION_ARG_NONE, &track_modifiers,
64 "Track the current modifiers", NULL((void*)0)},
65 {"track-config", '\0', 0, G_OPTION_ARG_NONE, &track_config,
66 "Track the server XKB configuration", NULL((void*)0)},
67 {"version", '\0', 0, G_OPTION_ARG_NONE, &program_version,
68 "Show current version", NULL((void*)0)},
69 {NULL((void*)0), 0, 0, G_OPTION_ARG_NONE, NULL((void*)0), NULL((void*)0), NULL((void*)0)},
70};
71
72static gboolean
73set_groups (gchar * groups_option,
74 MatekbdKeyboardDrawingGroupLevel * groupLevels)
75{
76 MatekbdKeyboardDrawingGroupLevel *pgl = groupLevels;
77 gint cntr, g;
78
79 groupLevels[0].group =
80 groupLevels[1].group =
81 groupLevels[2].group = groupLevels[3].group = -1;
82
83 if (groups_option == NULL((void*)0))
84 return TRUE(!(0));
85
86 for (cntr = 4; --cntr >= 0;) {
87 if (*groups_option == '\0')
88 return FALSE(0);
89
90 g = *groups_option - '1';
91 if (g < 0 || g >= 4)
92 return FALSE(0);
93
94 pgl->group = g;
95 /* printf ("group %d\n", pgl->group); */
96
97 groups_option++;
98 if (*groups_option == '\0')
99 return TRUE(!(0));
100 if (*groups_option != ',')
101 return FALSE(0);
102
103 groups_option++;
104 pgl++;
105 }
106
107 return TRUE(!(0));
108}
109
110static gboolean
111set_levels (gchar * levels_option,
112 MatekbdKeyboardDrawingGroupLevel * groupLevels)
113{
114 MatekbdKeyboardDrawingGroupLevel *pgl = groupLevels;
115 gint cntr, l;
116 gchar *p;
117
118 groupLevels[0].level =
119 groupLevels[1].level =
120 groupLevels[2].level = groupLevels[3].level = -1;
121
122 if (levels_option == NULL((void*)0))
123 return TRUE(!(0));
124
125 for (cntr = 4; --cntr >= 0;) {
126 if (*levels_option == '\0')
127 return FALSE(0);
128
129 l = (gint) strtol (levels_option, &p, 10) - 1;
130 if (l < 0 || l >= 64)
131 return FALSE(0);
132
133 pgl->level = l;
134 /* printf ("level %d\n", pgl->level); */
135
136 levels_option = p;
137 if (*levels_option == '\0')
138 return TRUE(!(0));
139 if (*levels_option != ',')
140 return FALSE(0);
141
142 levels_option++;
143 pgl++;
144 }
145
146 return TRUE(!(0));
147}
148
149static void
150bad_keycode (MatekbdKeyboardDrawing * drawing, guint keycode)
151{
152 g_warning
153 ("got keycode %u, which is not on your keyboard according to your configuration",
154 keycode);
155}
156
157gint
158main (gint argc, gchar ** argv)
159{
160 GtkWidget *window;
161 GtkWidget *matekbd_keyboard_drawing;
162 GdkScreen *screen;
163 GdkMonitor *monitor;
164 GdkRectangle rect;
165 GOptionContext *context;
166 GError *error = NULL((void*)0);
167
168 MatekbdKeyboardDrawingGroupLevel groupLevels[4] =
169 { {0, 0}, {1, 0}, {0, 1}, {1, 1} };
170 MatekbdKeyboardDrawingGroupLevel *pgroupLevels[4] =
171 { &groupLevels[0], &groupLevels[1], &groupLevels[2],
172 &groupLevels[3]
173 };
174
175 context = g_option_context_new ("kbdraw");
176 g_option_context_add_main_entries (context, options, NULL((void*)0));
177 if (!g_option_context_parse (context, &argc, &argv, &error)) {
178 g_message ("option parsing failed: %s", error->message);
179 g_option_context_free (context);
180 exit (EXIT_FAILURE1);
181 }
182 g_option_context_free (context);
183
184 if (program_version) {
185 g_print ("kbdraw %s\n", VERSION"1.27.1");
186 exit (0);
187 }
188
189 gtk_init (&argc, &argv);
190
191 if (!set_groups (groups, groupLevels)) {
192 g_printerr ("--groups: invalid argument\n");
193 exit (1);
194 }
195
196 if (!set_levels (levels, groupLevels)) {
197 g_printerr ("--levels: invalid argument\n");
This statement is never executed
198 exit (1);
199 }
200
201 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
202 g_signal_connect (G_OBJECT (window), "destroy",g_signal_connect_data ((((((GObject*) (void *) ((window))))))
, ("destroy"), (((GCallback) (gtk_main_quit))), (((void*)0)),
((void*)0), (GConnectFlags) 0)
203 G_CALLBACK (gtk_main_quit), NULL)g_signal_connect_data ((((((GObject*) (void *) ((window))))))
, ("destroy"), (((GCallback) (gtk_main_quit))), (((void*)0)),
((void*)0), (GConnectFlags) 0)
;
204
205 screen = gtk_window_get_screen (GTK_WINDOW (window)((((GtkWindow*) (void *) ((window))))));
206 monitor = gdk_display_get_monitor_at_point (gdk_screen_get_display (screen), 0, 0);
207 gdk_monitor_get_geometry (monitor, &rect);
208 gtk_window_set_default_size (GTK_WINDOW (window)((((GtkWindow*) (void *) ((window))))),
209 rect.width * 4 / 5,
210 rect.height * 1 / 2);
211
212 gtk_widget_show (window);
213
214 matekbd_keyboard_drawing = matekbd_keyboard_drawing_new ();
215 gtk_widget_show (matekbd_keyboard_drawing);
216 gtk_container_add (GTK_CONTAINER (window)((((GtkContainer*) (void *) ((window))))), matekbd_keyboard_drawing);
217
218 matekbd_keyboard_drawing_set_groups_levels (MATEKBD_KEYBOARD_DRAWING((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
219 (matekbd_keyboard_drawing)((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
,
220 pgroupLevels);
221
222 if (track_modifiers)
223 matekbd_keyboard_drawing_set_track_modifiers
224 (MATEKBD_KEYBOARD_DRAWING (matekbd_keyboard_drawing)((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
, TRUE(!(0)));
225 if (track_config)
226 matekbd_keyboard_drawing_set_track_config
227 (MATEKBD_KEYBOARD_DRAWING (matekbd_keyboard_drawing)((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
, TRUE(!(0)));
228 g_signal_connect (G_OBJECT (matekbd_keyboard_drawing), "bad-keycode",g_signal_connect_data ((((((GObject*) (void *) ((matekbd_keyboard_drawing
)))))), ("bad-keycode"), (((GCallback) (bad_keycode))), (((void
*)0)), ((void*)0), (GConnectFlags) 0)
229 G_CALLBACK (bad_keycode), NULL)g_signal_connect_data ((((((GObject*) (void *) ((matekbd_keyboard_drawing
)))))), ("bad-keycode"), (((GCallback) (bad_keycode))), (((void
*)0)), ((void*)0), (GConnectFlags) 0)
;
230
231 if (symbols || geometry || keycodes) {
232 XkbComponentNamesRec names;
233 gint success;
234
235 memset (&names, '\0', sizeof (names));
236
237 if (symbols)
238 names.symbols = symbols;
239 else
240 names.symbols = (gchar *)
241 matekbd_keyboard_drawing_get_symbols
242 (MATEKBD_KEYBOARD_DRAWING((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
243 (matekbd_keyboard_drawing)((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
);
244
245 if (keycodes)
246 names.keycodes = keycodes;
247 else
248 names.keycodes = (gchar *)
249 matekbd_keyboard_drawing_get_keycodes
250 (MATEKBD_KEYBOARD_DRAWING((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
251 (matekbd_keyboard_drawing)((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
);
252
253 if (geometry)
254 names.geometry = geometry;
255 else
256 names.geometry = (gchar *)
257 matekbd_keyboard_drawing_get_geometry
258 (MATEKBD_KEYBOARD_DRAWING((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
259 (matekbd_keyboard_drawing)((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
);
260
261 success =
262 matekbd_keyboard_drawing_set_keyboard
263 (MATEKBD_KEYBOARD_DRAWING (matekbd_keyboard_drawing)((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
,
264 &names);
265 if (!success) {
266 g_printerr
267 ("\nError loading new keyboard description with components:\n\n"
268 " keycodes: %s\n" " types: %s\n"
269 " compat: %s\n" " symbols: %s\n"
270 " geometry: %s\n\n", names.keycodes,
271 names.types, names.compat, names.symbols,
272 names.geometry);
273 exit (1);
274 }
275 }
276
277 gtk_widget_grab_focus (matekbd_keyboard_drawing);
278
279 gtk_main ();
280
281 return 0;
282}
diff --git a/2023-10-28-125744-5647-1@b00c769a5abd_travis-test/report-5ce420.html b/2023-10-28-125744-5647-1@b00c769a5abd_travis-test/report-5ce420.html new file mode 100644 index 0000000..3165b63 --- /dev/null +++ b/2023-10-28-125744-5647-1@b00c769a5abd_travis-test/report-5ce420.html @@ -0,0 +1,962 @@ + + + +matekbd-keyboard-drawing-test.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:test/matekbd-keyboard-drawing-test.c
Warning:line 192, column 3
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name matekbd-keyboard-drawing-test.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/test -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -I .. -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libxml2 -D MATELOCALEDIR="/usr/local/share/locale" -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-unused-parameter -fdebug-compilation-dir=/rootdir/test -ferror-limit 19 -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-28-125744-5647-1 -x c matekbd-keyboard-drawing-test.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * Copyright (C) 2006 Sergey V. Udaltsov <svu@gnome.org>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20#if HAVE_CONFIG_H1
21# include <config.h>
22#endif
23
24#include <gtk/gtk.h>
25#include <stdlib.h>
26#include <string.h>
27#include <glib.h>
28#include "libmatekbd/matekbd-keyboard-drawing.h"
29
30static gchar *groups = NULL((void*)0);
31static gchar *levels = NULL((void*)0);
32static gchar *symbols = NULL((void*)0);
33static gchar *keycodes = NULL((void*)0);
34static gchar *geometry = NULL((void*)0);
35
36static gboolean track_config = FALSE(0);
37static gboolean track_modifiers = FALSE(0);
38static gboolean program_version = FALSE(0);
39
40static const GOptionEntry options[] = {
41 {"groups", '\0', 0, G_OPTION_ARG_STRING, &groups,
42 "Keyboard groups to display, from 1-4. Up to four groups only may be "
43 "displayed. Examples: --groups=3 or --groups=1,2,1,2",
44 "group1[,group2[,group3[,group4]]]"},
45 {"levels", '\0', 0, G_OPTION_ARG_STRING, &levels,
46 "Keyboard shift levels to display, from 1-64. Up to four shift levels "
47 "only may be displayed. Examples: --levels=3 or --levels=1,2,1,2",
48 "level1[,level2[,level3[,level4]]]"},
49 {"symbols", '\0', 0, G_OPTION_ARG_STRING, &symbols,
50 "Symbols component of the keyboard. If you omit this option, it is "
51 "obtained from the X server; that is, the keyboard that is currently "
52 "configured is drawn. Examples: --symbols=us or "
53 "--symbols=us(pc104)+iso9995-3+group(switch)+ctrl(nocaps)", NULL((void*)0)},
54 {"keycodes", '\0', 0, G_OPTION_ARG_STRING, &keycodes,
55 "Keycodes component of the keyboard. If you omit this option, it is "
56 "obtained from the X server; that is, the keyboard that is currently"
57 " configured is drawn. Examples: --keycodes=xfree86+aliases(qwerty)",
58 NULL((void*)0)},
59 {"geometry", '\0', 0, G_OPTION_ARG_STRING, &geometry,
60 "Geometry xkb component. If you omit this option, it is obtained from the"
61 " X server; that is, the keyboard that is currently configured is drawn. "
62 "Example: --geometry=kinesis", NULL((void*)0)},
63 {"track-modifiers", '\0', 0, G_OPTION_ARG_NONE, &track_modifiers,
64 "Track the current modifiers", NULL((void*)0)},
65 {"track-config", '\0', 0, G_OPTION_ARG_NONE, &track_config,
66 "Track the server XKB configuration", NULL((void*)0)},
67 {"version", '\0', 0, G_OPTION_ARG_NONE, &program_version,
68 "Show current version", NULL((void*)0)},
69 {NULL((void*)0), 0, 0, G_OPTION_ARG_NONE, NULL((void*)0), NULL((void*)0), NULL((void*)0)},
70};
71
72static gboolean
73set_groups (gchar * groups_option,
74 MatekbdKeyboardDrawingGroupLevel * groupLevels)
75{
76 MatekbdKeyboardDrawingGroupLevel *pgl = groupLevels;
77 gint cntr, g;
78
79 groupLevels[0].group =
80 groupLevels[1].group =
81 groupLevels[2].group = groupLevels[3].group = -1;
82
83 if (groups_option == NULL((void*)0))
84 return TRUE(!(0));
85
86 for (cntr = 4; --cntr >= 0;) {
87 if (*groups_option == '\0')
88 return FALSE(0);
89
90 g = *groups_option - '1';
91 if (g < 0 || g >= 4)
92 return FALSE(0);
93
94 pgl->group = g;
95 /* printf ("group %d\n", pgl->group); */
96
97 groups_option++;
98 if (*groups_option == '\0')
99 return TRUE(!(0));
100 if (*groups_option != ',')
101 return FALSE(0);
102
103 groups_option++;
104 pgl++;
105 }
106
107 return TRUE(!(0));
108}
109
110static gboolean
111set_levels (gchar * levels_option,
112 MatekbdKeyboardDrawingGroupLevel * groupLevels)
113{
114 MatekbdKeyboardDrawingGroupLevel *pgl = groupLevels;
115 gint cntr, l;
116 gchar *p;
117
118 groupLevels[0].level =
119 groupLevels[1].level =
120 groupLevels[2].level = groupLevels[3].level = -1;
121
122 if (levels_option == NULL((void*)0))
123 return TRUE(!(0));
124
125 for (cntr = 4; --cntr >= 0;) {
126 if (*levels_option == '\0')
127 return FALSE(0);
128
129 l = (gint) strtol (levels_option, &p, 10) - 1;
130 if (l < 0 || l >= 64)
131 return FALSE(0);
132
133 pgl->level = l;
134 /* printf ("level %d\n", pgl->level); */
135
136 levels_option = p;
137 if (*levels_option == '\0')
138 return TRUE(!(0));
139 if (*levels_option != ',')
140 return FALSE(0);
141
142 levels_option++;
143 pgl++;
144 }
145
146 return TRUE(!(0));
147}
148
149static void
150bad_keycode (MatekbdKeyboardDrawing * drawing, guint keycode)
151{
152 g_warning
153 ("got keycode %u, which is not on your keyboard according to your configuration",
154 keycode);
155}
156
157gint
158main (gint argc, gchar ** argv)
159{
160 GtkWidget *window;
161 GtkWidget *matekbd_keyboard_drawing;
162 GdkScreen *screen;
163 GdkMonitor *monitor;
164 GdkRectangle rect;
165 GOptionContext *context;
166 GError *error = NULL((void*)0);
167
168 MatekbdKeyboardDrawingGroupLevel groupLevels[4] =
169 { {0, 0}, {1, 0}, {0, 1}, {1, 1} };
170 MatekbdKeyboardDrawingGroupLevel *pgroupLevels[4] =
171 { &groupLevels[0], &groupLevels[1], &groupLevels[2],
172 &groupLevels[3]
173 };
174
175 context = g_option_context_new ("kbdraw");
176 g_option_context_add_main_entries (context, options, NULL((void*)0));
177 if (!g_option_context_parse (context, &argc, &argv, &error)) {
178 g_message ("option parsing failed: %s", error->message);
179 g_option_context_free (context);
180 exit (EXIT_FAILURE1);
181 }
182 g_option_context_free (context);
183
184 if (program_version) {
185 g_print ("kbdraw %s\n", VERSION"1.27.1");
186 exit (0);
187 }
188
189 gtk_init (&argc, &argv);
190
191 if (!set_groups (groups, groupLevels)) {
192 g_printerr ("--groups: invalid argument\n");
This statement is never executed
193 exit (1);
194 }
195
196 if (!set_levels (levels, groupLevels)) {
197 g_printerr ("--levels: invalid argument\n");
198 exit (1);
199 }
200
201 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
202 g_signal_connect (G_OBJECT (window), "destroy",g_signal_connect_data ((((((GObject*) (void *) ((window))))))
, ("destroy"), (((GCallback) (gtk_main_quit))), (((void*)0)),
((void*)0), (GConnectFlags) 0)
203 G_CALLBACK (gtk_main_quit), NULL)g_signal_connect_data ((((((GObject*) (void *) ((window))))))
, ("destroy"), (((GCallback) (gtk_main_quit))), (((void*)0)),
((void*)0), (GConnectFlags) 0)
;
204
205 screen = gtk_window_get_screen (GTK_WINDOW (window)((((GtkWindow*) (void *) ((window))))));
206 monitor = gdk_display_get_monitor_at_point (gdk_screen_get_display (screen), 0, 0);
207 gdk_monitor_get_geometry (monitor, &rect);
208 gtk_window_set_default_size (GTK_WINDOW (window)((((GtkWindow*) (void *) ((window))))),
209 rect.width * 4 / 5,
210 rect.height * 1 / 2);
211
212 gtk_widget_show (window);
213
214 matekbd_keyboard_drawing = matekbd_keyboard_drawing_new ();
215 gtk_widget_show (matekbd_keyboard_drawing);
216 gtk_container_add (GTK_CONTAINER (window)((((GtkContainer*) (void *) ((window))))), matekbd_keyboard_drawing);
217
218 matekbd_keyboard_drawing_set_groups_levels (MATEKBD_KEYBOARD_DRAWING((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
219 (matekbd_keyboard_drawing)((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
,
220 pgroupLevels);
221
222 if (track_modifiers)
223 matekbd_keyboard_drawing_set_track_modifiers
224 (MATEKBD_KEYBOARD_DRAWING (matekbd_keyboard_drawing)((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
, TRUE(!(0)));
225 if (track_config)
226 matekbd_keyboard_drawing_set_track_config
227 (MATEKBD_KEYBOARD_DRAWING (matekbd_keyboard_drawing)((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
, TRUE(!(0)));
228 g_signal_connect (G_OBJECT (matekbd_keyboard_drawing), "bad-keycode",g_signal_connect_data ((((((GObject*) (void *) ((matekbd_keyboard_drawing
)))))), ("bad-keycode"), (((GCallback) (bad_keycode))), (((void
*)0)), ((void*)0), (GConnectFlags) 0)
229 G_CALLBACK (bad_keycode), NULL)g_signal_connect_data ((((((GObject*) (void *) ((matekbd_keyboard_drawing
)))))), ("bad-keycode"), (((GCallback) (bad_keycode))), (((void
*)0)), ((void*)0), (GConnectFlags) 0)
;
230
231 if (symbols || geometry || keycodes) {
232 XkbComponentNamesRec names;
233 gint success;
234
235 memset (&names, '\0', sizeof (names));
236
237 if (symbols)
238 names.symbols = symbols;
239 else
240 names.symbols = (gchar *)
241 matekbd_keyboard_drawing_get_symbols
242 (MATEKBD_KEYBOARD_DRAWING((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
243 (matekbd_keyboard_drawing)((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
);
244
245 if (keycodes)
246 names.keycodes = keycodes;
247 else
248 names.keycodes = (gchar *)
249 matekbd_keyboard_drawing_get_keycodes
250 (MATEKBD_KEYBOARD_DRAWING((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
251 (matekbd_keyboard_drawing)((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
);
252
253 if (geometry)
254 names.geometry = geometry;
255 else
256 names.geometry = (gchar *)
257 matekbd_keyboard_drawing_get_geometry
258 (MATEKBD_KEYBOARD_DRAWING((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
259 (matekbd_keyboard_drawing)((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
);
260
261 success =
262 matekbd_keyboard_drawing_set_keyboard
263 (MATEKBD_KEYBOARD_DRAWING (matekbd_keyboard_drawing)((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
,
264 &names);
265 if (!success) {
266 g_printerr
267 ("\nError loading new keyboard description with components:\n\n"
268 " keycodes: %s\n" " types: %s\n"
269 " compat: %s\n" " symbols: %s\n"
270 " geometry: %s\n\n", names.keycodes,
271 names.types, names.compat, names.symbols,
272 names.geometry);
273 exit (1);
274 }
275 }
276
277 gtk_widget_grab_focus (matekbd_keyboard_drawing);
278
279 gtk_main ();
280
281 return 0;
282}
diff --git a/2023-10-28-125744-5647-1@b00c769a5abd_travis-test/report-88f11a.html b/2023-10-28-125744-5647-1@b00c769a5abd_travis-test/report-88f11a.html new file mode 100644 index 0000000..86df6e4 --- /dev/null +++ b/2023-10-28-125744-5647-1@b00c769a5abd_travis-test/report-88f11a.html @@ -0,0 +1,1481 @@ + + + +matekbd-keyboard-config.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:libmatekbd/matekbd-keyboard-config.c
Warning:line 145, column 3
Call to function 'strcat' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcat'. CWE-119
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name matekbd-keyboard-config.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/libmatekbd -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -I .. -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libxml2 -I ../intl -D G_LOG_DOMAIN="MateKbdIndicator" -D DATADIR="/usr/local/share" -D SYSCONFDIR="/usr/local/etc" -D LIBDIR="/usr/local/lib" -D PIC -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -fdebug-compilation-dir=/rootdir/libmatekbd -ferror-limit 19 -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-28-125744-5647-1 -x c matekbd-keyboard-config.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * Copyright (C) 2006 Sergey V. Udaltsov <svu@gnome.org>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20#include <config.h>
21
22#include <stdio.h>
23#include <string.h>
24#include <stdlib.h>
25#include <X11/keysym.h>
26
27#include <glib/gi18n-lib.h>
28
29#include <matekbd-keyboard-config.h>
30#include <matekbd-config-private.h>
31#include <matekbd-util.h>
32
33/*
34 * MatekbdKeyboardConfig
35 */
36#define MATEKBD_KEYBOARD_CONFIG_SCHEMA"org.mate.peripherals-keyboard-xkb" ".kbd" MATEKBD_CONFIG_SCHEMA"org.mate.peripherals-keyboard-xkb" ".kbd"
37
38#define GROUP_SWITCHERS_GROUP"grp" "grp"
39#define DEFAULT_GROUP_SWITCH"grp:shift_caps_toggle" "grp:shift_caps_toggle"
40
41const gchar MATEKBD_KEYBOARD_CONFIG_KEY_MODEL[] = "model";
42const gchar MATEKBD_KEYBOARD_CONFIG_KEY_LAYOUTS[] = "layouts";
43const gchar MATEKBD_KEYBOARD_CONFIG_KEY_OPTIONS[] = "options";
44
45const gchar *MATEKBD_KEYBOARD_CONFIG_ACTIVE[] = {
46 MATEKBD_KEYBOARD_CONFIG_KEY_MODEL,
47 MATEKBD_KEYBOARD_CONFIG_KEY_LAYOUTS,
48 MATEKBD_KEYBOARD_CONFIG_KEY_OPTIONS
49};
50
51/*
52 * static common functions
53 */
54
55static gboolean
56matekbd_strv_equal (gchar ** l1, gchar ** l2)
57{
58 if (l1 == l2)
59 return TRUE(!(0));
60 if (l1 == NULL((void*)0))
61 return g_strv_length (l2) == 0;
62 if (l2 == NULL((void*)0))
63 return g_strv_length (l1) == 0;
64
65 while ((*l1 != NULL((void*)0)) && (*l2 != NULL((void*)0))) {
66 if (*l1 != *l2) {
67 if (*l1 && *l2) {
68 if (g_ascii_strcasecmp (*l1, *l2))
69 return FALSE(0);
70 } else
71 return FALSE(0);
72 }
73
74 l1++;
75 l2++;
76 }
77 return (*l1 == NULL((void*)0)) && (*l2 == NULL((void*)0));
78}
79
80gboolean
81matekbd_keyboard_config_get_lv_descriptions (XklConfigRegistry *
82 config_registry,
83 const gchar * layout_name,
84 const gchar * variant_name,
85 gchar ** layout_short_descr,
86 gchar ** layout_descr,
87 gchar ** variant_short_descr,
88 gchar ** variant_descr)
89{
90 /* TODO make it not static */
91 static XklConfigItem *litem = NULL((void*)0);
92 static XklConfigItem *vitem = NULL((void*)0);
93
94 if (litem == NULL((void*)0))
95 litem = xkl_config_item_new ();
96 if (vitem == NULL((void*)0))
97 vitem = xkl_config_item_new ();
98
99 layout_name = g_strdup (layout_name)g_strdup_inline (layout_name);
100
101 g_snprintf (litem->name, sizeof litem->name, "%s", layout_name);
102 if (xkl_config_registry_find_layout (config_registry, litem)) {
103 *layout_short_descr = litem->short_description;
104 *layout_descr = litem->description;
105 } else
106 *layout_short_descr = *layout_descr = NULL((void*)0);
107
108 if (variant_name != NULL((void*)0)) {
109 variant_name = g_strdup (variant_name)g_strdup_inline (variant_name);
110 g_snprintf (vitem->name, sizeof vitem->name, "%s",
111 variant_name);
112 if (xkl_config_registry_find_variant
113 (config_registry, layout_name, vitem)) {
114 *variant_short_descr = vitem->short_description;
115 *variant_descr = vitem->description;
116 } else
117 *variant_short_descr = *variant_descr = NULL((void*)0);
118
119 g_free ((char *) variant_name);
120 } else
121 *variant_descr = NULL((void*)0);
122
123 g_free ((char *) layout_name);
124 return *layout_descr != NULL((void*)0);
125}
126
127/*
128 * extern common functions
129 */
130const gchar *
131matekbd_keyboard_config_merge_items (const gchar * parent,
132 const gchar * child)
133{
134 static gchar buffer[XKL_MAX_CI_NAME_LENGTH32 * 2 - 1];
135 *buffer = '\0';
136 if (parent != NULL((void*)0)) {
137 if (strlen (parent) >= XKL_MAX_CI_NAME_LENGTH32)
138 return NULL((void*)0);
139 strcat (buffer, parent);
140 }
141 if (child != NULL((void*)0) && *child != 0) {
142 if (strlen (child) >= XKL_MAX_CI_NAME_LENGTH32)
143 return NULL((void*)0);
144 strcat (buffer, "\t");
145 strcat (buffer, child);
Call to function 'strcat' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcat'. CWE-119
146 }
147 return buffer;
148}
149
150gboolean
151matekbd_keyboard_config_split_items (const gchar * merged, gchar ** parent,
152 gchar ** child)
153{
154 static gchar pbuffer[XKL_MAX_CI_NAME_LENGTH32];
155 static gchar cbuffer[XKL_MAX_CI_NAME_LENGTH32];
156 int plen;
157 const gchar *pos;
158 *parent = *child = NULL((void*)0);
159
160 if (merged == NULL((void*)0))
161 return FALSE(0);
162
163 pos = strchr (merged, '\t');
164 if (pos == NULL((void*)0)) {
165 plen = strlen (merged);
166 } else {
167 plen = pos - merged;
168 if (strlen (pos + 1) >= XKL_MAX_CI_NAME_LENGTH32)
169 return FALSE(0);
170 strcpy (*child = cbuffer, pos + 1);
171 }
172 if (plen >= XKL_MAX_CI_NAME_LENGTH32)
173 return FALSE(0);
174 memcpy (*parent = pbuffer, merged, plen);
175 pbuffer[plen] = '\0';
176 return TRUE(!(0));
177}
178
179/*
180 * static MatekbdKeyboardConfig functions
181 */
182static void
183matekbd_keyboard_config_copy_from_xkl_config (MatekbdKeyboardConfig * kbd_config,
184 XklConfigRec * pdata)
185{
186 char **p, **p1;
187 int i;
188 matekbd_keyboard_config_model_set (kbd_config, pdata->model);
189 xkl_debug (150, "Loaded Kbd model: [%s]\n", pdata->model)_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Loaded Kbd model: [%s]\n"
, pdata->model )
;
190
191 /* Layouts */
192 g_strfreev (kbd_config->layouts_variants);
193 kbd_config->layouts_variants = NULL((void*)0);
194 if (pdata->layouts != NULL((void*)0)) {
195 p = pdata->layouts;
196 p1 = pdata->variants;
197 kbd_config->layouts_variants =
198 g_new0 (gchar *, g_strv_length (pdata->layouts) + 1)(gchar * *) (__extension__ ({ gsize __n = (gsize) (g_strv_length
(pdata->layouts) + 1); gsize __s = sizeof (gchar *); gpointer
__p; if (__s == 1) __p = g_malloc0 (__n); else if (__builtin_constant_p
(__n) && (__s == 0 || __n <= (9223372036854775807L
*2UL+1UL) / __s)) __p = g_malloc0 (__n * __s); else __p = g_malloc0_n
(__n, __s); __p; }))
;
199 i = 0;
200 while (*p != NULL((void*)0)) {
201 const gchar *full_layout =
202 matekbd_keyboard_config_merge_items (*p, *p1);
203 xkl_debug (150,_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Loaded Kbd layout (with variant): [%s]\n"
, full_layout )
204 "Loaded Kbd layout (with variant): [%s]\n",_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Loaded Kbd layout (with variant): [%s]\n"
, full_layout )
205 full_layout)_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Loaded Kbd layout (with variant): [%s]\n"
, full_layout )
;
206 kbd_config->layouts_variants[i++] =
207 g_strdup (full_layout)g_strdup_inline (full_layout);
208 p++;
209 p1++;
210 }
211 }
212
213 /* Options */
214 g_strfreev (kbd_config->options);
215 kbd_config->options = NULL((void*)0);
216
217 if (pdata->options != NULL((void*)0)) {
218 p = pdata->options;
219 kbd_config->options =
220 g_new0 (gchar *, g_strv_length (pdata->options) + 1)(gchar * *) (__extension__ ({ gsize __n = (gsize) (g_strv_length
(pdata->options) + 1); gsize __s = sizeof (gchar *); gpointer
__p; if (__s == 1) __p = g_malloc0 (__n); else if (__builtin_constant_p
(__n) && (__s == 0 || __n <= (9223372036854775807L
*2UL+1UL) / __s)) __p = g_malloc0 (__n * __s); else __p = g_malloc0_n
(__n, __s); __p; }))
;
221 i = 0;
222 while (*p != NULL((void*)0)) {
223 char group[XKL_MAX_CI_NAME_LENGTH32];
224 char *option = *p;
225 char *delim =
226 (option != NULL((void*)0)) ? strchr (option, ':') : NULL((void*)0);
227 int len;
228 if ((delim != NULL((void*)0)) &&
229 ((len =
230 (delim - option)) <
231 XKL_MAX_CI_NAME_LENGTH32)) {
232 strncpy (group, option, len);
233 group[len] = 0;
234 xkl_debug (150,_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Loaded Kbd option: [%s][%s]\n"
, group, option )
235 "Loaded Kbd option: [%s][%s]\n",_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Loaded Kbd option: [%s][%s]\n"
, group, option )
236 group, option)_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Loaded Kbd option: [%s][%s]\n"
, group, option )
;
237 matekbd_keyboard_config_options_set
238 (kbd_config, i++, group, option);
239 }
240 p++;
241 }
242 }
243}
244
245static void
246matekbd_keyboard_config_copy_to_xkl_config (MatekbdKeyboardConfig * kbd_config,
247 XklConfigRec * pdata)
248{
249 int i;
250 int num_layouts, num_options;
251 pdata->model =
252 (kbd_config->model ==
253 NULL((void*)0)) ? NULL((void*)0) : g_strdup (kbd_config->model)g_strdup_inline (kbd_config->model);
254
255 num_layouts =
256 (kbd_config->layouts_variants ==
257 NULL((void*)0)) ? 0 : g_strv_length (kbd_config->layouts_variants);
258 num_options =
259 (kbd_config->options ==
260 NULL((void*)0)) ? 0 : g_strv_length (kbd_config->options);
261
262 xkl_debug (150, "Taking %d layouts\n", num_layouts)_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Taking %d layouts\n"
, num_layouts )
;
263 if (num_layouts != 0) {
264 gchar **the_layout_variant = kbd_config->layouts_variants;
265 char **p1 = pdata->layouts =
266 g_new0 (char *, num_layouts + 1)(char * *) (__extension__ ({ gsize __n = (gsize) (num_layouts
+ 1); gsize __s = sizeof (char *); gpointer __p; if (__s == 1
) __p = g_malloc0 (__n); else if (__builtin_constant_p (__n) &&
(__s == 0 || __n <= (9223372036854775807L *2UL+1UL) / __s
)) __p = g_malloc0 (__n * __s); else __p = g_malloc0_n (__n, __s
); __p; }))
;
267 char **p2 = pdata->variants =
268 g_new0 (char *, num_layouts + 1)(char * *) (__extension__ ({ gsize __n = (gsize) (num_layouts
+ 1); gsize __s = sizeof (char *); gpointer __p; if (__s == 1
) __p = g_malloc0 (__n); else if (__builtin_constant_p (__n) &&
(__s == 0 || __n <= (9223372036854775807L *2UL+1UL) / __s
)) __p = g_malloc0 (__n * __s); else __p = g_malloc0_n (__n, __s
); __p; }))
;
269 for (i = num_layouts; --i >= 0;) {
270 char *layout, *variant;
271 if (matekbd_keyboard_config_split_items
272 (*the_layout_variant, &layout, &variant)
273 && variant != NULL((void*)0)) {
274 *p1 =
275 (layout ==
276 NULL((void*)0)) ? g_strdup ("")g_strdup_inline ("") :
277 g_strdup (layout)g_strdup_inline (layout);
278 *p2 =
279 (variant ==
280 NULL((void*)0)) ? g_strdup ("")g_strdup_inline ("") :
281 g_strdup (variant)g_strdup_inline (variant);
282 } else {
283 *p1 =
284 (*the_layout_variant ==
285 NULL((void*)0)) ? g_strdup ("")g_strdup_inline ("") :
286 g_strdup (*the_layout_variant)g_strdup_inline (*the_layout_variant);
287 *p2 = g_strdup ("")g_strdup_inline ("");
288 }
289 xkl_debug (150, "Adding [%s]/%p and [%s]/%p\n",_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Adding [%s]/%p and [%s]/%p\n"
, *p1 ? *p1 : "(nil)", *p1, *p2 ? *p2 : "(nil)", *p2 )
290 *p1 ? *p1 : "(nil)", *p1,_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Adding [%s]/%p and [%s]/%p\n"
, *p1 ? *p1 : "(nil)", *p1, *p2 ? *p2 : "(nil)", *p2 )
291 *p2 ? *p2 : "(nil)", *p2)_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Adding [%s]/%p and [%s]/%p\n"
, *p1 ? *p1 : "(nil)", *p1, *p2 ? *p2 : "(nil)", *p2 )
;
292 p1++;
293 p2++;
294 the_layout_variant++;
295 }
296 }
297
298 if (num_options != 0) {
299 gchar **the_option = kbd_config->options;
300 char **p = pdata->options =
301 g_new0 (char *, num_options + 1)(char * *) (__extension__ ({ gsize __n = (gsize) (num_options
+ 1); gsize __s = sizeof (char *); gpointer __p; if (__s == 1
) __p = g_malloc0 (__n); else if (__builtin_constant_p (__n) &&
(__s == 0 || __n <= (9223372036854775807L *2UL+1UL) / __s
)) __p = g_malloc0 (__n * __s); else __p = g_malloc0_n (__n, __s
); __p; }))
;
302 for (i = num_options; --i >= 0;) {
303 char *group, *option;
304 if (matekbd_keyboard_config_split_items
305 (*the_option, &group, &option)
306 && option != NULL((void*)0))
307 *(p++) = g_strdup (option)g_strdup_inline (option);
308 else {
309 *(p++) = g_strdup ("")g_strdup_inline ("");
310 xkl_debug (150, "Could not split [%s]\n",_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Could not split [%s]\n"
, *the_option )
311 *the_option)_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Could not split [%s]\n"
, *the_option )
;
312 }
313 the_option++;
314 }
315 }
316}
317
318static void
319matekbd_keyboard_config_load_params (MatekbdKeyboardConfig * kbd_config,
320 const gchar * param_names[])
321{
322 gchar *pc;
323
324 pc = g_settings_get_string (kbd_config->settings, param_names[0]);
325 if (pc == NULL((void*)0)) {
326 matekbd_keyboard_config_model_set (kbd_config, NULL((void*)0));
327 } else {
328 matekbd_keyboard_config_model_set (kbd_config, pc);
329 g_free (pc);
330 }
331 xkl_debug (150, "Loaded Kbd model: [%s]\n",_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Loaded Kbd model: [%s]\n"
, kbd_config->model ? kbd_config->model : "(null)" )
332 kbd_config->model ? kbd_config->model : "(null)")_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Loaded Kbd model: [%s]\n"
, kbd_config->model ? kbd_config->model : "(null)" )
;
333
334 g_strfreev (kbd_config->layouts_variants);
335
336 kbd_config->layouts_variants =
337 g_settings_get_strv (kbd_config->settings, param_names[1]);
338
339 if (kbd_config->layouts_variants != NULL((void*)0)
340 && kbd_config->layouts_variants[0] == NULL((void*)0)) {
341 g_strfreev (kbd_config->layouts_variants);
342 kbd_config->layouts_variants = NULL((void*)0);
343 }
344
345 g_strfreev (kbd_config->options);
346
347 kbd_config->options =
348 g_settings_get_strv (kbd_config->settings, param_names[2]);
349
350 if (kbd_config->options != NULL((void*)0) && kbd_config->options[0] == NULL((void*)0)) {
351 g_strfreev (kbd_config->options);
352 kbd_config->options = NULL((void*)0);
353 }
354}
355
356static void
357matekbd_keyboard_config_save_params (MatekbdKeyboardConfig * kbd_config,
358 const gchar * param_names[])
359{
360 gchar **pl;
361
362 if (kbd_config->model)
363 g_settings_set_string (kbd_config->settings, param_names[0],
364 kbd_config->model);
365 else
366 g_settings_set_string (kbd_config->settings, param_names[0],
367 NULL((void*)0));
368 xkl_debug (150, "Saved Kbd model: [%s]\n",_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Saved Kbd model: [%s]\n"
, kbd_config->model ? kbd_config->model : "(null)" )
369 kbd_config->model ? kbd_config->model : "(null)")_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Saved Kbd model: [%s]\n"
, kbd_config->model ? kbd_config->model : "(null)" )
;
370
371 if (kbd_config->layouts_variants) {
372 pl = kbd_config->layouts_variants;
373 while (*pl != NULL((void*)0)) {
374 xkl_debug (150, "Saved Kbd layout: [%s]\n", *pl)_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Saved Kbd layout: [%s]\n"
, *pl )
;
375 pl++;
376 }
377 g_settings_set_strv (kbd_config->settings,
378 param_names[1],
379 (const gchar * const *)
380 kbd_config->layouts_variants);
381 } else {
382 xkl_debug (150, "Saved Kbd layouts: []\n")_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Saved Kbd layouts: []\n"
)
;
383 g_settings_set_strv (kbd_config->settings,
384 param_names[1], NULL((void*)0));
385 }
386
387 if (kbd_config->options) {
388 pl = kbd_config->options;
389 while (*pl != NULL((void*)0)) {
390 xkl_debug (150, "Saved Kbd option: [%s]\n", *pl)_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Saved Kbd option: [%s]\n"
, *pl )
;
391 pl++;
392 }
393 g_settings_set_strv (kbd_config->settings,
394 param_names[2],
395 (const gchar *
396 const *) kbd_config->options);
397 } else {
398 xkl_debug (150, "Saved Kbd options: []\n")_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Saved Kbd options: []\n"
)
;
399 g_settings_set_strv (kbd_config->settings,
400 param_names[2], NULL((void*)0));
401 }
402}
403
404/*
405 * extern MatekbdKeyboardConfig config functions
406 */
407void
408matekbd_keyboard_config_init (MatekbdKeyboardConfig * kbd_config,
409 XklEngine * engine)
410{
411 memset (kbd_config, 0, sizeof (*kbd_config));
412 kbd_config->settings = g_settings_new (MATEKBD_KEYBOARD_CONFIG_SCHEMA"org.mate.peripherals-keyboard-xkb" ".kbd");
413 kbd_config->engine = engine;
414}
415
416void
417matekbd_keyboard_config_term (MatekbdKeyboardConfig * kbd_config)
418{
419 matekbd_keyboard_config_model_set (kbd_config, NULL((void*)0));
420
421 g_strfreev (kbd_config->layouts_variants);
422 kbd_config->layouts_variants = NULL((void*)0);
423 g_strfreev (kbd_config->options);
424 kbd_config->options = NULL((void*)0);
425
426 g_object_unref (kbd_config->settings);
427 kbd_config->settings = NULL((void*)0);
428}
429
430void
431matekbd_keyboard_config_load_from_gsettings (MatekbdKeyboardConfig * kbd_config,
432 MatekbdKeyboardConfig *
433 kbd_config_default)
434{
435 matekbd_keyboard_config_load_params (kbd_config,
436 MATEKBD_KEYBOARD_CONFIG_ACTIVE);
437
438 if (kbd_config_default != NULL((void*)0)) {
439
440 if (kbd_config->model == NULL((void*)0))
441 kbd_config->model =
442 g_strdup (kbd_config_default->model)g_strdup_inline (kbd_config_default->model);
443
444 if (kbd_config->layouts_variants == NULL((void*)0)) {
445 kbd_config->layouts_variants =
446 g_strdupv
447 (kbd_config_default->layouts_variants);
448 }
449
450 if (kbd_config->options == NULL((void*)0)) {
451 kbd_config->options =
452 g_strdupv (kbd_config_default->options);
453 }
454 }
455}
456
457void
458matekbd_keyboard_config_load_from_x_current (MatekbdKeyboardConfig * kbd_config,
459 XklConfigRec * data)
460{
461 gboolean own_data = data == NULL((void*)0);
462 xkl_debug (150, "Copying config from X(current)\n")_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Copying config from X(current)\n"
)
;
463 if (own_data)
464 data = xkl_config_rec_new ();
465 if (xkl_config_rec_get_from_server (data, kbd_config->engine))
466 matekbd_keyboard_config_copy_from_xkl_config (kbd_config,
467 data);
468 else
469 xkl_debug (150,_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Could not load keyboard config from server: [%s]\n"
, xkl_get_last_error () )
470 "Could not load keyboard config from server: [%s]\n",_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Could not load keyboard config from server: [%s]\n"
, xkl_get_last_error () )
471 xkl_get_last_error ())_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Could not load keyboard config from server: [%s]\n"
, xkl_get_last_error () )
;
472 if (own_data)
473 g_object_unref (G_OBJECT (data)((((GObject*) (void *) ((data))))));
474}
475
476void
477matekbd_keyboard_config_load_from_x_initial (MatekbdKeyboardConfig * kbd_config,
478 XklConfigRec * data)
479{
480 gboolean own_data = data == NULL((void*)0);
481 xkl_debug (150, "Copying config from X(initial)\n")_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Copying config from X(initial)\n"
)
;
482 if (own_data)
483 data = xkl_config_rec_new ();
484 if (xkl_config_rec_get_from_backup (data, kbd_config->engine))
485 matekbd_keyboard_config_copy_from_xkl_config (kbd_config,
486 data);
487 else
488 xkl_debug (150,_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Could not load keyboard config from backup: [%s]\n"
, xkl_get_last_error () )
489 "Could not load keyboard config from backup: [%s]\n",_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Could not load keyboard config from backup: [%s]\n"
, xkl_get_last_error () )
490 xkl_get_last_error ())_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Could not load keyboard config from backup: [%s]\n"
, xkl_get_last_error () )
;
491 if (own_data)
492 g_object_unref (G_OBJECT (data)((((GObject*) (void *) ((data))))));
493}
494
495static gboolean
496matekbd_keyboard_config_options_equals (MatekbdKeyboardConfig * kbd_config1,
497 MatekbdKeyboardConfig * kbd_config2)
498{
499 int num_options, num_options2;
500
501 num_options =
502 (kbd_config1->options ==
503 NULL((void*)0)) ? 0 : g_strv_length (kbd_config1->options);
504 num_options2 =
505 (kbd_config2->options ==
506 NULL((void*)0)) ? 0 : g_strv_length (kbd_config2->options);
507
508 if (num_options != num_options2)
509 return False0;
510
511 if (num_options != 0) {
512 int i;
513 char *group1, *option1;
514
515 for (i = 0; i < num_options; i++) {
516 int j;
517 char *group2, *option2;
518 gboolean are_equal = FALSE(0);
519
520 if (!matekbd_keyboard_config_split_items
521 (kbd_config1->options[i], &group1, &option1))
522 continue;
523
524 option1 = g_strdup (option1)g_strdup_inline (option1);
525
526 for (j = 0; j < num_options && !are_equal; j++) {
527 if (matekbd_keyboard_config_split_items
528 (kbd_config2->options[j], &group2,
529 &option2)) {
530 are_equal =
531 strcmp (option1, option2) == 0;
532 }
533 }
534
535 g_free (option1);
536
537 if (!are_equal)
538 return False0;
539 }
540 }
541
542 return True1;
543}
544
545gboolean
546matekbd_keyboard_config_equals (MatekbdKeyboardConfig * kbd_config1,
547 MatekbdKeyboardConfig * kbd_config2)
548{
549 if (kbd_config1 == kbd_config2)
550 return True1;
551 if ((kbd_config1->model != kbd_config2->model) &&
552 (kbd_config1->model != NULL((void*)0)) &&
553 (kbd_config2->model != NULL((void*)0)) &&
554 g_ascii_strcasecmp (kbd_config1->model, kbd_config2->model))
555 return False0;
556 if (!matekbd_strv_equal (kbd_config1->layouts_variants,
557 kbd_config2->layouts_variants))
558 return False0;
559
560 if (!matekbd_keyboard_config_options_equals
561 (kbd_config1, kbd_config2))
562 return False0;
563
564 return True1;
565}
566
567void
568matekbd_keyboard_config_save_to_gsettings (MatekbdKeyboardConfig * kbd_config)
569{
570 g_settings_delay (kbd_config->settings);
571
572 matekbd_keyboard_config_save_params (kbd_config,
573 MATEKBD_KEYBOARD_CONFIG_ACTIVE);
574
575 g_settings_apply (kbd_config->settings);
576}
577
578void
579matekbd_keyboard_config_model_set (MatekbdKeyboardConfig * kbd_config,
580 const gchar * model_name)
581{
582 if (kbd_config->model != NULL((void*)0))
583 g_free (kbd_config->model);
584 kbd_config->model =
585 (model_name == NULL((void*)0)
586 || model_name[0] == '\0') ? NULL((void*)0) : g_strdup (model_name)g_strdup_inline (model_name);
587}
588
589void
590matekbd_keyboard_config_options_set (MatekbdKeyboardConfig * kbd_config,
591 gint idx,
592 const gchar * group_name,
593 const gchar * option_name)
594{
595 const gchar *merged;
596 if (group_name == NULL((void*)0) || option_name == NULL((void*)0))
597 return;
598 merged =
599 matekbd_keyboard_config_merge_items (group_name, option_name);
600 if (merged == NULL((void*)0))
601 return;
602 kbd_config->options[idx] = g_strdup (merged)g_strdup_inline (merged);
603}
604
605gboolean
606matekbd_keyboard_config_options_is_set (MatekbdKeyboardConfig * kbd_config,
607 const gchar * group_name,
608 const gchar * option_name)
609{
610 gchar **p = kbd_config->options;
611 const gchar *merged =
612 matekbd_keyboard_config_merge_items (group_name, option_name);
613 if (merged == NULL((void*)0))
614 return FALSE(0);
615
616 while (p && *p) {
617 if (!g_ascii_strcasecmp (merged, *p++))
618 return TRUE(!(0));
619 }
620 return FALSE(0);
621}
622
623gboolean
624matekbd_keyboard_config_activate (MatekbdKeyboardConfig * kbd_config)
625{
626 gboolean rv;
627 XklConfigRec *data = xkl_config_rec_new ();
628
629 matekbd_keyboard_config_copy_to_xkl_config (kbd_config, data);
630 rv = xkl_config_rec_activate (data, kbd_config->engine);
631 g_object_unref (G_OBJECT (data)((((GObject*) (void *) ((data))))));
632
633 return rv;
634}
635
636/**
637 * matekbd_keyboard_config_start_listen:
638 * @func: (scope notified): a function to call when settings are changed
639 */
640void
641matekbd_keyboard_config_start_listen (MatekbdKeyboardConfig * kbd_config,
642 GCallback func,
643 gpointer user_data)
644{
645 kbd_config->config_listener_id =
646 g_signal_connect (kbd_config->settings, "changed", func,g_signal_connect_data ((kbd_config->settings), ("changed")
, (func), (user_data), ((void*)0), (GConnectFlags) 0)
647 user_data)g_signal_connect_data ((kbd_config->settings), ("changed")
, (func), (user_data), ((void*)0), (GConnectFlags) 0)
;
648}
649
650void
651matekbd_keyboard_config_stop_listen (MatekbdKeyboardConfig * kbd_config)
652{
653#if GLIB_CHECK_VERSION(2,62,0)(2 > (2) || (2 == (2) && 76 > (62)) || (2 == (2
) && 76 == (62) && 5 >= (0)))
654 g_clear_signal_handler (&kbd_config->config_listener_id,do { gpointer const _instance = (kbd_config->settings); gulong
*const _handler_id_ptr = (&kbd_config->config_listener_id
); const gulong _handler_id = *_handler_id_ptr; if (_handler_id
> 0) { *_handler_id_ptr = 0; g_signal_handler_disconnect (
_instance, _handler_id); } } while (0)
655 kbd_config->settings)do { gpointer const _instance = (kbd_config->settings); gulong
*const _handler_id_ptr = (&kbd_config->config_listener_id
); const gulong _handler_id = *_handler_id_ptr; if (_handler_id
> 0) { *_handler_id_ptr = 0; g_signal_handler_disconnect (
_instance, _handler_id); } } while (0)
;
656#else
657 if (kbd_config->config_listener_id != 0) {
658 g_signal_handler_disconnect (kbd_config->settings,
659 kbd_config->config_listener_id);
660 kbd_config->config_listener_id = 0;
661 }
662#endif
663}
664
665gboolean
666matekbd_keyboard_config_get_descriptions (XklConfigRegistry * config_registry,
667 const gchar * name,
668 gchar ** layout_short_descr,
669 gchar ** layout_descr,
670 gchar ** variant_short_descr,
671 gchar ** variant_descr)
672{
673 char *layout_name = NULL((void*)0), *variant_name = NULL((void*)0);
674 if (!matekbd_keyboard_config_split_items
675 (name, &layout_name, &variant_name))
676 return FALSE(0);
677 return matekbd_keyboard_config_get_lv_descriptions (config_registry,
678 layout_name,
679 variant_name,
680 layout_short_descr,
681 layout_descr,
682 variant_short_descr,
683 variant_descr);
684}
685
686const gchar *
687matekbd_keyboard_config_format_full_layout (const gchar * layout_descr,
688 const gchar * variant_descr)
689{
690 static gchar full_descr[XKL_MAX_CI_DESC_LENGTH192 * 2];
691 if (variant_descr == NULL((void*)0) || variant_descr[0] == 0)
692 g_snprintf (full_descr, sizeof (full_descr), "%s",
693 layout_descr);
694 else
695 g_snprintf (full_descr, sizeof (full_descr), "%s %s",
696 layout_descr, variant_descr);
697 return full_descr;
698}
699
700gchar *
701matekbd_keyboard_config_to_string (const MatekbdKeyboardConfig * config)
702{
703 gchar *layouts = NULL((void*)0), *options = NULL((void*)0);
704 GString *buffer = g_string_new (NULL((void*)0));
705
706 gchar **iter;
707 gint count;
708 gchar *result;
709
710 if (config->layouts_variants) {
711 /* g_slist_length is "expensive", so we determinate the length on the fly */
712 for (iter = config->layouts_variants, count = 0; *iter;
713 iter++, ++count) {
714 if (buffer->len)
715 g_string_append (buffer, " ")(__builtin_constant_p (" ") ? __extension__ ({ const char * const
__val = (" "); g_string_append_len_inline (buffer, __val, (__builtin_expect
(__extension__ ({ int _g_boolean_var_22; if (__val != ((void
*)0)) _g_boolean_var_22 = 1; else _g_boolean_var_22 = 0; _g_boolean_var_22
; }), 1)) ? (gssize) strlen (((__val) + !(__val))) : (gssize)
-1); }) : g_string_append_len_inline (buffer, " ", (gssize) -
1))
;
716
717 g_string_append (buffer, *iter)(__builtin_constant_p (*iter) ? __extension__ ({ const char *
const __val = (*iter); g_string_append_len_inline (buffer, __val
, (__builtin_expect (__extension__ ({ int _g_boolean_var_23; if
(__val != ((void*)0)) _g_boolean_var_23 = 1; else _g_boolean_var_23
= 0; _g_boolean_var_23; }), 1)) ? (gssize) strlen (((__val) +
!(__val))) : (gssize) -1); }) : g_string_append_len_inline (
buffer, *iter, (gssize) -1))
;
718 }
719
720 /* Translators: The count is related to the number of options. The %s
721 * format specifier should not be modified, left "as is". */
722 layouts =
723 g_strdup_printf (ngettextdcngettext (((void*)0), "layout \"%s\"", "layouts \"%s\"", count
, 5)
724 ("layout \"%s\"", "layouts \"%s\"",dcngettext (((void*)0), "layout \"%s\"", "layouts \"%s\"", count
, 5)
725 count)dcngettext (((void*)0), "layout \"%s\"", "layouts \"%s\"", count
, 5)
, buffer->str);
726 g_string_truncate (buffer, 0)g_string_truncate_inline (buffer, 0);
727 }
728 if (config->options) {
729 /* g_slist_length is "expensive", so we determinate the length on the fly */
730 for (iter = config->options, count = 0; *iter;
731 iter++, ++count) {
732 if (buffer->len)
733 g_string_append (buffer, " ")(__builtin_constant_p (" ") ? __extension__ ({ const char * const
__val = (" "); g_string_append_len_inline (buffer, __val, (__builtin_expect
(__extension__ ({ int _g_boolean_var_24; if (__val != ((void
*)0)) _g_boolean_var_24 = 1; else _g_boolean_var_24 = 0; _g_boolean_var_24
; }), 1)) ? (gssize) strlen (((__val) + !(__val))) : (gssize)
-1); }) : g_string_append_len_inline (buffer, " ", (gssize) -
1))
;
734
735 g_string_append (buffer, *iter)(__builtin_constant_p (*iter) ? __extension__ ({ const char *
const __val = (*iter); g_string_append_len_inline (buffer, __val
, (__builtin_expect (__extension__ ({ int _g_boolean_var_25; if
(__val != ((void*)0)) _g_boolean_var_25 = 1; else _g_boolean_var_25
= 0; _g_boolean_var_25; }), 1)) ? (gssize) strlen (((__val) +
!(__val))) : (gssize) -1); }) : g_string_append_len_inline (
buffer, *iter, (gssize) -1))
;
736 }
737
738 /* Translators: The count is related to the number of options. The %s
739 * format specifier should not be modified, left "as is". */
740 options =
741 g_strdup_printf (ngettextdcngettext (((void*)0), "option \"%s\"", "options \"%s\"", count
, 5)
742 ("option \"%s\"", "options \"%s\"",dcngettext (((void*)0), "option \"%s\"", "options \"%s\"", count
, 5)
743 count)dcngettext (((void*)0), "option \"%s\"", "options \"%s\"", count
, 5)
, buffer->str);
744 g_string_truncate (buffer, 0)g_string_truncate_inline (buffer, 0);
745 }
746
747 g_string_free (buffer, TRUE)(__builtin_constant_p ((!(0))) ? (((!(0))) ? (g_string_free) (
(buffer), ((!(0)))) : g_string_free_and_steal (buffer)) : (g_string_free
) ((buffer), ((!(0)))))
;
748
749 result =
750 g_strdup_printf (_("model \"%s\", %s and %s")((char *) g_dgettext ("libmatekbd", "model \"%s\", %s and %s"
))
, config->model,
751 layouts ? layouts : _("no layout")((char *) g_dgettext ("libmatekbd", "no layout")),
752 options ? options : _("no options")((char *) g_dgettext ("libmatekbd", "no options")));
753
754 g_free (options);
755 g_free (layouts);
756
757 return result;
758}
759
760/**
761 * matekbd_keyboard_config_add_default_switch_option_if_necessary:
762 *
763 * Returns: (transfer full) (array zero-terminated=1): List of options
764 */
765gchar **
766matekbd_keyboard_config_add_default_switch_option_if_necessary (gchar **
767 layouts_list,
768 gchar **
769 options_list,
770 gboolean *was_appended)
771{
772 *was_appended = FALSE(0);
773 if (g_strv_length (layouts_list) >= 2) {
774 gboolean any_switcher = False0;
775 if (*options_list != NULL((void*)0)) {
776 gchar **option = options_list;
777 while (*option != NULL((void*)0)) {
778 char *g, *o;
779 if (matekbd_keyboard_config_split_items
780 (*option, &g, &o)) {
781 if (!g_ascii_strcasecmp
782 (g, GROUP_SWITCHERS_GROUP"grp")) {
783 any_switcher = True1;
784 break;
785 }
786 }
787 option++;
788 }
789 }
790 if (!any_switcher) {
791 const gchar *id =
792 matekbd_keyboard_config_merge_items
793 (GROUP_SWITCHERS_GROUP"grp",
794 DEFAULT_GROUP_SWITCH"grp:shift_caps_toggle");
795 options_list =
796 matekbd_strv_append (options_list, g_strdup (id)g_strdup_inline (id));
797 *was_appended = TRUE(!(0));
798 }
799 }
800 return options_list;
801}
diff --git a/2023-10-28-125744-5647-1@b00c769a5abd_travis-test/report-c098bd.html b/2023-10-28-125744-5647-1@b00c769a5abd_travis-test/report-c098bd.html new file mode 100644 index 0000000..8c9911b --- /dev/null +++ b/2023-10-28-125744-5647-1@b00c769a5abd_travis-test/report-c098bd.html @@ -0,0 +1,962 @@ + + + +matekbd-keyboard-drawing-test.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:test/matekbd-keyboard-drawing-test.c
Warning:line 185, column 3
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name matekbd-keyboard-drawing-test.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/test -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -I .. -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libxml2 -D MATELOCALEDIR="/usr/local/share/locale" -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-unused-parameter -fdebug-compilation-dir=/rootdir/test -ferror-limit 19 -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-28-125744-5647-1 -x c matekbd-keyboard-drawing-test.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * Copyright (C) 2006 Sergey V. Udaltsov <svu@gnome.org>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20#if HAVE_CONFIG_H1
21# include <config.h>
22#endif
23
24#include <gtk/gtk.h>
25#include <stdlib.h>
26#include <string.h>
27#include <glib.h>
28#include "libmatekbd/matekbd-keyboard-drawing.h"
29
30static gchar *groups = NULL((void*)0);
31static gchar *levels = NULL((void*)0);
32static gchar *symbols = NULL((void*)0);
33static gchar *keycodes = NULL((void*)0);
34static gchar *geometry = NULL((void*)0);
35
36static gboolean track_config = FALSE(0);
37static gboolean track_modifiers = FALSE(0);
38static gboolean program_version = FALSE(0);
39
40static const GOptionEntry options[] = {
41 {"groups", '\0', 0, G_OPTION_ARG_STRING, &groups,
42 "Keyboard groups to display, from 1-4. Up to four groups only may be "
43 "displayed. Examples: --groups=3 or --groups=1,2,1,2",
44 "group1[,group2[,group3[,group4]]]"},
45 {"levels", '\0', 0, G_OPTION_ARG_STRING, &levels,
46 "Keyboard shift levels to display, from 1-64. Up to four shift levels "
47 "only may be displayed. Examples: --levels=3 or --levels=1,2,1,2",
48 "level1[,level2[,level3[,level4]]]"},
49 {"symbols", '\0', 0, G_OPTION_ARG_STRING, &symbols,
50 "Symbols component of the keyboard. If you omit this option, it is "
51 "obtained from the X server; that is, the keyboard that is currently "
52 "configured is drawn. Examples: --symbols=us or "
53 "--symbols=us(pc104)+iso9995-3+group(switch)+ctrl(nocaps)", NULL((void*)0)},
54 {"keycodes", '\0', 0, G_OPTION_ARG_STRING, &keycodes,
55 "Keycodes component of the keyboard. If you omit this option, it is "
56 "obtained from the X server; that is, the keyboard that is currently"
57 " configured is drawn. Examples: --keycodes=xfree86+aliases(qwerty)",
58 NULL((void*)0)},
59 {"geometry", '\0', 0, G_OPTION_ARG_STRING, &geometry,
60 "Geometry xkb component. If you omit this option, it is obtained from the"
61 " X server; that is, the keyboard that is currently configured is drawn. "
62 "Example: --geometry=kinesis", NULL((void*)0)},
63 {"track-modifiers", '\0', 0, G_OPTION_ARG_NONE, &track_modifiers,
64 "Track the current modifiers", NULL((void*)0)},
65 {"track-config", '\0', 0, G_OPTION_ARG_NONE, &track_config,
66 "Track the server XKB configuration", NULL((void*)0)},
67 {"version", '\0', 0, G_OPTION_ARG_NONE, &program_version,
68 "Show current version", NULL((void*)0)},
69 {NULL((void*)0), 0, 0, G_OPTION_ARG_NONE, NULL((void*)0), NULL((void*)0), NULL((void*)0)},
70};
71
72static gboolean
73set_groups (gchar * groups_option,
74 MatekbdKeyboardDrawingGroupLevel * groupLevels)
75{
76 MatekbdKeyboardDrawingGroupLevel *pgl = groupLevels;
77 gint cntr, g;
78
79 groupLevels[0].group =
80 groupLevels[1].group =
81 groupLevels[2].group = groupLevels[3].group = -1;
82
83 if (groups_option == NULL((void*)0))
84 return TRUE(!(0));
85
86 for (cntr = 4; --cntr >= 0;) {
87 if (*groups_option == '\0')
88 return FALSE(0);
89
90 g = *groups_option - '1';
91 if (g < 0 || g >= 4)
92 return FALSE(0);
93
94 pgl->group = g;
95 /* printf ("group %d\n", pgl->group); */
96
97 groups_option++;
98 if (*groups_option == '\0')
99 return TRUE(!(0));
100 if (*groups_option != ',')
101 return FALSE(0);
102
103 groups_option++;
104 pgl++;
105 }
106
107 return TRUE(!(0));
108}
109
110static gboolean
111set_levels (gchar * levels_option,
112 MatekbdKeyboardDrawingGroupLevel * groupLevels)
113{
114 MatekbdKeyboardDrawingGroupLevel *pgl = groupLevels;
115 gint cntr, l;
116 gchar *p;
117
118 groupLevels[0].level =
119 groupLevels[1].level =
120 groupLevels[2].level = groupLevels[3].level = -1;
121
122 if (levels_option == NULL((void*)0))
123 return TRUE(!(0));
124
125 for (cntr = 4; --cntr >= 0;) {
126 if (*levels_option == '\0')
127 return FALSE(0);
128
129 l = (gint) strtol (levels_option, &p, 10) - 1;
130 if (l < 0 || l >= 64)
131 return FALSE(0);
132
133 pgl->level = l;
134 /* printf ("level %d\n", pgl->level); */
135
136 levels_option = p;
137 if (*levels_option == '\0')
138 return TRUE(!(0));
139 if (*levels_option != ',')
140 return FALSE(0);
141
142 levels_option++;
143 pgl++;
144 }
145
146 return TRUE(!(0));
147}
148
149static void
150bad_keycode (MatekbdKeyboardDrawing * drawing, guint keycode)
151{
152 g_warning
153 ("got keycode %u, which is not on your keyboard according to your configuration",
154 keycode);
155}
156
157gint
158main (gint argc, gchar ** argv)
159{
160 GtkWidget *window;
161 GtkWidget *matekbd_keyboard_drawing;
162 GdkScreen *screen;
163 GdkMonitor *monitor;
164 GdkRectangle rect;
165 GOptionContext *context;
166 GError *error = NULL((void*)0);
167
168 MatekbdKeyboardDrawingGroupLevel groupLevels[4] =
169 { {0, 0}, {1, 0}, {0, 1}, {1, 1} };
170 MatekbdKeyboardDrawingGroupLevel *pgroupLevels[4] =
171 { &groupLevels[0], &groupLevels[1], &groupLevels[2],
172 &groupLevels[3]
173 };
174
175 context = g_option_context_new ("kbdraw");
176 g_option_context_add_main_entries (context, options, NULL((void*)0));
177 if (!g_option_context_parse (context, &argc, &argv, &error)) {
178 g_message ("option parsing failed: %s", error->message);
179 g_option_context_free (context);
180 exit (EXIT_FAILURE1);
181 }
182 g_option_context_free (context);
183
184 if (program_version) {
185 g_print ("kbdraw %s\n", VERSION"1.27.1");
This statement is never executed
186 exit (0);
187 }
188
189 gtk_init (&argc, &argv);
190
191 if (!set_groups (groups, groupLevels)) {
192 g_printerr ("--groups: invalid argument\n");
193 exit (1);
194 }
195
196 if (!set_levels (levels, groupLevels)) {
197 g_printerr ("--levels: invalid argument\n");
198 exit (1);
199 }
200
201 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
202 g_signal_connect (G_OBJECT (window), "destroy",g_signal_connect_data ((((((GObject*) (void *) ((window))))))
, ("destroy"), (((GCallback) (gtk_main_quit))), (((void*)0)),
((void*)0), (GConnectFlags) 0)
203 G_CALLBACK (gtk_main_quit), NULL)g_signal_connect_data ((((((GObject*) (void *) ((window))))))
, ("destroy"), (((GCallback) (gtk_main_quit))), (((void*)0)),
((void*)0), (GConnectFlags) 0)
;
204
205 screen = gtk_window_get_screen (GTK_WINDOW (window)((((GtkWindow*) (void *) ((window))))));
206 monitor = gdk_display_get_monitor_at_point (gdk_screen_get_display (screen), 0, 0);
207 gdk_monitor_get_geometry (monitor, &rect);
208 gtk_window_set_default_size (GTK_WINDOW (window)((((GtkWindow*) (void *) ((window))))),
209 rect.width * 4 / 5,
210 rect.height * 1 / 2);
211
212 gtk_widget_show (window);
213
214 matekbd_keyboard_drawing = matekbd_keyboard_drawing_new ();
215 gtk_widget_show (matekbd_keyboard_drawing);
216 gtk_container_add (GTK_CONTAINER (window)((((GtkContainer*) (void *) ((window))))), matekbd_keyboard_drawing);
217
218 matekbd_keyboard_drawing_set_groups_levels (MATEKBD_KEYBOARD_DRAWING((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
219 (matekbd_keyboard_drawing)((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
,
220 pgroupLevels);
221
222 if (track_modifiers)
223 matekbd_keyboard_drawing_set_track_modifiers
224 (MATEKBD_KEYBOARD_DRAWING (matekbd_keyboard_drawing)((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
, TRUE(!(0)));
225 if (track_config)
226 matekbd_keyboard_drawing_set_track_config
227 (MATEKBD_KEYBOARD_DRAWING (matekbd_keyboard_drawing)((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
, TRUE(!(0)));
228 g_signal_connect (G_OBJECT (matekbd_keyboard_drawing), "bad-keycode",g_signal_connect_data ((((((GObject*) (void *) ((matekbd_keyboard_drawing
)))))), ("bad-keycode"), (((GCallback) (bad_keycode))), (((void
*)0)), ((void*)0), (GConnectFlags) 0)
229 G_CALLBACK (bad_keycode), NULL)g_signal_connect_data ((((((GObject*) (void *) ((matekbd_keyboard_drawing
)))))), ("bad-keycode"), (((GCallback) (bad_keycode))), (((void
*)0)), ((void*)0), (GConnectFlags) 0)
;
230
231 if (symbols || geometry || keycodes) {
232 XkbComponentNamesRec names;
233 gint success;
234
235 memset (&names, '\0', sizeof (names));
236
237 if (symbols)
238 names.symbols = symbols;
239 else
240 names.symbols = (gchar *)
241 matekbd_keyboard_drawing_get_symbols
242 (MATEKBD_KEYBOARD_DRAWING((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
243 (matekbd_keyboard_drawing)((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
);
244
245 if (keycodes)
246 names.keycodes = keycodes;
247 else
248 names.keycodes = (gchar *)
249 matekbd_keyboard_drawing_get_keycodes
250 (MATEKBD_KEYBOARD_DRAWING((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
251 (matekbd_keyboard_drawing)((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
);
252
253 if (geometry)
254 names.geometry = geometry;
255 else
256 names.geometry = (gchar *)
257 matekbd_keyboard_drawing_get_geometry
258 (MATEKBD_KEYBOARD_DRAWING((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
259 (matekbd_keyboard_drawing)((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
);
260
261 success =
262 matekbd_keyboard_drawing_set_keyboard
263 (MATEKBD_KEYBOARD_DRAWING (matekbd_keyboard_drawing)((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
,
264 &names);
265 if (!success) {
266 g_printerr
267 ("\nError loading new keyboard description with components:\n\n"
268 " keycodes: %s\n" " types: %s\n"
269 " compat: %s\n" " symbols: %s\n"
270 " geometry: %s\n\n", names.keycodes,
271 names.types, names.compat, names.symbols,
272 names.geometry);
273 exit (1);
274 }
275 }
276
277 gtk_widget_grab_focus (matekbd_keyboard_drawing);
278
279 gtk_main ();
280
281 return 0;
282}
diff --git a/2023-10-28-125744-5647-1@b00c769a5abd_travis-test/report-f5e1ce.html b/2023-10-28-125744-5647-1@b00c769a5abd_travis-test/report-f5e1ce.html new file mode 100644 index 0000000..207ca76 --- /dev/null +++ b/2023-10-28-125744-5647-1@b00c769a5abd_travis-test/report-f5e1ce.html @@ -0,0 +1,1481 @@ + + + +matekbd-keyboard-config.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:libmatekbd/matekbd-keyboard-config.c
Warning:line 139, column 3
Call to function 'strcat' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcat'. CWE-119
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name matekbd-keyboard-config.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/libmatekbd -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -I .. -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libxml2 -I ../intl -D G_LOG_DOMAIN="MateKbdIndicator" -D DATADIR="/usr/local/share" -D SYSCONFDIR="/usr/local/etc" -D LIBDIR="/usr/local/lib" -D PIC -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -fdebug-compilation-dir=/rootdir/libmatekbd -ferror-limit 19 -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-28-125744-5647-1 -x c matekbd-keyboard-config.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * Copyright (C) 2006 Sergey V. Udaltsov <svu@gnome.org>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20#include <config.h>
21
22#include <stdio.h>
23#include <string.h>
24#include <stdlib.h>
25#include <X11/keysym.h>
26
27#include <glib/gi18n-lib.h>
28
29#include <matekbd-keyboard-config.h>
30#include <matekbd-config-private.h>
31#include <matekbd-util.h>
32
33/*
34 * MatekbdKeyboardConfig
35 */
36#define MATEKBD_KEYBOARD_CONFIG_SCHEMA"org.mate.peripherals-keyboard-xkb" ".kbd" MATEKBD_CONFIG_SCHEMA"org.mate.peripherals-keyboard-xkb" ".kbd"
37
38#define GROUP_SWITCHERS_GROUP"grp" "grp"
39#define DEFAULT_GROUP_SWITCH"grp:shift_caps_toggle" "grp:shift_caps_toggle"
40
41const gchar MATEKBD_KEYBOARD_CONFIG_KEY_MODEL[] = "model";
42const gchar MATEKBD_KEYBOARD_CONFIG_KEY_LAYOUTS[] = "layouts";
43const gchar MATEKBD_KEYBOARD_CONFIG_KEY_OPTIONS[] = "options";
44
45const gchar *MATEKBD_KEYBOARD_CONFIG_ACTIVE[] = {
46 MATEKBD_KEYBOARD_CONFIG_KEY_MODEL,
47 MATEKBD_KEYBOARD_CONFIG_KEY_LAYOUTS,
48 MATEKBD_KEYBOARD_CONFIG_KEY_OPTIONS
49};
50
51/*
52 * static common functions
53 */
54
55static gboolean
56matekbd_strv_equal (gchar ** l1, gchar ** l2)
57{
58 if (l1 == l2)
59 return TRUE(!(0));
60 if (l1 == NULL((void*)0))
61 return g_strv_length (l2) == 0;
62 if (l2 == NULL((void*)0))
63 return g_strv_length (l1) == 0;
64
65 while ((*l1 != NULL((void*)0)) && (*l2 != NULL((void*)0))) {
66 if (*l1 != *l2) {
67 if (*l1 && *l2) {
68 if (g_ascii_strcasecmp (*l1, *l2))
69 return FALSE(0);
70 } else
71 return FALSE(0);
72 }
73
74 l1++;
75 l2++;
76 }
77 return (*l1 == NULL((void*)0)) && (*l2 == NULL((void*)0));
78}
79
80gboolean
81matekbd_keyboard_config_get_lv_descriptions (XklConfigRegistry *
82 config_registry,
83 const gchar * layout_name,
84 const gchar * variant_name,
85 gchar ** layout_short_descr,
86 gchar ** layout_descr,
87 gchar ** variant_short_descr,
88 gchar ** variant_descr)
89{
90 /* TODO make it not static */
91 static XklConfigItem *litem = NULL((void*)0);
92 static XklConfigItem *vitem = NULL((void*)0);
93
94 if (litem == NULL((void*)0))
95 litem = xkl_config_item_new ();
96 if (vitem == NULL((void*)0))
97 vitem = xkl_config_item_new ();
98
99 layout_name = g_strdup (layout_name)g_strdup_inline (layout_name);
100
101 g_snprintf (litem->name, sizeof litem->name, "%s", layout_name);
102 if (xkl_config_registry_find_layout (config_registry, litem)) {
103 *layout_short_descr = litem->short_description;
104 *layout_descr = litem->description;
105 } else
106 *layout_short_descr = *layout_descr = NULL((void*)0);
107
108 if (variant_name != NULL((void*)0)) {
109 variant_name = g_strdup (variant_name)g_strdup_inline (variant_name);
110 g_snprintf (vitem->name, sizeof vitem->name, "%s",
111 variant_name);
112 if (xkl_config_registry_find_variant
113 (config_registry, layout_name, vitem)) {
114 *variant_short_descr = vitem->short_description;
115 *variant_descr = vitem->description;
116 } else
117 *variant_short_descr = *variant_descr = NULL((void*)0);
118
119 g_free ((char *) variant_name);
120 } else
121 *variant_descr = NULL((void*)0);
122
123 g_free ((char *) layout_name);
124 return *layout_descr != NULL((void*)0);
125}
126
127/*
128 * extern common functions
129 */
130const gchar *
131matekbd_keyboard_config_merge_items (const gchar * parent,
132 const gchar * child)
133{
134 static gchar buffer[XKL_MAX_CI_NAME_LENGTH32 * 2 - 1];
135 *buffer = '\0';
136 if (parent != NULL((void*)0)) {
137 if (strlen (parent) >= XKL_MAX_CI_NAME_LENGTH32)
138 return NULL((void*)0);
139 strcat (buffer, parent);
Call to function 'strcat' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcat'. CWE-119
140 }
141 if (child != NULL((void*)0) && *child != 0) {
142 if (strlen (child) >= XKL_MAX_CI_NAME_LENGTH32)
143 return NULL((void*)0);
144 strcat (buffer, "\t");
145 strcat (buffer, child);
146 }
147 return buffer;
148}
149
150gboolean
151matekbd_keyboard_config_split_items (const gchar * merged, gchar ** parent,
152 gchar ** child)
153{
154 static gchar pbuffer[XKL_MAX_CI_NAME_LENGTH32];
155 static gchar cbuffer[XKL_MAX_CI_NAME_LENGTH32];
156 int plen;
157 const gchar *pos;
158 *parent = *child = NULL((void*)0);
159
160 if (merged == NULL((void*)0))
161 return FALSE(0);
162
163 pos = strchr (merged, '\t');
164 if (pos == NULL((void*)0)) {
165 plen = strlen (merged);
166 } else {
167 plen = pos - merged;
168 if (strlen (pos + 1) >= XKL_MAX_CI_NAME_LENGTH32)
169 return FALSE(0);
170 strcpy (*child = cbuffer, pos + 1);
171 }
172 if (plen >= XKL_MAX_CI_NAME_LENGTH32)
173 return FALSE(0);
174 memcpy (*parent = pbuffer, merged, plen);
175 pbuffer[plen] = '\0';
176 return TRUE(!(0));
177}
178
179/*
180 * static MatekbdKeyboardConfig functions
181 */
182static void
183matekbd_keyboard_config_copy_from_xkl_config (MatekbdKeyboardConfig * kbd_config,
184 XklConfigRec * pdata)
185{
186 char **p, **p1;
187 int i;
188 matekbd_keyboard_config_model_set (kbd_config, pdata->model);
189 xkl_debug (150, "Loaded Kbd model: [%s]\n", pdata->model)_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Loaded Kbd model: [%s]\n"
, pdata->model )
;
190
191 /* Layouts */
192 g_strfreev (kbd_config->layouts_variants);
193 kbd_config->layouts_variants = NULL((void*)0);
194 if (pdata->layouts != NULL((void*)0)) {
195 p = pdata->layouts;
196 p1 = pdata->variants;
197 kbd_config->layouts_variants =
198 g_new0 (gchar *, g_strv_length (pdata->layouts) + 1)(gchar * *) (__extension__ ({ gsize __n = (gsize) (g_strv_length
(pdata->layouts) + 1); gsize __s = sizeof (gchar *); gpointer
__p; if (__s == 1) __p = g_malloc0 (__n); else if (__builtin_constant_p
(__n) && (__s == 0 || __n <= (9223372036854775807L
*2UL+1UL) / __s)) __p = g_malloc0 (__n * __s); else __p = g_malloc0_n
(__n, __s); __p; }))
;
199 i = 0;
200 while (*p != NULL((void*)0)) {
201 const gchar *full_layout =
202 matekbd_keyboard_config_merge_items (*p, *p1);
203 xkl_debug (150,_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Loaded Kbd layout (with variant): [%s]\n"
, full_layout )
204 "Loaded Kbd layout (with variant): [%s]\n",_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Loaded Kbd layout (with variant): [%s]\n"
, full_layout )
205 full_layout)_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Loaded Kbd layout (with variant): [%s]\n"
, full_layout )
;
206 kbd_config->layouts_variants[i++] =
207 g_strdup (full_layout)g_strdup_inline (full_layout);
208 p++;
209 p1++;
210 }
211 }
212
213 /* Options */
214 g_strfreev (kbd_config->options);
215 kbd_config->options = NULL((void*)0);
216
217 if (pdata->options != NULL((void*)0)) {
218 p = pdata->options;
219 kbd_config->options =
220 g_new0 (gchar *, g_strv_length (pdata->options) + 1)(gchar * *) (__extension__ ({ gsize __n = (gsize) (g_strv_length
(pdata->options) + 1); gsize __s = sizeof (gchar *); gpointer
__p; if (__s == 1) __p = g_malloc0 (__n); else if (__builtin_constant_p
(__n) && (__s == 0 || __n <= (9223372036854775807L
*2UL+1UL) / __s)) __p = g_malloc0 (__n * __s); else __p = g_malloc0_n
(__n, __s); __p; }))
;
221 i = 0;
222 while (*p != NULL((void*)0)) {
223 char group[XKL_MAX_CI_NAME_LENGTH32];
224 char *option = *p;
225 char *delim =
226 (option != NULL((void*)0)) ? strchr (option, ':') : NULL((void*)0);
227 int len;
228 if ((delim != NULL((void*)0)) &&
229 ((len =
230 (delim - option)) <
231 XKL_MAX_CI_NAME_LENGTH32)) {
232 strncpy (group, option, len);
233 group[len] = 0;
234 xkl_debug (150,_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Loaded Kbd option: [%s][%s]\n"
, group, option )
235 "Loaded Kbd option: [%s][%s]\n",_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Loaded Kbd option: [%s][%s]\n"
, group, option )
236 group, option)_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Loaded Kbd option: [%s][%s]\n"
, group, option )
;
237 matekbd_keyboard_config_options_set
238 (kbd_config, i++, group, option);
239 }
240 p++;
241 }
242 }
243}
244
245static void
246matekbd_keyboard_config_copy_to_xkl_config (MatekbdKeyboardConfig * kbd_config,
247 XklConfigRec * pdata)
248{
249 int i;
250 int num_layouts, num_options;
251 pdata->model =
252 (kbd_config->model ==
253 NULL((void*)0)) ? NULL((void*)0) : g_strdup (kbd_config->model)g_strdup_inline (kbd_config->model);
254
255 num_layouts =
256 (kbd_config->layouts_variants ==
257 NULL((void*)0)) ? 0 : g_strv_length (kbd_config->layouts_variants);
258 num_options =
259 (kbd_config->options ==
260 NULL((void*)0)) ? 0 : g_strv_length (kbd_config->options);
261
262 xkl_debug (150, "Taking %d layouts\n", num_layouts)_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Taking %d layouts\n"
, num_layouts )
;
263 if (num_layouts != 0) {
264 gchar **the_layout_variant = kbd_config->layouts_variants;
265 char **p1 = pdata->layouts =
266 g_new0 (char *, num_layouts + 1)(char * *) (__extension__ ({ gsize __n = (gsize) (num_layouts
+ 1); gsize __s = sizeof (char *); gpointer __p; if (__s == 1
) __p = g_malloc0 (__n); else if (__builtin_constant_p (__n) &&
(__s == 0 || __n <= (9223372036854775807L *2UL+1UL) / __s
)) __p = g_malloc0 (__n * __s); else __p = g_malloc0_n (__n, __s
); __p; }))
;
267 char **p2 = pdata->variants =
268 g_new0 (char *, num_layouts + 1)(char * *) (__extension__ ({ gsize __n = (gsize) (num_layouts
+ 1); gsize __s = sizeof (char *); gpointer __p; if (__s == 1
) __p = g_malloc0 (__n); else if (__builtin_constant_p (__n) &&
(__s == 0 || __n <= (9223372036854775807L *2UL+1UL) / __s
)) __p = g_malloc0 (__n * __s); else __p = g_malloc0_n (__n, __s
); __p; }))
;
269 for (i = num_layouts; --i >= 0;) {
270 char *layout, *variant;
271 if (matekbd_keyboard_config_split_items
272 (*the_layout_variant, &layout, &variant)
273 && variant != NULL((void*)0)) {
274 *p1 =
275 (layout ==
276 NULL((void*)0)) ? g_strdup ("")g_strdup_inline ("") :
277 g_strdup (layout)g_strdup_inline (layout);
278 *p2 =
279 (variant ==
280 NULL((void*)0)) ? g_strdup ("")g_strdup_inline ("") :
281 g_strdup (variant)g_strdup_inline (variant);
282 } else {
283 *p1 =
284 (*the_layout_variant ==
285 NULL((void*)0)) ? g_strdup ("")g_strdup_inline ("") :
286 g_strdup (*the_layout_variant)g_strdup_inline (*the_layout_variant);
287 *p2 = g_strdup ("")g_strdup_inline ("");
288 }
289 xkl_debug (150, "Adding [%s]/%p and [%s]/%p\n",_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Adding [%s]/%p and [%s]/%p\n"
, *p1 ? *p1 : "(nil)", *p1, *p2 ? *p2 : "(nil)", *p2 )
290 *p1 ? *p1 : "(nil)", *p1,_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Adding [%s]/%p and [%s]/%p\n"
, *p1 ? *p1 : "(nil)", *p1, *p2 ? *p2 : "(nil)", *p2 )
291 *p2 ? *p2 : "(nil)", *p2)_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Adding [%s]/%p and [%s]/%p\n"
, *p1 ? *p1 : "(nil)", *p1, *p2 ? *p2 : "(nil)", *p2 )
;
292 p1++;
293 p2++;
294 the_layout_variant++;
295 }
296 }
297
298 if (num_options != 0) {
299 gchar **the_option = kbd_config->options;
300 char **p = pdata->options =
301 g_new0 (char *, num_options + 1)(char * *) (__extension__ ({ gsize __n = (gsize) (num_options
+ 1); gsize __s = sizeof (char *); gpointer __p; if (__s == 1
) __p = g_malloc0 (__n); else if (__builtin_constant_p (__n) &&
(__s == 0 || __n <= (9223372036854775807L *2UL+1UL) / __s
)) __p = g_malloc0 (__n * __s); else __p = g_malloc0_n (__n, __s
); __p; }))
;
302 for (i = num_options; --i >= 0;) {
303 char *group, *option;
304 if (matekbd_keyboard_config_split_items
305 (*the_option, &group, &option)
306 && option != NULL((void*)0))
307 *(p++) = g_strdup (option)g_strdup_inline (option);
308 else {
309 *(p++) = g_strdup ("")g_strdup_inline ("");
310 xkl_debug (150, "Could not split [%s]\n",_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Could not split [%s]\n"
, *the_option )
311 *the_option)_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Could not split [%s]\n"
, *the_option )
;
312 }
313 the_option++;
314 }
315 }
316}
317
318static void
319matekbd_keyboard_config_load_params (MatekbdKeyboardConfig * kbd_config,
320 const gchar * param_names[])
321{
322 gchar *pc;
323
324 pc = g_settings_get_string (kbd_config->settings, param_names[0]);
325 if (pc == NULL((void*)0)) {
326 matekbd_keyboard_config_model_set (kbd_config, NULL((void*)0));
327 } else {
328 matekbd_keyboard_config_model_set (kbd_config, pc);
329 g_free (pc);
330 }
331 xkl_debug (150, "Loaded Kbd model: [%s]\n",_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Loaded Kbd model: [%s]\n"
, kbd_config->model ? kbd_config->model : "(null)" )
332 kbd_config->model ? kbd_config->model : "(null)")_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Loaded Kbd model: [%s]\n"
, kbd_config->model ? kbd_config->model : "(null)" )
;
333
334 g_strfreev (kbd_config->layouts_variants);
335
336 kbd_config->layouts_variants =
337 g_settings_get_strv (kbd_config->settings, param_names[1]);
338
339 if (kbd_config->layouts_variants != NULL((void*)0)
340 && kbd_config->layouts_variants[0] == NULL((void*)0)) {
341 g_strfreev (kbd_config->layouts_variants);
342 kbd_config->layouts_variants = NULL((void*)0);
343 }
344
345 g_strfreev (kbd_config->options);
346
347 kbd_config->options =
348 g_settings_get_strv (kbd_config->settings, param_names[2]);
349
350 if (kbd_config->options != NULL((void*)0) && kbd_config->options[0] == NULL((void*)0)) {
351 g_strfreev (kbd_config->options);
352 kbd_config->options = NULL((void*)0);
353 }
354}
355
356static void
357matekbd_keyboard_config_save_params (MatekbdKeyboardConfig * kbd_config,
358 const gchar * param_names[])
359{
360 gchar **pl;
361
362 if (kbd_config->model)
363 g_settings_set_string (kbd_config->settings, param_names[0],
364 kbd_config->model);
365 else
366 g_settings_set_string (kbd_config->settings, param_names[0],
367 NULL((void*)0));
368 xkl_debug (150, "Saved Kbd model: [%s]\n",_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Saved Kbd model: [%s]\n"
, kbd_config->model ? kbd_config->model : "(null)" )
369 kbd_config->model ? kbd_config->model : "(null)")_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Saved Kbd model: [%s]\n"
, kbd_config->model ? kbd_config->model : "(null)" )
;
370
371 if (kbd_config->layouts_variants) {
372 pl = kbd_config->layouts_variants;
373 while (*pl != NULL((void*)0)) {
374 xkl_debug (150, "Saved Kbd layout: [%s]\n", *pl)_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Saved Kbd layout: [%s]\n"
, *pl )
;
375 pl++;
376 }
377 g_settings_set_strv (kbd_config->settings,
378 param_names[1],
379 (const gchar * const *)
380 kbd_config->layouts_variants);
381 } else {
382 xkl_debug (150, "Saved Kbd layouts: []\n")_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Saved Kbd layouts: []\n"
)
;
383 g_settings_set_strv (kbd_config->settings,
384 param_names[1], NULL((void*)0));
385 }
386
387 if (kbd_config->options) {
388 pl = kbd_config->options;
389 while (*pl != NULL((void*)0)) {
390 xkl_debug (150, "Saved Kbd option: [%s]\n", *pl)_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Saved Kbd option: [%s]\n"
, *pl )
;
391 pl++;
392 }
393 g_settings_set_strv (kbd_config->settings,
394 param_names[2],
395 (const gchar *
396 const *) kbd_config->options);
397 } else {
398 xkl_debug (150, "Saved Kbd options: []\n")_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Saved Kbd options: []\n"
)
;
399 g_settings_set_strv (kbd_config->settings,
400 param_names[2], NULL((void*)0));
401 }
402}
403
404/*
405 * extern MatekbdKeyboardConfig config functions
406 */
407void
408matekbd_keyboard_config_init (MatekbdKeyboardConfig * kbd_config,
409 XklEngine * engine)
410{
411 memset (kbd_config, 0, sizeof (*kbd_config));
412 kbd_config->settings = g_settings_new (MATEKBD_KEYBOARD_CONFIG_SCHEMA"org.mate.peripherals-keyboard-xkb" ".kbd");
413 kbd_config->engine = engine;
414}
415
416void
417matekbd_keyboard_config_term (MatekbdKeyboardConfig * kbd_config)
418{
419 matekbd_keyboard_config_model_set (kbd_config, NULL((void*)0));
420
421 g_strfreev (kbd_config->layouts_variants);
422 kbd_config->layouts_variants = NULL((void*)0);
423 g_strfreev (kbd_config->options);
424 kbd_config->options = NULL((void*)0);
425
426 g_object_unref (kbd_config->settings);
427 kbd_config->settings = NULL((void*)0);
428}
429
430void
431matekbd_keyboard_config_load_from_gsettings (MatekbdKeyboardConfig * kbd_config,
432 MatekbdKeyboardConfig *
433 kbd_config_default)
434{
435 matekbd_keyboard_config_load_params (kbd_config,
436 MATEKBD_KEYBOARD_CONFIG_ACTIVE);
437
438 if (kbd_config_default != NULL((void*)0)) {
439
440 if (kbd_config->model == NULL((void*)0))
441 kbd_config->model =
442 g_strdup (kbd_config_default->model)g_strdup_inline (kbd_config_default->model);
443
444 if (kbd_config->layouts_variants == NULL((void*)0)) {
445 kbd_config->layouts_variants =
446 g_strdupv
447 (kbd_config_default->layouts_variants);
448 }
449
450 if (kbd_config->options == NULL((void*)0)) {
451 kbd_config->options =
452 g_strdupv (kbd_config_default->options);
453 }
454 }
455}
456
457void
458matekbd_keyboard_config_load_from_x_current (MatekbdKeyboardConfig * kbd_config,
459 XklConfigRec * data)
460{
461 gboolean own_data = data == NULL((void*)0);
462 xkl_debug (150, "Copying config from X(current)\n")_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Copying config from X(current)\n"
)
;
463 if (own_data)
464 data = xkl_config_rec_new ();
465 if (xkl_config_rec_get_from_server (data, kbd_config->engine))
466 matekbd_keyboard_config_copy_from_xkl_config (kbd_config,
467 data);
468 else
469 xkl_debug (150,_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Could not load keyboard config from server: [%s]\n"
, xkl_get_last_error () )
470 "Could not load keyboard config from server: [%s]\n",_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Could not load keyboard config from server: [%s]\n"
, xkl_get_last_error () )
471 xkl_get_last_error ())_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Could not load keyboard config from server: [%s]\n"
, xkl_get_last_error () )
;
472 if (own_data)
473 g_object_unref (G_OBJECT (data)((((GObject*) (void *) ((data))))));
474}
475
476void
477matekbd_keyboard_config_load_from_x_initial (MatekbdKeyboardConfig * kbd_config,
478 XklConfigRec * data)
479{
480 gboolean own_data = data == NULL((void*)0);
481 xkl_debug (150, "Copying config from X(initial)\n")_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Copying config from X(initial)\n"
)
;
482 if (own_data)
483 data = xkl_config_rec_new ();
484 if (xkl_config_rec_get_from_backup (data, kbd_config->engine))
485 matekbd_keyboard_config_copy_from_xkl_config (kbd_config,
486 data);
487 else
488 xkl_debug (150,_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Could not load keyboard config from backup: [%s]\n"
, xkl_get_last_error () )
489 "Could not load keyboard config from backup: [%s]\n",_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Could not load keyboard config from backup: [%s]\n"
, xkl_get_last_error () )
490 xkl_get_last_error ())_xkl_debug( "matekbd-keyboard-config.c", __func__, 150, "Could not load keyboard config from backup: [%s]\n"
, xkl_get_last_error () )
;
491 if (own_data)
492 g_object_unref (G_OBJECT (data)((((GObject*) (void *) ((data))))));
493}
494
495static gboolean
496matekbd_keyboard_config_options_equals (MatekbdKeyboardConfig * kbd_config1,
497 MatekbdKeyboardConfig * kbd_config2)
498{
499 int num_options, num_options2;
500
501 num_options =
502 (kbd_config1->options ==
503 NULL((void*)0)) ? 0 : g_strv_length (kbd_config1->options);
504 num_options2 =
505 (kbd_config2->options ==
506 NULL((void*)0)) ? 0 : g_strv_length (kbd_config2->options);
507
508 if (num_options != num_options2)
509 return False0;
510
511 if (num_options != 0) {
512 int i;
513 char *group1, *option1;
514
515 for (i = 0; i < num_options; i++) {
516 int j;
517 char *group2, *option2;
518 gboolean are_equal = FALSE(0);
519
520 if (!matekbd_keyboard_config_split_items
521 (kbd_config1->options[i], &group1, &option1))
522 continue;
523
524 option1 = g_strdup (option1)g_strdup_inline (option1);
525
526 for (j = 0; j < num_options && !are_equal; j++) {
527 if (matekbd_keyboard_config_split_items
528 (kbd_config2->options[j], &group2,
529 &option2)) {
530 are_equal =
531 strcmp (option1, option2) == 0;
532 }
533 }
534
535 g_free (option1);
536
537 if (!are_equal)
538 return False0;
539 }
540 }
541
542 return True1;
543}
544
545gboolean
546matekbd_keyboard_config_equals (MatekbdKeyboardConfig * kbd_config1,
547 MatekbdKeyboardConfig * kbd_config2)
548{
549 if (kbd_config1 == kbd_config2)
550 return True1;
551 if ((kbd_config1->model != kbd_config2->model) &&
552 (kbd_config1->model != NULL((void*)0)) &&
553 (kbd_config2->model != NULL((void*)0)) &&
554 g_ascii_strcasecmp (kbd_config1->model, kbd_config2->model))
555 return False0;
556 if (!matekbd_strv_equal (kbd_config1->layouts_variants,
557 kbd_config2->layouts_variants))
558 return False0;
559
560 if (!matekbd_keyboard_config_options_equals
561 (kbd_config1, kbd_config2))
562 return False0;
563
564 return True1;
565}
566
567void
568matekbd_keyboard_config_save_to_gsettings (MatekbdKeyboardConfig * kbd_config)
569{
570 g_settings_delay (kbd_config->settings);
571
572 matekbd_keyboard_config_save_params (kbd_config,
573 MATEKBD_KEYBOARD_CONFIG_ACTIVE);
574
575 g_settings_apply (kbd_config->settings);
576}
577
578void
579matekbd_keyboard_config_model_set (MatekbdKeyboardConfig * kbd_config,
580 const gchar * model_name)
581{
582 if (kbd_config->model != NULL((void*)0))
583 g_free (kbd_config->model);
584 kbd_config->model =
585 (model_name == NULL((void*)0)
586 || model_name[0] == '\0') ? NULL((void*)0) : g_strdup (model_name)g_strdup_inline (model_name);
587}
588
589void
590matekbd_keyboard_config_options_set (MatekbdKeyboardConfig * kbd_config,
591 gint idx,
592 const gchar * group_name,
593 const gchar * option_name)
594{
595 const gchar *merged;
596 if (group_name == NULL((void*)0) || option_name == NULL((void*)0))
597 return;
598 merged =
599 matekbd_keyboard_config_merge_items (group_name, option_name);
600 if (merged == NULL((void*)0))
601 return;
602 kbd_config->options[idx] = g_strdup (merged)g_strdup_inline (merged);
603}
604
605gboolean
606matekbd_keyboard_config_options_is_set (MatekbdKeyboardConfig * kbd_config,
607 const gchar * group_name,
608 const gchar * option_name)
609{
610 gchar **p = kbd_config->options;
611 const gchar *merged =
612 matekbd_keyboard_config_merge_items (group_name, option_name);
613 if (merged == NULL((void*)0))
614 return FALSE(0);
615
616 while (p && *p) {
617 if (!g_ascii_strcasecmp (merged, *p++))
618 return TRUE(!(0));
619 }
620 return FALSE(0);
621}
622
623gboolean
624matekbd_keyboard_config_activate (MatekbdKeyboardConfig * kbd_config)
625{
626 gboolean rv;
627 XklConfigRec *data = xkl_config_rec_new ();
628
629 matekbd_keyboard_config_copy_to_xkl_config (kbd_config, data);
630 rv = xkl_config_rec_activate (data, kbd_config->engine);
631 g_object_unref (G_OBJECT (data)((((GObject*) (void *) ((data))))));
632
633 return rv;
634}
635
636/**
637 * matekbd_keyboard_config_start_listen:
638 * @func: (scope notified): a function to call when settings are changed
639 */
640void
641matekbd_keyboard_config_start_listen (MatekbdKeyboardConfig * kbd_config,
642 GCallback func,
643 gpointer user_data)
644{
645 kbd_config->config_listener_id =
646 g_signal_connect (kbd_config->settings, "changed", func,g_signal_connect_data ((kbd_config->settings), ("changed")
, (func), (user_data), ((void*)0), (GConnectFlags) 0)
647 user_data)g_signal_connect_data ((kbd_config->settings), ("changed")
, (func), (user_data), ((void*)0), (GConnectFlags) 0)
;
648}
649
650void
651matekbd_keyboard_config_stop_listen (MatekbdKeyboardConfig * kbd_config)
652{
653#if GLIB_CHECK_VERSION(2,62,0)(2 > (2) || (2 == (2) && 76 > (62)) || (2 == (2
) && 76 == (62) && 5 >= (0)))
654 g_clear_signal_handler (&kbd_config->config_listener_id,do { gpointer const _instance = (kbd_config->settings); gulong
*const _handler_id_ptr = (&kbd_config->config_listener_id
); const gulong _handler_id = *_handler_id_ptr; if (_handler_id
> 0) { *_handler_id_ptr = 0; g_signal_handler_disconnect (
_instance, _handler_id); } } while (0)
655 kbd_config->settings)do { gpointer const _instance = (kbd_config->settings); gulong
*const _handler_id_ptr = (&kbd_config->config_listener_id
); const gulong _handler_id = *_handler_id_ptr; if (_handler_id
> 0) { *_handler_id_ptr = 0; g_signal_handler_disconnect (
_instance, _handler_id); } } while (0)
;
656#else
657 if (kbd_config->config_listener_id != 0) {
658 g_signal_handler_disconnect (kbd_config->settings,
659 kbd_config->config_listener_id);
660 kbd_config->config_listener_id = 0;
661 }
662#endif
663}
664
665gboolean
666matekbd_keyboard_config_get_descriptions (XklConfigRegistry * config_registry,
667 const gchar * name,
668 gchar ** layout_short_descr,
669 gchar ** layout_descr,
670 gchar ** variant_short_descr,
671 gchar ** variant_descr)
672{
673 char *layout_name = NULL((void*)0), *variant_name = NULL((void*)0);
674 if (!matekbd_keyboard_config_split_items
675 (name, &layout_name, &variant_name))
676 return FALSE(0);
677 return matekbd_keyboard_config_get_lv_descriptions (config_registry,
678 layout_name,
679 variant_name,
680 layout_short_descr,
681 layout_descr,
682 variant_short_descr,
683 variant_descr);
684}
685
686const gchar *
687matekbd_keyboard_config_format_full_layout (const gchar * layout_descr,
688 const gchar * variant_descr)
689{
690 static gchar full_descr[XKL_MAX_CI_DESC_LENGTH192 * 2];
691 if (variant_descr == NULL((void*)0) || variant_descr[0] == 0)
692 g_snprintf (full_descr, sizeof (full_descr), "%s",
693 layout_descr);
694 else
695 g_snprintf (full_descr, sizeof (full_descr), "%s %s",
696 layout_descr, variant_descr);
697 return full_descr;
698}
699
700gchar *
701matekbd_keyboard_config_to_string (const MatekbdKeyboardConfig * config)
702{
703 gchar *layouts = NULL((void*)0), *options = NULL((void*)0);
704 GString *buffer = g_string_new (NULL((void*)0));
705
706 gchar **iter;
707 gint count;
708 gchar *result;
709
710 if (config->layouts_variants) {
711 /* g_slist_length is "expensive", so we determinate the length on the fly */
712 for (iter = config->layouts_variants, count = 0; *iter;
713 iter++, ++count) {
714 if (buffer->len)
715 g_string_append (buffer, " ")(__builtin_constant_p (" ") ? __extension__ ({ const char * const
__val = (" "); g_string_append_len_inline (buffer, __val, (__builtin_expect
(__extension__ ({ int _g_boolean_var_14; if (__val != ((void
*)0)) _g_boolean_var_14 = 1; else _g_boolean_var_14 = 0; _g_boolean_var_14
; }), 1)) ? (gssize) strlen (((__val) + !(__val))) : (gssize)
-1); }) : g_string_append_len_inline (buffer, " ", (gssize) -
1))
;
716
717 g_string_append (buffer, *iter)(__builtin_constant_p (*iter) ? __extension__ ({ const char *
const __val = (*iter); g_string_append_len_inline (buffer, __val
, (__builtin_expect (__extension__ ({ int _g_boolean_var_15; if
(__val != ((void*)0)) _g_boolean_var_15 = 1; else _g_boolean_var_15
= 0; _g_boolean_var_15; }), 1)) ? (gssize) strlen (((__val) +
!(__val))) : (gssize) -1); }) : g_string_append_len_inline (
buffer, *iter, (gssize) -1))
;
718 }
719
720 /* Translators: The count is related to the number of options. The %s
721 * format specifier should not be modified, left "as is". */
722 layouts =
723 g_strdup_printf (ngettextdcngettext (((void*)0), "layout \"%s\"", "layouts \"%s\"", count
, 5)
724 ("layout \"%s\"", "layouts \"%s\"",dcngettext (((void*)0), "layout \"%s\"", "layouts \"%s\"", count
, 5)
725 count)dcngettext (((void*)0), "layout \"%s\"", "layouts \"%s\"", count
, 5)
, buffer->str);
726 g_string_truncate (buffer, 0)g_string_truncate_inline (buffer, 0);
727 }
728 if (config->options) {
729 /* g_slist_length is "expensive", so we determinate the length on the fly */
730 for (iter = config->options, count = 0; *iter;
731 iter++, ++count) {
732 if (buffer->len)
733 g_string_append (buffer, " ")(__builtin_constant_p (" ") ? __extension__ ({ const char * const
__val = (" "); g_string_append_len_inline (buffer, __val, (__builtin_expect
(__extension__ ({ int _g_boolean_var_16; if (__val != ((void
*)0)) _g_boolean_var_16 = 1; else _g_boolean_var_16 = 0; _g_boolean_var_16
; }), 1)) ? (gssize) strlen (((__val) + !(__val))) : (gssize)
-1); }) : g_string_append_len_inline (buffer, " ", (gssize) -
1))
;
734
735 g_string_append (buffer, *iter)(__builtin_constant_p (*iter) ? __extension__ ({ const char *
const __val = (*iter); g_string_append_len_inline (buffer, __val
, (__builtin_expect (__extension__ ({ int _g_boolean_var_17; if
(__val != ((void*)0)) _g_boolean_var_17 = 1; else _g_boolean_var_17
= 0; _g_boolean_var_17; }), 1)) ? (gssize) strlen (((__val) +
!(__val))) : (gssize) -1); }) : g_string_append_len_inline (
buffer, *iter, (gssize) -1))
;
736 }
737
738 /* Translators: The count is related to the number of options. The %s
739 * format specifier should not be modified, left "as is". */
740 options =
741 g_strdup_printf (ngettextdcngettext (((void*)0), "option \"%s\"", "options \"%s\"", count
, 5)
742 ("option \"%s\"", "options \"%s\"",dcngettext (((void*)0), "option \"%s\"", "options \"%s\"", count
, 5)
743 count)dcngettext (((void*)0), "option \"%s\"", "options \"%s\"", count
, 5)
, buffer->str);
744 g_string_truncate (buffer, 0)g_string_truncate_inline (buffer, 0);
745 }
746
747 g_string_free (buffer, TRUE)(__builtin_constant_p ((!(0))) ? (((!(0))) ? (g_string_free) (
(buffer), ((!(0)))) : g_string_free_and_steal (buffer)) : (g_string_free
) ((buffer), ((!(0)))))
;
748
749 result =
750 g_strdup_printf (_("model \"%s\", %s and %s")((char *) g_dgettext ("libmatekbd", "model \"%s\", %s and %s"
))
, config->model,
751 layouts ? layouts : _("no layout")((char *) g_dgettext ("libmatekbd", "no layout")),
752 options ? options : _("no options")((char *) g_dgettext ("libmatekbd", "no options")));
753
754 g_free (options);
755 g_free (layouts);
756
757 return result;
758}
759
760/**
761 * matekbd_keyboard_config_add_default_switch_option_if_necessary:
762 *
763 * Returns: (transfer full) (array zero-terminated=1): List of options
764 */
765gchar **
766matekbd_keyboard_config_add_default_switch_option_if_necessary (gchar **
767 layouts_list,
768 gchar **
769 options_list,
770 gboolean *was_appended)
771{
772 *was_appended = FALSE(0);
773 if (g_strv_length (layouts_list) >= 2) {
774 gboolean any_switcher = False0;
775 if (*options_list != NULL((void*)0)) {
776 gchar **option = options_list;
777 while (*option != NULL((void*)0)) {
778 char *g, *o;
779 if (matekbd_keyboard_config_split_items
780 (*option, &g, &o)) {
781 if (!g_ascii_strcasecmp
782 (g, GROUP_SWITCHERS_GROUP"grp")) {
783 any_switcher = True1;
784 break;
785 }
786 }
787 option++;
788 }
789 }
790 if (!any_switcher) {
791 const gchar *id =
792 matekbd_keyboard_config_merge_items
793 (GROUP_SWITCHERS_GROUP"grp",
794 DEFAULT_GROUP_SWITCH"grp:shift_caps_toggle");
795 options_list =
796 matekbd_strv_append (options_list, g_strdup (id)g_strdup_inline (id));
797 *was_appended = TRUE(!(0));
798 }
799 }
800 return options_list;
801}
diff --git a/2023-10-28-125744-5647-1@b00c769a5abd_travis-test/report-fb6164.html b/2023-10-28-125744-5647-1@b00c769a5abd_travis-test/report-fb6164.html new file mode 100644 index 0000000..93b1920 --- /dev/null +++ b/2023-10-28-125744-5647-1@b00c769a5abd_travis-test/report-fb6164.html @@ -0,0 +1,1408 @@ + + + +/rootdir/libmatekbd/tmp-introspecthdajf3ov/Matekbd-1.0.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:libmatekbd/tmp-introspecthdajf3ov/Matekbd-1.0.c
Warning:line 181, column 11
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name Matekbd-1.0.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/libmatekbd -resource-dir /usr/lib64/clang/16 -D G_LOG_DOMAIN="MateKbdIndicator" -D DATADIR="/usr/local/share" -D SYSCONFDIR="/usr/local/etc" -D LIBDIR="/usr/local/lib" -I /usr/include/atk-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /rootdir -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libxml2 -I /rootdir/intl -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-deprecated-declarations -fdebug-compilation-dir=/rootdir/libmatekbd -ferror-limit 19 -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-28-125744-5647-1 -x c /rootdir/libmatekbd/tmp-introspecthdajf3ov/Matekbd-1.0.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* This file is generated, do not edit */
2
3#undef GLIB_VERSION_MIN_REQUIRED((((2) << 16 | (76) << 8)))
4#undef GLIB_VERSION_MAX_ALLOWED((((2) << 16 | (76) << 8)))
5
6#include <glib.h>
7#include <string.h>
8#include <stdlib.h>
9
10/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
11 * GObject introspection: Dump introspection data
12 *
13 * Copyright (C) 2008 Colin Walters <walters@verbum.org>
14 *
15 * This library is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU Lesser General Public
17 * License as published by the Free Software Foundation; either
18 * version 2 of the License, or (at your option) any later version.
19 *
20 * This library is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 * Lesser General Public License for more details.
24 *
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with this library; if not, write to the
27 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
28 * Boston, MA 02111-1307, USA.
29 */
30
31#include <stdlib.h>
32
33#include <glib.h>
34#include <glib-object.h>
35#include <gio/gio.h>
36
37/* This file is both compiled into libgirepository.so, and installed
38 * on the filesystem. But for the dumper, we want to avoid linking
39 * to libgirepository; see
40 * https://bugzilla.gnome.org/show_bug.cgi?id=630342
41 */
42#ifdef G_IREPOSITORY_COMPILATION
43#include "config.h"
44#include "girepository.h"
45#endif
46
47#include <string.h>
48
49static void
50escaped_printf (GOutputStream *out, const char *fmt, ...) G_GNUC_PRINTF (2, 3)__attribute__((__format__ (__printf__, 2, 3)));
51
52static void
53escaped_printf (GOutputStream *out, const char *fmt, ...)
54{
55 char *str;
56 va_list args;
57 gsize written;
58 GError *error = NULL((void*)0);
59
60 va_start (args, fmt)__builtin_va_start(args, fmt);
61
62 str = g_markup_vprintf_escaped (fmt, args);
63 if (!g_output_stream_write_all (out, str, strlen (str), &written, NULL((void*)0), &error))
64 {
65 g_critical ("failed to write to iochannel: %s", error->message);
66 g_clear_error (&error);
67 }
68 g_free (str);
69
70 va_end (args)__builtin_va_end(args);
71}
72
73static void
74goutput_write (GOutputStream *out, const char *str)
75{
76 gsize written;
77 GError *error = NULL((void*)0);
78 if (!g_output_stream_write_all (out, str, strlen (str), &written, NULL((void*)0), &error))
79 {
80 g_critical ("failed to write to iochannel: %s", error->message);
81 g_clear_error (&error);
82 }
83}
84
85typedef GType (*GetTypeFunc)(void);
86typedef GQuark (*ErrorQuarkFunc)(void);
87
88static GType
89invoke_get_type (GModule *self, const char *symbol, GError **error)
90{
91 GetTypeFunc sym;
92 GType ret;
93
94 if (!g_module_symbol (self, symbol, (void**)&sym))
95 {
96 g_set_error (error,
97 G_IO_ERRORg_io_error_quark(),
98 G_IO_ERROR_FAILED,
99 "Failed to find symbol '%s'", symbol);
100 return G_TYPE_INVALID((GType) ((0) << (2)));
101 }
102
103 ret = sym ();
104 if (ret == G_TYPE_INVALID((GType) ((0) << (2))))
105 {
106 g_set_error (error,
107 G_IO_ERRORg_io_error_quark(),
108 G_IO_ERROR_FAILED,
109 "Function '%s' returned G_TYPE_INVALID", symbol);
110 }
111 return ret;
112}
113
114static GQuark
115invoke_error_quark (GModule *self, const char *symbol, GError **error)
116{
117 ErrorQuarkFunc sym;
118
119 if (!g_module_symbol (self, symbol, (void**)&sym))
120 {
121 g_set_error (error,
122 G_IO_ERRORg_io_error_quark(),
123 G_IO_ERROR_FAILED,
124 "Failed to find symbol '%s'", symbol);
125 return G_TYPE_INVALID((GType) ((0) << (2)));
126 }
127
128 return sym ();
129}
130
131static char *
132value_transform_to_string (const GValue *value)
133{
134 GValue tmp = G_VALUE_INIT{ 0, { { 0 } } };
135 char *s = NULL((void*)0);
136
137 g_value_init (&tmp, G_TYPE_STRING((GType) ((16) << (2))));
138
139 if (g_value_transform (value, &tmp))
140 {
141 const char *str = g_value_get_string (&tmp);
142
143 if (str != NULL((void*)0))
144 s = g_strescape (str, NULL((void*)0));
145 }
146
147 g_value_unset (&tmp);
148
149 return s;
150}
151
152/* A simpler version of g_strdup_value_contents(), but with stable
153 * output and less complex semantics
154 */
155static char *
156value_to_string (const GValue *value)
157{
158 if (value == NULL((void*)0))
159 return NULL((void*)0);
160
161 if (G_VALUE_HOLDS_STRING (value)(((__extension__ ({ const GValue *__val = (const GValue*) ((value
)); GType __t = (((GType) ((16) << (2)))); gboolean __r
; if (!__val) __r = (0); else if (__val->g_type == __t) __r
= (!(0)); else __r = g_type_check_value_holds (__val, __t); __r
; }))))
)
162 {
163 const char *s = g_value_get_string (value);
164
165 if (s == NULL((void*)0))
166 return g_strdup ("NULL")g_strdup_inline ("NULL");
167
168 return g_strescape (s, NULL((void*)0));
169 }
170 else
171 {
172 GType value_type = G_VALUE_TYPE (value)(((GValue*) (value))->g_type);
173
174 switch (G_TYPE_FUNDAMENTAL (value_type)(g_type_fundamental (value_type)))
175 {
176 case G_TYPE_BOXED((GType) ((18) << (2))):
177 if (g_value_get_boxed (value) == NULL((void*)0))
178 return NULL((void*)0);
179 else
180 return value_transform_to_string (value);
181 break;
This statement is never executed
182
183 case G_TYPE_OBJECT((GType) ((20) << (2))):
184 if (g_value_get_object (value) == NULL((void*)0))
185 return NULL((void*)0);
186 else
187 return value_transform_to_string (value);
188 break;
189
190 case G_TYPE_POINTER((GType) ((17) << (2))):
191 return NULL((void*)0);
192
193 default:
194 return value_transform_to_string (value);
195 }
196 }
197
198 return NULL((void*)0);
199}
200
201static void
202dump_properties (GType type, GOutputStream *out)
203{
204 guint i;
205 guint n_properties;
206 GParamSpec **props;
207
208 if (G_TYPE_FUNDAMENTAL (type)(g_type_fundamental (type)) == G_TYPE_OBJECT((GType) ((20) << (2))))
209 {
210 GObjectClass *klass;
211 klass = g_type_class_ref (type);
212 props = g_object_class_list_properties (klass, &n_properties);
213 }
214 else
215 {
216 void *klass;
217 klass = g_type_default_interface_ref (type);
218 props = g_object_interface_list_properties (klass, &n_properties);
219 }
220
221 for (i = 0; i < n_properties; i++)
222 {
223 GParamSpec *prop;
224
225 prop = props[i];
226 if (prop->owner_type != type)
227 continue;
228
229 const GValue *v = g_param_spec_get_default_value (prop);
230 char *default_value = value_to_string (v);
231
232 if (v != NULL((void*)0) && default_value != NULL((void*)0))
233 {
234 escaped_printf (out, " <property name=\"%s\" type=\"%s\" flags=\"%d\" default-value=\"%s\"/>\n",
235 prop->name,
236 g_type_name (prop->value_type),
237 prop->flags,
238 default_value);
239 }
240 else
241 {
242 escaped_printf (out, " <property name=\"%s\" type=\"%s\" flags=\"%d\"/>\n",
243 prop->name,
244 g_type_name (prop->value_type),
245 prop->flags);
246 }
247
248 g_free (default_value);
249 }
250
251 g_free (props);
252}
253
254static void
255dump_signals (GType type, GOutputStream *out)
256{
257 guint i;
258 guint n_sigs;
259 guint *sig_ids;
260
261 sig_ids = g_signal_list_ids (type, &n_sigs);
262 for (i = 0; i < n_sigs; i++)
263 {
264 guint sigid;
265 GSignalQuery query;
266 guint j;
267
268 sigid = sig_ids[i];
269 g_signal_query (sigid, &query);
270
271 escaped_printf (out, " <signal name=\"%s\" return=\"%s\"",
272 query.signal_name, g_type_name (query.return_type));
273
274 if (query.signal_flags & G_SIGNAL_RUN_FIRST)
275 escaped_printf (out, " when=\"first\"");
276 else if (query.signal_flags & G_SIGNAL_RUN_LAST)
277 escaped_printf (out, " when=\"last\"");
278 else if (query.signal_flags & G_SIGNAL_RUN_CLEANUP)
279 escaped_printf (out, " when=\"cleanup\"");
280#if GLIB_CHECK_VERSION(2, 29, 15)(2 > (2) || (2 == (2) && 76 > (29)) || (2 == (2
) && 76 == (29) && 5 >= (15)))
281 else if (query.signal_flags & G_SIGNAL_MUST_COLLECT)
282 escaped_printf (out, " when=\"must-collect\"");
283#endif
284 if (query.signal_flags & G_SIGNAL_NO_RECURSE)
285 escaped_printf (out, " no-recurse=\"1\"");
286
287 if (query.signal_flags & G_SIGNAL_DETAILED)
288 escaped_printf (out, " detailed=\"1\"");
289
290 if (query.signal_flags & G_SIGNAL_ACTION)
291 escaped_printf (out, " action=\"1\"");
292
293 if (query.signal_flags & G_SIGNAL_NO_HOOKS)
294 escaped_printf (out, " no-hooks=\"1\"");
295
296 goutput_write (out, ">\n");
297
298 for (j = 0; j < query.n_params; j++)
299 {
300 escaped_printf (out, " <param type=\"%s\"/>\n",
301 g_type_name (query.param_types[j]));
302 }
303 goutput_write (out, " </signal>\n");
304 }
305 g_free (sig_ids);
306}
307
308static void
309dump_object_type (GType type, const char *symbol, GOutputStream *out)
310{
311 guint n_interfaces;
312 guint i;
313 GType *interfaces;
314
315 escaped_printf (out, " <class name=\"%s\" get-type=\"%s\"",
316 g_type_name (type), symbol);
317 if (type != G_TYPE_OBJECT((GType) ((20) << (2))))
318 {
319 GString *parent_str;
320 GType parent;
321 gboolean first = TRUE(!(0));
322
323 parent = g_type_parent (type);
324 parent_str = g_string_new ("");
325 while (parent != G_TYPE_INVALID((GType) ((0) << (2))))
326 {
327 if (first)
328 first = FALSE(0);
329 else
330 g_string_append_c (parent_str, ',')g_string_append_c_inline (parent_str, ',');
331 g_string_append (parent_str, g_type_name (parent))(__builtin_constant_p (g_type_name (parent)) ? __extension__ (
{ const char * const __val = (g_type_name (parent)); g_string_append_len_inline
(parent_str, __val, (__builtin_expect (__extension__ ({ int _g_boolean_var_13
; if (__val != ((void*)0)) _g_boolean_var_13 = 1; else _g_boolean_var_13
= 0; _g_boolean_var_13; }), 1)) ? (gssize) strlen (((__val) +
!(__val))) : (gssize) -1); }) : g_string_append_len_inline (
parent_str, g_type_name (parent), (gssize) -1))
;
332 parent = g_type_parent (parent);
333 }
334
335 escaped_printf (out, " parents=\"%s\"", parent_str->str);
336
337 g_string_free (parent_str, TRUE)(__builtin_constant_p ((!(0))) ? (((!(0))) ? (g_string_free) (
(parent_str), ((!(0)))) : g_string_free_and_steal (parent_str
)) : (g_string_free) ((parent_str), ((!(0)))))
;
338 }
339
340 if (G_TYPE_IS_ABSTRACT (type)(g_type_test_flags ((type), G_TYPE_FLAG_ABSTRACT)))
341 escaped_printf (out, " abstract=\"1\"");
342
343#if GLIB_CHECK_VERSION (2, 70, 0)(2 > (2) || (2 == (2) && 76 > (70)) || (2 == (2
) && 76 == (70) && 5 >= (0)))
344 if (G_TYPE_IS_FINAL (type)(g_type_test_flags ((type), G_TYPE_FLAG_FINAL)))
345 escaped_printf (out, " final=\"1\"");
346#endif
347
348 goutput_write (out, ">\n");
349
350 interfaces = g_type_interfaces (type, &n_interfaces);
351 for (i = 0; i < n_interfaces; i++)
352 {
353 GType itype = interfaces[i];
354 escaped_printf (out, " <implements name=\"%s\"/>\n",
355 g_type_name (itype));
356 }
357 g_free (interfaces);
358
359 dump_properties (type, out);
360 dump_signals (type, out);
361 goutput_write (out, " </class>\n");
362}
363
364static void
365dump_interface_type (GType type, const char *symbol, GOutputStream *out)
366{
367 guint n_interfaces;
368 guint i;
369 GType *interfaces;
370
371 escaped_printf (out, " <interface name=\"%s\" get-type=\"%s\">\n",
372 g_type_name (type), symbol);
373
374 interfaces = g_type_interface_prerequisites (type, &n_interfaces);
375 for (i = 0; i < n_interfaces; i++)
376 {
377 GType itype = interfaces[i];
378 if (itype == G_TYPE_OBJECT((GType) ((20) << (2))))
379 {
380 /* Treat this as implicit for now; in theory GInterfaces are
381 * supported on things like GstMiniObject, but right now
382 * the introspection system only supports GObject.
383 * http://bugzilla.gnome.org/show_bug.cgi?id=559706
384 */
385 continue;
386 }
387 escaped_printf (out, " <prerequisite name=\"%s\"/>\n",
388 g_type_name (itype));
389 }
390 g_free (interfaces);
391
392 dump_properties (type, out);
393 dump_signals (type, out);
394 goutput_write (out, " </interface>\n");
395}
396
397static void
398dump_boxed_type (GType type, const char *symbol, GOutputStream *out)
399{
400 escaped_printf (out, " <boxed name=\"%s\" get-type=\"%s\"/>\n",
401 g_type_name (type), symbol);
402}
403
404static void
405dump_flags_type (GType type, const char *symbol, GOutputStream *out)
406{
407 guint i;
408 GFlagsClass *klass;
409
410 klass = g_type_class_ref (type);
411 escaped_printf (out, " <flags name=\"%s\" get-type=\"%s\">\n",
412 g_type_name (type), symbol);
413
414 for (i = 0; i < klass->n_values; i++)
415 {
416 GFlagsValue *value = &(klass->values[i]);
417
418 escaped_printf (out, " <member name=\"%s\" nick=\"%s\" value=\"%u\"/>\n",
419 value->value_name, value->value_nick, value->value);
420 }
421 goutput_write (out, " </flags>\n");
422}
423
424static void
425dump_enum_type (GType type, const char *symbol, GOutputStream *out)
426{
427 guint i;
428 GEnumClass *klass;
429
430 klass = g_type_class_ref (type);
431 escaped_printf (out, " <enum name=\"%s\" get-type=\"%s\">\n",
432 g_type_name (type), symbol);
433
434 for (i = 0; i < klass->n_values; i++)
435 {
436 GEnumValue *value = &(klass->values[i]);
437
438 escaped_printf (out, " <member name=\"%s\" nick=\"%s\" value=\"%d\"/>\n",
439 value->value_name, value->value_nick, value->value);
440 }
441 goutput_write (out, " </enum>");
442}
443
444static void
445dump_fundamental_type (GType type, const char *symbol, GOutputStream *out)
446{
447 guint n_interfaces;
448 guint i;
449 GType *interfaces;
450 GString *parent_str;
451 GType parent;
452 gboolean first = TRUE(!(0));
453
454
455 escaped_printf (out, " <fundamental name=\"%s\" get-type=\"%s\"",
456 g_type_name (type), symbol);
457
458 if (G_TYPE_IS_ABSTRACT (type)(g_type_test_flags ((type), G_TYPE_FLAG_ABSTRACT)))
459 escaped_printf (out, " abstract=\"1\"");
460
461#if GLIB_CHECK_VERSION (2, 70, 0)(2 > (2) || (2 == (2) && 76 > (70)) || (2 == (2
) && 76 == (70) && 5 >= (0)))
462 if (G_TYPE_IS_FINAL (type)(g_type_test_flags ((type), G_TYPE_FLAG_FINAL)))
463 escaped_printf (out, " final=\"1\"");
464#endif
465
466 if (G_TYPE_IS_INSTANTIATABLE (type)(g_type_test_flags ((type), G_TYPE_FLAG_INSTANTIATABLE)))
467 escaped_printf (out, " instantiatable=\"1\"");
468
469 parent = g_type_parent (type);
470 parent_str = g_string_new ("");
471 while (parent != G_TYPE_INVALID((GType) ((0) << (2))))
472 {
473 if (first)
474 first = FALSE(0);
475 else
476 g_string_append_c (parent_str, ',')g_string_append_c_inline (parent_str, ',');
477 if (!g_type_name (parent))
478 break;
479 g_string_append (parent_str, g_type_name (parent))(__builtin_constant_p (g_type_name (parent)) ? __extension__ (
{ const char * const __val = (g_type_name (parent)); g_string_append_len_inline
(parent_str, __val, (__builtin_expect (__extension__ ({ int _g_boolean_var_14
; if (__val != ((void*)0)) _g_boolean_var_14 = 1; else _g_boolean_var_14
= 0; _g_boolean_var_14; }), 1)) ? (gssize) strlen (((__val) +
!(__val))) : (gssize) -1); }) : g_string_append_len_inline (
parent_str, g_type_name (parent), (gssize) -1))
;
480 parent = g_type_parent (parent);
481 }
482
483 if (parent_str->len > 0)
484 escaped_printf (out, " parents=\"%s\"", parent_str->str);
485 g_string_free (parent_str, TRUE)(__builtin_constant_p ((!(0))) ? (((!(0))) ? (g_string_free) (
(parent_str), ((!(0)))) : g_string_free_and_steal (parent_str
)) : (g_string_free) ((parent_str), ((!(0)))))
;
486
487 goutput_write (out, ">\n");
488
489 interfaces = g_type_interfaces (type, &n_interfaces);
490 for (i = 0; i < n_interfaces; i++)
491 {
492 GType itype = interfaces[i];
493 escaped_printf (out, " <implements name=\"%s\"/>\n",
494 g_type_name (itype));
495 }
496 g_free (interfaces);
497 goutput_write (out, " </fundamental>\n");
498}
499
500static void
501dump_type (GType type, const char *symbol, GOutputStream *out)
502{
503 switch (g_type_fundamental (type))
504 {
505 case G_TYPE_OBJECT((GType) ((20) << (2))):
506 dump_object_type (type, symbol, out);
507 break;
508 case G_TYPE_INTERFACE((GType) ((2) << (2))):
509 dump_interface_type (type, symbol, out);
510 break;
511 case G_TYPE_BOXED((GType) ((18) << (2))):
512 dump_boxed_type (type, symbol, out);
513 break;
514 case G_TYPE_FLAGS((GType) ((13) << (2))):
515 dump_flags_type (type, symbol, out);
516 break;
517 case G_TYPE_ENUM((GType) ((12) << (2))):
518 dump_enum_type (type, symbol, out);
519 break;
520 case G_TYPE_POINTER((GType) ((17) << (2))):
521 /* GValue, etc. Just skip them. */
522 break;
523 default:
524 dump_fundamental_type (type, symbol, out);
525 break;
526 }
527}
528
529static void
530dump_error_quark (GQuark quark, const char *symbol, GOutputStream *out)
531{
532 escaped_printf (out, " <error-quark function=\"%s\" domain=\"%s\"/>\n",
533 symbol, g_quark_to_string (quark));
534}
535
536/**
537 * g_irepository_dump:
538 * @arg: Comma-separated pair of input and output filenames
539 * @error: a %GError
540 *
541 * Argument specified is a comma-separated pair of filenames; i.e. of
542 * the form "input.txt,output.xml". The input file should be a
543 * UTF-8 Unix-line-ending text file, with each line containing either
544 * "get-type:" followed by the name of a GType _get_type function, or
545 * "error-quark:" followed by the name of an error quark function. No
546 * extra whitespace is allowed.
547 *
548 * The output file should already exist, but be empty. This function will
549 * overwrite its contents.
550 *
551 * Returns: %TRUE on success, %FALSE on error
552 */
553#ifndef G_IREPOSITORY_COMPILATION
554static gboolean
555dump_irepository (const char *arg, GError **error) G_GNUC_UNUSED__attribute__ ((__unused__));
556static gboolean
557dump_irepository (const char *arg, GError **error)
558#else
559gboolean
560g_irepository_dump (const char *arg, GError **error)
561#endif
562{
563 GHashTable *output_types;
564 char **args;
565 GFile *input_file;
566 GFile *output_file;
567 GFileInputStream *input;
568 GFileOutputStream *output;
569 GDataInputStream *in;
570 GModule *self;
571 gboolean caught_error = FALSE(0);
572
573 self = g_module_open (NULL((void*)0), 0);
574 if (!self)
575 {
576 g_set_error (error,
577 G_IO_ERRORg_io_error_quark(),
578 G_IO_ERROR_FAILED,
579 "failed to open self: %s",
580 g_module_error ());
581 return FALSE(0);
582 }
583
584 args = g_strsplit (arg, ",", 2);
585
586 input_file = g_file_new_for_path (args[0]);
587 output_file = g_file_new_for_path (args[1]);
588
589 g_strfreev (args);
590
591 input = g_file_read (input_file, NULL((void*)0), error);
592 g_object_unref (input_file);
593
594 if (input == NULL((void*)0))
595 {
596 g_object_unref (output_file);
597 return FALSE(0);
598 }
599
600 output = g_file_replace (output_file, NULL((void*)0), FALSE(0), 0, NULL((void*)0), error);
601 g_object_unref (output_file);
602
603 if (output == NULL((void*)0))
604 {
605 g_input_stream_close (G_INPUT_STREAM (input)((((GInputStream*) (void *) ((input))))), NULL((void*)0), NULL((void*)0));
606 return FALSE(0);
607 }
608
609 goutput_write (G_OUTPUT_STREAM (output)((((GOutputStream*) (void *) ((output))))), "<?xml version=\"1.0\"?>\n");
610 goutput_write (G_OUTPUT_STREAM (output)((((GOutputStream*) (void *) ((output))))), "<dump>\n");
611
612 output_types = g_hash_table_new (NULL((void*)0), NULL((void*)0));
613
614 in = g_data_input_stream_new (G_INPUT_STREAM (input)((((GInputStream*) (void *) ((input))))));
615 g_object_unref (input);
616
617 while (TRUE(!(0)))
618 {
619 gsize len;
620 char *line = g_data_input_stream_read_line (in, &len, NULL((void*)0), NULL((void*)0));
621 const char *function;
622
623 if (line == NULL((void*)0) || *line == '\0')
624 {
625 g_free (line);
626 break;
627 }
628
629 g_strchomp (line);
630
631 if (strncmp (line, "get-type:", strlen ("get-type:")) == 0)
632 {
633 GType type;
634
635 function = line + strlen ("get-type:");
636
637 type = invoke_get_type (self, function, error);
638
639 if (type == G_TYPE_INVALID((GType) ((0) << (2))))
640 {
641 g_printerr ("Invalid GType function: '%s'\n", function);
642 caught_error = TRUE(!(0));
643 g_free (line);
644 break;
645 }
646
647 if (g_hash_table_lookup (output_types, (gpointer) type))
648 goto next;
649 g_hash_table_insert (output_types, (gpointer) type, (gpointer) type);
650
651 dump_type (type, function, G_OUTPUT_STREAM (output)((((GOutputStream*) (void *) ((output))))));
652 }
653 else if (strncmp (line, "error-quark:", strlen ("error-quark:")) == 0)
654 {
655 GQuark quark;
656 function = line + strlen ("error-quark:");
657 quark = invoke_error_quark (self, function, error);
658
659 if (quark == 0)
660 {
661 g_printerr ("Invalid error quark function: '%s'\n", function);
662 caught_error = TRUE(!(0));
663 g_free (line);
664 break;
665 }
666
667 dump_error_quark (quark, function, G_OUTPUT_STREAM (output)((((GOutputStream*) (void *) ((output))))));
668 }
669
670
671 next:
672 g_free (line);
673 }
674
675 g_hash_table_destroy (output_types);
676
677 goutput_write (G_OUTPUT_STREAM (output)((((GOutputStream*) (void *) ((output))))), "</dump>\n");
678
679 {
680 GError **ioerror;
681 /* Avoid overwriting an earlier set error */
682 if (caught_error)
683 ioerror = NULL((void*)0);
684 else
685 ioerror = error;
686 if (!g_input_stream_close (G_INPUT_STREAM (in)((((GInputStream*) (void *) ((in))))), NULL((void*)0), ioerror))
687 return FALSE(0);
688 if (!g_output_stream_close (G_OUTPUT_STREAM (output)((((GOutputStream*) (void *) ((output))))), NULL((void*)0), ioerror))
689 return FALSE(0);
690 }
691
692 return !caught_error;
693}
694
695
696int
697main(int argc, char **argv)
698{
699 GError *error = NULL((void*)0);
700 const char *introspect_dump_prefix = "--introspect-dump=";
701
702#if !GLIB_CHECK_VERSION(2,35,0)(2 > (2) || (2 == (2) && 76 > (35)) || (2 == (2
) && 76 == (35) && 5 >= (0)))
703 g_type_init ();
704#endif
705
706
707
708 if (argc != 2 || !g_str_has_prefix (argv[1], introspect_dump_prefix)(__builtin_constant_p (introspect_dump_prefix)? __extension__
({ const char * const __str = (argv[1]); const char * const __prefix
= (introspect_dump_prefix); gboolean __result = (0); if (__builtin_expect
(__extension__ ({ int _g_boolean_var_15; if (__str == ((void
*)0) || __prefix == ((void*)0)) _g_boolean_var_15 = 1; else _g_boolean_var_15
= 0; _g_boolean_var_15; }), 0)) __result = (g_str_has_prefix
) (__str, __prefix); else { const size_t __str_len = strlen (
((__str) + !(__str))); const size_t __prefix_len = strlen (((
__prefix) + !(__prefix))); if (__str_len >= __prefix_len) __result
= memcmp (((__str) + !(__str)), ((__prefix) + !(__prefix)), __prefix_len
) == 0; } __result; }) : (g_str_has_prefix) (argv[1], introspect_dump_prefix
) )
)
709 {
710 g_printerr ("Usage: %s --introspect-dump=input,output", argv[0]);
711 exit (1);
712 }
713
714 if (!dump_irepository (argv[1] + strlen(introspect_dump_prefix), &error))
715 {
716 g_printerr ("%s\n", error->message);
717 exit (1);
718 }
719 exit (0);
720}
721extern GType matekbd_indicator_get_type(void);
722extern GType matekbd_status_get_type(void);
723extern GType matekbd_keyboard_drawing_get_type(void);
724G_MODULE_EXPORT__attribute__((visibility("default"))) GType (*GI_GET_TYPE_FUNCS_[])(void) = {
725 matekbd_indicator_get_type,
726 matekbd_status_get_type,
727 matekbd_keyboard_drawing_get_type
728};
diff --git a/2023-10-28-125744-5647-1@b00c769a5abd_travis-test/report-ff92e7.html b/2023-10-28-125744-5647-1@b00c769a5abd_travis-test/report-ff92e7.html new file mode 100644 index 0000000..8a3684c --- /dev/null +++ b/2023-10-28-125744-5647-1@b00c769a5abd_travis-test/report-ff92e7.html @@ -0,0 +1,962 @@ + + + +matekbd-keyboard-drawing-test.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:test/matekbd-keyboard-drawing-test.c
Warning:line 254, column 21
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name matekbd-keyboard-drawing-test.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/test -resource-dir /usr/lib64/clang/16 -D HAVE_CONFIG_H -I . -I .. -I .. -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/at-spi-2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libxml2 -D MATELOCALEDIR="/usr/local/share/locale" -internal-isystem /usr/lib64/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/13/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-unused-parameter -fdebug-compilation-dir=/rootdir/test -ferror-limit 19 -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2023-10-28-125744-5647-1 -x c matekbd-keyboard-drawing-test.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 * Copyright (C) 2006 Sergey V. Udaltsov <svu@gnome.org>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20#if HAVE_CONFIG_H1
21# include <config.h>
22#endif
23
24#include <gtk/gtk.h>
25#include <stdlib.h>
26#include <string.h>
27#include <glib.h>
28#include "libmatekbd/matekbd-keyboard-drawing.h"
29
30static gchar *groups = NULL((void*)0);
31static gchar *levels = NULL((void*)0);
32static gchar *symbols = NULL((void*)0);
33static gchar *keycodes = NULL((void*)0);
34static gchar *geometry = NULL((void*)0);
35
36static gboolean track_config = FALSE(0);
37static gboolean track_modifiers = FALSE(0);
38static gboolean program_version = FALSE(0);
39
40static const GOptionEntry options[] = {
41 {"groups", '\0', 0, G_OPTION_ARG_STRING, &groups,
42 "Keyboard groups to display, from 1-4. Up to four groups only may be "
43 "displayed. Examples: --groups=3 or --groups=1,2,1,2",
44 "group1[,group2[,group3[,group4]]]"},
45 {"levels", '\0', 0, G_OPTION_ARG_STRING, &levels,
46 "Keyboard shift levels to display, from 1-64. Up to four shift levels "
47 "only may be displayed. Examples: --levels=3 or --levels=1,2,1,2",
48 "level1[,level2[,level3[,level4]]]"},
49 {"symbols", '\0', 0, G_OPTION_ARG_STRING, &symbols,
50 "Symbols component of the keyboard. If you omit this option, it is "
51 "obtained from the X server; that is, the keyboard that is currently "
52 "configured is drawn. Examples: --symbols=us or "
53 "--symbols=us(pc104)+iso9995-3+group(switch)+ctrl(nocaps)", NULL((void*)0)},
54 {"keycodes", '\0', 0, G_OPTION_ARG_STRING, &keycodes,
55 "Keycodes component of the keyboard. If you omit this option, it is "
56 "obtained from the X server; that is, the keyboard that is currently"
57 " configured is drawn. Examples: --keycodes=xfree86+aliases(qwerty)",
58 NULL((void*)0)},
59 {"geometry", '\0', 0, G_OPTION_ARG_STRING, &geometry,
60 "Geometry xkb component. If you omit this option, it is obtained from the"
61 " X server; that is, the keyboard that is currently configured is drawn. "
62 "Example: --geometry=kinesis", NULL((void*)0)},
63 {"track-modifiers", '\0', 0, G_OPTION_ARG_NONE, &track_modifiers,
64 "Track the current modifiers", NULL((void*)0)},
65 {"track-config", '\0', 0, G_OPTION_ARG_NONE, &track_config,
66 "Track the server XKB configuration", NULL((void*)0)},
67 {"version", '\0', 0, G_OPTION_ARG_NONE, &program_version,
68 "Show current version", NULL((void*)0)},
69 {NULL((void*)0), 0, 0, G_OPTION_ARG_NONE, NULL((void*)0), NULL((void*)0), NULL((void*)0)},
70};
71
72static gboolean
73set_groups (gchar * groups_option,
74 MatekbdKeyboardDrawingGroupLevel * groupLevels)
75{
76 MatekbdKeyboardDrawingGroupLevel *pgl = groupLevels;
77 gint cntr, g;
78
79 groupLevels[0].group =
80 groupLevels[1].group =
81 groupLevels[2].group = groupLevels[3].group = -1;
82
83 if (groups_option == NULL((void*)0))
84 return TRUE(!(0));
85
86 for (cntr = 4; --cntr >= 0;) {
87 if (*groups_option == '\0')
88 return FALSE(0);
89
90 g = *groups_option - '1';
91 if (g < 0 || g >= 4)
92 return FALSE(0);
93
94 pgl->group = g;
95 /* printf ("group %d\n", pgl->group); */
96
97 groups_option++;
98 if (*groups_option == '\0')
99 return TRUE(!(0));
100 if (*groups_option != ',')
101 return FALSE(0);
102
103 groups_option++;
104 pgl++;
105 }
106
107 return TRUE(!(0));
108}
109
110static gboolean
111set_levels (gchar * levels_option,
112 MatekbdKeyboardDrawingGroupLevel * groupLevels)
113{
114 MatekbdKeyboardDrawingGroupLevel *pgl = groupLevels;
115 gint cntr, l;
116 gchar *p;
117
118 groupLevels[0].level =
119 groupLevels[1].level =
120 groupLevels[2].level = groupLevels[3].level = -1;
121
122 if (levels_option == NULL((void*)0))
123 return TRUE(!(0));
124
125 for (cntr = 4; --cntr >= 0;) {
126 if (*levels_option == '\0')
127 return FALSE(0);
128
129 l = (gint) strtol (levels_option, &p, 10) - 1;
130 if (l < 0 || l >= 64)
131 return FALSE(0);
132
133 pgl->level = l;
134 /* printf ("level %d\n", pgl->level); */
135
136 levels_option = p;
137 if (*levels_option == '\0')
138 return TRUE(!(0));
139 if (*levels_option != ',')
140 return FALSE(0);
141
142 levels_option++;
143 pgl++;
144 }
145
146 return TRUE(!(0));
147}
148
149static void
150bad_keycode (MatekbdKeyboardDrawing * drawing, guint keycode)
151{
152 g_warning
153 ("got keycode %u, which is not on your keyboard according to your configuration",
154 keycode);
155}
156
157gint
158main (gint argc, gchar ** argv)
159{
160 GtkWidget *window;
161 GtkWidget *matekbd_keyboard_drawing;
162 GdkScreen *screen;
163 GdkMonitor *monitor;
164 GdkRectangle rect;
165 GOptionContext *context;
166 GError *error = NULL((void*)0);
167
168 MatekbdKeyboardDrawingGroupLevel groupLevels[4] =
169 { {0, 0}, {1, 0}, {0, 1}, {1, 1} };
170 MatekbdKeyboardDrawingGroupLevel *pgroupLevels[4] =
171 { &groupLevels[0], &groupLevels[1], &groupLevels[2],
172 &groupLevels[3]
173 };
174
175 context = g_option_context_new ("kbdraw");
176 g_option_context_add_main_entries (context, options, NULL((void*)0));
177 if (!g_option_context_parse (context, &argc, &argv, &error)) {
178 g_message ("option parsing failed: %s", error->message);
179 g_option_context_free (context);
180 exit (EXIT_FAILURE1);
181 }
182 g_option_context_free (context);
183
184 if (program_version) {
185 g_print ("kbdraw %s\n", VERSION"1.27.1");
186 exit (0);
187 }
188
189 gtk_init (&argc, &argv);
190
191 if (!set_groups (groups, groupLevels)) {
192 g_printerr ("--groups: invalid argument\n");
193 exit (1);
194 }
195
196 if (!set_levels (levels, groupLevels)) {
197 g_printerr ("--levels: invalid argument\n");
198 exit (1);
199 }
200
201 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
202 g_signal_connect (G_OBJECT (window), "destroy",g_signal_connect_data ((((((GObject*) (void *) ((window))))))
, ("destroy"), (((GCallback) (gtk_main_quit))), (((void*)0)),
((void*)0), (GConnectFlags) 0)
203 G_CALLBACK (gtk_main_quit), NULL)g_signal_connect_data ((((((GObject*) (void *) ((window))))))
, ("destroy"), (((GCallback) (gtk_main_quit))), (((void*)0)),
((void*)0), (GConnectFlags) 0)
;
204
205 screen = gtk_window_get_screen (GTK_WINDOW (window)((((GtkWindow*) (void *) ((window))))));
206 monitor = gdk_display_get_monitor_at_point (gdk_screen_get_display (screen), 0, 0);
207 gdk_monitor_get_geometry (monitor, &rect);
208 gtk_window_set_default_size (GTK_WINDOW (window)((((GtkWindow*) (void *) ((window))))),
209 rect.width * 4 / 5,
210 rect.height * 1 / 2);
211
212 gtk_widget_show (window);
213
214 matekbd_keyboard_drawing = matekbd_keyboard_drawing_new ();
215 gtk_widget_show (matekbd_keyboard_drawing);
216 gtk_container_add (GTK_CONTAINER (window)((((GtkContainer*) (void *) ((window))))), matekbd_keyboard_drawing);
217
218 matekbd_keyboard_drawing_set_groups_levels (MATEKBD_KEYBOARD_DRAWING((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
219 (matekbd_keyboard_drawing)((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
,
220 pgroupLevels);
221
222 if (track_modifiers)
223 matekbd_keyboard_drawing_set_track_modifiers
224 (MATEKBD_KEYBOARD_DRAWING (matekbd_keyboard_drawing)((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
, TRUE(!(0)));
225 if (track_config)
226 matekbd_keyboard_drawing_set_track_config
227 (MATEKBD_KEYBOARD_DRAWING (matekbd_keyboard_drawing)((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
, TRUE(!(0)));
228 g_signal_connect (G_OBJECT (matekbd_keyboard_drawing), "bad-keycode",g_signal_connect_data ((((((GObject*) (void *) ((matekbd_keyboard_drawing
)))))), ("bad-keycode"), (((GCallback) (bad_keycode))), (((void
*)0)), ((void*)0), (GConnectFlags) 0)
229 G_CALLBACK (bad_keycode), NULL)g_signal_connect_data ((((((GObject*) (void *) ((matekbd_keyboard_drawing
)))))), ("bad-keycode"), (((GCallback) (bad_keycode))), (((void
*)0)), ((void*)0), (GConnectFlags) 0)
;
230
231 if (symbols || geometry || keycodes) {
232 XkbComponentNamesRec names;
233 gint success;
234
235 memset (&names, '\0', sizeof (names));
236
237 if (symbols)
238 names.symbols = symbols;
239 else
240 names.symbols = (gchar *)
241 matekbd_keyboard_drawing_get_symbols
242 (MATEKBD_KEYBOARD_DRAWING((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
243 (matekbd_keyboard_drawing)((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
);
244
245 if (keycodes)
246 names.keycodes = keycodes;
247 else
248 names.keycodes = (gchar *)
249 matekbd_keyboard_drawing_get_keycodes
250 (MATEKBD_KEYBOARD_DRAWING((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
251 (matekbd_keyboard_drawing)((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
);
252
253 if (geometry)
254 names.geometry = geometry;
This statement is never executed
255 else
256 names.geometry = (gchar *)
257 matekbd_keyboard_drawing_get_geometry
258 (MATEKBD_KEYBOARD_DRAWING((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
259 (matekbd_keyboard_drawing)((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
);
260
261 success =
262 matekbd_keyboard_drawing_set_keyboard
263 (MATEKBD_KEYBOARD_DRAWING (matekbd_keyboard_drawing)((((MatekbdKeyboardDrawing*) (void *) ((matekbd_keyboard_drawing
)))))
,
264 &names);
265 if (!success) {
266 g_printerr
267 ("\nError loading new keyboard description with components:\n\n"
268 " keycodes: %s\n" " types: %s\n"
269 " compat: %s\n" " symbols: %s\n"
270 " geometry: %s\n\n", names.keycodes,
271 names.types, names.compat, names.symbols,
272 names.geometry);
273 exit (1);
274 }
275 }
276
277 gtk_widget_grab_focus (matekbd_keyboard_drawing);
278
279 gtk_main ();
280
281 return 0;
282}
diff --git a/2023-10-28-125744-5647-1@b00c769a5abd_travis-test/scanview.css b/2023-10-28-125744-5647-1@b00c769a5abd_travis-test/scanview.css new file mode 100644 index 0000000..cf8a5a6 --- /dev/null +++ b/2023-10-28-125744-5647-1@b00c769a5abd_travis-test/scanview.css @@ -0,0 +1,62 @@ +body { color:#000000; background-color:#ffffff } +body { font-family: Helvetica, sans-serif; font-size:9pt } +h1 { font-size: 14pt; } +h2 { font-size: 12pt; } +table { font-size:9pt } +table { border-spacing: 0px; border: 1px solid black } +th, table thead { + background-color:#eee; color:#666666; + font-weight: bold; cursor: default; + text-align:center; + font-weight: bold; font-family: Verdana; + white-space:nowrap; +} +.W { font-size:0px } +th, td { padding:5px; padding-left:8px; text-align:left } +td.SUMM_DESC { padding-left:12px } +td.DESC { white-space:pre } +td.Q { text-align:right } +td { text-align:left } +tbody.scrollContent { overflow:auto } + +table.form_group { + background-color: #ccc; + border: 1px solid #333; + padding: 2px; +} + +table.form_inner_group { + background-color: #ccc; + border: 1px solid #333; + padding: 0px; +} + +table.form { + background-color: #999; + border: 1px solid #333; + padding: 2px; +} + +td.form_label { + text-align: right; + vertical-align: top; +} +/* For one line entires */ +td.form_clabel { + text-align: right; + vertical-align: center; +} +td.form_value { + text-align: left; + vertical-align: top; +} +td.form_submit { + text-align: right; + vertical-align: top; +} + +h1.SubmitFail { + color: #f00; +} +h1.SubmitOk { +} diff --git a/2023-10-28-125744-5647-1@b00c769a5abd_travis-test/sorttable.js b/2023-10-28-125744-5647-1@b00c769a5abd_travis-test/sorttable.js new file mode 100644 index 0000000..32faa07 --- /dev/null +++ b/2023-10-28-125744-5647-1@b00c769a5abd_travis-test/sorttable.js @@ -0,0 +1,492 @@ +/* + SortTable + version 2 + 7th April 2007 + Stuart Langridge, http://www.kryogenix.org/code/browser/sorttable/ + + Instructions: + Download this file + Add to your HTML + Add class="sortable" to any table you'd like to make sortable + Click on the headers to sort + + Thanks to many, many people for contributions and suggestions. + Licenced as X11: http://www.kryogenix.org/code/browser/licence.html + This basically means: do what you want with it. +*/ + + +var stIsIE = /*@cc_on!@*/false; + +sorttable = { + init: function() { + // quit if this function has already been called + if (arguments.callee.done) return; + // flag this function so we don't do the same thing twice + arguments.callee.done = true; + // kill the timer + if (_timer) clearInterval(_timer); + + if (!document.createElement || !document.getElementsByTagName) return; + + sorttable.DATE_RE = /^(\d\d?)[\/\.-](\d\d?)[\/\.-]((\d\d)?\d\d)$/; + + forEach(document.getElementsByTagName('table'), function(table) { + if (table.className.search(/\bsortable\b/) != -1) { + sorttable.makeSortable(table); + } + }); + + }, + + makeSortable: function(table) { + if (table.getElementsByTagName('thead').length == 0) { + // table doesn't have a tHead. Since it should have, create one and + // put the first table row in it. + the = document.createElement('thead'); + the.appendChild(table.rows[0]); + table.insertBefore(the,table.firstChild); + } + // Safari doesn't support table.tHead, sigh + if (table.tHead == null) table.tHead = table.getElementsByTagName('thead')[0]; + + if (table.tHead.rows.length != 1) return; // can't cope with two header rows + + // Sorttable v1 put rows with a class of "sortbottom" at the bottom (as + // "total" rows, for example). This is B&R, since what you're supposed + // to do is put them in a tfoot. So, if there are sortbottom rows, + // for backward compatibility, move them to tfoot (creating it if needed). + sortbottomrows = []; + for (var i=0; i5' : ' ▴'; + this.appendChild(sortrevind); + return; + } + if (this.className.search(/\bsorttable_sorted_reverse\b/) != -1) { + // if we're already sorted by this column in reverse, just + // re-reverse the table, which is quicker + sorttable.reverse(this.sorttable_tbody); + this.className = this.className.replace('sorttable_sorted_reverse', + 'sorttable_sorted'); + this.removeChild(document.getElementById('sorttable_sortrevind')); + sortfwdind = document.createElement('span'); + sortfwdind.id = "sorttable_sortfwdind"; + sortfwdind.innerHTML = stIsIE ? ' 6' : ' ▾'; + this.appendChild(sortfwdind); + return; + } + + // remove sorttable_sorted classes + theadrow = this.parentNode; + forEach(theadrow.childNodes, function(cell) { + if (cell.nodeType == 1) { // an element + cell.className = cell.className.replace('sorttable_sorted_reverse',''); + cell.className = cell.className.replace('sorttable_sorted',''); + } + }); + sortfwdind = document.getElementById('sorttable_sortfwdind'); + if (sortfwdind) { sortfwdind.parentNode.removeChild(sortfwdind); } + sortrevind = document.getElementById('sorttable_sortrevind'); + if (sortrevind) { sortrevind.parentNode.removeChild(sortrevind); } + + this.className += ' sorttable_sorted'; + sortfwdind = document.createElement('span'); + sortfwdind.id = "sorttable_sortfwdind"; + sortfwdind.innerHTML = stIsIE ? ' 6' : ' ▾'; + this.appendChild(sortfwdind); + + // build an array to sort. This is a Schwartzian transform thing, + // i.e., we "decorate" each row with the actual sort key, + // sort based on the sort keys, and then put the rows back in order + // which is a lot faster because you only do getInnerText once per row + row_array = []; + col = this.sorttable_columnindex; + rows = this.sorttable_tbody.rows; + for (var j=0; j 12) { + // definitely dd/mm + return sorttable.sort_ddmm; + } else if (second > 12) { + return sorttable.sort_mmdd; + } else { + // looks like a date, but we can't tell which, so assume + // that it's dd/mm (English imperialism!) and keep looking + sortfn = sorttable.sort_ddmm; + } + } + } + } + return sortfn; + }, + + getInnerText: function(node) { + // gets the text we want to use for sorting for a cell. + // strips leading and trailing whitespace. + // this is *not* a generic getInnerText function; it's special to sorttable. + // for example, you can override the cell text with a customkey attribute. + // it also gets .value for fields. + + hasInputs = (typeof node.getElementsByTagName == 'function') && + node.getElementsByTagName('input').length; + + if (node.getAttribute("sorttable_customkey") != null) { + return node.getAttribute("sorttable_customkey"); + } + else if (typeof node.textContent != 'undefined' && !hasInputs) { + return node.textContent.replace(/^\s+|\s+$/g, ''); + } + else if (typeof node.innerText != 'undefined' && !hasInputs) { + return node.innerText.replace(/^\s+|\s+$/g, ''); + } + else if (typeof node.text != 'undefined' && !hasInputs) { + return node.text.replace(/^\s+|\s+$/g, ''); + } + else { + switch (node.nodeType) { + case 3: + if (node.nodeName.toLowerCase() == 'input') { + return node.value.replace(/^\s+|\s+$/g, ''); + } + case 4: + return node.nodeValue.replace(/^\s+|\s+$/g, ''); + break; + case 1: + case 11: + var innerText = ''; + for (var i = 0; i < node.childNodes.length; i++) { + innerText += sorttable.getInnerText(node.childNodes[i]); + } + return innerText.replace(/^\s+|\s+$/g, ''); + break; + default: + return ''; + } + } + }, + + reverse: function(tbody) { + // reverse the rows in a tbody + newrows = []; + for (var i=0; i=0; i--) { + tbody.appendChild(newrows[i]); + } + delete newrows; + }, + + /* sort functions + each sort function takes two parameters, a and b + you are comparing a[0] and b[0] */ + sort_numeric: function(a,b) { + aa = parseFloat(a[0].replace(/[^0-9.-]/g,'')); + if (isNaN(aa)) aa = 0; + bb = parseFloat(b[0].replace(/[^0-9.-]/g,'')); + if (isNaN(bb)) bb = 0; + return aa-bb; + }, + sort_alpha: function(a,b) { + if (a[0]==b[0]) return 0; + if (a[0] 0 ) { + var q = list[i]; list[i] = list[i+1]; list[i+1] = q; + swap = true; + } + } // for + t--; + + if (!swap) break; + + for(var i = t; i > b; --i) { + if ( comp_func(list[i], list[i-1]) < 0 ) { + var q = list[i]; list[i] = list[i-1]; list[i-1] = q; + swap = true; + } + } // for + b++; + + } // while(swap) + } +} + +/* ****************************************************************** + Supporting functions: bundled here to avoid depending on a library + ****************************************************************** */ + +// Dean Edwards/Matthias Miller/John Resig + +/* for Mozilla/Opera9 */ +if (document.addEventListener) { + document.addEventListener("DOMContentLoaded", sorttable.init, false); +} + +/* for Internet Explorer */ +/*@cc_on @*/ +/*@if (@_win32) + document.write("