Introduction
Introduction Statistics Contact Development Disclaimer Help
Improved the fuzzy filename matching algorithm. - sam - An updated version of t…
git clone git://vernunftzentrum.de/sam.git
Log
Files
Refs
LICENSE
---
commit ddafc188b6e492d1908ae84e4c2ba02c26464c0b
parent 273f9318ba04e45989bbb82cedb596d163156b73
Author: Rob King <[email protected]>
Date: Thu, 26 May 2016 12:02:47 -0500
Improved the fuzzy filename matching algorithm.
Diffstat:
sam/multi.c | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
---
diff --git a/sam/multi.c b/sam/multi.c
@@ -1,6 +1,8 @@
/* Copyright (c) 1998 Lucent Technologies - All rights reserved. */
#include "sam.h"
+#include <libgen.h>
+
List file;
ushort tag;
@@ -80,20 +82,26 @@ state(File *f, int cleandirty)
}
File *
-lookfile(String *s, int doprefix)
+lookfile(String *s, int fuzzy)
{
int i;
File *b = NULL;
- int l1 = 0;
+ char *sc = Strtoc(s);
+ size_t sl = strlen(sc);
for(i=0; i<file.nused; i++){
int l2;
if(Strcmp(&file.filepptr[i]->name, s, &l2) == 0)
return file.filepptr[i];
- if (doprefix && l2 > l1 && l2 == s->n - 1){
- l1 = l2;
- b = file.filepptr[i];
+ if (fuzzy){
+ char *ac = Strtoc(&file.filepptr[i]->name);
+ if (strcmp(basename(sc), ac) == 0)
+ return free(ac), file.filepptr[i];
+
+ if (!b && strstr(ac, sc))
+ b = file.filepptr[i];
+ free(ac);
}
}
You are viewing proxied material from vernunftzentrum.de. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.