Bug Summary

File:eel/eel-string.c
Warning:line 424, column 21
Access of 'handlers' at index 3, while it holds only 3 'EelPrintfHandler' elements

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name eel-string.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=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/eel -fcoverage-compilation-dir=/rootdir/eel -resource-dir /usr/lib/llvm-19/lib/clang/19 -D HAVE_CONFIG_H -I . -I .. -D G_LOG_DOMAIN="Eel" -I .. -I .. -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/sysprof-6 -I /usr/include/cafe-desktop-2.0 -I /usr/include/ctk-3.0 -I /usr/include/pango-1.0 -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/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/x86_64-linux-gnu -I /usr/include/webp -I /usr/include/gio-unix-2.0 -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/lib/x86_64-linux-gnu/dbus-1.0/include -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/cail-3.0 -I /usr/include/libxml2 -D G_DISABLE_DEPRECATED -D GDK_PIXBUF_DISABLE_DEPRECATED -D DATADIR="/usr/share" -D SOURCE_DATADIR="../data" -D CAFELOCALEDIR="/usr//locale" -D PIC -internal-isystem /usr/lib/llvm-19/lib/clang/19/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -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.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-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2025-01-27-072242-27568-1 -x c eel-string.c
1/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
2
3 eel-string.c: String routines to augment <string.h>.
4
5 Copyright (C) 2000 Eazel, Inc.
6
7 The Cafe Library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public License as
9 published by the Free Software Foundation; either version 2 of the
10 License, or (at your option) any later version.
11
12 The Cafe Library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
16
17 You should have received a copy of the GNU Library General Public
18 License along with the Cafe Library; see the file COPYING.LIB. If not,
19 write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
20 Boston, MA 02110-1301, USA.
21
22 Authors: Darin Adler <darin@eazel.com>
23*/
24
25#include <config.h>
26#include "eel-glib-extensions.h"
27#include "eel-string.h"
28
29#include <errno(*__errno_location ()).h>
30#include <locale.h>
31#include <stdlib.h>
32#include <string.h>
33
34#if !defined (EEL_OMIT_SELF_CHECK)
35#include "eel-lib-self-check-functions.h"
36#endif
37
38size_t
39eel_strlen (const char *string)
40{
41 return string == NULL((void*)0) ? 0 : strlen (string);
42}
43
44char *
45eel_strchr (const char *haystack, char needle)
46{
47 return haystack == NULL((void*)0) ? NULL((void*)0) : strchr (haystack, needle);
48}
49
50int
51eel_strcmp (const char *string_a, const char *string_b)
52{
53 /* FIXME bugzilla.eazel.com 5450: Maybe we need to make this
54 * treat 'NULL < ""', or have a flavor that does that. If we
55 * didn't have code that already relies on 'NULL == ""', I
56 * would change it right now.
57 */
58 return strcmp (string_a == NULL((void*)0) ? "" : string_a,
59 string_b == NULL((void*)0) ? "" : string_b);
60}
61
62gboolean
63eel_str_is_empty (const char *string_or_null)
64{
65 return eel_strcmp (string_or_null, NULL((void*)0)) == 0;
66}
67
68gboolean
69eel_str_has_prefix (const char *haystack, const char *needle)
70{
71 return g_str_has_prefix (haystack == NULL ? "" : haystack,(__builtin_constant_p (needle == ((void*)0) ? "" : needle)? __extension__
({ const char * const __str = (haystack == ((void*)0) ? "" :
haystack); const char * const __prefix = (needle == ((void*)
0) ? "" : needle); gboolean __result = (0); if (__str == ((void
*)0) || __prefix == ((void*)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) (haystack == ((void
*)0) ? "" : haystack, needle == ((void*)0) ? "" : needle) )
72 needle == NULL ? "" : needle)(__builtin_constant_p (needle == ((void*)0) ? "" : needle)? __extension__
({ const char * const __str = (haystack == ((void*)0) ? "" :
haystack); const char * const __prefix = (needle == ((void*)
0) ? "" : needle); gboolean __result = (0); if (__str == ((void
*)0) || __prefix == ((void*)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) (haystack == ((void
*)0) ? "" : haystack, needle == ((void*)0) ? "" : needle) )
;
73}
74
75gboolean
76eel_istr_has_prefix (const char *haystack, const char *needle)
77{
78 const char *h, *n;
79 char hc, nc;
80
81 /* Eat one character at a time. */
82 h = haystack == NULL((void*)0) ? "" : haystack;
83 n = needle == NULL((void*)0) ? "" : needle;
84 do
85 {
86 if (*n == '\0')
87 {
88 return TRUE(!(0));
89 }
90 if (*h == '\0')
91 {
92 return FALSE(0);
93 }
94 hc = *h++;
95 nc = *n++;
96 hc = g_ascii_tolower (hc);
97 nc = g_ascii_tolower (nc);
98 }
99 while (hc == nc);
100 return FALSE(0);
101}
102
103/**
104 * eel_str_get_prefix:
105 * Get a new string containing the first part of an existing string.
106 *
107 * @source: The string whose prefix should be extracted.
108 * @delimiter: The string that marks the end of the prefix.
109 *
110 * Return value: A newly-allocated string that that matches the first part
111 * of @source, up to but not including the first occurrence of
112 * @delimiter. If @source is NULL, returns NULL. If
113 * @delimiter is NULL, returns a copy of @source.
114 * If @delimiter does not occur in @source, returns
115 * a copy of @source.
116 **/
117char *
118eel_str_get_prefix (const char *source,
119 const char *delimiter)
120{
121 char *prefix_start;
122
123 if (source == NULL((void*)0))
124 {
125 return NULL((void*)0);
126 }
127
128 if (delimiter == NULL((void*)0))
129 {
130 return g_strdup (source)g_strdup_inline (source);
131 }
132
133 prefix_start = strstr (source, delimiter);
134
135 if (prefix_start == NULL((void*)0))
136 {
137 return g_strdup ("")g_strdup_inline ("");
138 }
139
140 return g_strndup (source, prefix_start - source);
141}
142
143char *
144eel_str_double_underscores (const char *string)
145{
146 int underscores;
147 const char *p;
148 char *q;
149 char *escaped;
150
151 if (string == NULL((void*)0))
152 {
153 return NULL((void*)0);
154 }
155
156 underscores = 0;
157 for (p = string; *p != '\0'; p++)
158 {
159 underscores += (*p == '_');
160 }
161
162 if (underscores == 0)
163 {
164 return g_strdup (string)g_strdup_inline (string);
165 }
166
167 escaped = g_new (char, strlen (string) + underscores + 1)((char *) g_malloc_n ((strlen (string) + underscores + 1), sizeof
(char)))
;
168 for (p = string, q = escaped; *p != '\0'; p++, q++)
169 {
170 /* Add an extra underscore. */
171 if (*p == '_')
172 {
173 *q++ = '_';
174 }
175 *q = *p;
176 }
177 *q = '\0';
178
179 return escaped;
180}
181
182char *
183eel_str_capitalize (const char *string)
184{
185 char *capitalized;
186
187 if (string == NULL((void*)0))
188 {
189 return NULL((void*)0);
190 }
191
192 capitalized = g_strdup (string)g_strdup_inline (string);
193
194 capitalized[0] = g_ascii_toupper (capitalized[0]);
195
196 return capitalized;
197}
198
199/* Note: eel_string_ellipsize_* that use a length in pixels
200 * rather than characters can be found in eel_cdk_extensions.h
201 *
202 * FIXME bugzilla.eazel.com 5089:
203 * we should coordinate the names of eel_string_ellipsize_*
204 * and eel_str_*_truncate so that they match better and reflect
205 * their different behavior.
206 */
207char *
208eel_str_middle_truncate (const char *string,
209 guint truncate_length)
210{
211 char *truncated;
212 guint length;
213 guint num_left_chars;
214 guint num_right_chars;
215
216 const char delimter[] = "...";
217 const guint delimter_length = strlen (delimter);
218 const guint min_truncate_length = delimter_length + 2;
219
220 if (string == NULL((void*)0))
221 {
222 return NULL((void*)0);
223 }
224
225 /* It doesnt make sense to truncate strings to less than
226 * the size of the delimiter plus 2 characters (one on each
227 * side)
228 */
229 if (truncate_length < min_truncate_length)
230 {
231 return g_strdup (string)g_strdup_inline (string);
232 }
233
234 length = g_utf8_strlen (string, -1);
235
236 /* Make sure the string is not already small enough. */
237 if (length <= truncate_length)
238 {
239 return g_strdup (string)g_strdup_inline (string);
240 }
241
242 /* Find the 'middle' where the truncation will occur. */
243 num_left_chars = (truncate_length - delimter_length) / 2;
244 num_right_chars = truncate_length - num_left_chars - delimter_length;
245
246 truncated = g_new (char, strlen (string) + 1)((char *) g_malloc_n ((strlen (string) + 1), sizeof (char)));
247
248 g_utf8_strncpy (truncated, string, num_left_chars);
249 g_strlcat (truncated, delimter, (truncate_length + 1));
250 g_strlcat (truncated, g_utf8_offset_to_pointer (string, length - num_right_chars), (truncate_length + 1));
251
252 return truncated;
253}
254
255char *
256eel_str_strip_substring_and_after (const char *string,
257 const char *substring)
258{
259 const char *substring_position;
260
261 g_return_val_if_fail (substring != NULL, g_strdup (string))do { if ((substring != ((void*)0))) { } else { g_return_if_fail_warning
("Eel", ((const char*) (__func__)), "substring != NULL"); return
(g_strdup_inline (string)); } } while (0)
;
262 g_return_val_if_fail (substring[0] != '\0', g_strdup (string))do { if ((substring[0] != '\0')) { } else { g_return_if_fail_warning
("Eel", ((const char*) (__func__)), "substring[0] != '\\0'")
; return (g_strdup_inline (string)); } } while (0)
;
263
264 if (string == NULL((void*)0))
265 {
266 return NULL((void*)0);
267 }
268
269 substring_position = strstr (string, substring);
270 if (substring_position == NULL((void*)0))
271 {
272 return g_strdup (string)g_strdup_inline (string);
273 }
274
275 return g_strndup (string,
276 substring_position - string);
277}
278
279char *
280eel_str_replace_substring (const char *string,
281 const char *substring,
282 const char *replacement)
283{
284 int substring_length, replacement_length, result_length, remaining_length;
285 const char *p, *substring_position;
286 char *result, *result_position;
287
288 g_return_val_if_fail (substring != NULL, g_strdup (string))do { if ((substring != ((void*)0))) { } else { g_return_if_fail_warning
("Eel", ((const char*) (__func__)), "substring != NULL"); return
(g_strdup_inline (string)); } } while (0)
;
289 g_return_val_if_fail (substring[0] != '\0', g_strdup (string))do { if ((substring[0] != '\0')) { } else { g_return_if_fail_warning
("Eel", ((const char*) (__func__)), "substring[0] != '\\0'")
; return (g_strdup_inline (string)); } } while (0)
;
290
291 if (string == NULL((void*)0))
292 {
293 return NULL((void*)0);
294 }
295
296 if (replacement == NULL((void*)0))
297 {
298 replacement = "";
299 }
300
301 substring_length = strlen (substring);
302 replacement_length = eel_strlen (replacement);
303
304 result_length = strlen (string);
305 for (p = string; ; p = substring_position + substring_length)
306 {
307 substring_position = strstr (p, substring);
308 if (substring_position == NULL((void*)0))
309 {
310 break;
311 }
312 if (replacement_length > substring_length)
313 result_length += replacement_length - substring_length;
314 }
315
316 result = g_malloc (result_length + 1);
317
318 result_position = result;
319 for (p = string; ; p = substring_position + substring_length)
320 {
321 substring_position = strstr (p, substring);
322 if (substring_position == NULL((void*)0))
323 {
324 remaining_length = strlen (p);
325 memcpy (result_position, p, remaining_length);
326 result_position += remaining_length;
327 break;
328 }
329 memcpy (result_position, p, substring_position - p);
330 result_position += substring_position - p;
331 memcpy (result_position, replacement, replacement_length);
332 result_position += replacement_length;
333 }
334
335 result_position[0] = '\0';
336
337 return result;
338}
339
340/**************** Custom printf ***********/
341
342typedef struct
343{
344 const char *start;
345 const char *end;
346 GString *format;
347 int arg_pos;
348 int width_pos;
349 int width_format_index;
350 int precision_pos;
351 int precision_format_index;
352} ConversionInfo;
353
354enum
355{
356 ARG_TYPE_INVALID,
357 ARG_TYPE_INT,
358 ARG_TYPE_LONG,
359 ARG_TYPE_LONG_LONG,
360 ARG_TYPE_SIZE,
361 ARG_TYPE_LONG_DOUBLE,
362 ARG_TYPE_DOUBLE,
363 ARG_TYPE_POINTER
364};
365
366typedef int ArgType; /* An int, because custom are < 0 */
367
368
369static const char *
370get_position (const char *format, int *i)
371{
372 const char *p;
373
374 p = format;
375
376 if (g_ascii_isdigit (*p)((g_ascii_table[(guchar) (*p)] & G_ASCII_DIGIT) != 0))
377 {
378 p++;
379
380 while (g_ascii_isdigit (*p)((g_ascii_table[(guchar) (*p)] & G_ASCII_DIGIT) != 0))
381 {
382 p++;
383 }
384
385 if (*p == '$')
386 {
387 if (i != NULL((void*)0))
388 {
389 *i = atoi (format) - 1;
390 }
391 return p + 1;
392 }
393 }
394
395 return format;
396}
397
398static gboolean
399is_flag (char c)
400{
401 return strchr ("#0- +'I", c) != NULL((void*)0);
402}
403
404static gboolean
405is_length_modifier (char c)
406{
407 return strchr ("hlLjzt", c) != NULL((void*)0);
408}
409
410
411static ArgType
412get_arg_type_from_format (EelPrintfHandler *custom_handlers,
413 const char *format,
414 int len)
415{
416 char c;
417
418 c = format[len-1];
419
420 if (custom_handlers
22.1
'custom_handlers' is not equal to NULL
!= NULL((void*)0))
23
Taking true branch
421 {
422 int i;
423
424 for (i = 0; custom_handlers[i].character != 0; i++)
24
Assuming field 'character' is not equal to 0
25
Loop condition is true. Entering loop body
28
Assuming field 'character' is not equal to 0
29
Loop condition is true. Entering loop body
32
Assuming field 'character' is not equal to 0
33
Loop condition is true. Entering loop body
36
Access of 'handlers' at index 3, while it holds only 3 'EelPrintfHandler' elements
425 {
426 if (custom_handlers[i].character == c)
26
Assuming 'c' is not equal to field 'character'
27
Taking false branch
30
Assuming 'c' is not equal to field 'character'
31
Taking false branch
34
Assuming 'c' is not equal to field 'character'
35
Taking false branch
427 {
428 return -(i + 1);
429 }
430 }
431 }
432
433 switch (c)
434 {
435 case 'd':
436 case 'i':
437 case 'o':
438 case 'u':
439 case 'x':
440 case 'X':
441 if (g_str_has_prefix (format, "ll")(__builtin_constant_p ("ll")? __extension__ ({ const char * const
__str = (format); const char * const __prefix = ("ll"); gboolean
__result = (0); if (__str == ((void*)0) || __prefix == ((void
*)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) (format, "ll") )
)
442 {
443 return ARG_TYPE_LONG_LONG;
444 }
445 if (g_str_has_prefix (format, "l")(__builtin_constant_p ("l")? __extension__ ({ const char * const
__str = (format); const char * const __prefix = ("l"); gboolean
__result = (0); if (__str == ((void*)0) || __prefix == ((void
*)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) (format, "l") )
)
446 {
447 return ARG_TYPE_LONG;
448 }
449 if (g_str_has_prefix (format, "l")(__builtin_constant_p ("l")? __extension__ ({ const char * const
__str = (format); const char * const __prefix = ("l"); gboolean
__result = (0); if (__str == ((void*)0) || __prefix == ((void
*)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) (format, "l") )
)
450 {
451 return ARG_TYPE_LONG;
452 }
453 if (g_str_has_prefix (format, "z")(__builtin_constant_p ("z")? __extension__ ({ const char * const
__str = (format); const char * const __prefix = ("z"); gboolean
__result = (0); if (__str == ((void*)0) || __prefix == ((void
*)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) (format, "z") )
)
454 {
455 return ARG_TYPE_SIZE;
456 }
457 return ARG_TYPE_INT;
458 case 'e':
459 case 'E':
460 case 'f':
461 case 'F':
462 case 'g':
463 case 'G':
464 case 'a':
465 case 'A':
466 if (g_str_has_prefix (format, "L")(__builtin_constant_p ("L")? __extension__ ({ const char * const
__str = (format); const char * const __prefix = ("L"); gboolean
__result = (0); if (__str == ((void*)0) || __prefix == ((void
*)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) (format, "L") )
)
467 {
468 return ARG_TYPE_LONG_DOUBLE;
469 }
470 return ARG_TYPE_DOUBLE;
471 case 'c':
472 return ARG_TYPE_INT;
473 case 's':
474 case 'p':
475 case 'n':
476 return ARG_TYPE_POINTER;
477 }
478 return ARG_TYPE_INVALID;
479}
480
481static void
482skip_argv (va_list *va,
483 ArgType type,
484 EelPrintfHandler *custom_handlers)
485{
486 if (type < 0)
487 {
488 custom_handlers[-type - 1].skip (va);
489 return;
490 }
491
492 switch (type)
493 {
494 default:
495 case ARG_TYPE_INVALID:
496 return;
497
498 case ARG_TYPE_INT:
499 (void) va_arg (*va, int)__builtin_va_arg(*va, int);
500 break;
501 case ARG_TYPE_LONG:
502 (void) va_arg (*va, long int)__builtin_va_arg(*va, long int);
503 break;
504 case ARG_TYPE_LONG_LONG:
505 (void) va_arg (*va, long long int)__builtin_va_arg(*va, long long int);
506 break;
507 case ARG_TYPE_SIZE:
508 (void) va_arg (*va, gsize)__builtin_va_arg(*va, gsize);
509 break;
510 case ARG_TYPE_LONG_DOUBLE:
511 (void) va_arg (*va, long double)__builtin_va_arg(*va, long double);
512 break;
513 case ARG_TYPE_DOUBLE:
514 (void) va_arg (*va, double)__builtin_va_arg(*va, double);
515 break;
516 case ARG_TYPE_POINTER:
517 (void) va_arg (*va, void *)__builtin_va_arg(*va, void *);
518 break;
519 }
520}
521
522static void
523skip_to_arg (va_list *va,
524 ArgType *types,
525 EelPrintfHandler *custom_handlers,
526 int n)
527{
528 int i;
529 for (i = 0; i < n; i++)
530 {
531 skip_argv (va, types[i], custom_handlers);
532 }
533}
534
535char *
536eel_strdup_vprintf_with_custom (EelPrintfHandler *custom,
537 const char *format,
538 va_list va_orig)
539{
540 va_list va;
541 const char *p;
542 int num_args, i, j;
543 ArgType *args;
544 ConversionInfo *conversions;
545 GString *f, *str;
546 const char *flags, *width, *prec, *mod, *pos;
547 char *s;
548
549 num_args = 0;
550 for (p = format; *p != 0; p++)
2
Assuming the condition is true
3
Loop condition is true. Entering loop body
8
Assuming the condition is false
9
Loop condition is false. Execution continues on line 562
551 {
552 if (*p == '%')
4
Assuming the condition is true
5
Taking true branch
553 {
554 p++;
555 if (*p != '%')
6
Assuming the condition is true
7
Taking true branch
556 {
557 num_args++;
558 }
559 }
560 }
561
562 args = g_new0 (ArgType, num_args * 3 + 1)((ArgType *) g_malloc0_n ((num_args * 3 + 1), sizeof (ArgType
)))
;
563 conversions = g_new0 (ConversionInfo, num_args)((ConversionInfo *) g_malloc0_n ((num_args), sizeof (ConversionInfo
)))
;
564
565 /* i indexes conversions, j indexes args */
566 i = 0;
567 j = 0;
568 p = format;
569 while (*p != 0)
10
Loop condition is true. Entering loop body
570 {
571 if (*p != '%')
11
Taking false branch
572 {
573 p++;
574 continue;
575 }
576 p++;
577 if (*p == '%')
12
Taking false branch
578 {
579 p++;
580 continue;
581 }
582
583 /* We got a real conversion: */
584 f = g_string_new ("%");
585 conversions[i].start = p - 1;
586
587 /* First comes the positional arg */
588
589 pos = p;
590 p = get_position (p, NULL((void*)0));
591
592 /* Then flags */
593 flags = p;
594 while (is_flag (*p))
13
Loop condition is false. Execution continues on line 598
595 {
596 p++;
597 }
598 g_string_append_len (f, flags, p - flags)g_string_append_len_inline (f, flags, p - flags);
599
600 /* Field width */
601
602 if (*p == '*')
14
Assuming the condition is false
15
Taking false branch
603 {
604 p++;
605 p = get_position (p, &j);
606 args[j] = ARG_TYPE_INT;
607 conversions[i].width_pos = j++;
608 conversions[i].width_format_index = f->len;
609 }
610 else
611 {
612 conversions[i].width_pos = -1;
613 conversions[i].width_format_index = -1;
614 width = p;
615 while (g_ascii_isdigit (*p)((g_ascii_table[(guchar) (*p)] & G_ASCII_DIGIT) != 0))
16
Loop condition is false. Execution continues on line 619
616 {
617 p++;
618 }
619 g_string_append_len (f, width, p - width)g_string_append_len_inline (f, width, p - width);
620 }
621
622 /* Precision */
623 conversions[i].precision_pos = -1;
624 conversions[i].precision_format_index = -1;
625 if (*p == '.')
17
Assuming the condition is false
18
Taking false branch
626 {
627 g_string_append_c (f, '.')g_string_append_c_inline (f, '.');
628 p++;
629
630 if (*p == '*')
631 {
632 p++;
633 p = get_position (p, &j);
634 args[j] = ARG_TYPE_INT;
635 conversions[i].precision_pos = j++;
636 conversions[i].precision_format_index = f->len;
637 }
638 else
639 {
640 prec = p;
641 while (g_ascii_isdigit (*p)((g_ascii_table[(guchar) (*p)] & G_ASCII_DIGIT) != 0) || *p == '-')
642 {
643 p++;
644 }
645 g_string_append_len (f, prec, p - prec)g_string_append_len_inline (f, prec, p - prec);
646 }
647 }
648
649 /* length modifier */
650
651 mod = p;
652
653 while (is_length_modifier (*p))
19
Loop condition is false. Execution continues on line 659
654 {
655 p++;
656 }
657
658 /* conversion specifier */
659 if (*p != 0)
20
Assuming the condition is false
21
Taking false branch
660 p++;
661
662 g_string_append_len (f, mod, p - mod)g_string_append_len_inline (f, mod, p - mod);
663
664 get_position (pos, &j);
665 args[j] = get_arg_type_from_format (custom, mod, p - mod);
22
Calling 'get_arg_type_from_format'
666 conversions[i].arg_pos = j++;
667 conversions[i].format = f;
668 conversions[i].end = p;
669
670 i++;
671 }
672
673 g_assert (i == num_args)do { if (i == num_args) ; else g_assertion_message_expr ("Eel"
, "eel-string.c", 673, ((const char*) (__func__)), "i == num_args"
); } while (0)
;
674
675 str = g_string_new ("");
676
677 p = format;
678 for (i = 0; i < num_args; i++)
679 {
680 ArgType type;
681
682 g_string_append_len (str, p, conversions[i].start - p)g_string_append_len_inline (str, p, conversions[i].start - p);
683 p = conversions[i].end;
684
685 if (conversions[i].precision_pos != -1)
686 {
687 char *val;
688
689 va_copy (va, va_orig)__builtin_va_copy(va, va_orig);
690 skip_to_arg (&va, args, custom, conversions[i].precision_pos);
691 val = g_strdup_vprintf ("%d", va);
692 va_end (va)__builtin_va_end(va);
693
694 g_string_insert (conversions[i].format,
695 conversions[i].precision_format_index,
696 val);
697
698 g_free (val);
699 }
700
701 if (conversions[i].width_pos != -1)
702 {
703 char *val;
704
705 va_copy (va, va_orig)__builtin_va_copy(va, va_orig);
706 skip_to_arg (&va, args, custom, conversions[i].width_pos);
707 val = g_strdup_vprintf ("%d", va);
708 va_end (va)__builtin_va_end(va);
709
710 g_string_insert (conversions[i].format,
711 conversions[i].width_format_index,
712 val);
713
714 g_free (val);
715 }
716
717 va_copy (va, va_orig)__builtin_va_copy(va, va_orig);
718 skip_to_arg (&va, args, custom, conversions[i].arg_pos);
719 type = args[conversions[i].arg_pos];
720 if (type < 0)
721 {
722 s = custom[-type - 1].to_string (conversions[i].format->str, va);
723 g_string_append (str, s)(__builtin_constant_p (s) ? __extension__ ({ const char * const
__val = (s); g_string_append_len_inline (str, __val, (__val !=
((void*)0)) ? (gssize) strlen (((__val) + !(__val))) : (gssize
) -1); }) : g_string_append_len_inline (str, s, (gssize) -1))
;
724 g_free (s);
725 }
726 else
727 {
728 g_string_append_vprintf (str, conversions[i].format->str, va);
729 }
730 va_end (va)__builtin_va_end(va);
731
732 g_string_free (conversions[i].format, TRUE)(__builtin_constant_p ((!(0))) ? (((!(0))) ? (g_string_free) (
(conversions[i].format), ((!(0)))) : g_string_free_and_steal (
conversions[i].format)) : (g_string_free) ((conversions[i].format
), ((!(0)))))
;
733 }
734 g_string_append (str, p)(__builtin_constant_p (p) ? __extension__ ({ const char * const
__val = (p); g_string_append_len_inline (str, __val, (__val !=
((void*)0)) ? (gssize) strlen (((__val) + !(__val))) : (gssize
) -1); }) : g_string_append_len_inline (str, p, (gssize) -1))
;
735
736 g_free (args);
737 g_free (conversions);
738
739 return g_string_free (str, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((str)
, ((0))) : g_string_free_and_steal (str)) : (g_string_free) (
(str), ((0))))
;
740}
741
742char *
743eel_strdup_printf_with_custom (EelPrintfHandler *handlers,
744 const char *format,
745 ...)
746{
747 va_list va;
748 char *res;
749
750 va_start (va, format)__builtin_va_start(va, format);
751 res = eel_strdup_vprintf_with_custom (handlers, format, va);
752 va_end (va)__builtin_va_end(va);
753
754 return res;
755}
756
757#if !defined (EEL_OMIT_SELF_CHECK)
758
759static void
760verify_printf (const char *format, ...)
761{
762 va_list va;
763 char *orig, *new;
764
765 va_start (va, format)__builtin_va_start(va, format);
766 orig = g_strdup_vprintf (format, va);
767 va_end (va)__builtin_va_end(va);
768
769 va_start (va, format)__builtin_va_start(va, format);
770 new = eel_strdup_vprintf_with_custom (NULL((void*)0), format, va);
771 va_end (va)__builtin_va_end(va);
772
773 EEL_CHECK_STRING_RESULT (new, orig)do { eel_before_check ("new", "eel-string.c", 773); eel_check_string_result
(new, orig); } while (0)
;
774
775 g_free (orig);
776}
777
778static char *
779custom1_to_string (char *format G_GNUC_UNUSED__attribute__ ((__unused__)),
780 va_list va)
781{
782 int i;
783
784 i = va_arg (va, int)__builtin_va_arg(va, int);
785
786 return g_strdup_printf ("c1-%d-", i);
787}
788
789static void
790custom1_skip (va_list *va)
791{
792 (void) va_arg (*va, int)__builtin_va_arg(*va, int);
793}
794
795static char *
796custom2_to_string (char *format G_GNUC_UNUSED__attribute__ ((__unused__)),
797 va_list va)
798{
799 char *s;
800
801 s = va_arg (va, char *)__builtin_va_arg(va, char *);
802
803 return g_strdup_printf ("c2-%s-", s);
804}
805
806static void
807custom2_skip (va_list *va)
808{
809 (void) va_arg (*va, char *)__builtin_va_arg(*va, char *);
810}
811
812static EelPrintfHandler handlers[] =
813{
814 { 'N', custom1_to_string, custom1_skip },
815 { 'Y', custom2_to_string, custom2_skip },
816 { 0 }
817};
818
819static void
820verify_custom (const char *orig, const char *format, ...)
821{
822 char *new;
823 va_list va;
824
825 va_start (va, format)__builtin_va_start(va, format);
826 new = eel_strdup_vprintf_with_custom (handlers, format, va);
1
Calling 'eel_strdup_vprintf_with_custom'
827 va_end (va)__builtin_va_end(va);
828
829 EEL_CHECK_STRING_RESULT (new, orig)do { eel_before_check ("new", "eel-string.c", 829); eel_check_string_result
(new, orig); } while (0)
;
830}
831
832void
833eel_self_check_string (void)
834{
835 EEL_CHECK_INTEGER_RESULT (eel_strlen (NULL), 0)do { eel_before_check ("eel_strlen (((void*)0))", "eel-string.c"
, 835); eel_check_integer_result (eel_strlen (((void*)0)), 0)
; } while (0)
;
836 EEL_CHECK_INTEGER_RESULT (eel_strlen (""), 0)do { eel_before_check ("eel_strlen (\"\")", "eel-string.c", 836
); eel_check_integer_result (eel_strlen (""), 0); } while (0)
;
837 EEL_CHECK_INTEGER_RESULT (eel_strlen ("abc"), 3)do { eel_before_check ("eel_strlen (\"abc\")", "eel-string.c"
, 837); eel_check_integer_result (eel_strlen ("abc"), 3); } while
(0)
;
838
839 EEL_CHECK_INTEGER_RESULT (eel_strcmp (NULL, NULL), 0)do { eel_before_check ("eel_strcmp (((void*)0), ((void*)0))",
"eel-string.c", 839); eel_check_integer_result (eel_strcmp (
((void*)0), ((void*)0)), 0); } while (0)
;
840 EEL_CHECK_INTEGER_RESULT (eel_strcmp (NULL, ""), 0)do { eel_before_check ("eel_strcmp (((void*)0), \"\")", "eel-string.c"
, 840); eel_check_integer_result (eel_strcmp (((void*)0), "")
, 0); } while (0)
;
841 EEL_CHECK_INTEGER_RESULT (eel_strcmp ("", NULL), 0)do { eel_before_check ("eel_strcmp (\"\", ((void*)0))", "eel-string.c"
, 841); eel_check_integer_result (eel_strcmp ("", ((void*)0))
, 0); } while (0)
;
842 EEL_CHECK_INTEGER_RESULT (eel_strcmp ("a", "a"), 0)do { eel_before_check ("eel_strcmp (\"a\", \"a\")", "eel-string.c"
, 842); eel_check_integer_result (eel_strcmp ("a", "a"), 0); }
while (0)
;
843 EEL_CHECK_INTEGER_RESULT (eel_strcmp ("aaab", "aaab"), 0)do { eel_before_check ("eel_strcmp (\"aaab\", \"aaab\")", "eel-string.c"
, 843); eel_check_integer_result (eel_strcmp ("aaab", "aaab")
, 0); } while (0)
;
844 EEL_CHECK_BOOLEAN_RESULT (eel_strcmp (NULL, "a") < 0, TRUE)do { eel_before_check ("eel_strcmp (((void*)0), \"a\") < 0"
, "eel-string.c", 844); eel_check_boolean_result (eel_strcmp (
((void*)0), "a") < 0, (!(0))); } while (0)
;
845 EEL_CHECK_BOOLEAN_RESULT (eel_strcmp ("a", NULL) > 0, TRUE)do { eel_before_check ("eel_strcmp (\"a\", ((void*)0)) > 0"
, "eel-string.c", 845); eel_check_boolean_result (eel_strcmp (
"a", ((void*)0)) > 0, (!(0))); } while (0)
;
846 EEL_CHECK_BOOLEAN_RESULT (eel_strcmp ("", "a") < 0, TRUE)do { eel_before_check ("eel_strcmp (\"\", \"a\") < 0", "eel-string.c"
, 846); eel_check_boolean_result (eel_strcmp ("", "a") < 0
, (!(0))); } while (0)
;
847 EEL_CHECK_BOOLEAN_RESULT (eel_strcmp ("a", "") > 0, TRUE)do { eel_before_check ("eel_strcmp (\"a\", \"\") > 0", "eel-string.c"
, 847); eel_check_boolean_result (eel_strcmp ("a", "") > 0
, (!(0))); } while (0)
;
848 EEL_CHECK_BOOLEAN_RESULT (eel_strcmp ("a", "b") < 0, TRUE)do { eel_before_check ("eel_strcmp (\"a\", \"b\") < 0", "eel-string.c"
, 848); eel_check_boolean_result (eel_strcmp ("a", "b") < 0
, (!(0))); } while (0)
;
849 EEL_CHECK_BOOLEAN_RESULT (eel_strcmp ("a", "ab") < 0, TRUE)do { eel_before_check ("eel_strcmp (\"a\", \"ab\") < 0", "eel-string.c"
, 849); eel_check_boolean_result (eel_strcmp ("a", "ab") <
0, (!(0))); } while (0)
;
850 EEL_CHECK_BOOLEAN_RESULT (eel_strcmp ("ab", "a") > 0, TRUE)do { eel_before_check ("eel_strcmp (\"ab\", \"a\") > 0", "eel-string.c"
, 850); eel_check_boolean_result (eel_strcmp ("ab", "a") >
0, (!(0))); } while (0)
;
851 EEL_CHECK_BOOLEAN_RESULT (eel_strcmp ("aaa", "aaab") < 0, TRUE)do { eel_before_check ("eel_strcmp (\"aaa\", \"aaab\") < 0"
, "eel-string.c", 851); eel_check_boolean_result (eel_strcmp (
"aaa", "aaab") < 0, (!(0))); } while (0)
;
852 EEL_CHECK_BOOLEAN_RESULT (eel_strcmp ("aaab", "aaa") > 0, TRUE)do { eel_before_check ("eel_strcmp (\"aaab\", \"aaa\") > 0"
, "eel-string.c", 852); eel_check_boolean_result (eel_strcmp (
"aaab", "aaa") > 0, (!(0))); } while (0)
;
853
854 EEL_CHECK_BOOLEAN_RESULT (eel_str_has_prefix (NULL, NULL), TRUE)do { eel_before_check ("eel_str_has_prefix (((void*)0), ((void*)0))"
, "eel-string.c", 854); eel_check_boolean_result (eel_str_has_prefix
(((void*)0), ((void*)0)), (!(0))); } while (0)
;
855 EEL_CHECK_BOOLEAN_RESULT (eel_str_has_prefix (NULL, ""), TRUE)do { eel_before_check ("eel_str_has_prefix (((void*)0), \"\")"
, "eel-string.c", 855); eel_check_boolean_result (eel_str_has_prefix
(((void*)0), ""), (!(0))); } while (0)
;
856 EEL_CHECK_BOOLEAN_RESULT (eel_str_has_prefix ("", NULL), TRUE)do { eel_before_check ("eel_str_has_prefix (\"\", ((void*)0))"
, "eel-string.c", 856); eel_check_boolean_result (eel_str_has_prefix
("", ((void*)0)), (!(0))); } while (0)
;
857 EEL_CHECK_BOOLEAN_RESULT (eel_str_has_prefix ("a", "a"), TRUE)do { eel_before_check ("eel_str_has_prefix (\"a\", \"a\")", "eel-string.c"
, 857); eel_check_boolean_result (eel_str_has_prefix ("a", "a"
), (!(0))); } while (0)
;
858 EEL_CHECK_BOOLEAN_RESULT (eel_str_has_prefix ("aaab", "aaab"), TRUE)do { eel_before_check ("eel_str_has_prefix (\"aaab\", \"aaab\")"
, "eel-string.c", 858); eel_check_boolean_result (eel_str_has_prefix
("aaab", "aaab"), (!(0))); } while (0)
;
859 EEL_CHECK_BOOLEAN_RESULT (eel_str_has_prefix (NULL, "a"), FALSE)do { eel_before_check ("eel_str_has_prefix (((void*)0), \"a\")"
, "eel-string.c", 859); eel_check_boolean_result (eel_str_has_prefix
(((void*)0), "a"), (0)); } while (0)
;
860 EEL_CHECK_BOOLEAN_RESULT (eel_str_has_prefix ("a", NULL), TRUE)do { eel_before_check ("eel_str_has_prefix (\"a\", ((void*)0))"
, "eel-string.c", 860); eel_check_boolean_result (eel_str_has_prefix
("a", ((void*)0)), (!(0))); } while (0)
;
861 EEL_CHECK_BOOLEAN_RESULT (eel_str_has_prefix ("", "a"), FALSE)do { eel_before_check ("eel_str_has_prefix (\"\", \"a\")", "eel-string.c"
, 861); eel_check_boolean_result (eel_str_has_prefix ("", "a"
), (0)); } while (0)
;
862 EEL_CHECK_BOOLEAN_RESULT (eel_str_has_prefix ("a", ""), TRUE)do { eel_before_check ("eel_str_has_prefix (\"a\", \"\")", "eel-string.c"
, 862); eel_check_boolean_result (eel_str_has_prefix ("a", ""
), (!(0))); } while (0)
;
863 EEL_CHECK_BOOLEAN_RESULT (eel_str_has_prefix ("a", "b"), FALSE)do { eel_before_check ("eel_str_has_prefix (\"a\", \"b\")", "eel-string.c"
, 863); eel_check_boolean_result (eel_str_has_prefix ("a", "b"
), (0)); } while (0)
;
864 EEL_CHECK_BOOLEAN_RESULT (eel_str_has_prefix ("a", "ab"), FALSE)do { eel_before_check ("eel_str_has_prefix (\"a\", \"ab\")", "eel-string.c"
, 864); eel_check_boolean_result (eel_str_has_prefix ("a", "ab"
), (0)); } while (0)
;
865 EEL_CHECK_BOOLEAN_RESULT (eel_str_has_prefix ("ab", "a"), TRUE)do { eel_before_check ("eel_str_has_prefix (\"ab\", \"a\")", "eel-string.c"
, 865); eel_check_boolean_result (eel_str_has_prefix ("ab", "a"
), (!(0))); } while (0)
;
866 EEL_CHECK_BOOLEAN_RESULT (eel_str_has_prefix ("aaa", "aaab"), FALSE)do { eel_before_check ("eel_str_has_prefix (\"aaa\", \"aaab\")"
, "eel-string.c", 866); eel_check_boolean_result (eel_str_has_prefix
("aaa", "aaab"), (0)); } while (0)
;
867 EEL_CHECK_BOOLEAN_RESULT (eel_str_has_prefix ("aaab", "aaa"), TRUE)do { eel_before_check ("eel_str_has_prefix (\"aaab\", \"aaa\")"
, "eel-string.c", 867); eel_check_boolean_result (eel_str_has_prefix
("aaab", "aaa"), (!(0))); } while (0)
;
868
869 EEL_CHECK_STRING_RESULT (eel_str_get_prefix (NULL, NULL), NULL)do { eel_before_check ("eel_str_get_prefix (((void*)0), ((void*)0))"
, "eel-string.c", 869); eel_check_string_result (eel_str_get_prefix
(((void*)0), ((void*)0)), ((void*)0)); } while (0)
;
870 EEL_CHECK_STRING_RESULT (eel_str_get_prefix (NULL, "foo"), NULL)do { eel_before_check ("eel_str_get_prefix (((void*)0), \"foo\")"
, "eel-string.c", 870); eel_check_string_result (eel_str_get_prefix
(((void*)0), "foo"), ((void*)0)); } while (0)
;
871 EEL_CHECK_STRING_RESULT (eel_str_get_prefix ("foo", NULL), "foo")do { eel_before_check ("eel_str_get_prefix (\"foo\", ((void*)0))"
, "eel-string.c", 871); eel_check_string_result (eel_str_get_prefix
("foo", ((void*)0)), "foo"); } while (0)
;
872 EEL_CHECK_STRING_RESULT (eel_str_get_prefix ("", ""), "")do { eel_before_check ("eel_str_get_prefix (\"\", \"\")", "eel-string.c"
, 872); eel_check_string_result (eel_str_get_prefix ("", ""),
""); } while (0)
;
873 EEL_CHECK_STRING_RESULT (eel_str_get_prefix ("", "foo"), "")do { eel_before_check ("eel_str_get_prefix (\"\", \"foo\")", "eel-string.c"
, 873); eel_check_string_result (eel_str_get_prefix ("", "foo"
), ""); } while (0)
;
874 EEL_CHECK_STRING_RESULT (eel_str_get_prefix ("foo", ""), "")do { eel_before_check ("eel_str_get_prefix (\"foo\", \"\")", "eel-string.c"
, 874); eel_check_string_result (eel_str_get_prefix ("foo", ""
), ""); } while (0)
;
875 EEL_CHECK_STRING_RESULT (eel_str_get_prefix ("foo", "foo"), "")do { eel_before_check ("eel_str_get_prefix (\"foo\", \"foo\")"
, "eel-string.c", 875); eel_check_string_result (eel_str_get_prefix
("foo", "foo"), ""); } while (0)
;
876 EEL_CHECK_STRING_RESULT (eel_str_get_prefix ("foo:", ":"), "foo")do { eel_before_check ("eel_str_get_prefix (\"foo:\", \":\")"
, "eel-string.c", 876); eel_check_string_result (eel_str_get_prefix
("foo:", ":"), "foo"); } while (0)
;
877 EEL_CHECK_STRING_RESULT (eel_str_get_prefix ("foo:bar", ":"), "foo")do { eel_before_check ("eel_str_get_prefix (\"foo:bar\", \":\")"
, "eel-string.c", 877); eel_check_string_result (eel_str_get_prefix
("foo:bar", ":"), "foo"); } while (0)
;
878 EEL_CHECK_STRING_RESULT (eel_str_get_prefix ("footle:bar", "tle:"), "foo")do { eel_before_check ("eel_str_get_prefix (\"footle:bar\", \"tle:\")"
, "eel-string.c", 878); eel_check_string_result (eel_str_get_prefix
("footle:bar", "tle:"), "foo"); } while (0)
;
879
880 EEL_CHECK_STRING_RESULT (eel_str_double_underscores (NULL), NULL)do { eel_before_check ("eel_str_double_underscores (((void*)0))"
, "eel-string.c", 880); eel_check_string_result (eel_str_double_underscores
(((void*)0)), ((void*)0)); } while (0)
;
881 EEL_CHECK_STRING_RESULT (eel_str_double_underscores (""), "")do { eel_before_check ("eel_str_double_underscores (\"\")", "eel-string.c"
, 881); eel_check_string_result (eel_str_double_underscores (
""), ""); } while (0)
;
882 EEL_CHECK_STRING_RESULT (eel_str_double_underscores ("_"), "__")do { eel_before_check ("eel_str_double_underscores (\"_\")", "eel-string.c"
, 882); eel_check_string_result (eel_str_double_underscores (
"_"), "__"); } while (0)
;
883 EEL_CHECK_STRING_RESULT (eel_str_double_underscores ("foo"), "foo")do { eel_before_check ("eel_str_double_underscores (\"foo\")"
, "eel-string.c", 883); eel_check_string_result (eel_str_double_underscores
("foo"), "foo"); } while (0)
;
884 EEL_CHECK_STRING_RESULT (eel_str_double_underscores ("foo_bar"), "foo__bar")do { eel_before_check ("eel_str_double_underscores (\"foo_bar\")"
, "eel-string.c", 884); eel_check_string_result (eel_str_double_underscores
("foo_bar"), "foo__bar"); } while (0)
;
885 EEL_CHECK_STRING_RESULT (eel_str_double_underscores ("foo_bar_2"), "foo__bar__2")do { eel_before_check ("eel_str_double_underscores (\"foo_bar_2\")"
, "eel-string.c", 885); eel_check_string_result (eel_str_double_underscores
("foo_bar_2"), "foo__bar__2"); } while (0)
;
886 EEL_CHECK_STRING_RESULT (eel_str_double_underscores ("_foo"), "__foo")do { eel_before_check ("eel_str_double_underscores (\"_foo\")"
, "eel-string.c", 886); eel_check_string_result (eel_str_double_underscores
("_foo"), "__foo"); } while (0)
;
887 EEL_CHECK_STRING_RESULT (eel_str_double_underscores ("foo_"), "foo__")do { eel_before_check ("eel_str_double_underscores (\"foo_\")"
, "eel-string.c", 887); eel_check_string_result (eel_str_double_underscores
("foo_"), "foo__"); } while (0)
;
888
889 EEL_CHECK_STRING_RESULT (eel_str_capitalize (NULL), NULL)do { eel_before_check ("eel_str_capitalize (((void*)0))", "eel-string.c"
, 889); eel_check_string_result (eel_str_capitalize (((void*)
0)), ((void*)0)); } while (0)
;
890 EEL_CHECK_STRING_RESULT (eel_str_capitalize (""), "")do { eel_before_check ("eel_str_capitalize (\"\")", "eel-string.c"
, 890); eel_check_string_result (eel_str_capitalize (""), "")
; } while (0)
;
891 EEL_CHECK_STRING_RESULT (eel_str_capitalize ("foo"), "Foo")do { eel_before_check ("eel_str_capitalize (\"foo\")", "eel-string.c"
, 891); eel_check_string_result (eel_str_capitalize ("foo"), "Foo"
); } while (0)
;
892 EEL_CHECK_STRING_RESULT (eel_str_capitalize ("Foo"), "Foo")do { eel_before_check ("eel_str_capitalize (\"Foo\")", "eel-string.c"
, 892); eel_check_string_result (eel_str_capitalize ("Foo"), "Foo"
); } while (0)
;
893
894 EEL_CHECK_STRING_RESULT (eel_str_middle_truncate ("foo", 0), "foo")do { eel_before_check ("eel_str_middle_truncate (\"foo\", 0)"
, "eel-string.c", 894); eel_check_string_result (eel_str_middle_truncate
("foo", 0), "foo"); } while (0)
;
895 EEL_CHECK_STRING_RESULT (eel_str_middle_truncate ("foo", 1), "foo")do { eel_before_check ("eel_str_middle_truncate (\"foo\", 1)"
, "eel-string.c", 895); eel_check_string_result (eel_str_middle_truncate
("foo", 1), "foo"); } while (0)
;
896 EEL_CHECK_STRING_RESULT (eel_str_middle_truncate ("foo", 3), "foo")do { eel_before_check ("eel_str_middle_truncate (\"foo\", 3)"
, "eel-string.c", 896); eel_check_string_result (eel_str_middle_truncate
("foo", 3), "foo"); } while (0)
;
897 EEL_CHECK_STRING_RESULT (eel_str_middle_truncate ("foo", 4), "foo")do { eel_before_check ("eel_str_middle_truncate (\"foo\", 4)"
, "eel-string.c", 897); eel_check_string_result (eel_str_middle_truncate
("foo", 4), "foo"); } while (0)
;
898 EEL_CHECK_STRING_RESULT (eel_str_middle_truncate ("foo", 5), "foo")do { eel_before_check ("eel_str_middle_truncate (\"foo\", 5)"
, "eel-string.c", 898); eel_check_string_result (eel_str_middle_truncate
("foo", 5), "foo"); } while (0)
;
899 EEL_CHECK_STRING_RESULT (eel_str_middle_truncate ("foo", 6), "foo")do { eel_before_check ("eel_str_middle_truncate (\"foo\", 6)"
, "eel-string.c", 899); eel_check_string_result (eel_str_middle_truncate
("foo", 6), "foo"); } while (0)
;
900 EEL_CHECK_STRING_RESULT (eel_str_middle_truncate ("foo", 7), "foo")do { eel_before_check ("eel_str_middle_truncate (\"foo\", 7)"
, "eel-string.c", 900); eel_check_string_result (eel_str_middle_truncate
("foo", 7), "foo"); } while (0)
;
901 EEL_CHECK_STRING_RESULT (eel_str_middle_truncate ("a_much_longer_foo", 0), "a_much_longer_foo")do { eel_before_check ("eel_str_middle_truncate (\"a_much_longer_foo\", 0)"
, "eel-string.c", 901); eel_check_string_result (eel_str_middle_truncate
("a_much_longer_foo", 0), "a_much_longer_foo"); } while (0)
;
902 EEL_CHECK_STRING_RESULT (eel_str_middle_truncate ("a_much_longer_foo", 1), "a_much_longer_foo")do { eel_before_check ("eel_str_middle_truncate (\"a_much_longer_foo\", 1)"
, "eel-string.c", 902); eel_check_string_result (eel_str_middle_truncate
("a_much_longer_foo", 1), "a_much_longer_foo"); } while (0)
;
903 EEL_CHECK_STRING_RESULT (eel_str_middle_truncate ("a_much_longer_foo", 2), "a_much_longer_foo")do { eel_before_check ("eel_str_middle_truncate (\"a_much_longer_foo\", 2)"
, "eel-string.c", 903); eel_check_string_result (eel_str_middle_truncate
("a_much_longer_foo", 2), "a_much_longer_foo"); } while (0)
;
904 EEL_CHECK_STRING_RESULT (eel_str_middle_truncate ("a_much_longer_foo", 3), "a_much_longer_foo")do { eel_before_check ("eel_str_middle_truncate (\"a_much_longer_foo\", 3)"
, "eel-string.c", 904); eel_check_string_result (eel_str_middle_truncate
("a_much_longer_foo", 3), "a_much_longer_foo"); } while (0)
;
905 EEL_CHECK_STRING_RESULT (eel_str_middle_truncate ("a_much_longer_foo", 4), "a_much_longer_foo")do { eel_before_check ("eel_str_middle_truncate (\"a_much_longer_foo\", 4)"
, "eel-string.c", 905); eel_check_string_result (eel_str_middle_truncate
("a_much_longer_foo", 4), "a_much_longer_foo"); } while (0)
;
906 EEL_CHECK_STRING_RESULT (eel_str_middle_truncate ("a_much_longer_foo", 5), "a...o")do { eel_before_check ("eel_str_middle_truncate (\"a_much_longer_foo\", 5)"
, "eel-string.c", 906); eel_check_string_result (eel_str_middle_truncate
("a_much_longer_foo", 5), "a...o"); } while (0)
;
907 EEL_CHECK_STRING_RESULT (eel_str_middle_truncate ("a_much_longer_foo", 6), "a...oo")do { eel_before_check ("eel_str_middle_truncate (\"a_much_longer_foo\", 6)"
, "eel-string.c", 907); eel_check_string_result (eel_str_middle_truncate
("a_much_longer_foo", 6), "a...oo"); } while (0)
;
908 EEL_CHECK_STRING_RESULT (eel_str_middle_truncate ("a_much_longer_foo", 7), "a_...oo")do { eel_before_check ("eel_str_middle_truncate (\"a_much_longer_foo\", 7)"
, "eel-string.c", 908); eel_check_string_result (eel_str_middle_truncate
("a_much_longer_foo", 7), "a_...oo"); } while (0)
;
909 EEL_CHECK_STRING_RESULT (eel_str_middle_truncate ("a_much_longer_foo", 8), "a_...foo")do { eel_before_check ("eel_str_middle_truncate (\"a_much_longer_foo\", 8)"
, "eel-string.c", 909); eel_check_string_result (eel_str_middle_truncate
("a_much_longer_foo", 8), "a_...foo"); } while (0)
;
910 EEL_CHECK_STRING_RESULT (eel_str_middle_truncate ("a_much_longer_foo", 9), "a_m...foo")do { eel_before_check ("eel_str_middle_truncate (\"a_much_longer_foo\", 9)"
, "eel-string.c", 910); eel_check_string_result (eel_str_middle_truncate
("a_much_longer_foo", 9), "a_m...foo"); } while (0)
;
911 EEL_CHECK_STRING_RESULT (eel_str_middle_truncate ("something_even", 8), "so...ven")do { eel_before_check ("eel_str_middle_truncate (\"something_even\", 8)"
, "eel-string.c", 911); eel_check_string_result (eel_str_middle_truncate
("something_even", 8), "so...ven"); } while (0)
;
912 EEL_CHECK_STRING_RESULT (eel_str_middle_truncate ("something_odd", 8), "so...odd")do { eel_before_check ("eel_str_middle_truncate (\"something_odd\", 8)"
, "eel-string.c", 912); eel_check_string_result (eel_str_middle_truncate
("something_odd", 8), "so...odd"); } while (0)
;
913 EEL_CHECK_STRING_RESULT (eel_str_middle_truncate ("something_even", 9), "som...ven")do { eel_before_check ("eel_str_middle_truncate (\"something_even\", 9)"
, "eel-string.c", 913); eel_check_string_result (eel_str_middle_truncate
("something_even", 9), "som...ven"); } while (0)
;
914 EEL_CHECK_STRING_RESULT (eel_str_middle_truncate ("something_odd", 9), "som...odd")do { eel_before_check ("eel_str_middle_truncate (\"something_odd\", 9)"
, "eel-string.c", 914); eel_check_string_result (eel_str_middle_truncate
("something_odd", 9), "som...odd"); } while (0)
;
915 EEL_CHECK_STRING_RESULT (eel_str_middle_truncate ("something_even", 10), "som...even")do { eel_before_check ("eel_str_middle_truncate (\"something_even\", 10)"
, "eel-string.c", 915); eel_check_string_result (eel_str_middle_truncate
("something_even", 10), "som...even"); } while (0)
;
916 EEL_CHECK_STRING_RESULT (eel_str_middle_truncate ("something_odd", 10), "som..._odd")do { eel_before_check ("eel_str_middle_truncate (\"something_odd\", 10)"
, "eel-string.c", 916); eel_check_string_result (eel_str_middle_truncate
("something_odd", 10), "som..._odd"); } while (0)
;
917 EEL_CHECK_STRING_RESULT (eel_str_middle_truncate ("something_even", 11), "some...even")do { eel_before_check ("eel_str_middle_truncate (\"something_even\", 11)"
, "eel-string.c", 917); eel_check_string_result (eel_str_middle_truncate
("something_even", 11), "some...even"); } while (0)
;
918 EEL_CHECK_STRING_RESULT (eel_str_middle_truncate ("something_odd", 11), "some..._odd")do { eel_before_check ("eel_str_middle_truncate (\"something_odd\", 11)"
, "eel-string.c", 918); eel_check_string_result (eel_str_middle_truncate
("something_odd", 11), "some..._odd"); } while (0)
;
919 EEL_CHECK_STRING_RESULT (eel_str_middle_truncate ("something_even", 12), "some..._even")do { eel_before_check ("eel_str_middle_truncate (\"something_even\", 12)"
, "eel-string.c", 919); eel_check_string_result (eel_str_middle_truncate
("something_even", 12), "some..._even"); } while (0)
;
920 EEL_CHECK_STRING_RESULT (eel_str_middle_truncate ("something_odd", 12), "some...g_odd")do { eel_before_check ("eel_str_middle_truncate (\"something_odd\", 12)"
, "eel-string.c", 920); eel_check_string_result (eel_str_middle_truncate
("something_odd", 12), "some...g_odd"); } while (0)
;
921 EEL_CHECK_STRING_RESULT (eel_str_middle_truncate ("something_even", 13), "somet..._even")do { eel_before_check ("eel_str_middle_truncate (\"something_even\", 13)"
, "eel-string.c", 921); eel_check_string_result (eel_str_middle_truncate
("something_even", 13), "somet..._even"); } while (0)
;
922 EEL_CHECK_STRING_RESULT (eel_str_middle_truncate ("something_odd", 13), "something_odd")do { eel_before_check ("eel_str_middle_truncate (\"something_odd\", 13)"
, "eel-string.c", 922); eel_check_string_result (eel_str_middle_truncate
("something_odd", 13), "something_odd"); } while (0)
;
923 EEL_CHECK_STRING_RESULT (eel_str_middle_truncate ("something_even", 14), "something_even")do { eel_before_check ("eel_str_middle_truncate (\"something_even\", 14)"
, "eel-string.c", 923); eel_check_string_result (eel_str_middle_truncate
("something_even", 14), "something_even"); } while (0)
;
924 EEL_CHECK_STRING_RESULT (eel_str_middle_truncate ("something_odd", 13), "something_odd")do { eel_before_check ("eel_str_middle_truncate (\"something_odd\", 13)"
, "eel-string.c", 924); eel_check_string_result (eel_str_middle_truncate
("something_odd", 13), "something_odd"); } while (0)
;
925
926 EEL_CHECK_STRING_RESULT (eel_str_strip_substring_and_after (NULL, "bar"), NULL)do { eel_before_check ("eel_str_strip_substring_and_after (((void*)0), \"bar\")"
, "eel-string.c", 926); eel_check_string_result (eel_str_strip_substring_and_after
(((void*)0), "bar"), ((void*)0)); } while (0)
;
927 EEL_CHECK_STRING_RESULT (eel_str_strip_substring_and_after ("", "bar"), "")do { eel_before_check ("eel_str_strip_substring_and_after (\"\", \"bar\")"
, "eel-string.c", 927); eel_check_string_result (eel_str_strip_substring_and_after
("", "bar"), ""); } while (0)
;
928 EEL_CHECK_STRING_RESULT (eel_str_strip_substring_and_after ("foo", "bar"), "foo")do { eel_before_check ("eel_str_strip_substring_and_after (\"foo\", \"bar\")"
, "eel-string.c", 928); eel_check_string_result (eel_str_strip_substring_and_after
("foo", "bar"), "foo"); } while (0)
;
929 EEL_CHECK_STRING_RESULT (eel_str_strip_substring_and_after ("foo bar", "bar"), "foo ")do { eel_before_check ("eel_str_strip_substring_and_after (\"foo bar\", \"bar\")"
, "eel-string.c", 929); eel_check_string_result (eel_str_strip_substring_and_after
("foo bar", "bar"), "foo "); } while (0)
;
930 EEL_CHECK_STRING_RESULT (eel_str_strip_substring_and_after ("foo bar xxx", "bar"), "foo ")do { eel_before_check ("eel_str_strip_substring_and_after (\"foo bar xxx\", \"bar\")"
, "eel-string.c", 930); eel_check_string_result (eel_str_strip_substring_and_after
("foo bar xxx", "bar"), "foo "); } while (0)
;
931 EEL_CHECK_STRING_RESULT (eel_str_strip_substring_and_after ("bar", "bar"), "")do { eel_before_check ("eel_str_strip_substring_and_after (\"bar\", \"bar\")"
, "eel-string.c", 931); eel_check_string_result (eel_str_strip_substring_and_after
("bar", "bar"), ""); } while (0)
;
932
933 EEL_CHECK_STRING_RESULT (eel_str_replace_substring (NULL, "foo", NULL), NULL)do { eel_before_check ("eel_str_replace_substring (((void*)0), \"foo\", ((void*)0))"
, "eel-string.c", 933); eel_check_string_result (eel_str_replace_substring
(((void*)0), "foo", ((void*)0)), ((void*)0)); } while (0)
;
934 EEL_CHECK_STRING_RESULT (eel_str_replace_substring (NULL, "foo", "bar"), NULL)do { eel_before_check ("eel_str_replace_substring (((void*)0), \"foo\", \"bar\")"
, "eel-string.c", 934); eel_check_string_result (eel_str_replace_substring
(((void*)0), "foo", "bar"), ((void*)0)); } while (0)
;
935 EEL_CHECK_STRING_RESULT (eel_str_replace_substring ("bar", "foo", NULL), "bar")do { eel_before_check ("eel_str_replace_substring (\"bar\", \"foo\", ((void*)0))"
, "eel-string.c", 935); eel_check_string_result (eel_str_replace_substring
("bar", "foo", ((void*)0)), "bar"); } while (0)
;
936 EEL_CHECK_STRING_RESULT (eel_str_replace_substring ("", "foo", ""), "")do { eel_before_check ("eel_str_replace_substring (\"\", \"foo\", \"\")"
, "eel-string.c", 936); eel_check_string_result (eel_str_replace_substring
("", "foo", ""), ""); } while (0)
;
937 EEL_CHECK_STRING_RESULT (eel_str_replace_substring ("", "foo", "bar"), "")do { eel_before_check ("eel_str_replace_substring (\"\", \"foo\", \"bar\")"
, "eel-string.c", 937); eel_check_string_result (eel_str_replace_substring
("", "foo", "bar"), ""); } while (0)
;
938 EEL_CHECK_STRING_RESULT (eel_str_replace_substring ("bar", "foo", ""), "bar")do { eel_before_check ("eel_str_replace_substring (\"bar\", \"foo\", \"\")"
, "eel-string.c", 938); eel_check_string_result (eel_str_replace_substring
("bar", "foo", ""), "bar"); } while (0)
;
939 EEL_CHECK_STRING_RESULT (eel_str_replace_substring ("xxx", "x", "foo"), "foofoofoo")do { eel_before_check ("eel_str_replace_substring (\"xxx\", \"x\", \"foo\")"
, "eel-string.c", 939); eel_check_string_result (eel_str_replace_substring
("xxx", "x", "foo"), "foofoofoo"); } while (0)
;
940 EEL_CHECK_STRING_RESULT (eel_str_replace_substring ("fff", "f", "foo"), "foofoofoo")do { eel_before_check ("eel_str_replace_substring (\"fff\", \"f\", \"foo\")"
, "eel-string.c", 940); eel_check_string_result (eel_str_replace_substring
("fff", "f", "foo"), "foofoofoo"); } while (0)
;
941 EEL_CHECK_STRING_RESULT (eel_str_replace_substring ("foofoofoo", "foo", "f"), "fff")do { eel_before_check ("eel_str_replace_substring (\"foofoofoo\", \"foo\", \"f\")"
, "eel-string.c", 941); eel_check_string_result (eel_str_replace_substring
("foofoofoo", "foo", "f"), "fff"); } while (0)
;
942 EEL_CHECK_STRING_RESULT (eel_str_replace_substring ("foofoofoo", "f", ""), "oooooo")do { eel_before_check ("eel_str_replace_substring (\"foofoofoo\", \"f\", \"\")"
, "eel-string.c", 942); eel_check_string_result (eel_str_replace_substring
("foofoofoo", "f", ""), "oooooo"); } while (0)
;
943
944 verify_printf ("%.*s", 2, "foo");
945 verify_printf ("%*.*s", 2, 4, "foo");
946 verify_printf ("before %5$*1$.*2$s between %6$*3$.*4$d after",
947 4, 5, 6, 7, "foo", G_PI3.1415926535897932384626433832795028841971693993751);
948 verify_custom ("c1-42- c2-foo-","%N %Y", 42 ,"foo");
949 verify_custom ("c1-42- bar c2-foo-","%N %s %Y", 42, "bar" ,"foo");
950 verify_custom ("c1-42- bar c2-foo-","%3$N %2$s %1$Y","foo", "bar", 42);
951
952}
953
954#endif /* !EEL_OMIT_SELF_CHECK */