From 6561447cafc0b9a857094c8aa43c0aeb0aa7adb2 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Sun, 21 Jan 2007 18:01:39 +0000 Subject: Check if value has changed before writing it --- common/textfile.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'common/textfile.c') diff --git a/common/textfile.c b/common/textfile.c index 36bde03f..895e3f3d 100644 --- a/common/textfile.c +++ b/common/textfile.c @@ -168,7 +168,8 @@ static int write_key(const char *pathname, const char *key, const char *value, i goto unlock; } - off = find_key(map, key, strlen(key), icase); + len = strlen(key); + off = find_key(map, key, len, icase); if (!off) { if (value) { munmap(map, size); @@ -186,6 +187,10 @@ static int write_key(const char *pathname, const char *key, const char *value, i goto unmap; } + if (value && (strlen(value) == end - off - len - 1) && + !strncmp(off + len + 1, value, end - off - len - 1)) + goto unmap; + len = strspn(end, "\r\n"); end += len; -- cgit