summaryrefslogtreecommitdiff
path: root/libtextcat/libtextcat-2.2.patch
blob: 499ff3d4d44226b30df07bb0ff46c6de7bed5b9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
--- misc/libtextcat-2.2/configure	Thu May 22 13:39:55 2003
+++ misc/build/libtextcat-2.2/configure	Mon Mar 31 11:29:14 2008
@@ -5391,7 +5391,8 @@
 allow_undefined_flag=
 no_undefined_flag=
 need_lib_prefix=unknown
-need_version=unknown
+#need_version=unknown
+need_version=no
 # when you set need_version to no, make sure it does not cause -set_version
 # flags to be left without arguments
 archive_cmds=
@@ -5785,7 +5786,7 @@
     #        cross-compilation, but unfortunately the echo tests do not
     #        yet detect zsh echo's removal of \ escapes.  Also zsh mangles
     #	     `"' quotes if we put them in here... so don't!
-    archive_cmds='$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs && $CC $(test .$module = .yes && echo -bundle || echo -dynamiclib) $allow_undefined_flag -o $lib ${lib}-master.o $deplibs$linker_flags $(test .$module != .yes && echo -install_name $rpath/$soname $verstring)'
+    archive_cmds='$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs && $CC $(test .$module = .yes && echo -bundle || echo -dynamiclib) $allow_undefined_flag -o $lib ${lib}-master.o $deplibs$compiler_flags $(test .$module != .yes && echo -install_name $rpath/$soname $verstring)'
     # We need to add '_' to the symbols in $export_symbols first
     #archive_expsym_cmds="$archive_cmds"' && strip -s $export_symbols'
     hardcode_direct=yes
@@ -6280,7 +6281,7 @@
   ;;
 
 freebsd*)
-  objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout`
+  objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo elf`
   version_type=freebsd-$objformat
   case $version_type in
     freebsd-elf*)
--- misc/libtextcat-2.2/src/Makefile.in	Thu May 22 13:39:52 2003
+++ misc/build/libtextcat-2.2/src/Makefile.in	Mon Mar 31 11:29:14 2008
@@ -124,20 +124,20 @@
 target_vendor = @target_vendor@
 AUTOMAKE_OPTIONS = 1.4 foreign
 
-WARNS = -W -Wall -Wshadow -Wpointer-arith 
-IFLAGS = 
-FLAGS = -g -O3 -funroll-loops -D_THREAD_SAFE -D_GNU_SOURCE
+#WARNS = -W -Wall -Wshadow -Wpointer-arith
+IFLAGS =
+#FLAGS = -g -O3 -funroll-loops -D_THREAD_SAFE -D_GNU_SOURCE
 VERBOSE = -DVERBOSE
 AM_CFLAGS = $(IFLAGS) $(VERBOSE) $(WARNS) $(FLAGS)
 AM_LDFLAGS = -g
 
 noinst_HEADERS = \
-	common.h constants.h fingerprint.h textcat.h wg_mempool.h
+        common.h constants.h fingerprint.h textcat.h wg_mempool.h utf8misc.h
 
 
 lib_LTLIBRARIES = libtextcat.la
 libtextcat_la_SOURCES = \
-	common.c fingerprint.c textcat.c wg_mempool.c
+        common.c fingerprint.c textcat.c wg_mempool.c utf8misc.c
 
 
 bin_PROGRAMS = createfp
@@ -156,7 +156,7 @@
 libtextcat_la_LDFLAGS =
 libtextcat_la_LIBADD =
 am_libtextcat_la_OBJECTS = common.lo fingerprint.lo textcat.lo \
-	wg_mempool.lo
+        wg_mempool.lo utf8misc.lo
 libtextcat_la_OBJECTS = $(am_libtextcat_la_OBJECTS)
 bin_PROGRAMS = createfp$(EXEEXT)
 noinst_PROGRAMS = testtextcat$(EXEEXT)
@@ -177,7 +177,8 @@
 @AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/common.Plo ./$(DEPDIR)/createfp.Po \
 @AMDEP_TRUE@	./$(DEPDIR)/fingerprint.Plo \
 @AMDEP_TRUE@	./$(DEPDIR)/testtextcat.Po ./$(DEPDIR)/textcat.Plo \
-@AMDEP_TRUE@	./$(DEPDIR)/wg_mempool.Plo
+@AMDEP_TRUE@    ./$(DEPDIR)/wg_mempool.Plo \
+@AMDEP_TRUE@    ./$(DEPDIR)/utf8misc.Plo
 COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
 	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \
@@ -213,7 +214,7 @@
 	@rm -f stamp-h1
 	cd $(top_builddir) && $(SHELL) ./config.status src/config.h
 
-$(srcdir)/config.h.in:  $(top_srcdir)/configure.ac $(ACLOCAL_M4) 
+$(srcdir)/config.h.in:  $(top_srcdir)/configure.ac $(ACLOCAL_M4)
 	cd $(top_srcdir) && $(AUTOHEADER)
 	touch $(srcdir)/config.h.in
 
@@ -247,8 +248,8 @@
 	  echo "rm -f \"$${dir}/so_locations\""; \
 	  rm -f "$${dir}/so_locations"; \
 	done
-libtextcat.la: $(libtextcat_la_OBJECTS) $(libtextcat_la_DEPENDENCIES) 
-	$(LINK) -rpath $(libdir) $(libtextcat_la_LDFLAGS) $(libtextcat_la_OBJECTS) $(libtextcat_la_LIBADD) $(LIBS)
+libtextcat.la: $(libtextcat_la_OBJECTS) $(libtextcat_la_DEPENDENCIES)
+	$(LINK) -avoid-version -rpath $(libdir) $(libtextcat_la_LDFLAGS) $(libtextcat_la_OBJECTS) $(libtextcat_la_LIBADD) $(LIBS)
 binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
 install-binPROGRAMS: $(bin_PROGRAMS)
 	@$(NORMAL_INSTALL)
@@ -285,10 +286,10 @@
 	  echo " rm -f $$p $$f"; \
 	  rm -f $$p $$f ; \
 	done
-createfp$(EXEEXT): $(createfp_OBJECTS) $(createfp_DEPENDENCIES) 
+createfp$(EXEEXT): $(createfp_OBJECTS) $(createfp_DEPENDENCIES)
 	@rm -f createfp$(EXEEXT)
 	$(LINK) $(createfp_LDFLAGS) $(createfp_OBJECTS) $(createfp_LDADD) $(LIBS)
