Rewrite update algorithm.

* src/common.h (namebuf_t): New typedef.
(namebuf_create, namebuf_free)
(namebuf_name): New prototypes.
(remname): New prototype.
* src/misc.c (struct namebuf): New structure.
(namebuf_create, namebuf_free)
(namebuf_name): New functions.
* src/create.c (dup_dir0): Remove is_avoided_name
checks. This is taken care of in update_archive.
* src/incremen.c (scan_directory): Use namebuf
to produce full file names.
* src/names.c (nametail): Remove extra level of
indirection. All uses updated.
(avoided_name_table, add_avoided_name)
(is_avoided_name): Remove.
* src/update.c (update_archive): Change algorithm.
Instead of adding unmodified files to the avoided_name
table, create namelist so that it contains only
modified files.

* tests/Makefile.am: Add update01.at, update02.at
* tests/testsuite.at: Likewise.
* tests/update.at (AT_KEYWORDS): Add update00.
This commit is contained in:
Sergey Poznyakoff
2009-10-14 23:26:52 +03:00
parent 0c6c288b53
commit cac45fffc5
11 changed files with 290 additions and 140 deletions

View File

@@ -827,3 +827,44 @@ page_aligned_alloc (void **ptr, size_t size)
return ptr_align (*ptr, alignment);
}
struct namebuf
{
char *buffer; /* directory, `/', and directory member */
size_t buffer_size; /* allocated size of name_buffer */
size_t dir_length; /* length of directory part in buffer */
};
namebuf_t
namebuf_create (const char *dir)
{
namebuf_t buf = xmalloc (sizeof (*buf));
buf->buffer_size = strlen (dir) + 2;
buf->buffer = xmalloc (buf->buffer_size);
strcpy (buf->buffer, dir);
buf->dir_length = strlen (buf->buffer);
if (!ISSLASH (buf->buffer[buf->dir_length - 1]))
buf->buffer[buf->dir_length++] = DIRECTORY_SEPARATOR;
return buf;
}
void
namebuf_free (namebuf_t buf)
{
free (buf->buffer);
free (buf);
}
char *
namebuf_name (namebuf_t buf, const char *name)
{
size_t len = strlen (name);
while (buf->dir_length + len + 1 >= buf->buffer_size)
buf->buffer = x2realloc (buf->buffer, &buf->buffer_size);
strcpy (buf->buffer + buf->dir_length, name);
return buf->buffer;
}