summaryrefslogtreecommitdiff
path: root/navit/linguistics.c
diff options
context:
space:
mode:
authormartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2009-06-23 19:10:31 +0000
committermartin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220>2009-06-23 19:10:31 +0000
commit9e77e1194e08dda78e056ed22e54cb900caa7d44 (patch)
tree6106c10cbd003eb18354e838cbc9c58508ea87cf /navit/linguistics.c
parent66e43eecf1e399f657cc532d982f87a804bd9452 (diff)
downloadnavit-svn-9e77e1194e08dda78e056ed22e54cb900caa7d44.tar.gz
Add:Core:New module linguistics to cope with language specialities
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@2359 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit/linguistics.c')
-rw-r--r--navit/linguistics.c74
1 files changed, 74 insertions, 0 deletions
diff --git a/navit/linguistics.c b/navit/linguistics.c
new file mode 100644
index 00000000..0fb11c08
--- /dev/null
+++ b/navit/linguistics.c
@@ -0,0 +1,74 @@
+#include <string.h>
+#include <stdio.h>
+#include <glib.h>
+#include "debug.h"
+#include "linguistics.h"
+
+static const char *special[][3]={
+{"Ä","A","AE"},
+{"Ö","O","OE"},
+{"Ü","U","UE"},
+{"Ő","O"},
+{"Ű","U"},
+{"Á","A"},
+{"É","E"},
+{"Í","I"},
+{"Ó","O"},
+{"Ú","U"},
+{"ä","a","ae"},
+{"ö","o","oe"},
+{"ü","u","ue"},
+{"ő","o"},
+{"ű","u"},
+{"á","a"},
+{"é","e"},
+{"í","i"},
+{"ó","o"},
+{"ú","u"},
+{"ß","s","ss"},
+};
+
+char *
+linguistics_expand_special(char *str, int mode)
+{
+ char *in=str;
+ char *out,*ret;
+ int found=0;
+ out=ret=g_strdup(str);
+ mode++;
+ while (*in) {
+ char *next=g_utf8_find_next_char(in, NULL);
+ int i,len=next-in;
+ int match=0;
+ if (len > 1) {
+ for (i = 0 ; i < sizeof(special)/sizeof(special[0]); i++) {
+ const char *search=special[i][0];
+ if (!strncmp(in,search,len)) {
+ const char *replace=special[i][mode];
+ if (replace) {
+ int replace_len=strlen(replace);
+ dbg_assert(replace_len <= len);
+ dbg(1,"found %s %s %s\n",in,search,replace);
+ strcpy(out, replace);
+ out+=replace_len;
+ match=1;
+ break;
+ }
+ }
+ }
+ in=next;
+ }
+ if (match)
+ found=1;
+ else {
+ while (len-- > 0)
+ *out++=*in++;
+ }
+ }
+ *out++='\0';
+ if (!found) {
+ g_free(ret);
+ ret=NULL;
+ }
+ return ret;
+}