summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--NEWS4
-rw-r--r--doc/dico.texi26
-rw-r--r--include/dico/util.h1
-rw-r--r--modules/gcide/gcide.c91
-rw-r--r--modules/gcide/tests/Makefile.am4
-rw-r--r--modules/gcide/tests/def00.at2
-rw-r--r--modules/gcide/tests/def01.at4
-rw-r--r--modules/gcide/tests/def02.at2
-rw-r--r--modules/gcide/tests/def03.at2
-rw-r--r--modules/gcide/tests/def04.at2
-rw-r--r--modules/gcide/tests/def05.at2
-rw-r--r--modules/gcide/tests/descr.at31
-rw-r--r--modules/gcide/tests/dicod.cfin1
-rw-r--r--modules/gcide/tests/dict/INFO14
-rw-r--r--modules/gcide/tests/info.at45
-rw-r--r--modules/gcide/tests/testsuite.at4
-rw-r--r--scripts/Makefile.am3
17 files changed, 207 insertions, 31 deletions
diff --git a/NEWS b/NEWS
index 3fd7b93..a0cc8d1 100644
--- a/NEWS
+++ b/NEWS
@@ -1,11 +1,11 @@
1GNU Dico NEWS -- history of user-visible changes. 2012-03-03 1GNU Dico NEWS -- history of user-visible changes. 2012-03-04
2Copyright (C) 2008-2010, 2012 Sergey Poznyakoff 2Copyright (C) 2008-2010, 2012 Sergey Poznyakoff
3See the end of file for copying conditions. 3See the end of file for copying conditions.
4 4
5Please send Dico bug reports to <bug-dico@gnu.org.ua> 5Please send Dico bug reports to <bug-dico@gnu.org.ua>
6 6
7 7
8Version 2.2 (Git) 8Version 2.2, 2012-03-04
9 9
10* Configuration changes 10* Configuration changes
11 11
diff --git a/doc/dico.texi b/doc/dico.texi
index 59639a2..8c55707 100644
--- a/doc/dico.texi
+++ b/doc/dico.texi
@@ -2990,7 +2990,8 @@ for the user @command{dicod} is started as.
2990Other options are: 2990Other options are:
2991 2991
2992@deffn {gcide parameter} idxdir directory 2992@deffn {gcide parameter} idxdir directory
2993Specifies alternate directory for the @file{CIDE.IDX} index file. 2993Specifies the directory where the @file{CIDE.IDX} index file resides
2994or should reside.
2994@end deffn 2995@end deffn
2995 2996
2996@deffn {gcide parameter} index-cache-size size 2997@deffn {gcide parameter} index-cache-size size
@@ -3014,6 +3015,12 @@ fields have been filled in}, so it might be reasonable to avoid
3014displaying them at all. 3015displaying them at all.
3015@end deffn 3016@end deffn
3016 3017
3018 Starting from version 0.51, GCIDE contains the file @file{INFO},
3019which provides basic information about the dictionary. The
3020@command{gcide} module returns contents of this file at the
3021@samp{SHOW INFO} request. The first line of this file (with the
3022trailing newline and final point removed) is returned as the short
3023database description.
3017 3024
3018 Here's a full example of a @samp{gcide} as used in 3025 Here's a full example of a @samp{gcide} as used in
3019@indicateurl{dico.gnu.org.ua}: 3026@indicateurl{dico.gnu.org.ua}:
@@ -3024,28 +3031,13 @@ load-module gcide;
3024 3031
3025database @{ 3032database @{
3026 name "gcide"; 3033 name "gcide";
3027 handler "gcide dbdir=/var/dictdb/gcide suppress-pr"; 3034 handler "gcide dbdir=/var/dictdb/gcide-0.51 suppress-pr";
3028 languages-from "en"; 3035 languages-from "en";
3029 languages-to "en"; 3036 languages-to "en";
3030 description "Collaborative International Dictionary"
3031 " of English";
3032 info <<EOT
3033The dictionary was derived from the
3034 Webster's Revised Unabridged Dictionary
3035 Version published 1913
3036 by the C. & G. Merriam Co.
3037 Springfield, Mass.
3038 Under the direction of
3039 Noah Porter, D.D., LL.D.
3040@dots{}
3041EOT;
3042@} 3037@}
3043@end group 3038@end group
3044@end example 3039@end example
3045 3040
3046 The dots represent further content of the description which is too
3047big and irrelevant to copy it here.
3048
3049@menu 3041@menu
3050* idxgcide:: 3042* idxgcide::
3051@end menu 3043@end menu
diff --git a/include/dico/util.h b/include/dico/util.h
index 115ae08..899dbcb 100644
--- a/include/dico/util.h
+++ b/include/dico/util.h
@@ -18,6 +18,7 @@
18#define __dico_util_h 18#define __dico_util_h
19 19
20char *dico_full_file_name(const char *dir, const char *file); 20char *dico_full_file_name(const char *dir, const char *file);
21size_t dico_string_trim(char *buf, size_t len, int (*pred)(int c));
21size_t dico_trim_nl(char *buf); 22size_t dico_trim_nl(char *buf);
22size_t dico_trim_ws(char *buf); 23size_t dico_trim_ws(char *buf);
23 24
diff --git a/modules/gcide/gcide.c b/modules/gcide/gcide.c
index fa10c02..fbbd788 100644
--- a/modules/gcide/gcide.c
+++ b/modules/gcide/gcide.c
@@ -296,7 +296,94 @@ gcide_free_db(dico_handle_t hp)
296 free_db(db); 296 free_db(db);
297 return 0; 297 return 0;
298} 298}
299
300static int
301_is_nl_or_punct(int c)
302{
303 return !!strchr("\r\n!,-./:;?", c);
304}
305
306static char *
307read_info_file(const char *fname, int first_line)
308{
309 dico_stream_t stream;
310 int rc;
311 char *bufptr = NULL;
312 size_t bufsize = 0;
313
314 stream = dico_mapfile_stream_create(fname, DICO_STREAM_READ);
315 if (!stream) {
316 dico_log(L_NOTICE, errno, _("cannot create stream `%s'"), fname);
317 return NULL;
318 }
319
320 rc = dico_stream_open(stream);
321 if (rc) {
322 dico_log(L_ERR, 0,
323 _("cannot open stream `%s': %s"),
324 fname, dico_stream_strerror(stream, rc));
325 dico_stream_destroy(&stream);
326 return NULL;
327 }
328
329 if (first_line) {
330 size_t n;
331
332 rc = dico_stream_getline(stream, &bufptr, &bufsize, &n);
333 if (rc) {
334 dico_log(L_ERR, 0,
335 _("read error in stream `%s': %s"),
336 fname, dico_stream_strerror(stream, rc));
337 } else
338 dico_string_trim(bufptr, n, _is_nl_or_punct);
339 } else {
340 off_t size;
341 rc = dico_stream_size(stream, &size);
342 if (rc) {
343 dico_log(L_ERR, 0,
344 _("cannot get size of stream `%s': %s"),
345 fname, dico_stream_strerror(stream, rc));
346 } else {
347 bufsize = size;
348 bufptr = malloc (bufsize + 1);
349 if (!bufptr) {
350 dico_log(L_ERR, errno,
351 _("cannot allocate dictionary information buffer"));
352 } else if ((rc = dico_stream_read(stream, bufptr, bufsize, NULL))) {
353 dico_log(L_ERR, 0,
354 _("read error in stream `%s': %s"),
355 fname, dico_stream_strerror(stream, rc));
356 free(bufptr);
357 bufptr = NULL;
358 } else
359 bufptr[bufsize] = 0;
360 }
361 }
362
363 dico_stream_destroy(&stream);
364 return bufptr;
365}
366
367static char *
368read_dictionary_info(struct gcide_db *db, int first_line)
369{
370 char *fname = dico_full_file_name(db->db_dir, "INFO");
371 char *info = read_info_file(fname, first_line);
372 free(fname);
373 return info;
374}
375
376char *
377gcide_info(dico_handle_t hp)
378{
379 return read_dictionary_info((struct gcide_db *) hp, 0);
380}
299 381
382char *
383gcide_descr(dico_handle_t hp)
384{
385 return read_dictionary_info((struct gcide_db *) hp, 1);
386}
300 387
301static gcide_iterator_t 388static gcide_iterator_t
302exact_match(struct gcide_db *db, const char *hw) 389exact_match(struct gcide_db *db, const char *hw)
@@ -748,8 +835,8 @@ struct dico_database_module DICO_EXPORT(gcide, module) = {
748 gcide_free_db, 835 gcide_free_db,
749 NULL, 836 NULL,
750 NULL, 837 NULL,
751 NULL, 838 gcide_info,
752 NULL, 839 gcide_descr,
753 NULL, 840 NULL,
754 gcide_match, 841 gcide_match,
755 gcide_define, 842 gcide_define,
diff --git a/modules/gcide/tests/Makefile.am b/modules/gcide/tests/Makefile.am
index 3bbda92..3145258 100644
--- a/modules/gcide/tests/Makefile.am
+++ b/modules/gcide/tests/Makefile.am
@@ -27,7 +27,7 @@ noinst_DATA = dicod.conf
27CLEANFILES = dicod.conf 27CLEANFILES = dicod.conf
28 28
29dist-hook: 29dist-hook:
30 tar -C $(srcdir) -c -f - dict/CIDE.[A-Z] | \ 30 tar -C $(srcdir) -c -f - dict/CIDE.[A-Z] dict/INFO | \
31 tar -C $(distdir) -x -f - 31 tar -C $(distdir) -x -f -
32 32
33## ------------ ## 33## ------------ ##
@@ -71,9 +71,11 @@ TESTSUITE_AT = \
71 def03.at\ 71 def03.at\
72 def04.at\ 72 def04.at\
73 def05.at\ 73 def05.at\
74 descr.at\
74 exact.at\ 75 exact.at\
75 greek.at\ 76 greek.at\
76 idx.at\ 77 idx.at\
78 info.at\
77 markup.at\ 79 markup.at\
78 nopr.at\ 80 nopr.at\
79 prefix.at\ 81 prefix.at\
diff --git a/modules/gcide/tests/def00.at b/modules/gcide/tests/def00.at
index bd8a153..bbf134e 100644
--- a/modules/gcide/tests/def00.at
+++ b/modules/gcide/tests/def00.at
@@ -21,7 +21,7 @@ quit
21], 21],
22[220 22[220
23150 1 definitions found: list follows 23150 1 definitions found: list follows
24151 "GNU" gcide "A mock GCIDE dictionary" 24151 "GNU" gcide "A mock GCIDE dictionary for GNU Dico test suite"
25GNU n. GNU's Not UNIX. 25GNU n. GNU's Not UNIX.
26 26
27[[Dico testsuite]] 27[[Dico testsuite]]
diff --git a/modules/gcide/tests/def01.at b/modules/gcide/tests/def01.at
index 0f2ed99..f12d5bb 100644
--- a/modules/gcide/tests/def01.at
+++ b/modules/gcide/tests/def01.at
@@ -21,14 +21,14 @@ quit
21], 21],
22[220 22[220
23150 2 definitions found: list follows 23150 2 definitions found: list follows
24151 "kludge" gcide "A mock GCIDE dictionary" 24151 "kludge" gcide "A mock GCIDE dictionary for GNU Dico test suite"
25kludge n. A working solution, not particularly elegant. 25kludge n. A working solution, not particularly elegant.
26 26
27[[Dico testsuite]] 27[[Dico testsuite]]
28 28
29 29
30. 30.
31151 "kludge" gcide "A mock GCIDE dictionary" 31151 "kludge" gcide "A mock GCIDE dictionary for GNU Dico test suite"
32kludge v. To use such a solution. 32kludge v. To use such a solution.
33 33
34[[Dico testsuite]] 34[[Dico testsuite]]
diff --git a/modules/gcide/tests/def02.at b/modules/gcide/tests/def02.at
index eeb2722..18631ff 100644
--- a/modules/gcide/tests/def02.at
+++ b/modules/gcide/tests/def02.at
@@ -21,7 +21,7 @@ quit
21], 21],
22[220 22[220
23150 1 definitions found: list follows 23150 1 definitions found: list follows
24151 "atlantes" gcide "A mock GCIDE dictionary" 24151 "atlantes" gcide "A mock GCIDE dictionary for GNU Dico test suite"
25‖Atlantes, n. pl. A definition with alternate name telamones. 25‖Atlantes, n. pl. A definition with alternate name telamones.
26 26
27[[Dico testsuite]] 27[[Dico testsuite]]
diff --git a/modules/gcide/tests/def03.at b/modules/gcide/tests/def03.at
index 6393734..f20f01a 100644
--- a/modules/gcide/tests/def03.at
+++ b/modules/gcide/tests/def03.at
@@ -21,7 +21,7 @@ quit
21], 21],
22[220 22[220
23150 1 definitions found: list follows 23150 1 definitions found: list follows
24151 "telamones" gcide "A mock GCIDE dictionary" 24151 "telamones" gcide "A mock GCIDE dictionary for GNU Dico test suite"
25||Atlantes, n. pl. A definition with alternate name telamones. 25||Atlantes, n. pl. A definition with alternate name telamones.
26 26
27[[Dico testsuite]] 27[[Dico testsuite]]
diff --git a/modules/gcide/tests/def04.at b/modules/gcide/tests/def04.at
index 73b49a3..1b23b32 100644
--- a/modules/gcide/tests/def04.at
+++ b/modules/gcide/tests/def04.at
@@ -21,7 +21,7 @@ quit
21], 21],
22[220 22[220
23150 1 definitions found: list follows 23150 1 definitions found: list follows
24151 "cyclic" gcide "A mock GCIDE dictionary" 24151 "cyclic" gcide "A mock GCIDE dictionary for GNU Dico test suite"
25{ Cyclic, Cyclical} a. 25{ Cyclic, Cyclical} a.
26[[Gr. κυκλικός, fr. κύκλος See {Cycle}.]] 26[[Gr. κυκλικός, fr. κύκλος See {Cycle}.]]
27Going in cycles 27Going in cycles
diff --git a/modules/gcide/tests/def05.at b/modules/gcide/tests/def05.at
index 16f17e0..bd8db48 100644
--- a/modules/gcide/tests/def05.at
+++ b/modules/gcide/tests/def05.at
@@ -21,7 +21,7 @@ quit
21], 21],
22[220 22[220
23150 1 definitions found: list follows 23150 1 definitions found: list follows
24151 "cyclical" gcide "A mock GCIDE dictionary" 24151 "cyclical" gcide "A mock GCIDE dictionary for GNU Dico test suite"
25{ Cyclic, Cyclical} a. 25{ Cyclic, Cyclical} a.
26[[Gr. κυκλικός, fr. κύκλος See {Cycle}.]] 26[[Gr. κυκλικός, fr. κύκλος See {Cycle}.]]
27Going in cycles 27Going in cycles
diff --git a/modules/gcide/tests/descr.at b/modules/gcide/tests/descr.at
new file mode 100644
index 0000000..9d3d153
--- a/dev/null
+++ b/modules/gcide/tests/descr.at
@@ -0,0 +1,31 @@
1# This file is part of GNU Dico -*- Autotest -*-
2# Copyright (C) 2012 Sergey Poznyakoff
3#
4# GNU Dico is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 3, or (at your option)
7# any later version.
8#
9# GNU Dico is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with GNU Dico. If not, see <http://www.gnu.org/licenses/>.
16
17AT_SETUP([descr])
18AT_KEYWORDS([descr])
19
20AT_DICOD([show db
21quit
22],
23[220
24110 1 databases present
25gcide "A mock GCIDE dictionary for GNU Dico test suite"
26.
27250
28221
29])
30AT_CLEANUP
31
diff --git a/modules/gcide/tests/dicod.cfin b/modules/gcide/tests/dicod.cfin
index 056f82a..8e5edf5 100644
--- a/modules/gcide/tests/dicod.cfin
+++ b/modules/gcide/tests/dicod.cfin
@@ -5,7 +5,6 @@ load-module gcide;
5load-module stratall; 5load-module stratall;
6database { 6database {
7 name "gcide"; 7 name "gcide";
8 description "A mock GCIDE dictionary";
9 handler "gcide dbdir=~dictdir~ idxdir=~idxdir~ index-program=~moddir~/gcide/idxgcide"; 8 handler "gcide dbdir=~dictdir~ idxdir=~idxdir~ index-program=~moddir~/gcide/idxgcide";
10} 9}
11 10
diff --git a/modules/gcide/tests/dict/INFO b/modules/gcide/tests/dict/INFO
new file mode 100644
index 0000000..a392421
--- a/dev/null
+++ b/modules/gcide/tests/dict/INFO
@@ -0,0 +1,14 @@
1A mock GCIDE dictionary for GNU Dico test suite.
2
3GNU Dico is free software; you can redistribute it and/or modify
4it under the terms of the GNU General Public License as published by
5the Free Software Foundation; either version 3, or (at your option)
6any later version.
7
8GNU Dico is distributed in the hope that it will be useful,
9but WITHOUT ANY WARRANTY; without even the implied warranty of
10MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11GNU General Public License for more details.
12
13You should have received a copy of the GNU General Public License
14along with GNU Dico. If not, see <http://www.gnu.org/licenses/>.
diff --git a/modules/gcide/tests/info.at b/modules/gcide/tests/info.at
new file mode 100644
index 0000000..b237c8c
--- a/dev/null
+++ b/modules/gcide/tests/info.at
@@ -0,0 +1,45 @@
1# This file is part of GNU Dico -*- Autotest -*-
2# Copyright (C) 2012 Sergey Poznyakoff
3#
4# GNU Dico is free software; you can redistribute it and/or modify
5# it under the terms of the GNU General Public License as published by
6# the Free Software Foundation; either version 3, or (at your option)
7# any later version.
8#
9# GNU Dico is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with GNU Dico. If not, see <http://www.gnu.org/licenses/>.
16
17AT_SETUP([info])
18AT_KEYWORDS([info])
19
20AT_DICOD([show info gcide
21quit
22],
23[220
24112 information for gcide
25A mock GCIDE dictionary for GNU Dico test suite.
26
27GNU Dico is free software; you can redistribute it and/or modify
28it under the terms of the GNU General Public License as published by
29the Free Software Foundation; either version 3, or (at your option)
30any later version.
31
32GNU Dico is distributed in the hope that it will be useful,
33but WITHOUT ANY WARRANTY; without even the implied warranty of
34MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35GNU General Public License for more details.
36
37You should have received a copy of the GNU General Public License
38along with GNU Dico. If not, see <http://www.gnu.org/licenses/>.
39
40.
41250
42221
43])
44AT_CLEANUP
45
diff --git a/modules/gcide/tests/testsuite.at b/modules/gcide/tests/testsuite.at
index 681ae90..0d034f9 100644
--- a/modules/gcide/tests/testsuite.at
+++ b/modules/gcide/tests/testsuite.at
@@ -34,6 +34,10 @@ m4_include(greek.at)
34m4_include(idx.at) 34m4_include(idx.at)
35m4_include(autoidx.at) 35m4_include(autoidx.at)
36 36
37AT_BANNER([Dictionary info])
38m4_include(descr.at)
39m4_include(info.at)
40
37AT_BANNER(Match) 41AT_BANNER(Match)
38m4_include(exact.at) 42m4_include(exact.at)
39m4_include(prefix.at) 43m4_include(prefix.at)
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index 3db7a7c..e09a234 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -18,4 +18,5 @@ if TK_WISH_COND
18 GCIDER=gcider 18 GCIDER=gcider
19endif 19endif
20bin_SCRIPTS = $(GCIDER) 20bin_SCRIPTS = $(GCIDER)
21EXTRA_DIST = gcider \ No newline at end of file 21EXTRA_DIST = gcider
22AM_INSTALLCHECK_STD_OPTIONS_EXEMPT = gcider

Return to:

Send suggestions and report system problems to the System administrator.