chiark / gitweb /
core: add minimal templating system
[elogind.git] / util.c
diff --git a/util.c b/util.c
index a1b9f1e0f1ed0cef45a420d60526cff3f0beb6cf..5f36819fa31f432181989130822d6f047c013da7 100644 (file)
--- a/util.c
+++ b/util.c
@@ -1041,16 +1041,15 @@ char *bus_path_escape(const char *s) {
         return r;
 }
 
-char *bus_path_unescape(const char *s) {
+char *bus_path_unescape(const char *f) {
         char *r, *t;
-        const char *f;
 
-        assert(s);
+        assert(f);
 
-        if (!(r = new(char, strlen(s)+1)))
+        if (!(r = strdup(f)))
                 return NULL;
 
-        for (f = s, t = r; *f; f++) {
+        for (t = r; *f; f++) {
 
                 if (*f == '_') {
                         int a, b;
@@ -1422,14 +1421,18 @@ int reset_terminal(int fd) {
 
         assert(fd >= 0);
 
-        /* Set terminal up for job control */
+        /* Set terminal to some sane defaults */
 
         if (tcgetattr(fd, &termios) < 0) {
                 r = -errno;
                 goto finish;
         }
 
-        termios.c_iflag &= ~(IGNBRK | BRKINT);
+        /* We only reset the stuff that matters to the software. How
+         * hardware is set up we don't touch assuming that somebody
+         * else will do that for us */
+
+        termios.c_iflag &= ~(IGNBRK | BRKINT | ISTRIP | INLCR | IGNCR | IUCLC);
         termios.c_iflag |= ICRNL | IMAXBEL | IUTF8;
         termios.c_oflag |= ONLCR;
         termios.c_cflag |= CREAD;
@@ -1446,6 +1449,8 @@ int reset_terminal(int fd) {
         termios.c_cc[VLNEXT]   =  026;  /* ^V */
         termios.c_cc[VWERASE]  =  027;  /* ^W */
         termios.c_cc[VREPRINT] =  022;  /* ^R */
+        termios.c_cc[VEOL]     =    0;
+        termios.c_cc[VEOL2]    =    0;
 
         termios.c_cc[VTIME]  = 0;
         termios.c_cc[VMIN]   = 1;