aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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,2 +1,2 @@
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
@@ -7,3 +7,3 @@ Please send Dico bug reports to <bug-dico@gnu.org.ua>
7 7
8Version 2.2 (Git) 8Version 2.2, 2012-03-04
9 9
diff --git a/doc/dico.texi b/doc/dico.texi
index 59639a2..8c55707 100644
--- a/doc/dico.texi
+++ b/doc/dico.texi
@@ -2992,3 +2992,4 @@ Other options are:
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
@@ -3016,2 +3017,8 @@ displaying them at all.
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
@@ -3026,17 +3033,5 @@ database @{
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@}
@@ -3045,5 +3040,2 @@ EOT;
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
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
@@ -20,2 +20,3 @@
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);
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
@@ -298,3 +298,90 @@ gcide_free_db(dico_handle_t hp)
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
@@ -750,4 +837,4 @@ struct dico_database_module DICO_EXPORT(gcide, module) = {
750 NULL, 837 NULL,
751 NULL, 838 gcide_info,
752 NULL, 839 gcide_descr,
753 NULL, 840 NULL,
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
@@ -29,3 +29,3 @@ CLEANFILES = dicod.conf
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 -
@@ -73,2 +73,3 @@ TESTSUITE_AT = \
73 def05.at\ 73 def05.at\
74 descr.at\
74 exact.at\ 75 exact.at\
@@ -76,2 +77,3 @@ TESTSUITE_AT = \
76 idx.at\ 77 idx.at\
78 info.at\
77 markup.at\ 79 markup.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
@@ -23,3 +23,3 @@ quit
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.
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
@@ -23,3 +23,3 @@ quit
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.
@@ -30,3 +30,3 @@ kludge n. A working solution, not particularly elegant.
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.
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
@@ -23,3 +23,3 @@ quit
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.
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
@@ -23,3 +23,3 @@ quit
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.
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
@@ -23,3 +23,3 @@ quit
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.
diff --git a/modules/gcide/tests/def05.at b/modules/gcide/tests/def05.at
index 16f17e0..bd8db48 100644
--- a/