diff -r 21a6c17f4e3e -r 629f61203db1 src/Ottoman.cpp --- a/src/Ottoman.cpp Mon Sep 28 23:39:08 2009 -0700 +++ b/src/Ottoman.cpp Tue Sep 29 15:46:42 2009 -0700 @@ -42,6 +42,7 @@ Ottoman::Ottoman() :_writeable(true), + _file(NULL), _filename(NULL), _lastVersion(NULL), _current( new OverlayDictionary(&Dictionary::kEmpty) ) @@ -96,6 +97,9 @@ delete _file; _file = curFile; } + + if (changed) + versionsChanged(); return changed; } @@ -196,11 +200,12 @@ if (!lastVersion) lastVersion = new VersionDictionary(dstFile); VersionDictionary *saved = lastVersion->_appendAndOpen(_current->overlay(), - dstFile, - _current->baseReplaced()); + dstFile, + _current->baseReplaced()); // (don't delete _lastVersion: saved->_previousVersion now points to it.) _lastVersion = saved; _current->revertTo(_lastVersion); + versionsChanged(); } bool Ottoman::save() { @@ -235,6 +240,7 @@ File *dstFile = _writeTo(dstFileName, overwriteAllowed); free(_filename); _filename = strdup(dstFileName); + delete _file; _file = dstFile; } @@ -242,8 +248,13 @@ if (!_file) return false; char tempFileName[1024]; +#ifdef _DARWIN_C_SOURCE + ::strlcpy(tempFileName, _filename, sizeof(tempFileName)-1); + ::strlcat(tempFileName, "~", sizeof(tempFileName)); +#else ::strncpy(tempFileName, _filename, sizeof(tempFileName)-1); ::strncat(tempFileName, "~", sizeof(tempFileName)); +#endif File *tempFile; { // Check for conflict in existing file: