#
# add_file "unix/unix.cc"
#
# add_file "unix/unix.hh"
#
# patch "ChangeLog"
# from [29e68be8bd50d2c8fb9ca2967c561f77078359ba]
# to [d6345c3a518fc9f44c70cbecd393e2901dfbf639]
#
# patch "Makefile.am"
# from [3eea4335169c33a02cb7323f7f333013a21187c0]
# to [1126b74203ca3867564b00caff7177ec8bd08e18]
#
# patch "ui.cc"
# from [f3e72d0c125a2ca9dddbe998f1d9f15d12d54199]
# to [359384e05f3ce77726285d606854eb967c3f0ff5]
#
# patch "unix/process.cc"
# from [2d952838b067e002206f6a67999534a3e1143218]
# to [5ebbfabd65a9f4e01a385a9dc991f55660e7e90e]
#
# patch "unix/unix.cc"
# from []
# to [24edec3d87384f43ad30ad2c480ff59c1337caa1]
#
# patch "unix/unix.hh"
# from []
# to [4f730b86bad3038195e1c845e592d5698adeb0e9]
#
========================================================================
--- ChangeLog 29e68be8bd50d2c8fb9ca2967c561f77078359ba
+++ ChangeLog d6345c3a518fc9f44c70cbecd393e2901dfbf639
@@ -1,5 +1,13 @@
2005-08-23 Nathaniel Smith
+ * ui.cc (sanitize): Fix signedness bug in comparison.
+ * unix/unix.{cc,hh}: New files.
+ * Makefile.am (UNIX_PLATFORM_SOURCES): Add them.
+ * unix/process.cc (is_executable, make_executable): Use new
+ function last_error.
+
+2005-08-23 Nathaniel Smith
+
* transforms.{cc,hh} (system_charset): Expose.
* monotone.cc (cpp_main): Use it to fiddle with gettext's charset
conversion and make --help output actually correct.
========================================================================
--- Makefile.am 3eea4335169c33a02cb7323f7f333013a21187c0
+++ Makefile.am 1126b74203ca3867564b00caff7177ec8bd08e18
@@ -196,7 +196,7 @@
UNIX_PLATFORM_SOURCES = \
unix/read_password.cc unix/get_system_flavour.cc unix/process.cc unix/terminal.cc \
- unix/platform_netsync.cc unix/inodeprint.cc
+ unix/platform_netsync.cc unix/inodeprint.cc unix/unix.hh unix/unix.cc
WIN32_PLATFORM_SOURCES = \
win32/read_password.cc win32/get_system_flavour.cc win32/process.cc win32/terminal.cc \
========================================================================
--- ui.cc f3e72d0c125a2ca9dddbe998f1d9f15d12d54199
+++ ui.cc 359384e05f3ce77726285d606854eb967c3f0ff5
@@ -347,7 +347,7 @@
for (size_t i = 0; i < line.size(); ++i)
{
if ((line[i] == '\n')
- || (line[i] >= static_cast(0x20)
+ || (static_cast(line[i]) >= static_cast(0x20)
&& line[i] != static_cast(0x7F)))
tmp += line[i];
else
========================================================================
--- unix/process.cc 2d952838b067e002206f6a67999534a3e1143218
+++ unix/process.cc 5ebbfabd65a9f4e01a385a9dc991f55660e7e90e
@@ -9,13 +9,12 @@
#include
#include
#include
-#include
-#include
#include
#include "sanity.hh"
#include "platform.hh"
+#include "unix/unix.hh"
int existsonpath(const char *exe)
{
@@ -50,7 +49,7 @@
struct stat s;
int rc = stat(path, &s);
- N(rc != -1, F("error getting status of file %s: %s") % path % strerror(errno));
+ N(rc != -1, F("error getting status of file %s: %s") % path % last_error());
return s.st_mode & S_IXUSR;
}
@@ -60,13 +59,13 @@
mode_t mode;
struct stat s;
int fd = open(path, O_RDONLY);
- N(fd != -1, F("error opening file %s: %s") % path % strerror(errno));
+ N(fd != -1, F("error opening file %s: %s") % path % last_error());
if (fstat(fd, &s))
return -1;
mode = s.st_mode;
mode |= S_IXUSR|S_IXGRP|S_IXOTH;
int ret = fchmod(fd, mode);
- N(close(fd) == 0, F("error closing file %s: %s") % path % strerror(errno));
+ N(close(fd) == 0, F("error closing file %s: %s") % path % last_error());
return ret;
}
========================================================================
--- unix/unix.cc
+++ unix/unix.cc 24edec3d87384f43ad30ad2c480ff59c1337caa1
@@ -0,0 +1,19 @@
+// copyright (C) 2005 nathaniel smith
+// all rights reserved.
+// licensed to the public under the terms of the GNU GPL (>= 2)
+// see the file COPYING for details
+
+#include
+#include
+
+#include "unix/unix.hh"
+#include "transforms.hh"
+
+utf8
+last_error()
+{
+ external msg = std::string(strerror(errno));
+ utf8 out;
+ system_to_utf8(msg, out);
+ return out;
+}
========================================================================
--- unix/unix.hh
+++ unix/unix.hh 4f730b86bad3038195e1c845e592d5698adeb0e9
@@ -0,0 +1,18 @@
+#ifndef __UNIX_HH__
+#define __UNIX_HH__
+
+// copyright (C) 2005 nathaniel smith
+// all rights reserved.
+// licensed to the public under the terms of the GNU GPL (>= 2)
+// see the file COPYING for details
+
+// some utilities useful when dealing with the posix api
+
+#include "vocab.hh"
+
+// get a string version of latest posix error
+// always use this instead of strerror; this function handles the charset
+// correctly.
+utf8 last_error();
+
+#endif