2020-12-23  Sergey Poznyakoff  <gray@gnu.org>

	Version 1.19

	Update the docs

	* doc/Makefile.am: Use gendocs.pl to generate web version of the
	manual.
	* doc/gdbm.texi: Update.
	* doc/gendocs.pl: New file.
	* doc/otherdoc.texi.in: New file.
	* doc/.gitignore: Ignore otherdoc.texi.
	* doc/webdoc.init: New file.
	* doc/gendocs.sh: Remove.
	* doc/gendocs_template: Remove.
	* doc/html.init: Remove.

2020-12-23  Sergey Poznyakoff  <gray@gnu.org.ua>

	Update copyright years

2020-12-23  Sergey Poznyakoff  <gray@gnu.org>

	Remove duplicate global declarations

	* src/gdbm_dump.c: Add missing I18N.
	* src/gdbm_load.c: Likewise.
	* src/parseopt.c (parseopt_program_doc)
	(parseopt_program_args): Remove duplicate declarations.

2020-10-09  Sergey Poznyakoff  <gray@gnu.org>

	Implement tagged structure initializers.

	* NEWS: Document changes.
	* doc/gdbm.texi: Document changes.
	* src/datconv.c (datum_scan_tag): Implement tagged structure
	initialization.
	* src/gdbmtool.c (kvlist_free): Made extern.
	(kvlist_find): New function.
	* src/gdbmtool.h (kvlist_find, kvlist_free)
	(dsegm_list_find): New protos.
	(dsegm_free_list): Rename to dsegm_list_free. All uses changed.
	* src/gram.y: Forbid duplicate tags in kvlist.

2020-10-08  Sergey Poznyakoff  <gray@gnu.org>

	Bugfixes.

	* doc/gdbm.texi: Fix the description of a sample content structure.
	* src/datconv.c (datum_scan_notag): Proceed to the next kvpair only
	for segments of the FDEF_FLD type.

2019-10-29  Sergey Poznyakoff  <gray@gnu.org>

	Pre-read the memory mapped regions on systems that support it

	* src/mmap.c (GDBM_MMAP_FLAGS): Define to MAP_POPULATE or
	MAP_PREFAULT_READ, if available.
	(_gdbm_internal_remap): Use GDBM_MMAP_FLAGS.

	Minor changes

	* src/gdbmconst.h: Don't redefine SIZE_T_MAX
	* src/gdbmtool.c: Likewise.
	Include <termios.h>, instead of <sys/termios.h>
	* configure.ac: Don't check for termios.h
	* tests/closerr.c: Minor fixes.

2019-04-08  Sergey Poznyakoff  <gray@gnu.org>

	Update copyright years

	Preserve locking type during database reorganization

	* src/recover.c (_gdbm_finish_transfer): Preserve locking type.

2018-11-27  Sergey Poznyakoff  <gray@gnu.org>

	Fix typo in the manpage.

2018-10-27  Sergey Poznyakoff  <gray@gnu.org>

	Version 1.18.1

2018-10-18  Sergey Poznyakoff  <gray@gnu.org>

	Restore backward compatibility with older databases

	* src/gdbmopen.c (validate_header): Silently accept databases with next_block
	pointing beyond end of file.

	Attempt recovery in case of invalid next_block header field

	* src/gdbmopen.c (validate_header): Return GDBM_NEED_RECOVERY
	if next_block is invalid.
	(_gdbm_validate_header): New function.
	(gdbm_fd_open): Set need_recovery depending on return from validate_header.
	(gdbm_open): Bail out on invalid value of GDBM_OPENMASK bits.
	* src/proto.h (_gdbm_validate_header): New proto.
	* src/recover.c (check_db): Re-validate the header.
	* src/gdbmtool.c (export_handler): Fix option processing.

