directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From elecha...@apache.org
Subject svn commit: r159179 - directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/utils/DNUtils.java
Date Sun, 27 Mar 2005 19:02:22 GMT
Author: elecharny
Date: Sun Mar 27 11:02:22 2005
New Revision: 159179

URL: http://svn.apache.org/viewcvs?view=rev&rev=159179
Log:
An error in isDigit function has been corrected... Junit test is now OK

Added:
    directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/utils/DNUtils.java

Added: directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/utils/DNUtils.java
URL: http://svn.apache.org/viewcvs/directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/utils/DNUtils.java?view=auto&rev=159179
==============================================================================
--- directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/utils/DNUtils.java
(added)
+++ directory/sandbox/trunk/asn1-new-codec/src/java/org/apache/asn1/ldap/codec/utils/DNUtils.java
Sun Mar 27 11:02:22 2005
@@ -0,0 +1,752 @@
+/*
+ *   Copyright 2005 The Apache Software Foundation
+ *
+ *   Licensed under the Apache License, Version 2.0 (the "License");
+ *   you may not use this file except in compliance with the License.
+ *   You may obtain a copy of the License at
+ *
+ *       http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *   Unless required by applicable law or agreed to in writing, software
+ *   distributed under the License is distributed on an "AS IS" BASIS,
+ *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *   See the License for the specific language governing permissions and
+ *   limitations under the License.
+ *
+ */
+package org.apache.asn1.ldap.codec.utils;
+
+/**
+ * Utility class used by the LdapDN Parser.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class DNUtils
+{
+    //~ Static fields/initializers -----------------------------------------------------------------
+
+    /** <safe-init-char>    ::= [0x01-0x09] | 0x0B | 0x0C | [0x0E-0x1F] | [0x21-0x39]
| 0x3B | [0x3D-0x7F] */
+    private static final boolean[] SAFE_INIT_CHAR =
+    {
+        false, true, true,  true, true,  true,  true, true, 
+		true,  true, false, true, true,  false, true, true,
+        true,  true, true,  true, true,  true,  true, true, 
+		true,  true, true,  true, true,  true,  true, true,
+        false, true, true,  true, true,  true,  true, true, 
+		true,  true, true,  true, true,  true,  true, true,
+        true,  true, true,  true, true,  true,  true, true, 
+		true,  true, false, true, false, true,  true, true,
+        true,  true, true,  true, true,  true,  true, true, 
+		true,  true, true,  true, true,  true,  true, true,
+        true,  true, true,  true, true,  true,  true, true, 
+		true,  true, true,  true, true,  true,  true, true,
+        true,  true, true,  true, true,  true,  true, true, 
+		true,  true, true,  true, true,  true,  true, true,
+        true,  true, true,  true, true,  true,  true, true, 
+		true,  true, true,  true, true,  true,  true, true
+    };
+
+    /** <safe-char>        ::= [0x01-0x09] | 0x0B | 0x0C | [0x0E-0x7F] */
+    private static final boolean[] SAFE_CHAR =
+    {
+        false, true, true,  true, true, true,  true, true, 
+		true,  true, false, true, true, false, true, true, 
+        true,  true, true,  true, true, true,  true, true, 
+		true,  true, true,  true, true, true,  true, true, 
+        true,  true, true,  true, true, true,  true, true, 
+		true,  true, true,  true, true, true,  true, true, 
+        true,  true, true,  true, true, true,  true, true, 
+		true,  true, true,  true, true, true,  true, true, 
+        true,  true, true,  true, true, true,  true, true, 
+		true,  true, true,  true, true, true,  true, true, 
+        true,  true, true,  true, true, true,  true, true, 
+		true,  true, true,  true, true, true,  true, true, 
+        true,  true, true,  true, true, true,  true, true, 
+		true,  true, true,  true, true, true,  true, true, 
+        true,  true, true,  true, true, true,  true, true, 
+		true,  true, true,  true, true, true,  true, true 
+    };
+
+    /** <base64-char>    ::= 0x2B | 0x2F | [0x30-0x39] | 0x3D | [0x41-0x5A] | [0x61-0x7A]
*/
+    private static final boolean[] BASE64_CHAR =
+    {
+        false, false, false, false, false, false, false, false, 
+		false, false, false, false, false, false, false, false, 
+        false, false, false, false, false, false, false, false, 
+		false, false, false, false, false, false, false, false, 
+        false, false, false, false, false, false, false, false, 
+		false, false, false, true,  false, false, false, true, 
+        true,  true,  true,  true,  true,  true,  true,  true, 
+		true,  true,  false, false, false, true,  false, false, 
+        false, true,  true,  true,  true,  true,  true,  true, 
+		true,  true,  true,  true,  true,  true,  true,  true, 
+        true,  true,  true,  true,  true,  true,  true,  true, 
+		true,  true,  true,  false, false, false, false, false, 
+        false, true,  true,  true,  true,  true,  true,  true, 
+		true,  true,  true,  true,  true,  true,  true,  true, 
+        true,  true,  true,  true,  true,  true,  true,  true, 
+		true,  true,  true,  false, false, false, false, false 
+    };
+
+    /** <alpha>    ::= [0x41-0x5A] | [0x61-0x7A] */
+    private static final boolean[] ALPHA =
+    {
+        false, false, false, false, false, false, false, false, 
+		false, false, false, false, false, false, false, false,
+        false, false, false, false, false, false, false, false, 
+		false, false, false, false, false, false, false, false,
+        false, false, false, false, false, false, false, false, 
+		false, false, false, false, false, false, false, false,
+        false, false, false, false, false, false, false, false, 
+		false, false, false, false, false, false, false, false,
+        false, true,  true,  true,  true,  true,  true,  true, 
+		true,  true,  true,  true,  true,  true,  true,  true, 
+		true,  true,  true,  true,  true,  true,  true,  true, 
+		true,  true,  true,  false, false, false, false, false,
+        false, true,  true,  true,  true,  true,  true,  true, 
+		true,  true,  true,  true,  true,  true,  true,  true,
+        true,  true,  true,  true,  true,  true,  true,  true, 
+		true,  true,  true,  false, false, false, false, false
+    };
+
+    /** <alpha> | <digit> | '-' */
+    private static final boolean[] CHAR =
+    {
+        false, false, false, false, false, false, false, false, 
+		false, false, false, false, false, false, false, false,
+        false, false, false, false, false, false, false, false, 
+		false, false, false, false, false, false, false, false,
+        false, false, false, false, false, false, false, false, 
+		false, false, false, false, false, true,  false, false,
+        true,  true,  true,  true,  true,  true,  true,  true, 
+		true,  true,  false, false, false, false, false, false,
+        false, true,  true,  true,  true,  true,  true,  true, 
+		true,  true,  true,  true,  true,  true,  true,  true,
+        true,  true,  true,  true,  true,  true,  true,  true, 
+		true,  true,  true,  false, false, false, false, false,
+        false, true,  true,  true,  true,  true,  true,  true, 
+		true,  true,  true,  true,  true,  true,  true,  true,
+        true,  true,  true,  true,  true,  true,  true,  true, 
+		true,  true,  true,  false, false, false, false, false
+    };
+
+    /** '"'  | '#'  | '+'  | ','  | [0-9] | ';'  | '<'  | '='  | '>'  | [A-F] | '\'
| [a-f] 
+     * 0x22 | 0x23 | 0x2B | 0x2C | [0x30-0x39] | 0x3B | 0x3C | 0x3D | 0x3E | [0x41-0x46]
| 0x5C | [0x61-0x66] */
+    private static final boolean[] PAIR_CHAR =
+    {
+        false, false, false, false, false, false, false, false, 
+		false, false, false, false, false, false, false, false,
+        false, false, false, false, false, false, false, false, 
+		false, false, false, false, false, false, false, false,
+        false, false, true,  true,  false, false, false, false, 
+		false, false, false, true,  true,  false, false, false,
+        true,  true,  true,  true,  true,  true,  true,  true, 
+		true,  true,  false, true,  true,  true,  true,  false,
+        false, true,  true,  true,  true,  true,  true,  false, 
+        false, false, false, false, false, false, false, false, 
+        false, false, false, false, false, false, false, false, 
+        false, false, false, false, true,  false, false, false, 
+        false, true,  true,  true,  true,  true,  true,  false, 
+        false, false, false, false, false, false, false, false, 
+        false, false, false, false, false, false, false, false, 
+        false, false, false, false, false, false, false, false 
+    };
+
+    /** '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' */
+    private static final boolean[] DIGIT =
+    {
+        false, false, false, false, false, false, false, false, 
+		false, false, false, false, false, false, false, false,
+        false, false, false, false, false, false, false, false, 
+		false, false, false, false, false, false, false, false,
+        false, false, false, false, false, false, false, false, 
+		false, false, false, false, false, false, false, false,
+        true,  true,  true,  true,  true,  true,  true,  true, 
+		true,  true,  false, false, false, false, false, false,
+        false, false, false, false, false, false, false, false, 
+		false, false, false, false, false, false, false, false,
+        false, false, false, false, false, false, false, false, 
+		false, false, false, false, false, false, false, false,
+        false, false, false, false, false, false, false, false, 
+		false, false, false, false, false, false, false, false,
+        false, false, false, false, false, false, false, false, 
+		false, false, false, false, false, false, false, false,
+    };
+
+    /** <hex>    ::= [0x30-0x39] | [0x41-0x46] | [0x61-0x66] */
+    private static final boolean[] HEX =
+    {
+        false, false, false, false, false, false, false, false, 
+		false, false, false, false, false, false, false, false,
+        false, false, false, false, false, false, false, false, 
+		false, false, false, false, false, false, false, false,
+        false, false, false, false, false, false, false, false, 
+		false, false, false, false, false, false, false, false,
+        true,  true,  true,  true,  true,  true,  true,  true, 
+		true,  true,  false, false, false, false, false, false,
+        false, true,  true,  true,  true,  true,  true,  false, 
+		false, false, false, false, false, false, false, false,
+        false, false, false, false, false, false, false, false, 
+		false, false, false, false, false, false, false, false,
+        false, true,  true,  true,  true,  true,  true,  false, 
+		false, false, false, false, false, false, false, false,
+        false, false, false, false, false, false, false, false, 
+		false, false, false, false, false, false, false, false
+    };
+
+    //~ Methods ------------------------------------------------------------------------------------
+
+    /**
+     * Test if the current character is equal to a specific character
+     *
+     * @param byteArray The buffer which contains the data
+     * @param index Current position in the buffer
+     * @param car The character we want to compare with the current buffer position
+     *
+     * @return <code>true</code> if the current character equals the given character.
+     */
+    public static boolean isChar( char[] charArray, int index, char car )
+    {
+
+        if ( ( charArray == null ) || ( charArray.length == 0 ) || ( index < 0 ) ||
+                ( index >= charArray.length ) )
+        {
+
+            return false;
+        }
+        else
+        {
+
+            return ( ( charArray[index] == car ) ? true : false );
+        }
+    }
+
+    /**
+     * Test if the current character is a digit
+     * <digit>    ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'
+     *
+     * @param byteArray The buffer which contains the data
+     * @param index Current position in the buffer
+     *
+     * @return <code>true</code> if the current character is a Digit
+     */
+    public static boolean isDigit( char[] charArray, int index )
+    {
+
+        if ( ( charArray == null ) || ( charArray.length == 0 ) || ( index < 0 ) ||
+                ( index >= charArray.length ) )
+        {
+
+            return false;
+        }
+        else
+        {
+            return ( ( ( charArray[index] > 127 ) || ! DIGIT[charArray[index]] ) ? false
: true );
+        }
+    }
+
+    /**
+     * Test if the current character is a digit
+     * <digit>    ::= '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'
+     *
+     * @param charArray The buffer which contains the data
+     *
+     * @return <code>true</code> if the current character is a Digit
+     */
+    public static boolean isDigit( char[] charArray )
+    {
+
+        if ( ( charArray == null ) || ( charArray.length == 0 ) )
+        {
+
+            return false;
+        }
+        else
+        {
+
+            return ( ( ( charArray[0] > 127 ) || ! DIGIT[charArray[0]] ) ? false : true
);
+        }
+    }
+
+    /**
+     * Test if the current character is an Alpha character :
+     *  <alpha>    ::= [0x41-0x5A] | [0x61-0x7A]
+     * 
+     * @param charArray The buffer which contains the data
+     * @param index Current position in the buffer
+     *
+     * @return <code>true</code> if the current character is an Alpha character
+     */
+    public static boolean isAlpha( char[] charArray, int index )
+    {
+
+        if ( ( charArray == null ) || ( charArray.length == 0 ) || ( index < 0 ) ||
+                ( index >= charArray.length ) )
+        {
+
+            return false;
+        }
+        else
+        {
+
+            char c = charArray[index++];
+
+            if ( ( c > 127 ) || ( ALPHA[c] == false ) )
+            {
+
+                return false;
+            }
+            else
+            {
+
+                return true;
+            }
+        }
+    }
+    
+    /**
+     * Walk the buffer while characters are Safe String characters :
+     *  <safe-string>    ::= <safe-init-char> <safe-chars>
+     *  <safe-init-char> ::= [0x01-0x09] | 0x0B | 0x0C | [0x0E-0x1F] | [0x21-0x39]
| 0x3B | [0x3D-0x7F]
+     *  <safe-chars>     ::= <safe-char> <safe-chars> |
+     *  <safe-char>      ::= [0x01-0x09] | 0x0B | 0x0C | [0x0E-0x7F]
+     *
+     * @param charArray The buffer which contains the data
+     * @param index Current position in the buffer
+     *
+     * @return The position of the first character which is not a Safe Char
+     */
+    public static int parseSafeString( char[] charArray, int index )
+    {
+
+        if ( ( charArray == null ) || ( charArray.length == 0 ) || ( index < 0 ) ||
+                ( index >= charArray.length ) )
+        {
+
+            return -1;
+        }
+        else
+        {
+
+            char c = charArray[index];
+
+            if ( ( c > 127 ) || ( SAFE_INIT_CHAR[c] == false ) )
+            {
+
+                return -1;
+            }
+
+            index++;
+
+            while ( index < charArray.length )
+            {
+                c = charArray[index];
+
+                if ( ( c > 127 ) || ( SAFE_CHAR[c] == false ) )
+                {
+
+                    break;
+                }
+
+                index++;
+            }
+
+            return index;
+        }
+    }
+
+    /**
+     * Walk the buffer while characters are Alpha characters :
+     *  <alpha>    ::= [0x41-0x5A] | [0x61-0x7A]
+     * 
+     * @param charArray The buffer which contains the data
+     * @param index Current position in the buffer
+     *
+     * @return The position of the first character which is not an Alpha Char
+     */
+    public static int parseAlpha( char[] charArray, int index )
+    {
+
+        if ( ( charArray == null ) || ( charArray.length == 0 ) || ( index < 0 ) ||
+                ( index >= charArray.length ) )
+        {
+
+            return -1;
+        }
+        else
+        {
+
+            char c = charArray[index++];
+
+            if ( ( c > 127 ) || ( ALPHA[c] == false ) )
+            {
+
+                return -1;
+            }
+            else
+            {
+
+                return index;
+            }
+        }
+    }
+
+    /**
+     * Check if the current character is an Hex Char
+     *  <hex>    ::= [0x30-0x39] | [0x41-0x46] | [0x61-0x66]
+     * 
+     * @param charArray The buffer which contains the data
+     * @param index Current position in the buffer
+     *
+     * @return <code>true</code> if the current character is a Hex Char
+     */
+    public static boolean isHex( char[] charArray, int index )
+    {
+
+        if ( ( charArray == null ) || ( charArray.length == 0 ) || ( index < 0 ) ||
+                ( index >= charArray.length ) )
+        {
+
+            return false;
+        }
+        else
+        {
+
+            char c = charArray[index];
+
+            if ( ( c > 127 ) || ( HEX[c] == false ) )
+            {
+
+                return false;
+            }
+            else
+            {
+
+                return true;
+            }
+        }
+    }
+
+    /**
+     * Check if the current character is a Pair Char
+     *  <pairchar>    ::= ',' | '=' | '+' | '<' | '>' | '#' | ';' | '\' | '"'
| [0-9a-fA-F] [0-9a-fA-F]
+     *  
+     * @param charArray The buffer which contains the data
+     * @param index Current position in the buffer
+     *
+     * @return <code>true</code> if the current character is a Pair Char
+     */
+    public static boolean isPairChar( char[] charArray, int index )
+    {
+
+        if ( ( charArray == null ) || ( charArray.length == 0 ) || ( index < 0 ) ||
+                ( index >= charArray.length ) )
+        {
+
+            return false;
+        }
+        else
+        {
+
+            char c = charArray[index];
+
+            if ( ( c > 127 ) || ( PAIR_CHAR[c] == false ) )
+            {
+
+                return false;
+            }
+            else
+            {
+
+            	if (isHex(charArray, index++)) 
+            	{
+            		return isHex(charArray, index);
+            	} 
+            	else 
+            	{
+            		return true;
+            	}
+            }
+        }
+    }
+
+    /**
+     * Check if the current character is a String Char
+     *  <stringchar>    ::= [0x00-0xFF] - [,=+<>#;\"\n\r]
+     * @param charArray The buffer which contains the data
+     * @param index Current position in the buffer
+     *
+     * @return <code>true</code> if the current character is a String Char
+     */
+    public static boolean isStringChar( char[] charArray, int index )
+    {
+
+        if ( ( charArray == null ) || ( charArray.length == 0 ) || ( index < 0 ) ||
+                ( index >= charArray.length ) )
+        {
+
+            return false;
+        }
+        else
+        {
+
+            char c = charArray[index++];
+
+            if ( ( c == 0x0A ) ||
+                    ( c == 0x0D ) ||
+                    ( c == '"' ) ||
+                    ( c == '#' ) ||
+                    ( c == '+' ) ||
+                    ( c == ',' ) ||
+                    ( c == ';' ) ||
+                    ( c == '<' ) ||
+                    ( c == '=' ) ||
+                    ( c == '>' ) )
+            {
+                return false;
+            }
+            else
+            {
+                return true;
+            }
+        }
+    }
+
+    /**
+     * Check if the current character is a Quote Char
+     *  <quotechar>    ::= [0x00-0xFF] - [\"]
+     * 
+     * @param charArray The buffer which contains the data
+     * @param index Current position in the buffer
+     *
+     * @return <code>true</code> if the current character is a Quote Char
+     */
+    public static boolean isQuoteChar( char[] charArray, int index )
+    {
+
+        if ( ( charArray == null ) || ( charArray.length == 0 ) || ( index < 0 ) ||
+                ( index >= charArray.length ) )
+        {
+            return false;
+        }
+        else
+        {
+            char c = charArray[index++];
+
+            if ( ( c == '\\' ) || ( c == '"' ) )
+            {
+                return false;
+            }
+            else
+            {
+                return true;
+            }
+        }
+    }
+
+    /**
+     * Parse an hex pair
+     *   <hexpair>    ::= <hex> <hex>
+     *
+     * @param charArray The buffer which contains the data
+     * @param index Current position in the buffer
+     *
+     * @return The new position, -1 if the buffer does not contain an HexPair, -2 if the
+     * buffer contains an hex byte but not two.
+     */
+    public static int parseHexPair( char[] charArray, int index )
+    {
+
+        if ( isHex( charArray, index ))
+        {
+        	if (isHex( charArray, index + 1 ))
+        	{
+        		return index + 2;
+        	}
+        	else
+        	{
+        		return -2;
+        	}
+        }
+        else
+        {
+            return -1;
+        }
+    }
+
+    /**
+     * Parse an hex string, which is a list of hex pairs
+     *  <hexstring>    ::= <hexpair> <hexpairs>
+     *  <hexpairs>    ::= <hexpair> <hexpairs> | e
+     *
+     * @param charArray The buffer which contains the data
+     * @param index Current position in the buffer
+     *
+     * @return Return the first position which is not an hex pair, or -1 if there is no
+     * hexpair at the beginning or if an hexpair is invalid (if we have only one hex instead
of 2)
+     */
+    public static int parseHexString( char[] charArray, int index )
+    {
+
+    	int result = parseHexPair( charArray, index );
+    	
+    	if (result < 0) 
+    	{
+    		return -1;
+		}
+    	else
+    	{
+			index += 2;
+    	}
+
+        while ((result = parseHexPair( charArray, index )) >= 0 )
+        {
+            index += 2;
+        }
+
+        return (result == -2 ? -1 : index);
+    }
+
+    /**
+     * Check if the current character is a CHAR.
+     *   <char>    ::= <alpha> | <digit> | '-'
+     *
+     * @param charArray The buffer which contains the data
+     * @param index Current position in the buffer
+     *
+     * @return The position of the next character, if the current one is a CHAR.
+     */
+    public static int parseChar( char[] charArray, int index )
+    {
+
+        if ( ( charArray == null ) || ( charArray.length == 0 ) || ( index < 0 ) ||
+                ( index >= charArray.length ) )
+        {
+            return -1;
+        }
+        else
+        {
+            char c = charArray[index++];
+
+            if ( ( c > 127 ) || ( CHAR[c] == false ) )
+            {
+                return -1;
+            }
+            else
+            {
+                return index;
+            }
+        }
+    }
+
+    /**
+     * Walk the buffer while characters are Base64 characters : 
+     * 	<base64-string>      ::= <base64-char> <base64-chars>
+     *  <base64-chars>       ::= <base64-char> <base64-chars> |
+     *  <base64-char>        ::= 0x2B | 0x2F | [0x30-0x39] | 0x3D | [0x41-0x5A] | [0x61-0x7A]
+     *
+     * @param charArray The buffer which contains the data
+     * @param index Current position in the buffer
+     *
+     * @return The position of the first character which is not a Base64 Char
+     */
+    public static int parseBase64String( char[] charArray, int index )
+    {
+
+        if ( ( charArray == null ) || ( charArray.length == 0 ) || ( index < 0 ) ||
+                ( index >= charArray.length ) )
+        {
+            return -1;
+        }
+        else
+        {
+
+            char c = charArray[index];
+
+            if ( ( c > 127 ) || ( BASE64_CHAR[c] == false ) )
+            {
+                return -1;
+            }
+
+            index++;
+
+            while ( index < charArray.length )
+            {
+                c = charArray[index];
+
+                if ( ( c > 127 ) || ( BASE64_CHAR[c] == false ) )
+                {
+                    break;
+                }
+
+                index++;
+            }
+
+            return index;
+        }
+    }
+
+    /**
+     * Check if a text is present at the current position in a buffer.
+     *
+     * @param charArray The buffer which contains the data
+     * @param index Current position in the buffer
+     * @param text The text we want to check
+     *
+     * @return <code>true</code> if the buffer contains the text.
+     */
+    public static int areEquals( byte[] charArray, int index, String text )
+    {
+
+        if ( ( charArray == null ) || ( charArray.length == 0 ) || ( charArray.length <=
index ) ||
+                ( index < 0 ) || ( text == null ) )
+        {
+
+            return -1;
+        }
+        else
+        {
+        	return areEquals(charArray, index, text);
+        }
+    }
+
+    /**
+     * Check if a text is present at the current position in a buffer.
+     *
+     * @param charArray The buffer which contains the data
+     * @param index Current position in the buffer
+     * @param charArray2 The text we want to check
+     *
+     * @return <code>true</code> if the buffer contains the text.
+     */
+    public static int areEquals( char[] charArray, int index, char[] charArray2 )
+    {
+
+        if ( ( charArray == null ) || 
+        		( charArray.length == 0 ) || 
+				( charArray.length <= index ) ||
+                ( index < 0 ) || 
+				( charArray2 == null ) || 
+				( charArray2.length == 0 ) || 
+				( charArray2.length > charArray.length + index ) )
+        {
+
+            return -1;
+        }
+        else
+        {
+
+            for ( int i = 0; i < charArray2.length; i++ )
+            {
+
+                if ( charArray[index++] != charArray2[i] )
+                {
+
+                    return -1;
+                }
+            }
+
+            return index;
+        }
+    }
+}



Mime
View raw message