Radix cross Linux

The main Radix cross Linux repository contains the build scripts of packages, which have the most complete and common functionality for desktop machines

452 Commits   2 Branches   1 Tag
Index: create.patch.sh
===================================================================
--- create.patch.sh	(nonexistent)
+++ create.patch.sh	(revision 35)
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+VERSION=2.37
+
+tar --files-from=file.list -xJvf ../glibc-$VERSION.tar.xz
+mv glibc-$VERSION glibc-$VERSION-orig
+
+cp -rf ./glibc-$VERSION-new ./glibc-$VERSION
+
+diff --unified -Nr  glibc-$VERSION-orig  glibc-$VERSION > glibc-$VERSION-CVE-2023-25139.patch
+
+mv glibc-$VERSION-CVE-2023-25139.patch ../patches
+
+rm -rf ./glibc-$VERSION
+rm -rf ./glibc-$VERSION-orig

Property changes on: create.patch.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: file.list
===================================================================
--- file.list	(nonexistent)
+++ file.list	(revision 35)
@@ -0,0 +1,2 @@
+glibc-2.37/stdio-common/Makefile
+glibc-2.37/stdio-common/vfprintf-process-arg.c
Index: glibc-2.37-new/stdio-common/Makefile
===================================================================
--- glibc-2.37-new/stdio-common/Makefile	(nonexistent)
+++ glibc-2.37-new/stdio-common/Makefile	(revision 35)
@@ -0,0 +1,450 @@
+# Copyright (C) 1991-2023 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, see
+# <https://www.gnu.org/licenses/>.
+
+#
+#	Specific makefile for stdio-common.
+#
+subdir	:= stdio-common
+
+include ../Makeconfig
+
+headers	:= stdio_ext.h printf.h bits/printf-ldbl.h bits/stdio_lim.h
+
+routines := \
+  _itoa \
+  _itowa \
+  asprintf \
+  ctermid \
+  cuserid \
+  dprintf \
+  flockfile \
+  fprintf \
+  fscanf \
+  ftrylockfile \
+  funlockfile \
+  gentempfd \
+  getline \
+  getw \
+  grouping_iterator \
+  iovfscanf \
+  isoc99_fscanf \
+  isoc99_scanf \
+  isoc99_sscanf \
+  isoc99_vfscanf \
+  isoc99_vscanf \
+  isoc99_vsscanf \
+  itoa-digits \
+  itoa-udigits \
+  itowa-digits \
+  perror \
+  printf \
+  printf-prs \
+  printf_buffer_as_file \
+  printf_buffer_done \
+  printf_buffer_flush \
+  printf_buffer_pad_1 \
+  printf_buffer_putc_1 \
+  printf_buffer_puts_1 \
+  printf_buffer_to_file \
+  printf_buffer_write \
+  printf_fp \
+  printf_fphex \
+  printf_function_invoke \
+  printf_size \
+  psiginfo \
+  psignal \
+  putw \
+  reg-modifier \
+  reg-printf \
+  reg-type \
+  remove \
+  rename \
+  renameat \
+  renameat2 \
+  scanf \
+  snprintf \
+  sprintf \
+  sscanf \
+  tempnam \
+  tempname \
+  tmpfile \
+  tmpfile64 \
+  tmpnam \
+  tmpnam_r \
+  translated_number_width \
+  vfprintf \
+  vfprintf-internal \
+  vfscanf \
+  vfscanf-internal \
+  vfwprintf \
+  vfwprintf-internal \
+  vfwscanf \
+  vfwscanf-internal \
+  vprintf \
+  wprintf_buffer_as_file \
+  wprintf_buffer_done \
+  wprintf_buffer_flush \
+  wprintf_buffer_pad_1 \
+  wprintf_buffer_putc_1 \
+  wprintf_buffer_puts_1 \
+  wprintf_buffer_to_file \
+  wprintf_buffer_write \
+  wprintf_function_invoke \
+  # routines
+
+aux := \
+  errlist \
+  errlist-data \
+  errname \
+  fxprintf \
+  printf-parsemb \
+  printf-parsewc \
+  siglist \
+  # aux
+
+tests := \
+  bug-vfprintf-nargs \
+  bug1 \
+  bug10 \
+  bug11 \
+  bug12 \
+  bug13 \
+  bug14 \
+  bug16 \
+  bug17 \
+  bug18 \
+  bug18a \
+  bug19 \
+  bug19a \
+  bug2 \
+  bug20 \
+  bug21 \
+  bug22 \
+  bug23 \
+  bug23-2 \
+  bug23-3 \
+  bug23-4 \
+  bug24 \
+  bug25 \
+  bug26 \
+  bug3 \
+  bug4 \
+  bug5 \
+  bug6 \
+  bug7 \
+  bug8 \
+  bug9 \
+  errnobug \
+  scanf1 \
+  scanf10 \
+  scanf11 \
+  scanf12 \
+  scanf13 \
+  scanf14 \
+  scanf14a \
+  scanf15 \
+  scanf16 \
+  scanf16a \
+  scanf17 \
+  scanf2 \
+  scanf3 \
+  scanf4 \
+  scanf5 \
+  scanf7 \
+  scanf8 \
+  scanf9 \
+  temptest \
+  test-fseek \
+  test-fwrite \
+  test-popen \
+  test-strerr \
+  test-vfprintf \
+  test_rdwr \
+  tfformat \
+  tiformat \
+  tllformat \
+  tst-bz11319 \
+  tst-bz11319-fortify2 \
+  tst-cookie \
+  tst-dprintf-length \
+  tst-fdopen \
+  tst-ferror \
+  tst-fgets \
+  tst-fileno \
+  tst-fmemopen \
+  tst-fmemopen2 \
+  tst-fmemopen3 \
+  tst-fmemopen4 \
+  tst-fphex \
+  tst-fphex-wide \
+  tst-fseek \
+  tst-fwrite \
+  tst-gets \
+  tst-grouping \
+  tst-grouping2 \
+  tst-grouping3 \
+  tst-long-dbl-fphex \
+  tst-memstream-string \
+  tst-obprintf \
+  tst-perror \
+  tst-popen \
+  tst-popen2 \
+  tst-printf-binary \
+  tst-printf-bz18872 \
+  tst-printf-bz25691 \
+  tst-printf-fp-free \
+  tst-printf-fp-leak \
+  tst-printf-oct \
+  tst-printf-round \
+  tst-printfsz \
+  tst-put-error \
+  tst-renameat2 \
+  tst-rndseek \
+  tst-scanf-round \
+  tst-setvbuf1 \
+  tst-sprintf \
+  tst-sprintf-errno \
+  tst-sprintf2 \
+  tst-sprintf3 \
+  tst-sscanf \
+  tst-swprintf \
+  tst-swscanf \
+  tst-tmpnam \
+  tst-ungetc \
+  tst-unlockedio \
+  tst-vfprintf-mbs-prec \
+  tst-vfprintf-user-type \
+  tst-vfprintf-width-prec \
+  tst-vfprintf-width-prec-alloc \
+  tst-vfprintf-width-i18n \
+  tst-wc-printf \
+  tstdiomisc \
+  tstgetln \
+  tstscanf \
+  xbug \
+  # tests
+
+generated += \
+  errlist-data-aux-shared.S \
+  errlist-data-aux.S \
+  siglist-aux-shared.S \
+  siglist-aux.S \
+  # generated
+
+tests-internal = \
+  tst-grouping_iterator \
+  # tests-internal
+
+test-srcs = tst-unbputc tst-printf tst-printfsz-islongdouble
+
+ifeq ($(run-built-tests),yes)
+tests-special += \
+  $(objpfx)tst-printf-bz18872-mem.out \
+  $(objpfx)tst-printf-bz25691-mem.out \
+  $(objpfx)tst-printf-fp-free-mem.out \
+  $(objpfx)tst-printf-fp-leak-mem.out \
+  $(objpfx)tst-printf.out \
+  $(objpfx)tst-printfsz-islongdouble.out \
+  $(objpfx)tst-setvbuf1-cmp.out \
+  $(objpfx)tst-unbputc.out \
+  $(objpfx)tst-vfprintf-width-prec-mem.out \
+  # tests-special
+
+generated += \
+  tst-printf-bz18872-mem.out \
+  tst-printf-bz18872.c \
+  tst-printf-bz18872.mtrace \
+  tst-printf-bz25691-mem.out \
+  tst-printf-bz25691.mtrace \
+  tst-printf-fp-free-mem.out \
+  tst-printf-fp-free.mtrace \
+  tst-printf-fp-leak-mem.out \
+  tst-printf-fp-leak.mtrace \
+  tst-vfprintf-width-prec-mem.out \
+  tst-vfprintf-width-prec.mtrace \
+  # generated
+endif # $(run-built-tests)
+
+tests-special += $(objpfx)tst-errno-manual.out
+
+include ../Rules
+
+# The errlist.c is built in two phases because compiler might reorder the
+# compat_symbol directive prior the object itself and on binutils older
+# than 2.29 it might generate object sizes different than the expected ones.
+$(objpfx)errlist-data-aux-shared.S: errlist-data-gen.c
+	$(make-target-directory)
+	$(compile-command.c) $(pic-cppflags) $(pic-ccflag) $(no-stack-protector) -S
+
+$(objpfx)errlist-data-aux.S: errlist-data-gen.c
+	$(make-target-directory)
+	$(compile-command.c) $(pie-default) $(no-stack-protector) -S
+
+ifndef no_deps
+-include $(objpfx)errlist-data-aux.S.d $(objpfx)errlist-data-aux-shared.S.d
+endif
+
+$(objpfx)errlist-data.os: $(objpfx)errlist-data-aux-shared.S
+$(addprefix $(objpfx)errlist-data, $(object-suffixes-noshared)): \
+  $(objpfx)errlist-data-aux.S
+
+$(objpfx)siglist-aux-shared.S: siglist-gen.c
+	$(make-target-directory)
+	$(compile-command.c) $(pic-cppflags) $(pic-ccflag) $(no-stack-protector) -S
+
+$(objpfx)siglist-aux.S: siglist-gen.c
+	$(make-target-directory)
+	$(compile-command.c) $(pie-default) $(no-stack-protector) -S
+
+ifndef no_deps
+-include $(objpfx)siglist-aux.S.d $(objpfx)siglist-aux-shared.S.d
+endif
+
+$(objpfx)siglist.os: $(objpfx)siglist-aux-shared.S
+$(addprefix $(objpfx)siglist, $(object-suffixes-noshared)): \
+  $(objpfx)siglist-aux.S
+
+ifeq ($(run-built-tests),yes)
+LOCALES := \
+  de_DE.ISO-8859-1 \
+  de_DE.UTF-8 \
+  en_US.ISO-8859-1 \
+  hi_IN.UTF-8 \
+  ja_JP.EUC-JP \
+  ps_AF.UTF-8 \
+  tg_TJ.UTF-8 \
+ # LOCALES
+include ../gen-locales.mk
+
+$(objpfx)bug14.out: $(gen-locales)
+$(objpfx)scanf13.out: $(gen-locales)
+$(objpfx)test-vfprintf.out: $(gen-locales)
+$(objpfx)tst-grouping.out: $(gen-locales)
+$(objpfx)tst-grouping2.out: $(gen-locales)
+$(objpfx)tst-grouping_iterator.out: $(gen-locales)
+$(objpfx)tst-sprintf.out: $(gen-locales)
+$(objpfx)tst-sscanf.out: $(gen-locales)
+$(objpfx)tst-swprintf.out: $(gen-locales)
+$(objpfx)tst-vfprintf-mbs-prec.out: $(gen-locales)
+$(objpfx)tst-vfprintf-width-i18n.out: $(gen-locales)
+endif
+
+tst-printf-bz18872-ENV = MALLOC_TRACE=$(objpfx)tst-printf-bz18872.mtrace \
+			LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
+tst-vfprintf-width-prec-ENV = \
+  MALLOC_TRACE=$(objpfx)tst-vfprintf-width-prec.mtrace \
+  LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
+tst-printf-bz25691-ENV = \
+  MALLOC_TRACE=$(objpfx)tst-printf-bz25691.mtrace \
+  LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
+tst-printf-fp-free-ENV = \
+  MALLOC_TRACE=$(objpfx)tst-printf-fp-free.mtrace \
+  LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
+tst-printf-fp-leak-ENV = \
+  MALLOC_TRACE=$(objpfx)tst-printf-fp-leak.mtrace \
+  LD_PRELOAD=$(common-objpfx)/malloc/libc_malloc_debug.so
+
+$(objpfx)tst-unbputc.out: tst-unbputc.sh $(objpfx)tst-unbputc
+	$(SHELL) $< $(common-objpfx) '$(test-program-prefix)'; \
+	$(evaluate-test)
+
+$(objpfx)tst-printf.out: tst-printf.sh $(objpfx)tst-printf
+	$(SHELL) $< $(common-objpfx) '$(test-program-prefix)'; \
+	$(evaluate-test)
+
+$(objpfx)tst-printfsz-islongdouble.out: \
+  tst-printfsz-islongdouble.sh $(objpfx)tst-printfsz-islongdouble
+	$(SHELL) $^ '$(test-program-prefix)' $@; \
+	$(evaluate-test)
+
+# We generate this source because it requires a printf invocation with
+# 10K arguments.
+$(objpfx)tst-printf-bz18872.c: tst-printf-bz18872.sh
+	rm -f $@ && $(BASH) $^ > $@.new && mv $@.new $@
+
+$(objpfx)tst-%-mem.out: $(objpfx)tst-%.out
+	$(common-objpfx)malloc/mtrace $(objpfx)tst-$*.mtrace > $@; \
+	$(evaluate-test)
+
+errlist-h = $(firstword $(wildcard $(addsuffix /errlist.h,$(sysdirs) .)))
+
+$(objpfx)tst-errno-manual.out: tst-errno-manual.py \
+			       $(errlist-h) \
+			       $(..)manual/errno.texi
+	$(PYTHON) tst-errno-manual.py -m $(..)manual/errno.texi \
+				      -e $(errlist-h) > $@; \
+	$(evaluate-test)
+
+CFLAGS-vfprintf.c += -Wno-uninitialized
+CFLAGS-vfwprintf.c += -Wno-uninitialized
+
+CFLAGS-tmpfile.c += -fexceptions
+CFLAGS-tmpfile64.c += -fexceptions
+CFLAGS-tempname.c += -fexceptions
+CFLAGS-psignal.c += -fexceptions
+CFLAGS-vprintf.c += -fexceptions
+CFLAGS-cuserid.c += -fexceptions
+
+CFLAGS-vfprintf.c += -fexceptions
+CFLAGS-fprintf.c += -fexceptions
+CFLAGS-printf.c += -fexceptions
+CFLAGS-vfwprintf.c += -fexceptions
+CFLAGS-vfscanf.c += -fexceptions
+CFLAGS-vfwscanf.c += -fexceptions
+CFLAGS-fscanf.c += -fexceptions
+CFLAGS-scanf.c += -fexceptions
+CFLAGS-isoc99_vfscanf.c += -fexceptions
+CFLAGS-isoc99_vscanf.c += -fexceptions
+CFLAGS-isoc99_fscanf.c += -fexceptions
+CFLAGS-isoc99_scanf.c += -fexceptions
+
+CFLAGS-dprintf.c += $(config-cflags-wno-ignored-attributes)
+
+# scanf14a.c and scanf16a.c test a deprecated extension which is no
+# longer visible under most conformance levels; see the source files
+# for more detail.
+CFLAGS-scanf14a.c += -std=gnu89
+CFLAGS-scanf16a.c += -std=gnu89
+
+CFLAGS-bug3.c += -DOBJPFX=\"$(objpfx)\"
+CFLAGS-bug4.c += -DOBJPFX=\"$(objpfx)\"
+CFLAGS-bug5.c += -DOBJPFX=\"$(objpfx)\"
+CFLAGS-test-fseek.c += -DOBJPFX=\"$(objpfx)\"
+CFLAGS-test-popen.c += -DOBJPFX=\"$(objpfx)\"
+CFLAGS-test_rdwr.c += -DOBJPFX=\"$(objpfx)\"
+
+# tst-gets.c tests a deprecated function.
+CFLAGS-tst-gets.c += -Wno-deprecated-declarations
+
+# BZ #11319 was first fixed for regular vdprintf, then reopened because
+# the fortified version had the same bug.
+CFLAGS-tst-bz11319-fortify2.c += -D_FORTIFY_SOURCE=2
+
+CFLAGS-tst-memstream-string.c += -fno-builtin-fprintf
+
+CPPFLAGS += $(libio-mtsafe)
+
+$(objpfx)tst-setvbuf1.out: /dev/null $(objpfx)tst-setvbuf1
+	$(test-program-cmd) > $@ 2>&1; \
+	$(evaluate-test)
+
+$(objpfx)tst-setvbuf1-cmp.out: tst-setvbuf1.expect $(objpfx)tst-setvbuf1.out
+	cmp $^ > $@; \
+	$(evaluate-test)
+
+$(objpfx)tst-printf-round: $(libm)
+$(objpfx)tst-scanf-round: $(libm)
Index: glibc-2.37-new/stdio-common/tst-grouping3.c
===================================================================
--- glibc-2.37-new/stdio-common/tst-grouping3.c	(nonexistent)
+++ glibc-2.37-new/stdio-common/tst-grouping3.c	(revision 35)
@@ -0,0 +1,37 @@
+/* Test printf with grouping and padding (bug 23432)
+   Copyright (C) 2023 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <locale.h>
+#include <stdio.h>
+#include <support/check.h>
+#include <support/support.h>
+
+static int
+do_test (void)
+{
+  char buf[80];
+
+  xsetlocale (LC_NUMERIC, "de_DE.UTF-8");
+
+  sprintf (buf, "%+-'13.9d", 1234567);
+  TEST_COMPARE_STRING (buf, "+001.234.567 ");
+
+  return 0;
+}
+
+#include <support/test-driver.c>
Index: glibc-2.37-new/stdio-common/vfprintf-process-arg.c
===================================================================
--- glibc-2.37-new/stdio-common/vfprintf-process-arg.c	(nonexistent)
+++ glibc-2.37-new/stdio-common/vfprintf-process-arg.c	(revision 35)
@@ -0,0 +1,495 @@
+/* Argument-processing fragment for vfprintf.
+   Copyright (C) 1991-2023 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+/* This file is included twice from vfprintf-internal.c, for standard
+   and GNU-style positional (%N$) arguments.  Before that,
+   process_arg_int etc. macros have to be defined to extract one
+   argument of the appropriate type, in addition to the file-specific
+   macros in vfprintf-internal.c.  */
+
+{
+  /* Start real work.  We know about all flags and modifiers and
+     now process the wanted format specifier.  */
+LABEL (form_percent):
+  /* Write a literal "%".  */
+  Xprintf_buffer_putc (buf, L_('%'));
+  break;
+
+LABEL (form_integer):
+  /* Signed decimal integer.  */
+  base = 10;
+
+  if (is_longlong)
+    {
+      long long int signed_number = process_arg_long_long_int ();
+      is_negative = signed_number < 0;
+      number.longlong = is_negative ? (- signed_number) : signed_number;
+
+      goto LABEL (longlong_number);
+    }
+  else
+    {
+      long int signed_number;
+      if (is_long_num)
+        signed_number = process_arg_long_int ();
+      else if (is_char)
+        signed_number = (signed char) process_arg_unsigned_int ();
+      else if (!is_short)
+        signed_number = process_arg_int ();
+      else
+        signed_number = (short int) process_arg_unsigned_int ();
+
+      is_negative = signed_number < 0;
+      number.word = is_negative ? (- signed_number) : signed_number;
+
+      goto LABEL (number);
+    }
+  /* NOTREACHED */
+
+LABEL (form_unsigned):
+  /* Unsigned decimal integer.  */
+  base = 10;
+  goto LABEL (unsigned_number);
+  /* NOTREACHED */
+
+LABEL (form_octal):
+  /* Unsigned octal integer.  */
+  base = 8;
+  goto LABEL (unsigned_number);
+  /* NOTREACHED */
+
+LABEL (form_hexa):
+  /* Unsigned hexadecimal integer.  */
+  base = 16;
+  goto LABEL (unsigned_number);
+  /* NOTREACHED */
+
+LABEL (form_binary):
+  /* Unsigned binary integer.  */
+  base = 2;
+  goto LABEL (unsigned_number);
+  /* NOTREACHED */
+
+LABEL (unsigned_number):      /* Unsigned number of base BASE.  */
+
+  /* ISO specifies the `+' and ` ' flags only for signed
+     conversions.  */
+  is_negative = 0;
+  showsign = 0;
+  space = 0;
+
+  if (is_longlong)
+    {
+      number.longlong = process_arg_unsigned_long_long_int ();
+
+      LABEL (longlong_number):
+      if (prec < 0)
+        /* Supply a default precision if none was given.  */
+        prec = 1;
+      else
+        /* We have to take care for the '0' flag.  If a precision
+           is given it must be ignored.  */
+        pad = L_(' ');
+
+      /* If the precision is 0 and the number is 0 nothing has to
+         be written for the number, except for the 'o' format in
+         alternate form.  */
+      if (prec == 0 && number.longlong == 0)
+        {
+          string = workend;
+          if (base == 8 && alt)
+            *--string = L_('0');
+        }
+      else
+        /* Put the number in WORK.  */
+        string = _itoa (number.longlong, workend, base, spec == L_('X'));
+      /* Simplify further test for num != 0.  */
+      number.word = number.longlong != 0;
+    }
+  else
+    {
+      if (is_long_num)
+        number.word = process_arg_unsigned_long_int ();
+      else if (is_char)
+        number.word = (unsigned char) process_arg_unsigned_int ();
+      else if (!is_short)
+        number.word = process_arg_unsigned_int ();
+      else
+        number.word = (unsigned short int) process_arg_unsigned_int ();
+
+      LABEL (number):
+      if (prec < 0)
+        /* Supply a default precision if none was given.  */
+        prec = 1;
+      else
+        /* We have to take care for the '0' flag.  If a precision
+           is given it must be ignored.  */
+        pad = L_(' ');
+
+      /* If the precision is 0 and the number is 0 nothing has to
+         be written for the number, except for the 'o' format in
+         alternate form.  */
+      if (prec == 0 && number.word == 0)
+        {
+          string = workend;
+          if (base == 8 && alt)
+            *--string = L_('0');
+        }
+      else
+        /* Put the number in WORK.  */
+        string = _itoa_word (number.word, workend, base,
+                             spec == L_('X'));
+    }
+
+  /* Grouping is also used for outdigits translation.  */
+  struct grouping_iterator iter;
+  bool number_slow_path = group || (use_outdigits && base == 10);
+  if (group)
+    __grouping_iterator_init (&iter, LC_NUMERIC, _NL_CURRENT_LOCALE,
+                              workend - string);
+  else if (use_outdigits && base == 10)
+    __grouping_iterator_init_none (&iter, workend - string);
+
+  int number_length;
+#ifndef COMPILE_WPRINTF
+  if (use_outdigits && base == 10)
+    number_length = __translated_number_width (_NL_CURRENT_LOCALE,
+                                               string, workend);
+  else
+    number_length = workend - string;
+  if (group)
+    number_length += iter.separators * strlen (thousands_sep);
+#else
+  number_length = workend - string;
+  /* All wide separators have length 1.  */
+  if (group && thousands_sep != L'\0')
+    number_length += iter.separators;
+#endif
+
+  /* The marker comes right before the number, but is not subject
+     to grouping.  */
+  bool octal_marker = (prec <= number_length && number.word != 0
+                       && alt && base == 8);
+
+  prec = MAX (0, prec - (workend - string));
+
+  if (!left)
+    {
+      width -= number_length + prec;
+
+      if (number.word != 0 && alt && (base == 16 || base == 2))
+        /* Account for 0X, 0x, 0B or 0b hex or binary marker.  */
+        width -= 2;
+
+      if (octal_marker)
+        --width;
+
+      if (is_negative || showsign || space)
+        --width;
+
+      if (pad == L_(' '))
+        {
+          Xprintf_buffer_pad (buf, L_(' '), width);
+          width = 0;
+        }
+
+      if (is_negative)
+        Xprintf_buffer_putc (buf, L_('-'));
+      else if (showsign)
+        Xprintf_buffer_putc (buf, L_('+'));
+      else if (space)
+        Xprintf_buffer_putc (buf, L_(' '));
+
+      if (number.word != 0 && alt && (base == 16 || base == 2))
+        {
+          Xprintf_buffer_putc (buf, L_('0'));
+          Xprintf_buffer_putc (buf, spec);
+        }
+
+      width += prec;
+      Xprintf_buffer_pad (buf, L_('0'), width);
+
+      if (octal_marker)
+        Xprintf_buffer_putc (buf, L_('0'));
+
+      if (number_slow_path)
+        group_number (buf, &iter, string, workend, thousands_sep,
+                      use_outdigits && base == 10);
+      else
+        Xprintf_buffer_write (buf, string, workend - string);
+
+      break;
+    }
+  else
+    {
+      if (is_negative)
+        {
+          Xprintf_buffer_putc (buf, L_('-'));
+          --width;
+        }
+      else if (showsign)
+        {
+          Xprintf_buffer_putc (buf, L_('+'));
+          --width;
+        }
+      else if (space)
+        {
+          Xprintf_buffer_putc (buf, L_(' '));
+          --width;
+        }
+
+      if (number.word != 0 && alt && (base == 16 || base == 2))
+        {
+          Xprintf_buffer_putc (buf, L_('0'));
+          Xprintf_buffer_putc (buf, spec);
+          width -= 2;
+        }
+
+      if (octal_marker)
+	--width;
+
+      width -= number_length + prec;
+
+      Xprintf_buffer_pad (buf, L_('0'), prec);
+
+      if (octal_marker)
+        Xprintf_buffer_putc (buf, L_('0'));
+
+      if (number_slow_path)
+        group_number (buf, &iter, string, workend, thousands_sep,
+                      use_outdigits && base == 10);
+      else
+        Xprintf_buffer_write (buf, string, workend - string);
+
+      Xprintf_buffer_pad (buf, L_(' '), width);
+      break;
+    }
+
+LABEL (form_pointer):
+  /* Generic pointer.  */
+  {
+    const void *ptr = process_arg_pointer ();
+    if (ptr != NULL)
+      {
+        /* If the pointer is not NULL, write it as a %#x spec.  */
+        base = 16;
+        number.word = (unsigned long int) ptr;
+        is_negative = 0;
+        alt = 1;
+        group = 0;
+        spec = L_('x');
+        goto LABEL (number);
+      }
+    else
+      {
+        /* Write "(nil)" for a nil pointer.  */
+        string = (CHAR_T *) L_("(nil)");
+        /* Make sure the full string "(nil)" is printed.  */
+        if (prec < 5)
+          prec = 5;
+        /* This is a wide string iff compiling wprintf.  */
+        is_long = sizeof (CHAR_T) > 1;
+        goto LABEL (print_string);
+      }
+  }
+  /* NOTREACHED */
+
+LABEL (form_number):
+  if ((mode_flags & PRINTF_FORTIFY) != 0)
+    {
+      if (! readonly_format)
+        {
+          extern int __readonly_area (const void *, size_t)
+            attribute_hidden;
+          readonly_format
+            = __readonly_area (format, ((STR_LEN (format) + 1)
+                                        * sizeof (CHAR_T)));
+        }
+      if (readonly_format < 0)
+        __libc_fatal ("*** %n in writable segment detected ***\n");
+    }
+  /* Answer the count of characters written.  */
+  void *ptrptr = process_arg_pointer ();
+  unsigned int written = Xprintf_buffer_done (buf);
+  if (is_longlong)
+    *(long long int *) ptrptr = written;
+  else if (is_long_num)
+    *(long int *) ptrptr = written;
+  else if (is_char)
+    *(char *) ptrptr = written;
+  else if (!is_short)
+    *(int *) ptrptr = written;
+  else
+    *(short int *) ptrptr = written;
+  break;
+
+LABEL (form_strerror):
+  /* Print description of error ERRNO.  */
+  if (alt)
+    string = (CHAR_T *) __get_errname (save_errno);
+  else
+    string = (CHAR_T *) __strerror_r (save_errno, (char *) work_buffer,
+                                      WORK_BUFFER_SIZE * sizeof (CHAR_T));
+  if (string == NULL)
+    {
+      /* Print as a decimal number. */
+      base = 10;
+      is_negative = save_errno < 0;
+      number.word = save_errno;
+      if (is_negative)
+        number.word = -number.word;
+      goto LABEL (number);
+    }
+  else
+    {
+      is_long = 0;  /* This is no wide-char string.  */
+      goto LABEL (print_string);
+    }
+
+LABEL (form_character):
+  /* Character.  */
+  if (is_long)
+    goto LABEL (form_wcharacter);
+  --width;  /* Account for the character itself.  */
+  if (!left)
+    Xprintf_buffer_pad (buf, L_(' '), width);
+#ifdef COMPILE_WPRINTF
+  __wprintf_buffer_putc (buf, __btowc ((unsigned char) /* Promoted. */
+                                       process_arg_int ()));
+#else
+  __printf_buffer_putc (buf, (unsigned char) /* Promoted.  */
+                        process_arg_int ());
+#endif
+  if (left)
+    Xprintf_buffer_pad (buf, L_(' '), width);
+  break;
+
+LABEL (form_string):
+  {
+    size_t len;
+
+    /* The string argument could in fact be `char *' or `wchar_t *'.
+       But this should not make a difference here.  */
+#ifdef COMPILE_WPRINTF
+    string = (CHAR_T *) process_arg_wstring ();
+#else
+    string = (CHAR_T *) process_arg_string ();
+#endif
+    /* Entry point for printing other strings.  */
+    LABEL (print_string):
+
+    if (string == NULL)
+      {
+        /* Write "(null)" if there's space.  */
+        if (prec == -1 || prec >= (int) array_length (null) - 1)
+          {
+            string = (CHAR_T *) null;
+            len = array_length (null) - 1;
+          }
+        else
+          {
+            string = (CHAR_T *) L"";
+            len = 0;
+          }
+      }
+    else if (!is_long && spec != L_('S'))
+      {
+#ifdef COMPILE_WPRINTF
+        outstring_converted_wide_string (buf, (const char *) string,
+                                         prec, width, left);
+        /* The padding has already been written.  */
+        break;
+#else
+        if (prec != -1)
+          /* Search for the end of the string, but don't search past
+             the length (in bytes) specified by the precision.  */
+          len = __strnlen (string, prec);
+        else
+          len = strlen (string);
+#endif
+      }
+    else
+      {
+#ifdef COMPILE_WPRINTF
+        if (prec != -1)
+          /* Search for the end of the string, but don't search past
+             the length specified by the precision.  */
+          len = __wcsnlen (string, prec);
+        else
+          len = __wcslen (string);
+#else
+        outstring_converted_wide_string (buf, (const wchar_t *) string,
+                                         prec, width, left);
+        /* The padding has already been written.  */
+        break;
+#endif
+      }
+
+    if ((width -= len) < 0)
+      {
+        Xprintf_buffer_write (buf, string, len);
+        break;
+      }
+
+    if (!left)
+      Xprintf_buffer_pad (buf, L_(' '), width);
+    Xprintf_buffer_write (buf, string, len);
+    if (left)
+      Xprintf_buffer_pad (buf, L_(' '), width);
+  }
+  break;
+
+#ifdef COMPILE_WPRINTF
+LABEL (form_wcharacter):
+  {
+    /* Wide character.  */
+    --width;
+    if (!left)
+      Xprintf_buffer_pad (buf, L_(' '), width);
+    Xprintf_buffer_putc (buf, process_arg_wchar_t ());
+    if (left)
+      Xprintf_buffer_pad (buf, L_(' '), width);
+  }
+  break;
+
+#else /* !COMPILE_WPRINTF */
+LABEL (form_wcharacter):
+  {
+    /* Wide character.  */
+    char wcbuf[MB_LEN_MAX];
+    mbstate_t mbstate;
+    size_t len;
+
+    memset (&mbstate, '\0', sizeof (mbstate_t));
+    len = __wcrtomb (wcbuf, process_arg_wchar_t (), &mbstate);
+    if (len == (size_t) -1)
+      {
+        /* Something went wrong during the conversion.  Bail out.  */
+        __printf_buffer_mark_failed (buf);
+        goto all_done;
+      }
+    width -= len;
+    if (!left)
+      Xprintf_buffer_pad (buf, L_(' '), width);
+    Xprintf_buffer_write (buf, wcbuf, len);
+    if (left)
+      Xprintf_buffer_pad (buf, L_(' '), width);
+  }
+  break;
+#endif /* !COMPILE_WPRINTF */
+}