This is an automated email from the git hooks/post-receive script. guillem pushed a commit to branch main in repository dpkg.
View the commit online: https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=01505a92295ee7767ebf92986ab569d9eb1d4f30 commit 01505a92295ee7767ebf92986ab569d9eb1d4f30 Author: Guillem Jover <[email protected]> AuthorDate: Mon May 20 01:07:09 2024 +0200 libdpkg: Factor fsys_list_parse_buffer() out of ensure_packagefiles_available() Split the .list file specific parsing out of this more general files metadata loading function. --- lib/dpkg/db-fsys-files.c | 73 ++++++++++++++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 31 deletions(-) diff --git a/lib/dpkg/db-fsys-files.c b/lib/dpkg/db-fsys-files.c index 099cad332..244ef0a0b 100644 --- a/lib/dpkg/db-fsys-files.c +++ b/lib/dpkg/db-fsys-files.c @@ -70,6 +70,46 @@ enum pkg_filesdb_load_status { static enum pkg_filesdb_load_status saidread = PKG_FILESDB_LOAD_NONE; +static void +fsys_list_parse_buffer(struct varbuf *vb, struct pkginfo *pkg) +{ + struct fsys_namenode_list **files_tail; + char *loaded_list_end, *thisline; + + loaded_list_end = vb->buf + vb->used; + + files_tail = &pkg->files; + thisline = vb->buf; + + while (thisline < loaded_list_end) { + struct fsys_namenode *namenode; + char *nextline, *ptr; + + ptr = memchr(thisline, '\n', loaded_list_end - thisline); + if (ptr == NULL) + ohshit(_("files list file for package '%.250s' is missing final newline"), + pkg_name(pkg, pnaw_nonambig)); + + /* Where to start next time around. */ + nextline = ptr + 1; + + /* Strip trailing ‘/’. */ + if (ptr > thisline && ptr[-1] == '/') + ptr--; + + /* Add the file to the list. */ + if (ptr == thisline) + ohshit(_("files list file for package '%.250s' contains empty filename"), + pkg_name(pkg, pnaw_nonambig)); + *ptr = '\0'; + + namenode = fsys_hash_find_node(thisline, FHFF_NONE); + files_tail = pkg_files_add_file(pkg, namenode, files_tail); + + thisline = nextline; + } +} + /** * Load the list of files in this package into memory, or update the * list if it is there but stale. @@ -114,37 +154,8 @@ ensure_packagefiles_available(struct pkginfo *pkg) return; } - if (buf.used) { - struct fsys_namenode_list **lendp; - char *loaded_list_end, *thisline; - - loaded_list_end = buf.buf + buf.used; - - lendp = &pkg->files; - thisline = buf.buf; - while (thisline < loaded_list_end) { - struct fsys_namenode *namenode; - char *nextline, *ptr; - - ptr = memchr(thisline, '\n', loaded_list_end - thisline); - if (ptr == NULL) - ohshit(_("files list file for package '%.250s' is missing final newline"), - pkg_name(pkg, pnaw_nonambig)); - /* Where to start next time around. */ - nextline = ptr + 1; - /* Strip trailing ‘/’. */ - if (ptr > thisline && ptr[-1] == '/') ptr--; - /* Add the file to the list. */ - if (ptr == thisline) - ohshit(_("files list file for package '%.250s' contains empty filename"), - pkg_name(pkg, pnaw_nonambig)); - *ptr = '\0'; - - namenode = fsys_hash_find_node(thisline, FHFF_NONE); - lendp = pkg_files_add_file(pkg, namenode, lendp); - thisline = nextline; - } - } + if (buf.used) + fsys_list_parse_buffer(&buf, pkg); varbuf_destroy(&buf); -- Dpkg.Org's dpkg

