chiark / gitweb /
list: LIST_INSERT_BEFORE: update head if necessary (#4261)
[elogind.git] / src / basic / escape.c
index 2e483880c80c53996a73c9d9816c8cbcac524b0c..aa5dece97e239628e551ca28f4626fd106aa9674 100644 (file)
@@ -333,7 +333,7 @@ int cunescape_length_with_prefix(const char *s, size_t length, const char *prefi
                 assert(remaining > 0);
 
                 if (*f != '\\') {
-                        /* A literal literal, copy verbatim */
+                        /* A literal, copy verbatim */
                         *(t++) = *f;
                         continue;
                 }
@@ -413,6 +413,35 @@ char *xescape(const char *s, const char *bad) {
         return r;
 }
 
+#if 0 /// UNNEEDED by elogind
+char *octescape(const char *s, size_t len) {
+        char *r, *t;
+        const char *f;
+
+        /* Escapes all chars in bad, in addition to \ and " chars,
+         * in \nnn style escaping. */
+
+        r = new(char, len * 4 + 1);
+        if (!r)
+                return NULL;
+
+        for (f = s, t = r; f < s + len; f++) {
+
+                if (*f < ' ' || *f >= 127 || *f == '\\' || *f == '"') {
+                        *(t++) = '\\';
+                        *(t++) = '0' + (*f >> 6);
+                        *(t++) = '0' + ((*f >> 3) & 8);
+                        *(t++) = '0' + (*f & 8);
+                } else
+                        *(t++) = *f;
+        }
+
+        *t = 0;
+
+        return r;
+
+}
+
 static char *strcpy_backslash_escaped(char *t, const char *s, const char *bad) {
         assert(bad);
 
@@ -472,3 +501,4 @@ char *shell_maybe_quote(const char *s) {
 
         return r;
 }
+#endif // 0