summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--real.make2
-rw-r--r--src/common/lock.cpp59
-rw-r--r--src/common/lock.hpp17
-rw-r--r--src/io/read.cpp2
-rw-r--r--src/io/write.cpp2
5 files changed, 3 insertions, 79 deletions
diff --git a/real.make b/real.make
index 8d5cfb6..0968503 100644
--- a/real.make
+++ b/real.make
@@ -245,7 +245,7 @@ obj/%.d: src/%.cpp
set -o pipefail; \
${CXX} ${CPPFLAGS} -DGENERATING_DEPENDENCIES ${CXXFLAGS} -MG -MP -MM $< \
-MT '$(patsubst %.d,%.ii,$@) $(patsubst %.d,%.ll,$@) $(patsubst %.d,%.bc,$@) $(patsubst %.d,%.s,$@) $(patsubst %.d,%.o,$@) $@' \
- | sed -e ':again; s:/[^/ ]*/../:/:; t again' \
+ | sed -e ':again; s:/[^/ ]*/\.\./:/:; t again' \
-e 's: ${SRC_DIR}/: :g' \
> $@
endif
diff --git a/src/common/lock.cpp b/src/common/lock.cpp
deleted file mode 100644
index e21aee5..0000000
--- a/src/common/lock.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-#include "lock.hpp"
-
-#include <unistd.h>
-
-#include <cstdio>
-
-#include "../strings/fstring.hpp"
-#include "../strings/zstring.hpp"
-
-#include "cxxstdio.hpp"
-#include "socket.hpp"
-
-#include "../poison.hpp"
-
-/// number of backups to keep
-static
-const int backup_count = 10;
-
-/// Protected file writing
-/// (Until the file is closed, it keeps the old file)
-
-// Start writing a tmpfile
-FILE *lock_fopen(ZString filename, int *info)
-{
- FILE *fp;
- int no = getpid();
-
- // Get a filename that doesn't already exist
- FString newfile;
- do
- {
- newfile = STRPRINTF("%s_%d.tmp", filename, no++);
- fp = fopen(newfile.c_str(), "wx");
- }
- while (!fp);
- *info = --no;
- return fp;
-}
-
-// Delete the old file and rename the new file
-void lock_fclose(FILE *fp, ZString filename, int *info)
-{
- if (fp)
- {
- fclose(fp);
- int n = backup_count;
- FString old_filename = STRPRINTF("%s.%d", filename, n);
- while (--n)
- {
- FString newer_filename = STRPRINTF("%s.%d", filename, n);
- rename(newer_filename.c_str(), old_filename.c_str());
- old_filename = std::move(newer_filename);
- }
- rename(filename.c_str(), old_filename.c_str());
-
- FString tmpfile = STRPRINTF("%s_%d.tmp", filename, *info);
- rename(tmpfile.c_str(), filename.c_str());
- }
-}
diff --git a/src/common/lock.hpp b/src/common/lock.hpp
deleted file mode 100644
index 5ca1aed..0000000
--- a/src/common/lock.hpp
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef LOCK_HPP
-#define LOCK_HPP
-
-#include "sanity.hpp"
-
-#include <cstdio>
-
-#include "../strings/fwd.hpp"
-
-// TODO replace with a class
-
-/// Locked FILE I/O
-// Changes are made in a separate file until lock_fclose
-FILE *lock_fopen(ZString filename, int *info);
-void lock_fclose(FILE *fp, ZString filename, int *info);
-
-#endif // LOCK_HPP
diff --git a/src/io/read.cpp b/src/io/read.cpp
index fad40bb..11a0020 100644
--- a/src/io/read.cpp
+++ b/src/io/read.cpp
@@ -27,7 +27,7 @@
#include "../common/cxxstdio.hpp"
-#include "src/poison.hpp"
+#include "../poison.hpp"
namespace io
diff --git a/src/io/write.cpp b/src/io/write.cpp
index 5f8a975..67002e2 100644
--- a/src/io/write.cpp
+++ b/src/io/write.cpp
@@ -25,7 +25,7 @@
#include "../strings/xstring.hpp"
-#include "src/poison.hpp"
+#include "../poison.hpp"
namespace io