From 90fe3a9d0cd766d18d1142d8d6981193a5715643 Mon Sep 17 00:00:00 2001 From: Nikola Pajkovsky Date: Mon, 4 Apr 2011 12:02:27 +0200 Subject: rhbz#692465 - Blacklist doesn't work parse_value() doesn't trim the string. Lest say BlackList = coreutils, mono the parsed list looks like -> 'coreutils', ' mono' Signed-off-by: Nikola Pajkovsky --- src/lib/strbuf.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src/lib') diff --git a/src/lib/strbuf.c b/src/lib/strbuf.c index f56815a0..572f11cc 100644 --- a/src/lib/strbuf.c +++ b/src/lib/strbuf.c @@ -37,6 +37,29 @@ int suffixcmp(const char *str, const char *suffix) return strcmp(str + len_minus_suflen, suffix); } +/* + * Trims whitespace characters both from left and right side of a string. + * Modifies the string in-place. Returns the trimmed string. + */ +char *strtrim(char *str) +{ + if (!str) + return NULL; + + // Remove leading spaces. + overlapping_strcpy(str, skip_whitespace(str)); + + // Remove trailing spaces. + int i = strlen(str); + while (--i >= 0) + { + if (!isspace(str[i])) + break; + } + str[++i] = '\0'; + return str; +} + struct strbuf *strbuf_new(void) { struct strbuf *buf = xzalloc(sizeof(*buf)); -- cgit From 98445ec1f011601cfe650ef9a36bdada6cb058cb Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 4 Apr 2011 21:35:35 +0200 Subject: dump dir stealing: try to preserve atime/mtime. closes bz#692688 Signed-off-by: Denys Vlasenko --- src/lib/copy_file_recursive.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/lib') diff --git a/src/lib/copy_file_recursive.c b/src/lib/copy_file_recursive.c index c3f021c7..48108a1d 100644 --- a/src/lib/copy_file_recursive.c +++ b/src/lib/copy_file_recursive.c @@ -126,6 +126,16 @@ int copy_file_recursive(const char *source, const char *dest) if (close(dst_fd) < 0) { perror_msg("Error writing to '%s'", dest); retval = -1; + } else { + /* (Try to) copy atime and mtime */ + struct timeval atime_mtime[2]; + atime_mtime[0].tv_sec = source_stat.st_atime; + // note: if "st_atim.tv_nsec" doesn't compile, try "st_atimensec": + atime_mtime[0].tv_usec = source_stat.st_atim.tv_nsec / 1000; + atime_mtime[1].tv_sec = source_stat.st_mtime; + atime_mtime[1].tv_usec = source_stat.st_mtim.tv_nsec / 1000; + // note: can use utimensat when it is more widely supported: + utimes(dest, atime_mtime); } goto ret; } -- cgit