2018-08-31  Sergey Poznyakoff  <gray@gnu.org>

	Various bugfixes.

	* compat/dbmopen.c (ndbm_open_dir_file0): Ignore ENOENT.
	* src/falloc.c (push_avail_block): Free temporary storage no matter
	what return status.
	* src/gdbm.h.in (GDBM_FILE_TRUNCATE_ERROR): New error code.
	* src/gdbmdump.c (_gdbm_dump_ascii): Initialize rc.
	* src/gdbmerrno.c: Handle new error.code
	* src/gdbmload.c (gdbm_load_bdb_dump): Initialize rc
	* src/gdbmopen.c (_gdbm_ftruncate): New function.
	(gdbm_fd_open): Use _gdbm_ftruncate. Check its return.
	* src/gdbmseq.c (gdbm_firstkey): Initialize dsize
	* src/gdbmtool.c (command_generator): Check if cmd is NULL.
	(shouldn't happen, but anyways).
	* src/mmap.c (_gdbm_mapped_lseek): Check for vailidity of the 'whence'
	parameter.
	* src/systems.h (TRUNCATE): Remove macro.
	* src/util.c (vgetyn): Remove unnecessary assignment.

2018-08-21  Sergey Poznyakoff  <gray@gnu.org>

	Version 1.18

2018-08-19  Sergey Poznyakoff  <gray@gnu.org>

	Fix directory entry validation.

	Bug reported by Miroslav Lichvar and Marek Skalický

	* src/bucket.c (gdbm_dir_entry_valid_p): Fix lower limit for
	the allowed bucket address. Initial allocation of second block
	for the directory can be eventually returned to the available
	list when the directory is expanded during bucket splitting.

2018-08-12  Sergey Poznyakoff  <gray@gnu.org>

	Bugfix

	* src/gdbmdump.c (_gdbm_dump_ascii): Clear the GDBM_ITEM_NOT_FOUND error.
	* src/gdbmexp.c (gdbm_export_to_file): Likewise.
	* NEWS: Update.

2018-08-03  Sergey Poznyakoff  <gray@gnu.org>

	Bugfix

	* src/gdbmopen.c (gdbm_avail_table_valid_p): Fix improper use of
	the GDBM_DEBUG macro.

2018-07-31  Sergey Poznyakoff  <gray@gnu.org>

	Bugfix

	* src/gdbmsync.c (gdbm_sync): Always return a meaningful value

2018-07-30  Sergey Poznyakoff  <gray@gnu.org>

	Version 1.17

2018-07-02  Sergey Poznyakoff  <gray@gnu.org>

	Bugfixes

	* src/recover.c (backup_name): Fix memory overwrite.
	* src/gdbmtool.c (recover_handler): New option "force".

2018-07-01  Sergey Poznyakoff  <gray@gnu.org>

	Change return value of gdbm_close and gdbm_sync

	* src/gdbm.h.in (gdbm_close, gdbm_sync): Return int
	(GDBM_FILE_CLOSE_ERROR, GDBM_FILE_SYNC_ERROR): New error codes.
	* src/gdbmclose.c (gdbm_close): Return 0 on success, -1 on failure.
	Set gdbm_errno and errno.
	* src/gdbmsync.c (gdbm_sync): Likewise.
	* src/gdbmerrno.c: Handle new error codes.
	* src/mmap.c (_gdbm_mapped_sync): Set gdbm_errno.
	* src/proto.h (gdbm_file_sync): Set gdbm_errno.

	* doc/gdbm.3: Document changes.
	* doc/gdbm.texi: Document changes.
	* NEWS: Document changes.
	* configure.ac: Set patchlevel.

	* tests/Makefile.am: Add new test.
	* tests/testsuite.at: Add new test.
	* tests/closerr.at: New test case.
	* tests/closerr.c: New test program.
	* tests/gtdel.c: Check gdbm_close return.
	* tests/gtdump.c: Likewise.
	* tests/gtfetch.c: Likewise.
	* tests/gtload.c: Likewise.
	* tests/gtopt.c: Likewise.
	* tests/gtrecover.c: Likewise.

2018-06-27  Sergey Poznyakoff  <gray@gnu.org>

	Version 1.16

	Fix typo

	New gdbmtool variables: coalesce and centfree

	The two boolean variables control the use of free block coalescing and
	central free block modes in newly opened databases.

	Coalesce mode: take into account both left- and right-adjacent slots.

	* src/falloc.c (avail_lookup): Remove the start parameter.
	(avail_move): Take pointer to the count of entries in av_table.
	Update the pointed to value after performing the move.
	All uses changed.
	(_gdbm_put_av_elem): Rewrite the "can_merge" loop.

2018-06-25  Sergey Poznyakoff  <gray@gnu.org>

	Optimize operations on avail lists.

	Use binary search for look-ups.

	* src/falloc.c (avail_lookup, avail_move): New functions.
	(get_elem): Use avail_lookup to search.
	(_gdbm_put_av_elem): Use avail_lookup and avail_move to handle the
	avail table. In coalesce mode, store the index of the greater than
	or equal entry to avoid extra lookup in case no suitable entry is
	found.

2018-06-23  Sergey Poznyakoff  <gray@gnu.org>

	Bugfixes. Consistently use the coalesce_blocks flag.

	* src/bucket.c (_gdbm_split_bucket): Take into account coalesce_blocks
	* src/falloc.c (_gdbm_put_av_elem): Change to void return. All uses changed.
	* src/proto.h: Likewise.

	Fix the previous patch

	Silently restore sorting order of avail array when checking it.

	* src/gdbmdefs.h (gdbm_avail_table_valid_p): Remove const qualifier from
	the AV parameter.
	* src/gdbmopen.c (gdbm_avail_table_valid_p): Don't insist on proper
	ordering of the array. Restore it if neccessary.

	Maintain correct ordering of the avail table after coalescing.

	* src/falloc.c (_gdbm_put_av_elem): Float the merged entry to its
	proper position to preserve the sorting order.
	* THANKS: Thanks Adam Sampson

	Fix typo

2018-06-16  Sergey Poznyakoff  <gray@gnu.org>

	Version 1.5

	* configure.ac: Version 1.5
	* NEWS: Update.
	* src/Makefile.am (VI_CURRENT): Increment to 6
	* src/bucket.c (_gdbm_get_bucket): Fix the upper limit for
	bucket_bits.
	* src/falloc.c (push_avail_block): Fill the allocated block
	with 0s.

2018-05-30  Sergey Poznyakoff  <gray@gnu.org>

	More error checking

	* src/bucket.c (_gdbm_get_bucket): Check if bucket_bits value is valid.
	* src/gdbmtool.c (_gdbm_print_avail_list): Reverse the sense of the
	conditional (fix regression).

	Avoid unnecessary memory reallocations during caching

	* src/findkey.c (_gdbm_read_entry): Reallocate cache_entry->ca_data.dptr only
	if necessary.
	* src/gdbmdefs.h (data_cache_elem): New member: dsize
	* src/gdbmdelete.c: Don't free cache_entry->ca_data.dptr
	* src/gdbmopen.c (_gdbm_init_cache): Initialize ca_data.dsize

	Rewrite gdbm_file_write etc. as inline functions.

	Fix the legacy operation (--disable-mmapped-io)

	* src/mmap.c (_gdbm_file_extend): Move to ...
	* src/fullio.c: ... here
	* src/proto.h (_gdbm_file_extend): New proto.
	* src/gdbmopen.c (gdbm_fd_open): Make sure the file size equals
	header->next_block.
	* src/gdbmsetopt.c [!HAVE_MMAP]: Don't disable GDBM_GETFLAGS.
	* src/update.c (_gdbm_end_update): Make sure disk file ends on
	header->next_block.

	Namespace cleanup

	Rename: __read   to  gdbm_file_read
	        __write  to  gdbm_file_write
	        __lseek  to  gdbm_file_seek
	        __fsync  to  gdbm_file_sync

	Drop debugging hooks

	The hooks were introduced as a temporary tool in de7834e9. They did
	their job and are not necessary any more.

	gdbmtool: bugfixes

	* src/gdbmtool.c (print_bucket_begin): Check return value from _gdbm_get_bucket.
	(source_handler): Don't gtry to push NULL stream.

	Fix memory leak in _gdbm_get_bucket

	Fix memory leaks in handling history (gdbmtool) and in gdbm_recover

2018-05-29  Sergey Poznyakoff  <gray@gnu.org>

	Minor changes

	* src/gdbmtool.c: Reduce memory consuption in -random mode. Some
	minor bugfixes as well.

2018-05-28  Sergey Poznyakoff  <gray@gnu.org>

	Improve num2word

	* tests/num2word.c: New options: -revert and -random

2018-05-27  Sergey Poznyakoff  <gray@gnu.org>

	Additional validation of avail_table.

	Verify that avail_table is sorted by size and that each element's
	size falls within allowed range.

	* src/bucket.c (gdbm_get_bucket): Fix bucket validation. Validate
	bucket_avail.
	(_gdbm_split_bucket): Check return from _gdbm_free.
	* src/falloc.c (adjust_bucket_avail,_gdbm_free): Return error code.
	All uses updated.
	(pop_avail_block): Fix eventual memory leak. Use gdbm_avail_block_validate.
	* src/gdbmdefs.h (gdbm_avail_table_valid_p): Change signature.
	* src/gdbmopen.c (gdbm_avail_table_valid_p): Traverse the array verifying
	address and size of each element.
	(gdbm_avail_block_validate)
	(gdbm_bucket_avail_table_validate): New functions.
	(validate_header): Remove call to gdbm_avail_block_valid_p. Avail_block
	is validated later, after it's been loaded.
	Bail out if header->next_block does not equal the file size.
	(gdbm_fd_open): Validate avail_block.
	* src/gdbmstore.c (_gdbm_store): Check return from _gdbm_free. Avoid
	endless loop in case of inconsistent h_table.
	* src/gdbmtool.c (_gdbm_print_avail_list): Use gdbm_avail_block_validate.
	* src/proto.h: Update.
	* tests/gtload.c: Improve error diagnostics.

2018-05-26  Sergey Poznyakoff  <gray@gnu.org>

	gdbmtool: quote special characters in command line input

2018-05-25  Sergey Poznyakoff  <gray@gnu.org>

	configure: emit a notice if --enable-gdbmtool-debug is used

	More database consistency checks

	* NEWS: Update.
	* THANKS: Update.
	* src/bucket.c (_gdbm_get_bucket): Check if directory entry is
	valid. Don't cache invalid buckets.
	* src/gdbm.h.in (GDBM_BAD_DIR_ENTRY): New error code.
	* src/gdbmerrno.c: Likewise.
	* src/gdbmopen.c (validate_header): Compute expected
	number of bucket elements based on the bucket size, not on
	the block size.
	(_gdbm_init_cache_entry): New function.
	* src/proto.h (_gdbm_init_cache_entry): New proto.
	* src/recover.c (gdbm_recover): Clear error state after return
	from check_db indicating failure.

2018-05-24  Sergey Poznyakoff  <gray@gnu.org>

	Various fixes

	* src/input-std.c: Bugfix
	* doc/gdbm.texi: Document changes.
	* README: Update.
	* configure.ac: New option --enable-gdbmtool-debug.
	* src/Makefile.am: Conditionally augment AM_YFLAGS and
	AM_LFLAGS with options that enable debugging.
	* src/gdbmtool.c: Conditionally enable --lex-trace and
	--gram-trace options.
	* src/gram.y: Likewise.
	* src/lex.l: Likewise.
	* tests/Makefile.am: Remove architecure-dependent tests.
	* tests/testsuite.at: Likewise.

	More input checking fixes

	* src/gdbmdefs.h (gdbm_avail_block_valid_p): Minimal capacity
	of an avail_block is 1 (one entry is stored in the block itself).
	* src/gdbmopen.c (gdbm_avail_table_valid_p): New function.
	(validate_header): Fix verification of dir_size and dir_bits.
	Verify avail.size.
	* src/falloc.c (pop_avail_block): Use gdbm_avail_table_valid_p
	* src/gdbmtool.c (_gdbm_print_avail_list): Likewise.

	Bugfix

	* tests/Makefile.am (EXTRA_DIST): Add missing file.

	More error checking; improve gdbm_recover

	* Makefile.am (set-dist-date): New rule
	(dist-hook): Catch FIXMEs in NEWS.
	* NEWS: Updated.
	* src/findkey.c (gdbm_bucket_element_valid_p): New function.
	(_gdbm_read_entry): Validate the retrieved bucket element.
	* src/gdbm.h.in (gdbm_recovery): New member: duplicate_keys.
	(GDBM_BAD_HASH_TABLE): New error code.
	* src/gdbmdefs.h (TYPE_WIDTH,SIGNED_TYPE_MAXIMUM)
	(OFF_T_MAX): New defines.
	(off_t_sum_ok): New function.
	(gdbm_bucket_element_valid_p): New prototype.
	* src/gdbmerrno.c: Support for GDBM_BAD_HASH_TABLE code.
	* src/gdbmtool.c (recover_handler): Fix argument counting.
	New argument 'summary' prints statistics summary at the end
	of the run.
	(export_handler,import_handler): Fix argument counting.
	* src/mmap.c (SUM_FILE_SIZE): Rewrite as inlined function.
	Add error checking.
	(_gdbm_mapped_remap): More error checking.
	* src/recover.c (run_recovery): Don't bail out on GDBM_CANNOT_REPLACE.
	(gdbm_recover): Initialize duplicate_keys
	* src/systems.h: Include limits.h

	Fix the use of return code from _gdbm_full_(read|write) functions

	error checking: check for avail_block consistency before using it

	* src/gdbmdefs.h (gdbm_avail_block_valid_p): New function.
	* src/gdbm.h.in (GDBM_BAD_AVAIL): New error code.
	* src/gdbmerrno.c: Support new error code.
	* src/falloc.c (pop_avail_block): Validate the avail_block
	* src/gdbmopen.c (validate_header): Validate the avail_block.
	* src/gdbmtool.c (_gdbm_avail_list_size)
	(_gdbm_print_avail_list): Validate the avail_block.

	Add new test

	gdbmtool: fix data conversion when storing structured content.

	* src/datconv.c (DEFNSCAN): Use proper target type to store in
	datum.
	(datum_scan_notag): Accept C-like initialization
	of array of characters by a quoted string.

2018-05-23  Sergey Poznyakoff  <gray@gnu.org>

	gdbmtool: accept commands from command line as well as from file

	Commands can be supplied to gdbmtool in three ways:

	 1. From a file, using the --file (-f) option:

	     gdbmtool -f comfile

	 2. From the command line, if first argument is the database name:

	     gdbmtool test.db count \; fetch mykey \; avail

	    Note the use of semicolon to delimit commands.

	 3. From the interactive shell, if neither of the above is used.

	* src/Makefile.am: Add new sources.
	* src/gdbmtool.c: Use new stream functions for input.
	* src/gdbmtool.h (setsource): Remove proto.
	(instream_t): New data type.
	(instream_name, instream_read)
	(instream_close, instream_interactive)
	(instream_eq): New functions.
	(instream_stdin_create)
	(instream_argv_create)
	(instream_file_create)
	(interactive, input_context_push): New protos.
	* src/gram.y: Accept ; in place of newline.
	* src/input-argv.c: New file.
	* src/input-file.c: New file.
	* src/input-rl.c: Rewrite to provide instream_t API.
	* src/input-std.c: Likewise.
	* src/lex.l: Rewrite.
	* tests/.gitignore: Update.
	* tests/Makefile.am: Add new tests. Incorporate
	DejaGNU tests.
	* tests/config/default.exp: New file.
	* tests/gdbmtool/base.exp: New file.
	* tests/gdbmtool00.at: New file.
	* tests/gdbmtool01.at: New file.
	* tests/gdbmtool02.at: New file.
	* tests/testsuite.at: Include new tests.

2018-05-19  Sergey Poznyakoff  <gray@gnu.org>

	Remove gdbm-1.8.3 compatibility layer

	* configure.ac: Remove gdbm-1.8.3 compatibility layer.
	Version 1.14.90
	* Makefile.am (ACLOCAL_AMFLAGS): Remove deprecated variable.
	(MAYBE_EXPORT): Remove variable and conditional.
	* NEWS: Update.
	* NOTE-WARNING: Update.
	* README: Update.
	* doc/gdbm.texi: Update.
	* export/.gitignore: Remove.
	* export/Makefile.am: Remove.
	* export/export.c: Remove.

	Catch more errors

	* src/gdbmdump.c (_gdbm_dump_ascii): Break on errors
	* src/gdbmopen.c (compute_directory_size): Remove unused argument.
	(validate_header): Catch dir_size and dir_bits mismatches.
	* src/mmap.c (_gdbm_mapped_lseek): Bail out on negative offsets.
	* tests/dump03.at: New test.
	* tests/dump04.at: New test.
	* tests/Makefile.am: Add new tests.
	* tests/testsuite.at: Add new tests.

	Add new tests

	* src/gdbm_dump.c: Fix exit code.
	* configure.ac: Determine presence of gzip and base64
	(GZIP_BIN,BASE64_BIN): New variables.
	* tests/atlocal.in (GZIP_BIN,BASE64_BIN): New variables.
	* tests/dump00.at: New file.
	* tests/dump01.at: New file.
	* tests/dump02.at: New file.
	* tests/Makefile.am: Add new tests.
	* tests/testsuite.at: Add new tests.

	Improve error checking

	* src/bucket.c (_gdbm_get_bucket): Improve validation.
	* src/fullio.c (_gdbm_full_read,_gdbm_full_write): Don't overwrite
	an already set error.
	* src/gdbm.h.in (GDBM_WRONG_OFF_T): Merge with GDBM_BAD_FILE_OFFSET.
	(GDBM_BAD_HEADER): New error code.
	* src/gdbmdump.c (_gdbm_dump_ascii): Check for database error code.
	* src/gdbmerrno.c (gdbm_errlist): Add GDBM_BAD_HEADER
	* src/gdbmopen.c (validate_header: Imporve logic.
	(_gdbm_init_cache): Initialize bucket_cache
	* src/gdbmseq.c (gdbm_firstkey): Check return value
	from _gdbm_get_bucket.
	* src/mmap.c (_gdbm_mapped_remap): Bail out if current position is bigger
	than file size.

	Fix typo

2018-05-16  Sergey Poznyakoff  <gray@gnu.org>

	Improve database file safety checks.

	* src/bucket.c (_gdbm_get_bucket): Verify bucket consistency.
	* src/gdbm.h.in (GDBM_BAD_BUCKET, GDBM_WRONG_ARCH): New error
	codes.
	* src/gdbmerrno.c (gdbm_errlist): New error codes.
	* src/gdbmopen.c (gdbm_fd_open): Improve header consistency checks.

2018-01-03  Sergey Poznyakoff  <gray@gnu.org>

	Bump library current version number

2018-01-01  Sergey Poznyakoff  <gray@gnu.org>

	Version 1.14

	Happy GNU Year

2017-12-23  Sergey Poznyakoff  <gray@gnu.org>

	Fix build with --enable-gdbm-export

	* THANKS: Add Jakub Bogusz
	* export/export.c: Define GDBM_EXPORT_18 prior to
	including gdbmexp.c
	* src/gdbmexp.c [GDBM_EXPORT_18]: Define GDBM_SET_ERRNO and
	GDBM_ASSERT_CONSISTENCY.

	Bugfix

	* src/gdbmsetopt.c: Ignore NULL entries

	Complement c175231e

	* configure.ac: Check whether __thread qualifier is supported
	* src/gdbmerrno.c (gdbm_errno_storage): Use GDBM_THREAD_LOCAL instead
	of __thread.

2017-12-21  Sergey Poznyakoff  <gray@gnu.org>

	Improve database reproducibility

	* src/gdbmopen.c (gdbm_fd_open): Fill allocated memory with 0's
	where necessary.
	Check return value from fstat.
	* src/mmap.c (_gdbm_file_size): Set errno here, instead of delegating
	that to the caller.
	(_gdbm_file_extend): New function.
	(_gdbm_mapped_remap): Call _gdbm_file_extend instead of leaving the
	newly allocated space filled with garbage.
	* src/gdbmload.c (_set_gdbm_meta_info): Additional error checking.
	* NEWS: Update.

2017-12-19  Sergey Poznyakoff  <gray@gnu.org.ua>

	Make gdbm_error thread-safe

	* src/gdbm.h.in (gdbm_errno_location): New extern
	(gdbm_errno): Change to a define.
	* src/gdbmerrno.c (gdbm_errno_location): New function.
	(gdbm_errno_storage): Thread-safe storage for the last errno.

2017-10-28  Sergey Poznyakoff  <gray@gnu.org>

	Fix manpage formatting.

2017-07-24  Sergey Poznyakoff  <gray@gnu.org.ua>

	Fix handling of group headers in --help output.

	* src/parseopt.c (print_option_descr): Return if descr is NULL
	or empty. Translate it using gettext.
	All callers changed.

2017-04-14  Sergey Poznyakoff  <gray@gnu.org.ua>

	Fix a typo

2017-03-11  Sergey Poznyakoff  <gray@gnu.org>

	Fix GENDOCS command line

	Version 1.13

2017-03-07  Sergey Poznyakoff  <gray@gnu.org>

	Fix parralel builds

	* src/Makefile.am: Add dependency for gram.h

	Reported by Petr Ovtchenkov <ptr@void-ptr.info>

2017-01-02  Sergey Poznyakoff  <gray@gnu.org>

	Happy GNU Year

2016-12-21  Sergey Poznyakoff  <gray@gnu.org>

	Minor fix

	* src/mmap.c (_gdbm_internal_remap): Avoid munmapping NULL pointer.
	Make sure mapped_region isn't a dangling pointer.

2016-08-06  Sergey Poznyakoff  <gray@gnu.org.ua>

	Fix typos

2016-07-27  Sergey Poznyakoff  <gray@gnu.org.ua>

	Remove obsolete error code.

	* doc/gdbm.texi: Remove description of GDBM_UNKNOWN_UPDATE.
	Document GDBM_DIR_OVERFLOW.
	* src/gdbm.h.in (GDBM_ERR_DIR_OVERFLOW): Rename to GDBM_DIR_OVERFLOW.
	(GDBM_UNKNOWN_ERROR): New error code.
	(GDBM_UNKNOWN_UPDATE): Define to GDBM_UNKNOWN_ERROR for
	backward compatibility.
	* src/gdbmerrno.c (gdbm_strerror, gdbm_db_strerror): Simplify a bit

	Avoid range error when doubling directory size.

	* src/bucket.c (_gdbm_split_bucket): Avoid range error
	when doubling directory size.
	* src/gdbm.h.in (GDBM_ERR_DIR_OVERFLOW): New error code.
	* src/gdbmerrno.c (gdbm_errlist): Describe GDBM_ERR_DIR_OVERFLOW.

2016-07-26  Sergey Poznyakoff  <gray@gnu.org.ua>

	Update gdbm.magic

	* src/gdbm.magic: Explicitly handle big- and little-endian databases.

	Minor changes

	* src/bucket.c (_gdbm_read_bucket_at): Remove unused variable.
	* src/debug.c: Include ctype.h
	(datbuf_format): Don't use sprintf; Precede each output line
	with data offset.

	Fix remaining uses of gdbm_set_errno function.

	Use the GDBM_SET_ERRNO and GDBM_SET_ERRNO2 macros to make
	sure the error gets reported in debug output.

	* src/fullio.c (_gdbm_full_read)
	(_gdbm_full_write): Return -1 and set gdbm_errno
	on error.
	* src/bucket.c: Use GDBM_SET_ERRNO(2?) or
	GDBM_DEBUG where necessary.
	* src/falloc.c: Likewise.
	* src/findkey.c: Likewise.
	* src/gdbmdefs.h: Likewise.
	* src/gdbmopen.c: Likewise.
	* src/gdbmstore.c: Likewise.
	* src/mmap.c: Likewise.
	* src/recover.c: Likewise.
	* src/update.c: Likewise.

2016-07-25  Sergey Poznyakoff  <gray@gnu.org.ua>

	Improve debugging and error tracing.

	* src/gdbmdefs.h (GDBM_SET_ERRNO)
	(GDBM_SET_ERRNO2): New macros.

	* src/base64.c: Use new macros to set error state.
	* src/bucket.c: Likewise.
	* src/falloc.c: Likewise.
	* src/findkey.c: Likewise.
	* src/gdbm_load.c: Likewise.
	* src/gdbmdelete.c: Likewise.
	* src/gdbmdump.c: Likewise.
	* src/gdbmexp.c: Likewise.
	* src/gdbmfetch.c: Likewise.
	* src/gdbmimp.c: Likewise.
	* src/gdbmload.c: Likewise.
	* src/gdbmopen.c: Likewise.
	* src/gdbmseq.c: Likewise.
	* src/gdbmsetopt.c: Likewise.
	* src/gdbmstore.c: Likewise.

	* src/gdbmtool.c: Fix preprocessor conditional.

	Fix distribution

	* src/Makefile.am: Mark gdbm.h as noinst
	* compat/Makefile.am (AM_CPPFLAGS): Make sure we pick up
	../src/gdbm.h

	Improve the "next" shortcut.

	* src/gdbmtool.c (open_handler): Close the previously
	opened database.
	(close_handler): Free the file name.
	(print_dir_handler): Print the number of buckets.
	(command_repeat_type): New enum.
	(command) <repeat>: Change type to enum command_repeat_type.
	(command_tab): Update accordingly. Mark "next" with REPEAT_NOARG.
	(run_last_command): Handle REPEAT_NOARG separately.
	* NEWS: Document the shortcut.
	* doc/gdbm.texi: Likewise.
	* src/debug.c (datbuf_format): Don't represent
	bytes after the end of datum as zeros.
	(gdbm_debug_datum): Print datum size.

	Add debug info.

	* configure.ac: Fix description wording.
	* src/Makefile.am [GDBM_COND_DEBUG_ENABLE]: Don't
	define GDBM_DEBUG_ENABLE.
	* tests/Makefile.am: Likewise.
	* src/debug.c (gdbm_debug_printer)
	(gdbm_debug_flags): New globals.
	(gdbm_debug_token, gdbm_debug_parse_state)
	(gdbm_debug_datum): New functions.
	* src/gdbm.h.in [@GDBM_DEBUG_ENABLE@]: Define GDBM_DEBUG_ENABLE.
	(gdbm_debug_printer_t): New typedef.
	(gdbm_debug_printer, gdbm_debug_flags): New externs.
	(GDBM_DEBUG_ERR,GDBM_DEBUG_OPEN)
	(GDBM_DEBUG_READ,GDBM_DEBUG_STORE)
	(GDBM_DEBUG_LOOKUP,GDBM_DEBUG_ALL): New defines.
	(gdbm_debug_token,gdbm_debug_parse_state)
	(gdbm_debug_datum): New protos.
	* src/gdbmdefs.h (GDBM_DEBUG,GDBM_DEBUG_DATUM): New macros.

	* src/findkey.c: Add debugging info.
	* src/gdbmfetch.c: Likewise.
	* src/gdbmopen.c: Likewise.
	* src/gdbmseq.c: Likewise.
	* src/gdbmstore.c: Likewise.
	* src/gdbmtool.c (open_handler): Allow the use of ~/
	(command) <repeat,variadic>: New members.
	(run_command): Handle variadic functions.
	(run_last_command): New command.  In interactive mode,
	repeats the last command if it was marked
	with repeat=1 (currently, only "next").
	New command: "debug".
	(all functions): Use terror instead of fprintf(stderr,...);
	* src/gdbmtool.h (handler_param) <vararg>: New member.
	(run_last_command): New proto.
	* src/gram.y: Call run_last_command) on empty input.
	* tests/gtload.c: New option: -debug=

2016-07-20  Sergey Poznyakoff  <gray@gnu.org>

	Introduce debug hooks.

	* configure.ac: New option --enable-debug
	Print feature summary at the end of the run.

	* src/debug.c: New file.
	* src/Makefile.am [GDBM_COND_DEBUG_ENABLE]: Build debug.o
	Define GDBM_DEBUG_ENABLE.
	* src/gdbmdefs.h [GDBM_DEBUG_ENABLE] (_gdbm_debug_hook_install)
	(_gdbm_debug_hook_remove,_gdbm_debug_hook_check)
	(_gdbm_debug_hook_val): New protos.
	(GDBM_DEBUG_HOOK, GDBM_DEBUG_OVERRIDE)
	(GDBM_DEBUG_ALLOC): New defines.
	* src/gdbm.h.in (GDBM_RCVR_FORCE): New flag.
	* src/recover.c (gdbm_recover): Check database before attempting
	recovery, unless GDBM_RCVR_FORCE flag is set.
	* doc/gdbm.texi: Document GDBM_RCVR_FORCE
	* src/gdbmreorg.c (gdbm_reorganize): Use GDBM_RCVR_FORCE.

	* src/gdbmtool.c (main): Always allocate file_name.

	* src/bucket.c: Put GDBM_DEBUG_OVERRIDE and GDBM_DEBUG_ALLOC
	in critical places.
	* src/falloc.c: Likewise.
	* src/findkey.c: Likewise.
	* src/gdbmopen.c: Likewise.
	* src/gdbmstore.c: Likewise.
	* src/update.c: Likewise.

	* tests/Makefile.am [GDBM_COND_DEBUG_ENABLE]: Define GDBM_DEBUG_ENABLE.
	* tests/gtload.c: New options -hook, -recover, -verbose,
	-backup, -max-failures, -max-failed-keys,
	and -max-failed-buckets.
	Attempt recovery after errors.

	Fix typo

2016-07-19  Sergey Poznyakoff  <gray@gnu.org>

	Improve docs. Minor changes.

	* NEWS: Document new features.
	* doc/gdbm.texi: Likewise.
	* src/gdbm.h.in (gdbm_last_errno): Fix return value.
	(gdbm_check_syserr): New proto.
	* src/gdbmdefs.h (gdbm_file_info) <last_error>: Fix data type.
	* src/gdbmerrno.c (gdbm_last_errno): Fix return value.
	(gdbm_check_syserr): New function.

	Implement gdbm_recover function

	* configure.ac: Don't check for rename.
	* src/Makefile.am (libgdbm_la_SOURCES): Add recover.c
	* src/recover.c: New file.
	* src/bucket.c (_gdbm_get_bucket): Remove extra space before [
	* src/err.c (prerror): Take additional argument
	(gdbm_perror): Print system errno if necessary.
	* src/gdbm.h.in (GDBM_CLOERROR): New flag.
	(gdbm_fd_open, gdbm_copy_meta): New proto.
	(gdbm_last_syserr,gdbm_db_strerror,gdbm_recover): New proto.
	(gdbm_syserr): New extern.
	(gdbm_recovery): New struct.
	(GDBM_RCVR_DEFAULT,GDBM_RCVR_ERRFUN)
	(GDBM_RCVR_MAX_FAILED_KEYS)
	(GDBM_RCVR_MAX_FAILED_BUCKETS)
	(GDBM_RCVR_MAX_FAILURES)
	(GDBM_RCVR_BACKUP): New flags.
	(GDBM_BACKUP_FAILED): New error code.
	* src/gdbmclose.c (gdbm_close): Work correctly if dbf->desc == -1.
	* src/gdbmcount.c (gdbm_count): Remove spurious sorting.
	Use _gdbm_next_bucket_dir for iterating over the buckets.
	* src/gdbmdefs.h (struct gdbm_file_info)<last_syserror>
	<last_errstr>: New members.
	* src/gdbmerrno.c (gdbm_set_errno): Set last_syserror as well.
	(gdbm_clear_error): Reset last_syserror.
	(gdbm_last_syserr): New function.
	(gdbm_errlist): New entry for GDBM_BACKUP_FAILED.
	(gdbm_db_strerror): New function.
	(gdbm_syserr): New global.
	* src/gdbmload.c (get_parms): Buffer can be NULL.
	* src/gdbmopen.c (gdbm_fd_open): New function.
	(gdbm_open): Rewrite as a wrapper over gdbm_fd_open.
	* src/gdbmreorg.c (gdbm_reorganize): Rewrite as a wrapper
	over gdbm_recover.
	* src/proto.h (_gdbm_next_bucket_dir): New proto.
	* src/gdbmtool.c: New command: recover.
	* tests/.gitignore: Add gtrecover
	* tests/gtrecover.c: New test program.
	* tests/Makefile.am: Build gtrecover

2016-07-16  Sergey Poznyakoff  <gray@gnu.org.ua>

	Bugfix

2016-07-15  Sergey Poznyakoff  <gray@gnu.org.ua>

	New gdbm_setopt option to get the actual block size value

	* src/gdbm.h.in (GDBM_GETBLOCKSIZE): New option.
	* src/gdbmcount.c (gdbm_count): Fix memory leak on
	error.
	* src/gdbmsetopt.c (gdbm_setopt): Rewrite.
	Handle GDBM_GETBLOCKSIZE.

	* NEWS: Document GDBM_GETBLOCKSIZE
	* doc/gdbm.texi: Likewise.

	* tests/gtload.c: New options -bsexact and -verbose.
	* tests/Makefile.am: Add new testcases.
	* tests/testsuite.at: Likewise.
	* tests/blocksize00.at: New testcase.
	* tests/blocksize01.at: Likewise.
	* tests/blocksize02.at: Likewise.

	gdbm_open adjusts requested block size to accomodate integer number of directory offsets.

	* src/gdbm.h.in (GDBM_BSEXACT): New flag.
	* src/gdbmopen.c (compute_directory_size): New function.
	(gdbm_open): When creating new database, adjust the requested
	block size so that the block holds integer number of directory
	indices.  Disable this behavior if GDBM_BSEXACT flag is set
	(this reverts to old behavior).  Always unset GDBM_BSEXACT if
	using block size returned by stat(2).  This makes sure gdbm_open
	succeeds on file systems reporting block sizes not divisible by
	512.
	* src/gdbmconst.h (GDBM_MIN_BLOCK_SIZE): New constant.
	* src/gdbmimp.c (gdbm_import_from_file): Use GDBM_MIN_BLOCK_SIZE
	instead of the hardcoded value.
	* NEWS: Document GDBM_BSEXACT.
	* doc/gdbm.texi: Likewise.

2016-07-14  Sergey Poznyakoff  <gray@gnu.org.ua>

	Don't use hardcoded constant

	* src/gdbmconst.h (GDBM_HASH_BITS): New constant.
	* src/bucket.c: Use GDBM_HASH_BITS instead of the
	hardcoded value.
	* src/findkey.c (_gdbm_findkey): Use _gdbm_hash_key.

	* src/gdbmtool.c (hash_handler): Use _gdbm_hash_key if the
	database is open.
	* src/hash.c (_gdbm_bucket_dir, _gdbm_hash_key): New functions.
	* src/proto.h (_gdbm_bucket_dir, _gdbm_hash_key): New protos.

	* src/systems.h (STATBLKSIZE): Take a struct stat as argument.
	* src/gdbmopen.c (STATBLKSIZE): Takes argument now.

	gdbmtool: improve bucket dump and hash calculator

	* src/gdbmtool.c (format_key_start): New function.
	(print_bucket): Take variadic arguments, use mesg
	as prinf-style format.
	Display first bytes of each non-empty key.
	(print_current_bucket_begin): Avoid coredump if
	gdbm_file is not initialized.
	(print_current_bucket_handler): Change header depending on the
	invoking command.
	(hash_handler): In presence of a database, print also the
	bucket number and offset within the bucket.

2016-07-13  Sergey Poznyakoff  <gray@gnu.org.ua>

	Bugfix

	Bugfix

	Update magic file

	* src/gdbm.magic: Recognize dumpfiles.

	Update NEWS

	Provide the gdbm.magic file for file(1).

	* src/gdbm.magic: New file.
	* README: Document existence of the magic file.
	* src/Makefile.am (EXTRA_DIST): Add gdbm.magic.

	gdbmtool: define macros for accessing typed handler arguments.

	* src/gdbmtool.h (PARAM_STRING, PARAM_DATUM)
	(PARAM_KVPAIR): New defines.
	* src/gdbmtool.c: Use above for accessing handler arguments.

2016-07-12  Sergey Poznyakoff  <gray@gnu.org.ua>

	Line-editing support in gdbmtool

	* configure.ac: Check if GNU Readline is available.
