]> git.sur5r.net Git - openldap/blobdiff - libraries/librewrite/map.c
Fix up abandon merge. Hallvard will holler if I get this wrong. :-)
[openldap] / libraries / librewrite / map.c
index 816a27edf76dd3c4afa8c8648615c225b9b6124e..8db54af13711b89701804bb6fdcf5a214cf20012 100644 (file)
@@ -245,19 +245,20 @@ rewrite_map_parse(
        for ( p = string, cnt = 1; p[ 0 ] != '\0' && cnt > 0; p++ ) {
                if ( p[ 0 ] == REWRITE_SUBMATCH_ESCAPE ) {
                        /*
-                        * '\' marks the beginning of a new map
+                        * '%' marks the beginning of a new map
                         */
                        if ( p[ 1 ] == '{' ) {
                                cnt++;
                        /*
-                        * '\' followed by a digit may mark the beginning
+                        * '%' followed by a digit may mark the beginning
                         * of an old map
                         */
-                       } else if ( isdigit( p[ 1 ] ) && p[ 2 ] == '{' ) {
+                       } else if ( isdigit( (unsigned char) p[ 1 ] ) && p[ 2 ] == '{' ) {
                                cnt++;
                                p++;
                        }
-                       p++;
+                       if ( p[ 1 ] != '\0' )
+                               p++;
                } else if ( p[ 0 ] == '}' ) {
                        cnt--;
                }
@@ -329,12 +330,12 @@ rewrite_map_parse(
        /*
         * Check the syntax of the variable name
         */
-       if ( !isalpha( p[ 0 ] ) ) {
+       if ( !isalpha( (unsigned char) p[ 0 ] ) ) {
                free( s );
                return NULL;
        }
        for ( p++; p[ 0 ] != '\0'; p++ ) {
-               if ( !isalnum( p[ 0 ] ) ) {
+               if ( !isalnum( (unsigned char) p[ 0 ] ) ) {
                        free( s );
                        return NULL;
                }