svn commit: r189478 - head/lib/libarchive

Tim Kientzle kientzle at FreeBSD.org
Fri Mar 6 18:58:16 PST 2009


Author: kientzle
Date: Sat Mar  7 02:58:15 2009
New Revision: 189478
URL: http://svn.freebsd.org/changeset/base/189478

Log:
  Merge r511,r513,r607 from libarchive.googlecode.com:  Mtree reader
  tweaks:  Support nanosecond timestamps, handle attributes broken
  across multiple lines.

Modified:
  head/lib/libarchive/archive_read_support_format_mtree.c

Modified: head/lib/libarchive/archive_read_support_format_mtree.c
==============================================================================
--- head/lib/libarchive/archive_read_support_format_mtree.c	Sat Mar  7 02:51:18 2009	(r189477)
+++ head/lib/libarchive/archive_read_support_format_mtree.c	Sat Mar  7 02:58:15 2009	(r189478)
@@ -891,8 +891,17 @@ parse_keyword(struct archive_read *a, st
 			break;
 		}
 		if (strcmp(key, "time") == 0) {
+			time_t m;
+			long ns;
+
 			*parsed_kws |= MTREE_HAS_MTIME;
-			archive_entry_set_mtime(entry, mtree_atol10(&val), 0);
+			m = (time_t)mtree_atol10(&val);
+			if (*val == '.') {
+				++val;
+				ns = (long)mtree_atol10(&val);
+			} else
+				ns = 0;
+			archive_entry_set_mtime(entry, m, ns);
 			break;
 		}
 		if (strcmp(key, "type") == 0) {
@@ -1225,6 +1234,7 @@ readline(struct archive_read *a, struct 
 {
 	ssize_t bytes_read;
 	ssize_t total_size = 0;
+	ssize_t find_off = 0;
 	const void *t;
 	const char *s;
 	void *p;
@@ -1262,9 +1272,7 @@ readline(struct archive_read *a, struct 
 		/* Null terminate. */
 		mtree->line.s[total_size] = '\0';
 		/* If we found an unescaped '\n', clean up and return. */
-		if (p == NULL)
-			continue;
-		for (u = mtree->line.s; *u; ++u) {
+		for (u = mtree->line.s + find_off; *u; ++u) {
 			if (u[0] == '\n') {
 				*start = mtree->line.s;
 				return total_size;
@@ -1285,8 +1293,12 @@ readline(struct archive_read *a, struct 
 				memmove(u, u + 1,
 				    total_size - (u - mtree->line.s) + 1);
 				--total_size;
-				continue;    
+				++u;
+				break;
 			}
+			if (u[1] == '\0')
+				break;
 		}
+		find_off = u - mtree->line.s;
 	}
 }


More information about the svn-src-all mailing list