r7873: hopefully fixed build of ldb_explode_dn() on AIX
authorAndrew Tridgell <tridge@samba.org>
Fri, 24 Jun 2005 05:17:36 +0000 (05:17 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:18:46 +0000 (13:18 -0500)
I'd really rather see this code completely replaced, but I'll leave
that to simo (he has volunteered) :-)

source/lib/ldb/common/ldb_explode_dn.c

index 0dcca5dc70b7eb2966f8772b6eff5cb70ea55543..0e2efa876cfe7dd16b7829c81bb552e004fd84df 100644 (file)
@@ -35,7 +35,6 @@
  *  Author: Derrell Lipman
  */
 
-#include <ctype.h>
 #include "includes.h"
 #include "ldb/include/ldb.h"
 #include "ldb/include/ldb_private.h"
@@ -496,35 +495,18 @@ failed:
 }
 
 
-static char *
-parse_slash(char *p,
-            char *end)
+static char *parse_slash(char *p, char *end)
 {
-       switch (*(p + 1)) {
-       case ',':
-       case '=':
-       case '\n':
-       case '+':
-       case '<':
-       case '>':
-       case '#':
-       case ';':
-       case '\\':
-       case '"':
+       unsigned x;
+       if (strchr(",=\n+<>#;\\\"", p[1])) {
                memmove(p, p + 1, end - (p + 1));
                return (end - 1);
-
-       default:
-                if (isxdigit(p[1]) && isxdigit(p[2])) {
-                        int             x;
-
-                        sscanf(p + 1, "%02x", &x);
-                        *p = (char) x;
-                        memmove(p + 1, p + 3, end - (p + 3));
-                        return (end - 2);
-                } else {
-                        return NULL;
-                }
        }
+       if (sscanf(p + 1, "%02x", &x) == 1) {
+               *p = (unsigned char)x;
+               memmove(p + 1, p + 3, end - (p + 3));
+               return (end - 2);
+       }
+       return NULL;
 }