summaryrefslogtreecommitdiffstats
path: root/common/textfile.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2007-01-21 18:01:39 +0000
committerMarcel Holtmann <marcel@holtmann.org>2007-01-21 18:01:39 +0000
commit6561447cafc0b9a857094c8aa43c0aeb0aa7adb2 (patch)
tree4638cc75720501413755024f1228072e450d9e8a /common/textfile.c
parentc57d6548a33e4222435162a3c4c09be1189ea36f (diff)
Check if value has changed before writing it
Diffstat (limited to 'common/textfile.c')
-rw-r--r--common/textfile.c7
1 files changed, 6 insertions, 1 deletions
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;