diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2021-05-10 21:28:26 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2021-05-10 21:28:26 +0300 |
commit | 38cd5733bf39211352af6dc54c7a6e08e2796228 (patch) | |
tree | 7820834efcce52c6de1d428737c4842f1a6979e6 | |
parent | b4fe35ca5bec12ac96522963b1922ac1303b86c9 (diff) | |
download | egawk-38cd5733bf39211352af6dc54c7a6e08e2796228.tar.gz egawk-38cd5733bf39211352af6dc54c7a6e08e2796228.tar.bz2 egawk-38cd5733bf39211352af6dc54c7a6e08e2796228.zip |
Add the rest of the dynarray_* junk. Sigh.
-rw-r--r-- | helpers/ChangeLog | 4 | ||||
-rwxr-xr-x | helpers/update-support.sh | 5 | ||||
-rw-r--r-- | pc/ChangeLog | 2 | ||||
-rw-r--r-- | pc/Makefile | 4 | ||||
-rw-r--r-- | support/ChangeLog | 6 | ||||
-rw-r--r-- | support/Makefile.am | 6 | ||||
-rw-r--r-- | support/Makefile.in | 28 | ||||
-rw-r--r-- | support/malloc/dynarray_at_failure.c | 39 | ||||
-rw-r--r-- | support/malloc/dynarray_resize_clear.c | 39 |
9 files changed, 123 insertions, 10 deletions
diff --git a/helpers/ChangeLog b/helpers/ChangeLog index 4f448b99..752e280a 100644 --- a/helpers/ChangeLog +++ b/helpers/ChangeLog @@ -1,3 +1,7 @@ +2021-05-10 Arnold D. Robbins <arnold@skeeve.com> + + * update-support.sh: Update list of files to copy over. + 2021-05-07 Arnold D. Robbins <arnold@skeeve.com> * update-support.sh: Change to work from top level directory. diff --git a/helpers/update-support.sh b/helpers/update-support.sh index 06ed1020..90de973a 100755 --- a/helpers/update-support.sh +++ b/helpers/update-support.sh @@ -29,9 +29,12 @@ regex_internal.h verify.h malloc/dynarray-skeleton.c malloc/dynarray.h +malloc/dynarray_at_failure.c malloc/dynarray_emplace_enlarge.c +malloc/dynarray_emplace_enlarge.c malloc/dynarray_finalize.c -malloc/dynarray_resize.c" +malloc/dynarray_resize.c +malloc/dynarray_resize_clear.c" for i in $FILE_LIST do diff --git a/pc/ChangeLog b/pc/ChangeLog index 0530e52b..e71ef987 100644 --- a/pc/ChangeLog +++ b/pc/ChangeLog @@ -4,6 +4,8 @@ gets things more right. Thanks to Manuel Collado for the suggestion. * Makefile.tst: Regenerated. + * Makefile (DYNOBJS): Add dynarray_at_failure$O and + dynarray_resize_clear$O. 2021-05-09 Eli Zaretskii <eliz@gnu.org> diff --git a/pc/Makefile b/pc/Makefile index b2ca315e..0dc8bb40 100644 --- a/pc/Makefile +++ b/pc/Makefile @@ -241,7 +241,9 @@ ALLOBJS = $(AWKOBJS) awkgram$O getid$O $(OBJ) # LIBOBJS # GNU and other stuff that gawk uses as library routines. -DYNOBJS= dynarray_resize$O dynarray_emplace_enlarge$O dynarray_finalize$O +DYNOBJS= dynarray_resize$O dynarray_emplace_enlarge$O dynarray_finalize$O \ + dynarray_at_failure$O dynarray_resize_clear$O + LIBOBJS= getopt$O getopt1$O dfa$O random$O localeinfo$O regex$O $(DYNOBJS) GAWKOBJS = $(ALLOBJS) $(LIBOBJS) diff --git a/support/ChangeLog b/support/ChangeLog index af1695d7..f7a52b02 100644 --- a/support/ChangeLog +++ b/support/ChangeLog @@ -1,3 +1,9 @@ +2021-05-10 Arnold D. Robbins <arnold@skeeve.com> + + * support/dynarray_at_failure.c, support/dynarray_resize_clear.c: + New files. + * Makefile.am (libsupport_a_SOURCES): Add them. + 2021-05-07 Arnold D. Robbins <arnold@skeeve.com> * cdefs.h, libc-config.h, malloc/dynarray-skeleton.c, diff --git a/support/Makefile.am b/support/Makefile.am index 6a7ef615..18e50204 100644 --- a/support/Makefile.am +++ b/support/Makefile.am @@ -62,9 +62,11 @@ libsupport_a_SOURCES = \ verify.h \ xalloc.h \ malloc/dynarray.h \ - malloc/dynarray_resize.c \ + malloc/dynarray_at_failure.c \ malloc/dynarray_emplace_enlarge.c \ - malloc/dynarray_finalize.c + malloc/dynarray_finalize.c \ + malloc/dynarray_resize.c \ + malloc/dynarray_resize_clear.c # For some make's, e.g. OpenBSD, that don't define this RM = rm -f diff --git a/support/Makefile.in b/support/Makefile.in index 719a38e8..2253488e 100644 --- a/support/Makefile.in +++ b/support/Makefile.in @@ -143,9 +143,11 @@ libsupport_a_LIBADD = am__dirstamp = $(am__leading_dot)dirstamp am_libsupport_a_OBJECTS = dfa.$(OBJEXT) getopt.$(OBJEXT) \ getopt1.$(OBJEXT) localeinfo.$(OBJEXT) random.$(OBJEXT) \ - regex.$(OBJEXT) malloc/dynarray_resize.$(OBJEXT) \ + regex.$(OBJEXT) malloc/dynarray_at_failure.$(OBJEXT) \ malloc/dynarray_emplace_enlarge.$(OBJEXT) \ - malloc/dynarray_finalize.$(OBJEXT) + malloc/dynarray_finalize.$(OBJEXT) \ + malloc/dynarray_resize.$(OBJEXT) \ + malloc/dynarray_resize_clear.$(OBJEXT) libsupport_a_OBJECTS = $(am_libsupport_a_OBJECTS) AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) @@ -165,9 +167,11 @@ am__maybe_remake_depfiles = depfiles am__depfiles_remade = ./$(DEPDIR)/dfa.Po ./$(DEPDIR)/getopt.Po \ ./$(DEPDIR)/getopt1.Po ./$(DEPDIR)/localeinfo.Po \ ./$(DEPDIR)/random.Po ./$(DEPDIR)/regex.Po \ + malloc/$(DEPDIR)/dynarray_at_failure.Po \ malloc/$(DEPDIR)/dynarray_emplace_enlarge.Po \ malloc/$(DEPDIR)/dynarray_finalize.Po \ - malloc/$(DEPDIR)/dynarray_resize.Po + malloc/$(DEPDIR)/dynarray_resize.Po \ + malloc/$(DEPDIR)/dynarray_resize_clear.Po am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) @@ -382,9 +386,11 @@ libsupport_a_SOURCES = \ verify.h \ xalloc.h \ malloc/dynarray.h \ - malloc/dynarray_resize.c \ + malloc/dynarray_at_failure.c \ malloc/dynarray_emplace_enlarge.c \ - malloc/dynarray_finalize.c + malloc/dynarray_finalize.c \ + malloc/dynarray_resize.c \ + malloc/dynarray_resize_clear.c # For some make's, e.g. OpenBSD, that don't define this @@ -431,12 +437,16 @@ malloc/$(am__dirstamp): malloc/$(DEPDIR)/$(am__dirstamp): @$(MKDIR_P) malloc/$(DEPDIR) @: > malloc/$(DEPDIR)/$(am__dirstamp) -malloc/dynarray_resize.$(OBJEXT): malloc/$(am__dirstamp) \ +malloc/dynarray_at_failure.$(OBJEXT): malloc/$(am__dirstamp) \ malloc/$(DEPDIR)/$(am__dirstamp) malloc/dynarray_emplace_enlarge.$(OBJEXT): malloc/$(am__dirstamp) \ malloc/$(DEPDIR)/$(am__dirstamp) malloc/dynarray_finalize.$(OBJEXT): malloc/$(am__dirstamp) \ malloc/$(DEPDIR)/$(am__dirstamp) +malloc/dynarray_resize.$(OBJEXT): malloc/$(am__dirstamp) \ + malloc/$(DEPDIR)/$(am__dirstamp) +malloc/dynarray_resize_clear.$(OBJEXT): malloc/$(am__dirstamp) \ + malloc/$(DEPDIR)/$(am__dirstamp) libsupport.a: $(libsupport_a_OBJECTS) $(libsupport_a_DEPENDENCIES) $(EXTRA_libsupport_a_DEPENDENCIES) $(AM_V_at)-rm -f libsupport.a @@ -456,9 +466,11 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/localeinfo.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/random.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/regex.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@malloc/$(DEPDIR)/dynarray_at_failure.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@malloc/$(DEPDIR)/dynarray_emplace_enlarge.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@malloc/$(DEPDIR)/dynarray_finalize.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@malloc/$(DEPDIR)/dynarray_resize.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@malloc/$(DEPDIR)/dynarray_resize_clear.Po@am__quote@ # am--include-marker $(am__depfiles_remade): @$(MKDIR_P) $(@D) @@ -614,9 +626,11 @@ distclean: distclean-am -rm -f ./$(DEPDIR)/localeinfo.Po -rm -f ./$(DEPDIR)/random.Po -rm -f ./$(DEPDIR)/regex.Po + -rm -f malloc/$(DEPDIR)/dynarray_at_failure.Po -rm -f malloc/$(DEPDIR)/dynarray_emplace_enlarge.Po -rm -f malloc/$(DEPDIR)/dynarray_finalize.Po -rm -f malloc/$(DEPDIR)/dynarray_resize.Po + -rm -f malloc/$(DEPDIR)/dynarray_resize_clear.Po -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-local distclean-tags @@ -668,9 +682,11 @@ maintainer-clean: maintainer-clean-am -rm -f ./$(DEPDIR)/localeinfo.Po -rm -f ./$(DEPDIR)/random.Po -rm -f ./$(DEPDIR)/regex.Po + -rm -f malloc/$(DEPDIR)/dynarray_at_failure.Po -rm -f malloc/$(DEPDIR)/dynarray_emplace_enlarge.Po -rm -f malloc/$(DEPDIR)/dynarray_finalize.Po -rm -f malloc/$(DEPDIR)/dynarray_resize.Po + -rm -f malloc/$(DEPDIR)/dynarray_resize_clear.Po -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic diff --git a/support/malloc/dynarray_at_failure.c b/support/malloc/dynarray_at_failure.c new file mode 100644 index 00000000..4f840db7 --- /dev/null +++ b/support/malloc/dynarray_at_failure.c @@ -0,0 +1,39 @@ +/* Report an dynamic array index out of bounds condition. + Copyright (C) 2017-2021 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/>. */ + +#ifndef _LIBC +# include <libc-config.h> +#endif + +#include <dynarray.h> +#include <stdio.h> +#include <stdlib.h> + +void +__libc_dynarray_at_failure (size_t size, size_t index) +{ +#ifdef _LIBC + char buf[200]; + __snprintf (buf, sizeof (buf), "Fatal glibc error: " + "array index %zu not less than array length %zu\n", + index, size); +#else + abort (); +#endif +} +libc_hidden_def (__libc_dynarray_at_failure) diff --git a/support/malloc/dynarray_resize_clear.c b/support/malloc/dynarray_resize_clear.c new file mode 100644 index 00000000..9c43b00c --- /dev/null +++ b/support/malloc/dynarray_resize_clear.c @@ -0,0 +1,39 @@ +/* Increase the size of a dynamic array and clear the new part. + Copyright (C) 2017-2021 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/>. */ + +#ifndef _LIBC +# include <libc-config.h> +#endif + +#include <dynarray.h> +#include <string.h> + +bool +__libc_dynarray_resize_clear (struct dynarray_header *list, size_t size, + void *scratch, size_t element_size) +{ + size_t old_size = list->used; + if (!__libc_dynarray_resize (list, size, scratch, element_size)) + return false; + /* __libc_dynarray_resize already checked for overflow. */ + char *array = list->array; + memset (array + (old_size * element_size), 0, + (size - old_size) * element_size); + return true; +} +libc_hidden_def (__libc_dynarray_resize_clear) |