summaryrefslogtreecommitdiffstats
path: root/gl/printf-parse.c
diff options
context:
space:
mode:
Diffstat (limited to 'gl/printf-parse.c')
-rw-r--r--gl/printf-parse.c22
1 files changed, 6 insertions, 16 deletions
diff --git a/gl/printf-parse.c b/gl/printf-parse.c
index a33e27a0..34d241a6 100644
--- a/gl/printf-parse.c
+++ b/gl/printf-parse.c
@@ -1,5 +1,5 @@
1/* Formatted output to strings. 1/* Formatted output to strings.
2 Copyright (C) 1999-2000, 2002-2003, 2006-2024 Free Software Foundation, Inc. 2 Copyright (C) 1999-2000, 2002-2003, 2006-2026 Free Software Foundation, Inc.
3 3
4 This file is free software: you can redistribute it and/or modify 4 This file is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as 5 it under the terms of the GNU Lesser General Public License as
@@ -323,8 +323,6 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
323 } 323 }
324 324
325 { 325 {
326 arg_type type;
327
328 /* Parse argument type/size specifiers. */ 326 /* Parse argument type/size specifiers. */
329 /* Relevant for the conversion characters d, i. */ 327 /* Relevant for the conversion characters d, i. */
330 arg_type signed_type = TYPE_INT; 328 arg_type signed_type = TYPE_INT;
@@ -561,6 +559,7 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
561 (void) pointer_type; 559 (void) pointer_type;
562 560
563 /* Read the conversion character. */ 561 /* Read the conversion character. */
562 arg_type type;
564 c = *cp++; 563 c = *cp++;
565 switch (c) 564 switch (c)
566 { 565 {
@@ -600,20 +599,14 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
600 if (signed_type == TYPE_LONGINT 599 if (signed_type == TYPE_LONGINT
601 /* For backward compatibility only. */ 600 /* For backward compatibility only. */
602 || signed_type == TYPE_LONGLONGINT) 601 || signed_type == TYPE_LONGLONGINT)
603#if HAVE_WCHAR_T
604 type = TYPE_WIDE_STRING; 602 type = TYPE_WIDE_STRING;
605#else
606 goto error;
607#endif
608 else 603 else
609 type = TYPE_STRING; 604 type = TYPE_STRING;
610 break; 605 break;
611#if HAVE_WCHAR_T
612 case 'S': 606 case 'S':
613 type = TYPE_WIDE_STRING; 607 type = TYPE_WIDE_STRING;
614 c = 's'; 608 c = 's';
615 break; 609 break;
616#endif
617 case 'p': 610 case 'p':
618 type = TYPE_POINTER; 611 type = TYPE_POINTER;
619 break; 612 break;
@@ -660,17 +653,14 @@ PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
660 d->count++; 653 d->count++;
661 if (d->count >= d_allocated) 654 if (d->count >= d_allocated)
662 { 655 {
663 size_t memory_size;
664 DIRECTIVE *memory;
665
666 d_allocated = xtimes (d_allocated, 2); 656 d_allocated = xtimes (d_allocated, 2);
667 memory_size = xtimes (d_allocated, sizeof (DIRECTIVE)); 657 size_t memory_size = xtimes (d_allocated, sizeof (DIRECTIVE));
668 if (size_overflow_p (memory_size)) 658 if (size_overflow_p (memory_size))
669 /* Overflow, would lead to out of memory. */ 659 /* Overflow, would lead to out of memory. */
670 goto out_of_memory; 660 goto out_of_memory;
671 memory = (DIRECTIVE *) (d->dir != d->direct_alloc_dir 661 DIRECTIVE *memory = (DIRECTIVE *) (d->dir != d->direct_alloc_dir
672 ? realloc (d->dir, memory_size) 662 ? realloc (d->dir, memory_size)
673 : malloc (memory_size)); 663 : malloc (memory_size));
674 if (memory == NULL) 664 if (memory == NULL)
675 /* Out of memory. */ 665 /* Out of memory. */
676 goto out_of_memory; 666 goto out_of_memory;