1616#include "paths.h"
1717
1818static struct xkb_compose_table *
19- xkb_compose_table_new (struct xkb_context * ctx ,
19+ xkb_compose_table_new (struct xkb_context * ctx , const char * func ,
2020 const char * locale ,
2121 enum xkb_compose_format format ,
2222 enum xkb_compose_compile_flags flags )
2323{
24+ static const enum xkb_compose_compile_flags XKB_COMPOSE_COMPILE_FLAGS =
25+ XKB_COMPOSE_COMPILE_NO_FLAGS ;
26+
27+ if (flags & ~XKB_COMPOSE_COMPILE_FLAGS ) {
28+ log_err (ctx , XKB_LOG_MESSAGE_NO_ID ,
29+ "%s: unrecognized flags: %#x\n" , func ,
30+ (flags & ~XKB_COMPOSE_COMPILE_FLAGS ));
31+ return NULL ;
32+ }
33+
34+ if (format != XKB_COMPOSE_FORMAT_TEXT_V1 ) {
35+ log_err (ctx , XKB_LOG_MESSAGE_NO_ID ,
36+ "%s: unsupported compose format: %d\n" , func , format );
37+ return NULL ;
38+ }
39+
2440 char * resolved_locale ;
2541 struct xkb_compose_table * table ;
2642 struct compose_node dummy = {0 };
@@ -84,27 +100,12 @@ xkb_compose_table_new_from_file(struct xkb_context *ctx,
84100 enum xkb_compose_format format ,
85101 enum xkb_compose_compile_flags flags )
86102{
87- struct xkb_compose_table * table ;
88- bool ok ;
89-
90- if (flags & ~(XKB_COMPOSE_COMPILE_NO_FLAGS )) {
91- log_err_func (ctx , XKB_LOG_MESSAGE_NO_ID ,
92- "unrecognized flags: %#x\n" , flags );
93- return NULL ;
94- }
95-
96- if (format != XKB_COMPOSE_FORMAT_TEXT_V1 ) {
97- log_err_func (ctx , XKB_LOG_MESSAGE_NO_ID ,
98- "unsupported compose format: %d\n" , format );
99- return NULL ;
100- }
101-
102- table = xkb_compose_table_new (ctx , locale , format , flags );
103+ struct xkb_compose_table * const table =
104+ xkb_compose_table_new (ctx , __func__ , locale , format , flags );
103105 if (!table )
104106 return NULL ;
105107
106- ok = parse_file (table , file , "(unknown file)" );
107- if (!ok ) {
108+ if (!parse_file (table , file , "(unknown file)" )) {
108109 xkb_compose_table_unref (table );
109110 return NULL ;
110111 }
@@ -119,27 +120,12 @@ xkb_compose_table_new_from_buffer(struct xkb_context *ctx,
119120 enum xkb_compose_format format ,
120121 enum xkb_compose_compile_flags flags )
121122{
122- struct xkb_compose_table * table ;
123- bool ok ;
124-
125- if (flags & ~(XKB_COMPOSE_COMPILE_NO_FLAGS )) {
126- log_err_func (ctx , XKB_LOG_MESSAGE_NO_ID ,
127- "unrecognized flags: %#x\n" , flags );
128- return NULL ;
129- }
130-
131- if (format != XKB_COMPOSE_FORMAT_TEXT_V1 ) {
132- log_err_func (ctx , XKB_LOG_MESSAGE_NO_ID ,
133- "unsupported compose format: %d\n" , format );
134- return NULL ;
135- }
136-
137- table = xkb_compose_table_new (ctx , locale , format , flags );
123+ struct xkb_compose_table * const table =
124+ xkb_compose_table_new (ctx , __func__ , locale , format , flags );
138125 if (!table )
139126 return NULL ;
140127
141- ok = parse_string (table , buffer , length , "(input string)" );
142- if (!ok ) {
128+ if (!parse_string (table , buffer , length , "(input string)" )) {
143129 xkb_compose_table_unref (table );
144130 return NULL ;
145131 }
@@ -152,24 +138,14 @@ xkb_compose_table_new_from_locale(struct xkb_context *ctx,
152138 const char * locale ,
153139 enum xkb_compose_compile_flags flags )
154140{
155- struct xkb_compose_table * table ;
156- char * path ;
157- FILE * file ;
158- bool ok ;
159-
160- if (flags & ~(XKB_COMPOSE_COMPILE_NO_FLAGS )) {
161- log_err_func (ctx , XKB_LOG_MESSAGE_NO_ID ,
162- "unrecognized flags: %#x\n" , flags );
163- return NULL ;
164- }
165-
166- table = xkb_compose_table_new (ctx , locale , XKB_COMPOSE_FORMAT_TEXT_V1 ,
167- flags );
141+ static const enum xkb_compose_format format = XKB_COMPOSE_FORMAT_TEXT_V1 ;
142+ struct xkb_compose_table * const table =
143+ xkb_compose_table_new (ctx , __func__ , locale , format , flags );
168144 if (!table )
169145 return NULL ;
170146
171- path = get_xcomposefile_path (ctx );
172- file = open_file (path );
147+ char * path = get_xcomposefile_path (ctx );
148+ FILE * file = open_file (path );
173149 if (file )
174150 goto found_path ;
175151 free (path );
@@ -199,7 +175,8 @@ xkb_compose_table_new_from_locale(struct xkb_context *ctx,
199175 return NULL ;
200176
201177found_path :
202- ok = parse_file (table , file , path );
178+ {} /* Label followed by a declaration is a C23 extension */
179+ const bool ok = parse_file (table , file , path );
203180 fclose (file );
204181 if (!ok ) {
205182 free (path );
0 commit comments