Sisyphus repositório
Última atualização: 19 setembro 2021 | SRPMs: 17353 | Visitas: 21906838
en ru br
ALT Linux repositórios
S:0.20.0-alt4
5.0: 0.9.2-alt1
4.1: 0.9.7-alt1.M41.2
4.0: 0.6.1-alt2
3.0: 0.0.3-alt0.1

Group :: Escritórios
RPM: xneur

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs e FR  Repocop 

Patch: xneur-unnest-function.patch
Download


diff --git a/xneur/lib/misc/text.c b/xneur/lib/misc/text.c
index f809c9d..2f34f7f 100644
--- a/xneur/lib/misc/text.c
+++ b/xneur/lib/misc/text.c
@@ -280,6 +280,30 @@ void del_final_numeric_char(char *word)
 	word[len - offset] = NULLSYM;
 }
 
+int levenshtein_dist(const int i, const int j,
+	const char *const s, const char *const t,
+	const int ls, const int lt, int d[ls+1][lt+1])
+{
+	if (d[i][j] >= 0) return d[i][j];
+
+	int x;
+	if (i == ls)
+		x = lt - j;
+	else if (j == lt)
+		x = ls - i;
+	else if (s[i] == t[j])
+		x = levenshtein_dist(i + 1, j + 1, s, t, ls, lt, d);
+	else {
+		x = levenshtein_dist(i + 1, j + 1, s, t, ls, lt, d);
+
+		int y;
+		if ((y = levenshtein_dist(i, j + 1, s, t, ls, lt, d)) < x) x = y;
+		if ((y = levenshtein_dist(i + 1, j, s, t, ls, lt, d)) < x) x = y;
+		x++;
+	}
+	return d[i][j] = x;
+}
+
 int levenshtein(const char *s, const char *t)
 {
 	int ls = strlen(s), lt = strlen(t);
@@ -287,25 +311,5 @@ int levenshtein(const char *s, const char *t)
  
 	memset(d, -1, sizeof(int) * (ls + 1) * (lt + 1));
  
-	int dist(int i, int j) {
-		if (d[i][j] >= 0) return d[i][j];
- 
-		int x;
-		if (i == ls)
-			x = lt - j;
-		else if (j == lt)
-			x = ls - i;
-		else if (s[i] == t[j])
-			x = dist(i + 1, j + 1);
-		else {
-			x = dist(i + 1, j + 1);
- 
-			int y;
-			if ((y = dist(i, j + 1)) < x) x = y;
-			if ((y = dist(i + 1, j)) < x) x = y;
-			x++;
-		}
-		return d[i][j] = x;
-	}
-	return dist(0, 0);
+	return levenshtein_dist(0, 0, s, t, ls, lt, d);
 }
 
projeto & código: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
mantenedor atual: Michael Shigorin
mantenedor da tradução: Fernando Martini aka fmartini © 2009