-testtextcat$(EXEEXT): $(testtextcat_OBJECTS) $(testtextcat_DEPENDENCIES) 
+testtextcat$(EXEEXT): $(testtextcat_OBJECTS) $(testtextcat_DEPENDENCIES)
 	@rm -f testtextcat$(EXEEXT)
 	$(LINK) $(testtextcat_LDFLAGS) $(testtextcat_OBJECTS) $(testtextcat_LDADD) $(LIBS)
 
@@ -304,6 +305,7 @@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testtextcat.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/textcat.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/wg_mempool.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utf8misc.Plo@am__quote@
 
 distclean-depend:
 	-rm -rf ./$(DEPDIR)
--- misc/libtextcat-2.2/src/common.c	Thu May 22 13:32:43 2003
+++ misc/build/libtextcat-2.2/src/common.c	Mon Mar 31 11:29:14 2008
@@ -3,23 +3,23 @@
  *
  * Copyright (c) 2003, WiseGuys Internet B.V.
  * All rights reserved.
- * 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
- * 
+ *
  * - Redistributions of source code must retain the above copyright
  * notice, this list of conditions and the following disclaimer.
- * 
+ *
  * - Redistributions in binary form must reproduce the above copyright
  * notice, this list of conditions and the following disclaimer in the
  * documentation and/or other materials provided with the
  * distribution.
- * 
+ *
  * - Neither the name of the WiseGuys Internet B.V. nor the names of
  * its contributors may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -114,11 +114,11 @@
 		wgmem_error( "Error while strduping %u bytes.\n", strlen(s) );
 	}
 
-	return( result ); 
+	return( result );
 }
 
-extern void* wg_realloc( void *ptr, size_t size ) 
-{ 
+extern void* wg_realloc( void *ptr, size_t size )
+{
 	void *result;
 
 	if (!size) {
@@ -131,7 +131,7 @@
 		wgmem_error( "Error while reallocing %u bytes.\n", size );
 	}
 
-	return( result ); 
+	return( result );
 }
 
 extern void wg_free( void *mem )
@@ -148,12 +148,12 @@
         if ( fgets(line, size, fp) == NULL ) {
 		return NULL;
 	}
-        
+
         /** kill term null **/
         if ( (p = strpbrk( line, "\n\r" )) ) {
                 *p = '\0';
-        }           
-  
+        }
+
         return line;
 }
 
@@ -164,39 +164,39 @@
  *
  * ARGUMENTS:
  * - result:
- * 
+ *
  *  After the split, this array contains pointers to the start of each
  *  detected segment. Must be preallocated and at least as large as
  *  maxsegments. The pointers point into the dest buffer.
- * 
- * - dest: 
- * 
+ *
+ * - dest:
+ *
  *  String into which result points as an index. Must be preallocated, and
  *  at least as big as src. You can use src as dest, but in that case src
  *  is overwritten!
- * 
- * - src:  
- * 
+ *
+ * - src:
+ *
  *  The string to split. Sequences of whitespace are treated as separators, unless
  *  escaped. There are two ways to escape: by using single quotes (anything
  *  between single quotes is treated as one segment), or by using a backslash
  *  to escape the next character. The backslash escape works inside quotation
  *  as well.
- * 
+ *
  *  Example:
- *  
+ *
  *  "It\'s   very\ easy   'to  use WiseGuys\' wg_split()' function" is split into:
- *  
+ *
  *  "It's"
  *  "very easy"
  *  "to  use WiseGuys' wg_split()"
  *  "function"
- *  
- * - maxsegments: 
- * 
+ *
+ * - maxsegments:
+ *
  *  The maximum number of segments. If the splitter runs out of segments,
  *  the remainder of the string is stored in the last segment.
- *  
+ *
  * RETURN VALUE:
  * The number of segments found.
  */
