All pastes #253242 Raw Edit

Something

public text v1 · immutable
#253242 ·published 2006-11-20 15:25 UTC
rendered paste body
--- levenshtein.c_orig	2006-11-20 13:32:33.000000000 +0100
+++ levenshtein.c	2006-11-20 16:08:42.000000000 +0100
@@ -24,6 +24,8 @@
 #include "php_string.h"
 
 #define LEVENSHTEIN_MAX_LENTH 255
+#define STRING_TOO_LONG -1
+#define CUSTOM_NOT_IMPL -2 
 
 /* {{{ reference_levdist
  * reference implementation, only optimized for memory usage, not speed */
@@ -72,10 +74,8 @@
  */
 static int custom_levdist(char *str1, char *str2, char *callback_name TSRMLS_DC) 
 {
-	php_error_docref(NULL TSRMLS_CC, E_WARNING, "The general Levenshtein support is not there yet");
-	/* not there yet */
-
-	return -1;
+	/* Not implemented yet*/
+	return -2;
 }
 /* }}} */
 
@@ -132,8 +132,23 @@
 		WRONG_PARAM_COUNT;
 	}	
 
+
+	/* General error handling */
+
 	if(distance<0) {
-		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Argument string(s) too long");
+		switch (distance) {
+			case STRING_TOO_LONG:
+				php_error_docref(NULL TSRMLS_CC, E_WARNING, "Argument string(s) too long");
+			break;
+
+			case CUSTOM_NOT_IMPL:
+	        	php_error_docref(NULL TSRMLS_CC, E_WARNING, "The general Levenshtein support is not there yet");
+			break;
+
+			default:
+			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unrecognised error code");
+
+		}
 	}
 	
 	RETURN_LONG(distance);