@@ -218,12 +218,12 @@
 		switch (state) {
 		case 0:
 			/*** Skip spaces ***/
-			while ( isspace((int) *p) ) {
+			while ( isspace((unsigned char) *p) ) {
 				p++;
 			}
 			state = 1;
 
-		case 1: 
+		case 1:
 			/*** Start segment ***/
 			result[cnt] = w;
 			cnt++;
@@ -232,12 +232,12 @@
 		case 2:
 			/*** Unquoted segment ***/
 			while (*p) {
-				if ( isspace((int) *p) ) {
+				if ( isspace((unsigned char) *p) ) {
 					*w++ = '\0';
 					p++;
 					state = 0;
 					break;
-				}				
+				}
 				else if ( *p == '\'' ) {
 					/*** Start quotation ***/
 					p++;
@@ -292,17 +292,17 @@
 }
 
 
+#ifdef HAVE_GETTIMEOFDAY    /* TL : no struct timeval under Win32 */
 extern void wg_timerstart(wgtimer_t *t)
 {
-#ifdef HAVE_GETTIMEOFDAY
         gettimeofday( &(t->start), NULL );
-#endif
 }
+#endif  /* TL : no struct timeval under Win32 */
 
 
+#ifdef HAVE_GETTIMEOFDAY    /* TL : no struct timeval under Win32 */
 extern uint4 wg_timerstop(wgtimer_t *t)
 {
-#ifdef HAVE_GETTIMEOFDAY
 	uint4 result;
         gettimeofday( &(t->stop), NULL );
         result = (t->stop.tv_sec - t->start.tv_sec) * 1000000 +
@@ -312,25 +312,23 @@
 	t->start.tv_usec = t->stop.tv_usec;
 
 	return result;
-#else
-	return 0;
-#endif
 }
+#endif  /* TL : no struct timeval under Win32 */
 
 
 /**
  * wg_strgmov -- a guarded strcpy() variation
- * 
+ *
  * copies src to dest (including terminating zero), and returns
  * pointer to position of terminating zero in dest. The function is
  * guaranteed not to write past destlimit. If the copy couldn't be
- * finished, the function returns NULL after restoring the first 
- * character in dest for your convenience (since this is usually a zero).  
+ * finished, the function returns NULL after restoring the first
+ * character in dest for your convenience (since this is usually a zero).
  */
 char *wg_strgmov( char *dest, const char *src, const char *destlimit )
 {
 	char tmp, *w;
-	
+
 	if ( !dest || dest >= destlimit ) {
 		return NULL;
 	}
@@ -355,7 +353,7 @@
 }
 
 /*
- * wg_trim() -- remove whitespace surrounding a string. 
+ * wg_trim() -- remove whitespace surrounding a string.
  *
  * Example: "   bla   bla   bla   " becomes "bla   bla   bla" after trimming.
  *
@@ -373,12 +371,12 @@
 	char *lastnonspace = &dest[-1];
 	const char *p = src;
 	char *w = dest;
-	
-	while ( isspace((int)*p) ) {
+
+	while ( isspace((unsigned char)*p) ) {
 		p++;
 	}
 	while (*p) {
-		if ( !isspace((int)*p) ) {
+		if ( !isspace((unsigned char)*p) ) {
 			lastnonspace = w;
 		}
 		*w++ = *p++;
--- misc/libtextcat-2.2/src/common.h	Thu May 22 15:02:29 2003
+++ misc/build/libtextcat-2.2/src/common.h	Mon Mar 31 11:29:14 2008
@@ -1,28 +1,28 @@
 #ifndef _COMMON_H_
 #define _COMMON_H_
 /**
- * common.h -- a mixed bag of helper functions 
+ * common.h -- a mixed bag of helper functions
  *
  * Copyright (C) 2003 WiseGuys Internet B.V.
  *
  * THE BSD LICENSE
- * 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
- * 
+ *
  * - Redistributions of source code must retain the above copyright
  * notice, this list of conditions and the following disclaimer.
- * 
+ *
  * - Redistributions in binary form must reproduce the above copyright
  * notice, this list of conditions and the following disclaimer in the
  * documentation and/or other materials provided with the
  * distribution.
- * 
+ *
  * - Neither the name of the WiseGuys Internet B.V. nor the names of
  * its contributors may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -86,10 +86,12 @@
 typedef char		boole;
 #endif
 
+#ifdef HAVE_GETTIMEOFDAY    /* TL : no struct timeval under Win32 */
 typedef struct wgtimer_s {
         struct timeval start;
         struct timeval stop;
 } wgtimer_t;
+#endif  /* TL : no struct timeval under Win32 */
 
 
 extern void *wg_malloc( size_t size );
@@ -101,13 +103,15 @@
 
 extern char *wg_getline( char *line, int size, FILE *fp );
 
+#ifdef HAVE_GETTIMEOFDAY    /* TL : no struct timeval under Win32 */
 extern void wg_timerstart(wgtimer_t *t);
 extern uint4 wg_timerstop(wgtimer_t *t);
+#endif  /* TL : no struct timeval under Win32 */
 
 extern unsigned int wg_split( char **result, char *dest, char *src, int maxsegments );
 extern char *wg_strgmov( char *dest, const char *src, const char *destlimit );
 extern char *wg_trim( char *dest, const char *src );
 
-      
+
 #endif
 
--- misc/libtextcat-2.2/src/constants.h	Thu May 22 13:32:43 2003
+++ misc/build/libtextcat-2.2/src/constants.h	Mon Mar 31 11:29:14 2008
@@ -39,6 +39,8 @@
  */
 #include <limits.h>
 
+#define _UTF8_
+
 #define DESCRIPTION "out of place"
 
 /* Reported matches are those fingerprints with a score less than best
@@ -59,14 +61,21 @@
 /* Maximum number of n-grams in a fingerprint */
 #define MAXNGRAMS  400
 
-/* Maximum size of an n-gram? */
-#define MAXNGRAMSIZE 5
+/* Maximum number of character of an n-gram? */
+#define MAXNGRAMSYMBOL 5
+
+/* Maximum size of the string representing an n-gram (must be greater than number of symbol) */
+#ifdef _UTF8_
+#define MAXNGRAMSIZE 20
+#else
+#define MAXNGRAMSIZE MAXNGRAMSYMBOL
+#endif
 
 /* Which characters are not acceptable in n-grams? */
-#define INVALID(c) (isspace((int)c) || isdigit((int)c)) 
+#define INVALID(c) (isspace((unsigned char)c) || isdigit((unsigned char)c)) 
 
 /* Minimum size (in characters) for accepting a document */
-#define MINDOCSIZE  25
+#define MINDOCSIZE  6
 
 /* Maximum penalty for missing an n-gram in fingerprint */
 #define MAXOUTOFPLACE 400
@@ -75,5 +84,8 @@
 #define TABLEPOW  13
 
 #define MAXSCORE  INT_MAX
+
+/* where the fingerprints files are stored */
+#define DEFAULT_FINGERPRINTS_PATH ""
 
 #endif
--- misc/libtextcat-2.2/src/fingerprint.c	Thu May 22 13:32:43 2003
+++ misc/build/libtextcat-2.2/src/fingerprint.c	Mon Mar 31 11:29:14 2008
@@ -6,23 +6,23 @@
  * All rights reserved.
  *
  * THE BSD LICENSE
- * 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
- * 
+ *
  * - Redistributions of source code must retain the above copyright
  * notice, this list of conditions and the following disclaimer.
- * 
+ *
  * - Redistributions in binary form must reproduce the above copyright
  * notice, this list of conditions and the following disclaimer in the
  * documentation and/or other materials provided with the
  * distribution.
- * 
+ *
  * - Neither the name of the WiseGuys Internet B.V. nor the names of
  * its contributors may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -51,7 +51,7 @@
  * The reason why we go through the trouble of doing a partial
  * (heap)sort is that a full quicksort behaves horribly on the data:
  * most n-grams have a very low count, resulting in a data set in
- * nearly-sorted order. This causes quicksort to behave very badly. 
+ * nearly-sorted order. This causes quicksort to behave very badly.
  * Heapsort, on the other hand, behaves handsomely: worst case is
  * Mlog(N) for M n-grams filtered through a N-sized heap.
  *
@@ -63,6 +63,10 @@
  * - put table/heap datastructure in a separate file.
  */
 
+#ifndef _UTF8_
+#define _UTF8_
+#endif
+
 #include "config.h"
 #include <stdio.h>
 #ifdef HAVE_STDLIB_H
@@ -80,10 +84,12 @@
 #include "wg_mempool.h"
 #include "constants.h"
 
+#include "utf8misc.h"
 
 #define TABLESIZE  (1<<TABLEPOW)
 #define TABLEMASK  ((TABLESIZE)-1)
 
+
 typedef struct {
 
 	sint2 rank;
@@ -96,7 +102,7 @@
 	const char *name;
 	ngram_t *fprint;
 	uint4 size;
-	
+
 } fp_t;
 
 typedef struct entry_s {
@@ -105,13 +111,13 @@
 	struct entry_s *next;
 } entry_t;
 
-typedef struct table_s {	
+typedef struct table_s {
 	void *pool;
 	entry_t **table;
 	entry_t *heap;
 
 	struct table_s *next;
-	
+
 	uint4 heapsize;
 	uint4 size;
 } table_t;
@@ -122,7 +128,7 @@
  * fast and furious little hash function
  *
  * (Note that we could use some kind of rolling checksum, and update it
- * during n-gram construction) 
+ * during n-gram construction)
  */
 static uint4 simplehash( const char *p, int len )
 {
@@ -134,29 +140,14 @@
 }
 
 
-/* checks if n-gram lex is a prefix of key and of length len */
-inline int issame( char *lex, char *key, int len )
-{
-	int i;
-	for (i=0; i<len; i++) {
-		if ( key[i] != lex[i] ) {
-			return 0;
-		}
-	}
-	if ( lex[i] != 0 ) {
-		return 0;
-	}
-	return 1;
-}
-
 
 /* increases frequency of ngram(p,len) */
-static inline int increasefreq( table_t *t, char *p, int len ) 
-{	
-	uint4 hash = simplehash( p, len ) & TABLEMASK;				
+static int increasefreq( table_t *t, char *p, int len )
+{
+	uint4 hash = simplehash( p, len ) & TABLEMASK;
 	entry_t *entry = t->table[ hash ];
-	
-	while ( entry ) {				
+
+	while ( entry ) {
 		if ( issame( entry->str, p, len ) ) {
 			/*** Found it! ***/
 			entry->cnt++;
@@ -168,7 +159,7 @@
 	}
 
 	/*** Not found, so create ***/
-	entry = wgmempool_alloc( t->pool, sizeof(entry_t) );
+        entry = (entry_t*)(wgmempool_alloc( t->pool, sizeof(entry_t) ));
 	strcpy( entry->str, p );
 	entry->cnt = 1;
 
@@ -181,12 +172,12 @@
 #if 0
 
 /* looks up ngram(p,len) */
-static entry_t *findfreq( table_t *t, char *p, int len ) 
-{	
-	uint4 hash = simplehash( p, len ) & TABLEMASK;				
+static entry_t *findfreq( table_t *t, char *p, int len )
+{
+	uint4 hash = simplehash( p, len ) & TABLEMASK;
 	entry_t *entry = t->table[ hash ];
-	
-	while ( entry ) {				
+
+	while ( entry ) {
 		if ( issame( entry->str, p, len ) ) {
 			return entry;
 		}
@@ -219,7 +210,7 @@
 #define GREATER(x,y) ((x).cnt > (y).cnt)
 #define LESS(x,y)    ((x).cnt < (y).cnt)
 
-inline static void siftup( table_t *t, unsigned int child )
+static void siftup( table_t *t, unsigned int child )
 {
 	entry_t *heap = t->heap;
 	unsigned int parent = (child-1) >> 1;
@@ -241,7 +232,7 @@
 }
 
 
-inline static void siftdown( table_t *t, unsigned int heapsize, uint4 parent )
+static void siftdown( table_t *t, unsigned int heapsize, uint4 parent )
 {
 	entry_t *heap = t->heap;
 	unsigned int child = parent*2 + 1;
@@ -273,7 +264,7 @@
 	if (t->size < t->heapsize) {
 		memcpy( &(heap[t->size]), item, sizeof(entry_t));
 		siftup( t, t->size );
-		t->size++;		
+		t->size++;
 		return 0;
 	}
 
@@ -316,18 +307,18 @@
 
 	/*** Fill result heap ***/
 	for (i=0; i<TABLESIZE; i++) {
-		entry_t *p = t->table[i];	       
+		entry_t *p = t->table[i];
 		while (p) {
 			heapinsert(t, p);
 			p = p->next;
 		}
-	}     
+	}
 	return 1;
 }
 
 
 static table_t *inittable(uint4 maxngrams)
-{	
+{
 	table_t *result = (table_t *)wg_zalloc( sizeof(table_t) );
 	result->table = (entry_t **)wg_zalloc( sizeof(entry_t*) * TABLESIZE );
 	result->pool = wgmempool_Init( 10000, 10 );
@@ -347,14 +338,14 @@
 	wgmempool_Done(t->pool);
 	wg_free(t->table);
 	wg_free(t->heap);
-	wg_free(t);	
+	wg_free(t);
 }
 
 
 extern void *fp_Init(const char *name)
 {
 	fp_t *h = (fp_t *)wg_zalloc( sizeof(fp_t) );
-	
+
 	if ( name ) {
 		h->name = wg_strdup(name);
 	}
@@ -458,21 +449,27 @@
 	return dest;
 }
 
-
+/**
+* this function extract all n-gram from past buffer and put them into the table "t"
+* [modified] by Jocelyn Merand to accept utf-8 multi-character symbols to be used in OpenOffice
+*/
 static void createngramtable( table_t *t, const char *buf )
 {
 	char n[MAXNGRAMSIZE+1];
 	const char *p = buf;
 	int i;
+        int pointer = 0;
 
 	/*** Get all n-grams where 1<=n<=MAXNGRAMSIZE. Allow underscores only at borders. ***/
-	for (;;p++) {
+	while(1) {
 
-		const char *q = p;
+     const char *q = &p[pointer];   /*[modified] previously p++ above (for(;;p++)) now, it's pointer wich is increased so we have to get the new pointer on the buffer*/
 		char *m = n;
 
 		/*** First char may be an underscore ***/
-		*m++ = *q++;
+                int decay = charcopy(q, m); /*[modified] previously *q++ = *m++*/
+                q = &(p[pointer+decay]);    /*[modified] the old copying method do not manage multi-character symbols*/
+                m += decay; /*[modified]*/
 		*m = '\0';
 
 		increasefreq( t, n, 1 );
@@ -482,19 +479,22 @@
 		}
 
 		/*** Let the compiler unroll this ***/
-		for ( i=2; i<=MAXNGRAMSIZE; i++) {
+		for ( i=2; i<=MAXNGRAMSYMBOL; i++) {
 
-			*m++ = *q;
+                        decay = charcopy(q, m); /*[modified] like above*/
+                        m += decay;
 			*m = '\0';
 
 			increasefreq( t, n, i );
 
 			if ( *q == '_' ) break;
-			q++;
+                        q += decay;
 			if ( *q == '\0' ) {
 				return;
 			}
 		}
+
+  pointer = nextcharstart(p,pointer);   /*[modified] p[pointer] must point on the next start of symbol, but whith utf next start is not surely next char*/
 	}
 	return;
 }
@@ -514,7 +514,7 @@
 {
 	ngram_t *x = (ngram_t *)a;
 	ngram_t *y = (ngram_t *)b;
-	
+
 	return mystrcmp( x->str, y->str );
 }
 
@@ -522,12 +522,12 @@
 {
 	ngram_t *x = (ngram_t *)a;
 	ngram_t *y = (ngram_t *)b;
-	
+
 	return x->rank - y->rank;
 }
 
 /**
- * Create a fingerprint: 
+ * Create a fingerprint:
  * - record the frequency of each unique n-gram in a hash table
  * - take the most frequent n-grams
  * - sort them alphabetically, recording their relative rank
@@ -544,20 +544,21 @@
 	}
 
 	/*** Throw out all invalid chars ***/
-	tmp = prepbuffer( buffer, bufsize ); 	
+	tmp = prepbuffer( buffer, bufsize );
+    /*printf("Cleaned buffer : %s\n",tmp);*/
 	if ( tmp == NULL ) {
 		return 0;
 	}
-
 	h = (fp_t*)handle;
 	t = inittable(maxngrams);
+    /*printf("Table initialized\n");*/
 
 	/*** Create a hash table containing n-gram counts ***/
 	createngramtable(t, tmp);
-
+    /*printf("Table created\n");*/
 	/*** Take the top N n-grams and add them to the profile ***/
-	table2heap(t);	
-	maxngrams = WGMIN( maxngrams, t->size );       
+	table2heap(t);
+	maxngrams = WGMIN( maxngrams, t->size );
 
 	h->fprint = (ngram_t *)wg_malloc( sizeof(ngram_t) * maxngrams );
 	h->size = maxngrams;
@@ -568,7 +569,7 @@
 		entry_t tmp2;
 
 		heapextract(t, &tmp2);
-		
+
 		/*** the string and its rank is all we need ***/
 		strcpy( h->fprint[i].str, tmp2.str );
 		h->fprint[i].rank = i;
@@ -578,7 +579,7 @@
 	wg_free(tmp);
 
 	/*** Sort n-grams alphabetically, for easy comparison ***/
-	qsort( h->fprint, h->size, sizeof(ngram_t), ngramcmp_str ); 
+	qsort( h->fprint, h->size, sizeof(ngram_t), ngramcmp_str );
 	return 1;
 }
 
@@ -608,7 +609,7 @@
 #endif
 		return 0;
 	}
-	
+
 	h->fprint = (ngram_t *)wg_malloc(maxngrams * sizeof(ngram_t));
 
 	while (cnt < maxngrams && wg_getline(line,1024,fp)) {
@@ -635,7 +636,7 @@
 	h->size = cnt;
 
 	/*** Sort n-grams, for easy comparison later on ***/
-	qsort( h->fprint, h->size, sizeof(ngram_t), ngramcmp_str ); 
+	qsort( h->fprint, h->size, sizeof(ngram_t), ngramcmp_str );
 
 	fclose(fp);
 
@@ -648,14 +649,15 @@
 {
 	uint4 i;
 	fp_t *h = (fp_t *)handle;
-	ngram_t *tmp = wg_malloc( sizeof(ngram_t) * h->size );
-	
+        ngram_t *tmp = (ngram_t*)wg_malloc( sizeof(ngram_t) * h->size );
+
 	/*** Make a temporary and sort it on rank ***/
 	memcpy( tmp, h->fprint, h->size * sizeof(ngram_t) );
-	qsort( tmp, h->size, sizeof(ngram_t), ngramcmp_rank ); 
+	qsort( tmp, h->size, sizeof(ngram_t), ngramcmp_rank );
 
 	for (i=0; i<h->size; i++) {
-		fprintf( fp, "%s\n", tmp[i].str );
+        /*fprintf( fp, "%s\t%i\n", tmp[i].str, tmp[i].rank );*/
+                fprintf( fp, "%s\n", tmp[i].str);
 	}
 	wg_free( tmp );
 }
@@ -669,7 +671,7 @@
 	uint4 i = 0;
 	uint4 j = 0;
 	sint4 sum = 0;
-	
+
 	/*** Compare the profiles in mergesort fashion ***/
 	while ( i < c->size && j < u->size ) {
 
@@ -705,7 +707,7 @@
 	}
 
 	return sum;
-	       	
+
 }
 
 
--- misc/libtextcat-2.2/src/fingerprint.h	Mon May 19 14:16:31 2003
+++ misc/build/libtextcat-2.2/src/fingerprint.h	Mon Mar 31 11:29:14 2008
@@ -41,7 +41,13 @@
 extern int fp_Read( void *handle, const char *fname, int maxngrams );
 extern sint4 fp_Compare( void *cat, void *unknown, int cutoff );
 extern void fp_Show( void *handle );
+#ifdef __cplusplus
+extern "C" {
+#endif
 extern const char *fp_Name( void *handle );
+#ifdef __cplusplus
+}
+#endif
 extern void fp_Print( void *handle, FILE *fp );
 
 #endif
--- misc/libtextcat-2.2/src/libtextcat.map	Mon Mar 31 11:30:06 2008
+++ misc/build/libtextcat-2.2/src/libtextcat.map	Mon Mar 31 11:29:14 2008
@@ -1 +1,40 @@
-dummy
+{
+	global: 
+		charcopy
+		issame
+		nextcharstart
+		utfstrlen
+		wgmempool_Done
+		wgmempool_Init
+		wgmempool_Reset
+		wgmempool_alloc
+		wgmempool_getline
+		wgmempool_strdup
+		special_textcat_Init
+		textcat_Classify
+		textcat_Done
+		textcat_Init
+		textcat_Version
+		fp_Compare
+		fp_Create
+		fp_Debug
+		fp_Done
+		fp_Init
+		fp_Name
+		fp_Print
+		fp_Read
+		heapextract
+		wg_calloc
+		wg_free
+		wg_getline
+		wg_malloc
+		wg_split
+		wg_strdup
+		wg_strgmov
+		wg_trim
+		wg_zalloc
+		wgmem_error
+		
+	local:
+		*;
+}
--- misc/libtextcat-2.2/src/makefile.mk	Mon Mar 31 11:30:06 2008
+++ misc/build/libtextcat-2.2/src/makefile.mk	Mon Mar 31 11:29:42 2008
@@ -1 +1,87 @@
-dummy
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+# 
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org.  If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ = ..$/..$/..$/..$/..
+
+PRJNAME = libtextcat
+TARGET  = libtextcat
+CFLAGSCALL=gsd
+
+USE_DEFFILE=TRUE
+EXTERNAL_WARNINGS_NOT_ERRORS := TRUE
+UWINAPILIB=
+
+.INCLUDE : settings.mk
+
+# --- Files --------------------------------------------------------
+
+# !! not to be compiled because those belong to a stand alone programs: !!
+#        $(SLO)$/createfp.obj\
+#        $(SLO)$/testtextcat.obj
+
+SLOFILES=   \
+        $(SLO)$/common.obj\
+        $(SLO)$/fingerprint.obj\
+        $(SLO)$/textcat.obj\
+        $(SLO)$/wg_mempool.obj\
+        $(SLO)$/utf8misc.obj
+
+#SHL1TARGET= $(TARGET)$(UPD)$(DLLPOSTFIX)
+SHL1TARGET= $(TARGET)
+
+SHL1STDLIBS=
+
+# build DLL
+SHL1LIBS=       $(SLB)$/$(TARGET).lib
+SHL1IMPLIB=     i$(TARGET)
+SHL1DEPN=       $(SHL1LIBS)
+SHL1DEF=        $(MISC)$/$(SHL1TARGET).def
+
+# build DEF file
+DEF1NAME=       $(SHL1TARGET)
+DEF1DEPN=$(MISC)$/$(SHL1TARGET).flt
+
+SHL1VERSIONMAP= libtextcat.map
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+# copy hand supplied configuration file for Win32 builds to the file
+# which is included in the source code
+$(SLOFILES) : config.h
+config.h :
+    $(GNUCOPY) $(OUT)$/misc$/build$/libtextcat-2.2$/src$/win32_config.h   $(OUT)$/misc$/build$/libtextcat-2.2$/src$/config.h
+
+
+$(MISC)$/$(SHL1TARGET).flt:  makefile.mk
+    @echo ------------------------------
+    @echo Making: $@
+    @echo Imp>$@
+    @echo __CT>>$@
+    @echo _real>>$@
+    @echo unnamed>>$@
--- misc/libtextcat-2.2/src/textcat.c	Thu May 22 13:32:43 2003
+++ misc/build/libtextcat-2.2/src/textcat.c	Mon Mar 31 11:29:14 2008
@@ -4,23 +4,23 @@
  * Copyright (C) 2003 WiseGuys Internet B.V.
  *
  * THE BSD LICENSE
- * 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
- * 
+ *
  * - Redistributions of source code must retain the above copyright
  * notice, this list of conditions and the following disclaimer.
- * 
+ *
  * - Redistributions in binary form must reproduce the above copyright
  * notice, this list of conditions and the following disclaimer in the
  * documentation and/or other materials provided with the
  * distribution.
- * 
+ *
  * - Neither the name of the WiseGuys Internet B.V. nor the names of
  * its contributors may be used to endorse or promote products derived
  * from this software without specific prior written permission.
- * 
+ *
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -74,6 +74,7 @@
 typedef struct {
 
 	void **fprint;
+        char *fprint_disable;
 	uint4 size;
 	uint4 maxsize;
 
@@ -112,11 +113,21 @@
 		fp_Done( h->fprint[i] );
 	}
 	wg_free( h->fprint );
+        wg_free( h->fprint_disable );
 	wg_free( h );
 
 }
 
-extern void *textcat_Init( const char *conffile )
+/** Replaces older function */
+extern void *textcat_Init( const char *conffile ){
+    return special_textcat_Init( conffile, DEFAULT_FINGERPRINTS_PATH );
+}
+
+/**
+ * Originaly this function had only one parameter (conffile) it has been modified since OOo use
+ * Basicaly prefix is the directory path where fingerprints are stored
+ */
+extern void *special_textcat_Init( const char *conffile, const char *prefix )
 {
 	textcat_t *h;
 	char line[1024];
@@ -134,11 +145,13 @@
 	h->size = 0;
 	h->maxsize = 16;
 	h->fprint = (void **)wg_malloc( sizeof(void*) * h->maxsize );
+ h->fprint_disable = (char *)wg_malloc( sizeof(char*) * h->maxsize );   /*added to store the state of languages*/
 
 	while ( wg_getline( line, 1024, fp ) ) {
 		char *p;
 		char *segment[4];
-		int res;
+                char finger_print_file_name[512];
+                int res;
 
 		/*** Skip comments ***/
 #ifdef HAVE_STRCHR
@@ -156,17 +169,23 @@
 		/*** Ensure enough space ***/
 		if ( h->size == h->maxsize ) {
 			h->maxsize *= 2;
-			h->fprint = (void *)wg_realloc( h->fprint, sizeof(void*) * h->maxsize );
+			h->fprint = (void **)wg_realloc( h->fprint, sizeof(void*) * h->maxsize );
+                        h->fprint_disable = (char *)wg_realloc( h->fprint_disable, sizeof(char*) * h->maxsize );
 		}
 
 		/*** Load data ***/
 		if ((h->fprint[ h->size ] = fp_Init( segment[1] ))==NULL) {
 			goto ERROR;
 		}
-		if ( fp_Read( h->fprint[h->size], segment[0], 400 ) == 0 ) {
+                finger_print_file_name[0] = '\0';
+                strcat(finger_print_file_name, prefix);
+                strcat(finger_print_file_name, segment[0]);
+
+                if ( fp_Read( h->fprint[h->size], finger_print_file_name, 400 ) == 0 ) {
 			textcat_Done(h);
 			goto ERROR;
-		}		
+		}
+                h->fprint_disable[h->size] = 0xF0;  /*0xF0 is the code for enabled languages, 0x0F is for disabled*/
 		h->size++;
 	}
 
@@ -203,11 +222,18 @@
 		result = _TEXTCAT_RESULT_SHORT;
 		goto READY;
 	}
-	
+
 	/*** Calculate the score for each category. ***/
 	for (i=0; i<h->size; i++) {
-		int score = fp_Compare( h->fprint[i], unknown, threshold );
-		candidates[i].score = score;
+                int score;
+                if(h->fprint_disable[i] & 0x0F){    /*if this language is disabled*/
+                    score = MAXSCORE;
+                }
+                else{
+                    score = fp_Compare( h->fprint[i], unknown, threshold );
+                    /*printf("Score for %s : %i\n", fp_Name(h->fprint[i]), score);*/
+                }
+                candidates[i].score = score;
 		candidates[i].name = fp_Name( h->fprint[i] );
 		if ( score < minscore ) {
 			minscore = score;
@@ -218,7 +244,6 @@
 	/*** Find the best performers ***/
 	for (i=0; i<h->size; i++) {
 		if ( candidates[i].score < threshold ) {
-
 			if ( ++cnt == MAXCANDIDATES+1 ) {
 				break;
 			}
@@ -235,7 +260,7 @@
 	else {
 		char *p = result;
 		char *plimit = result+MAXOUTPUTSIZE;
-		
+
 		qsort( candidates, cnt, sizeof(candidate_t), cmpcandidates );
 
 		*p = '\0';
@@ -247,7 +272,7 @@
 	}
  READY:
 	fp_Done(unknown);
-#ifdef SHOULD_FREE 
+#ifdef SHOULD_FREE
 	free(candidates);
 #undef SHOULD_FREE
 #endif
--- misc/libtextcat-2.2/src/textcat.h	Mon May 19 14:16:31 2003
+++ misc/build/libtextcat-2.2/src/textcat.h	Mon Mar 31 11:29:14 2008
@@ -40,6 +40,9 @@
 #define _TEXTCAT_RESULT_UNKOWN        "UNKNOWN"
 #define _TEXTCAT_RESULT_SHORT         "SHORT"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 /**
  * textcat_Init() - Initialize the text classifier. The textfile
@@ -51,10 +54,19 @@
  * Returns: handle on success, NULL on error. (At the moment, the
  * only way errors can occur, is when the library cannot read the
  * conffile, or one of the fingerprint files listed in it.)
+ *
+ * Replace older function (and has exacly the same behaviour)
+ * see below
  */
 extern void *textcat_Init( const char *conffile );
 
 /**
+ * Originaly this function had only one parameter (conffile) it has been modified since OOo must be able to load alternativ DB
+ * Basicaly prefix is the directory path where fingerprints are stored
+ */
+extern void *special_textcat_Init( const char *conffile, const char *prefix );
+
+/**
  * textcat_Done() - Free up resources for handle
  */
 extern void textcat_Done( void *handle );
@@ -77,4 +89,8 @@
  * textcat_Version() - Returns a string describing the version of this classifier.
  */
 extern char *textcat_Version();
+
+#ifdef __cplusplus
+}
+#endif
 #endif
--- misc/libtextcat-2.2/src/utf8misc.c	Mon Mar 31 11:30:06 2008
+++ misc/build/libtextcat-2.2/src/utf8misc.c	Mon Mar 31 11:29:14 2008
@@ -1 +1,132 @@
-dummy
+/***************************************************************************
+ *   Copyright (C) 2006 by Jocelyn Merand                                  *
+ *   joc.mer@gmail.com                                                     *
+ *                                                                         *
+ * THE BSD LICENSE
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the
+ * distribution.
+ *
+ * - Neither the name of the WiseGuys Internet B.V. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ ***************************************************************************/
+
+#ifndef _UTF8_MISC_H_
+#include "utf8misc.h"
+#endif
+
+
+int nextcharstart(const char *str, int position){
+    int pointer = position;
+
+    if(str[pointer] & ESCAPE_MASK){ /*if the first bit of the current char is 1*/
+
+        /*then str[pointer] is an escape character*/
+
+    char escape_char = ((str[pointer] & WEIGHT_MASK) << 1); /*and we use it to count (by bit translation) following characters (only the weightest part)*/
+
+    while(escape_char & ESCAPE_MASK && str[pointer]){/*every step, we move the byte of 1 bit left, when first bit is 0, it's finished*/
+        escape_char = escape_char <<1;
+        ++pointer;
+    }
+    }
+    if(str[pointer]){   /*finaly, if we are not on the \0 character, we jump to the next character*/
+        ++pointer;
+    }
+    return pointer;
+}
+
+
+int charcopy(const char *str, char *dest){
+
+    int pointer = 0;
+    if(str[pointer] & ESCAPE_MASK){ /*if the first bit of the current char is 1*/
+
+        /*then str[pointer] is an escape character*/
+
+        char escape_char = ((str[pointer] & WEIGHT_MASK) << 1); /*and we use it to count following characters (only the weightest part)*/
+
+        while(escape_char & ESCAPE_MASK && str[pointer]){   /*every step, we move the byte of 1 bit left, when first bit is 0, it's finished*/
+            dest[pointer] = str[pointer];
+            escape_char = escape_char <<1;
+            ++pointer;
+        }
+    }
+    if(str[pointer]){
+        dest[pointer] = str[pointer];
+        ++pointer;
+    }
+
+    return pointer;
+}
+
+
+int issame( char *lex, char *key, int len )
+{
+    /*printf("[%s] prefix of [%s] with length %i", lex, key, len);*/
+    int char_counter = 0;
+    int pointer = 0;
+    while(char_counter < len) {
+
+        if(key[pointer] & ESCAPE_MASK){ /*if the first bit of the current char is 1*/
+
+            /*then key[pointer] is an escap character*/
+
+            char escape_char = ((key[pointer] & WEIGHT_MASK) << 1);     /*and we use it to count (only the weightest part)*/
+
+            while(escape_char & ESCAPE_MASK && key[pointer] == lex[pointer] ){
+                escape_char = escape_char <<1;
+                ++pointer;
+            }
+        }
+        ++char_counter; /*and we are on a new utf8 character*/
+        if ( key[pointer] != lex[pointer] ) {
+            return 0;
+            /*printf(" NO\n", lex, key, len);*/
+        }
+        ++pointer;
+    }
+    if ( lex[pointer] != '\0' ) {
+        return 0;
+        /*printf(" NO\n");*/
+    }
+
+    /*printf(" YES\n");*/
+
+    return 1;
+}
+
+
+extern int utfstrlen(const char* str){
+    int char_counter = 0;
+    int pointer = 0;
+    while(str[pointer]) {
+        pointer = nextcharstart(str, pointer);
+
+        ++char_counter; /*and we are on a new utf8 character*/
+    }
+    return char_counter;
+}
+
--- misc/libtextcat-2.2/src/utf8misc.h	Mon Mar 31 11:30:06 2008
+++ misc/build/libtextcat-2.2/src/utf8misc.h	Mon Mar 31 11:29:14 2008
@@ -1 +1,88 @@
-dummy
+/***************************************************************************
+ *   Copyright (C) 2006 by Jocelyn Merand                                  *
+ *   joc.mer@gmail.com                                                     *
+ *                                                                         *
+ * THE BSD LICENSE
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the
+ * distribution.
+ *
+ * - Neither the name of the WiseGuys Internet B.V. nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ ***************************************************************************/
+
+#ifndef _UTF8_MISC_H_
+#define _UTF8_MISC_H_
+
+/**
+ * These variables are used in character processing functions
+ * These have been added to manage utf-8 symbols, particularly escape chars
+ */
+#ifdef _UTF8_
+#define ESCAPE_MASK 0x80
+#define WEIGHT_MASK 0xF0
+#else
+#define ESCAPE_MASK 0xFF
+#define WEIGHT_MASK 0x00
+#endif
+
+
+/*
+ * Is used to jump to the next start of char
+ * of course it's only usefull when encoding is utf-8
+ * This function have been added by Jocelyn Merand to use libtextcat in OOo
+ */
+int nextcharstart(const char *str, int position);
+
+
+/*Copy the char in str to dest
+ * of course it's only usefull when encoding is utf8 and the symbol is encoded with more than 1 char
+ * return the number of char jumped
+ * This function have been added by Jocelyn Merand to use libtextcat in OOo
+ */
+int charcopy(const char *str, char *dest);
+
+
+/* checks if n-gram lex is a prefix of key and of length len
+* if _UTF8_ is defined, it uses escap characters and len is not realy the length of lex
+* in this case, len is the number of utf-8 char strlen("€") == 3 but len == 1
+*/
+int issame( char *lex, char *key, int len );
+
+
+/* Counts the number of characters
+* if _UTF8_ is defined, it uses escap characters and the result is not realy the length of str
+* in this case, the result is the number of utf-8 char strlen("€") == 3 but utfstrlen("€") == 1
+*/
+#ifdef __cplusplus
+extern "C" {
+#endif
+extern int utfstrlen(const char* str);
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
--- misc/libtextcat-2.2/src/win32_config.h	Mon Mar 31 11:30:06 2008
+++ misc/build/libtextcat-2.2/src/win32_config.h	Mon Mar 31 11:29:14 2008
@@ -1 +1,136 @@
-dummy
+/* src/config.h.  Generated by configure.  */
+/* src/config.h.in.  Generated from configure.ac by autoheader.  */
+
+/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
+   systems. This function is required for `alloca.c' support on those systems.
+   */
+/* #undef CRAY_STACKSEG_END */
+
+/* Define to 1 if using `alloca.c'. */
+/* #undef C_ALLOCA */
+
+/* Define to 1 if you have `alloca', as a function or macro. */
+/* #undef HAVE_ALLOCA */
+
+/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
+   */
+/* #undef HAVE_ALLOCA_H */
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#define HAVE_DLFCN_H 1
+
+/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
+/* #undef HAVE_DOPRNT */
+
+/* Define to 1 if you have the `gettimeofday' function. */
+/* #undef  HAVE_GETTIMEOFDAY */
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+/* #undef  HAVE_INTTYPES_H */
+
+/* Define to 1 if you have the <limits.h> header file. */
+#define HAVE_LIMITS_H 1
+
+/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
+   to 0 otherwise. */
+#define HAVE_MALLOC 1
+
+/* Define to 1 if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define to 1 if you have the `memset' function. */
+#define HAVE_MEMSET 1
+
+/* Define to 1 if your system has a GNU libc compatible `realloc' function,
+   and to 0 otherwise. */
+#define HAVE_REALLOC 1
+
+/* Define to 1 if you have the <stdint.h> header file. */
+/* #undef  HAVE_STDINT_H */
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the `strchr' function. */
+#define HAVE_STRCHR 1
+
+/* Define to 1 if you have the `strdup' function. */
+#define HAVE_STRDUP 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+/* #undef HAVE_STRINGS_H */
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if you have the `strpbrk' function. */
+#define HAVE_STRPBRK 1
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+/* #undef  HAVE_SYS_TIME_H */
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#define HAVE_UNISTD_H 1
+
+/* Define to 1 if you have the `vprintf' function. */
+#define HAVE_VPRINTF 1
+
+/* Name of package */
+#define PACKAGE "libtextcat"
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT ""
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME "libtextcat"
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING "libtextcat 2.2"
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME "libtextcat"
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION "2.2"
+
+/* If using the C implementation of alloca, define if you know the
+   direction of stack growth for your system; otherwise it will be
+   automatically deduced at run-time.
+        STACK_DIRECTION > 0 => grows toward higher addresses
+        STACK_DIRECTION < 0 => grows toward lower addresses
+        STACK_DIRECTION = 0 => direction of growth unknown */
+/* #undef STACK_DIRECTION */
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
+#define TIME_WITH_SYS_TIME 1
+
+/* Define to 1 if your <sys/time.h> declares `struct tm'. */
+/* #undef TM_IN_SYS_TIME */
+
+/* Version number of package */
+#define VERSION "2.2"
+
+/* Define to empty if `const' does not conform to ANSI C. */
+/* #undef const */
+
+/* Define as `__inline' if that's what the C compiler calls it, or to nothing
+   if it is not supported. */
+/* #undef inline */
+
+/* Define to rpl_malloc if the replacement function should be used. */
+/* #undef malloc */
+
+/* Define to rpl_realloc if the replacement function should be used. */
+/* #undef realloc */
+
+/* Define to `unsigned' if <sys/types.h> does not define. */
+/* #undef size_t */