diff options
-rw-r--r-- | NEWS | 4 | ||||
-rw-r--r-- | doc/dico.texi | 26 | ||||
-rw-r--r-- | include/dico/util.h | 1 | ||||
-rw-r--r-- | modules/gcide/gcide.c | 91 | ||||
-rw-r--r-- | modules/gcide/tests/Makefile.am | 4 | ||||
-rw-r--r-- | modules/gcide/tests/def00.at | 2 | ||||
-rw-r--r-- | modules/gcide/tests/def01.at | 4 | ||||
-rw-r--r-- | modules/gcide/tests/def02.at | 2 | ||||
-rw-r--r-- | modules/gcide/tests/def03.at | 2 | ||||
-rw-r--r-- | modules/gcide/tests/def04.at | 2 | ||||
-rw-r--r-- | modules/gcide/tests/def05.at | 2 | ||||
-rw-r--r-- | modules/gcide/tests/descr.at | 31 | ||||
-rw-r--r-- | modules/gcide/tests/dicod.cfin | 1 | ||||
-rw-r--r-- | modules/gcide/tests/dict/INFO | 14 | ||||
-rw-r--r-- | modules/gcide/tests/info.at | 45 | ||||
-rw-r--r-- | modules/gcide/tests/testsuite.at | 4 | ||||
-rw-r--r-- | scripts/Makefile.am | 3 |
17 files changed, 207 insertions, 31 deletions
@@ -1,2 +1,2 @@ | |||
1 | GNU Dico NEWS -- history of user-visible changes. 2012-03-03 | 1 | GNU Dico NEWS -- history of user-visible changes. 2012-03-04 |
2 | Copyright (C) 2008-2010, 2012 Sergey Poznyakoff | 2 | Copyright (C) 2008-2010, 2012 Sergey Poznyakoff |
@@ -7,3 +7,3 @@ Please send Dico bug reports to <bug-dico@gnu.org.ua> | |||
7 | 7 | ||
8 | Version 2.2 (Git) | 8 | Version 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 |
2993 | Specifies alternate directory for the @file{CIDE.IDX} index file. | 2993 | Specifies the directory where the @file{CIDE.IDX} index file resides |
2994 | or 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}, | ||
3019 | which 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 | ||
3022 | trailing newline and final point removed) is returned as the short | ||
3023 | database 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 | ||
3033 | The 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{} | ||
3041 | EOT; | ||
3042 | @} | 3037 | @} |
@@ -3045,5 +3040,2 @@ EOT; | |||
3045 | 3040 | ||
3046 | The dots represent further content of the description which is too | ||
3047 | big 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 @@ | |||
20 | char *dico_full_file_name(const char *dir, const char *file); | 20 | char *dico_full_file_name(const char *dir, const char *file); |
21 | size_t dico_string_trim(char *buf, size_t len, int (*pred)(int c)); | ||
21 | size_t dico_trim_nl(char *buf); | 22 | size_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 | |||
300 | static int | ||
301 | _is_nl_or_punct(int c) | ||
302 | { | ||
303 | return !!strchr("\r\n!,-./:;?", c); | ||
304 | } | ||
305 | |||
306 | static char * | ||
307 | read_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 | |||
367 | static char * | ||
368 | read_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 | |||
376 | char * | ||
377 | gcide_info(dico_handle_t hp) | ||
378 | { | ||
379 | return read_dictionary_info((struct gcide_db *) hp, 0); | ||
380 | } | ||
299 | 381 | ||
382 | char * | ||
383 | gcide_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 | |||
29 | dist-hook: | 29 | dist-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 | |||
23 | 150 1 definitions found: list follows | 23 | 150 1 definitions found: list follows |
24 | 151 "GNU" gcide "A mock GCIDE dictionary" | 24 | 151 "GNU" gcide "A mock GCIDE dictionary for GNU Dico test suite" |
25 | GNU n. GNU's Not UNIX. | 25 | GNU 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 | |||
23 | 150 2 definitions found: list follows | 23 | 150 2 definitions found: list follows |
24 | 151 "kludge" gcide "A mock GCIDE dictionary" | 24 | 151 "kludge" gcide "A mock GCIDE dictionary for GNU Dico test suite" |
25 | kludge n. A working solution, not particularly elegant. | 25 | kludge n. A working solution, not particularly elegant. |
@@ -30,3 +30,3 @@ kludge n. A working solution, not particularly elegant. | |||
30 | . | 30 | . |
31 | 151 "kludge" gcide "A mock GCIDE dictionary" | 31 | 151 "kludge" gcide "A mock GCIDE dictionary for GNU Dico test suite" |
32 | kludge v. To use such a solution. | 32 | kludge 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 | |||
23 | 150 1 definitions found: list follows | 23 | 150 1 definitions found: list follows |
24 | 151 "atlantes" gcide "A mock GCIDE dictionary" | 24 | 151 "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 | |||
23 | 150 1 definitions found: list follows | 23 | 150 1 definitions found: list follows |
24 | 151 "telamones" gcide "A mock GCIDE dictionary" | 24 | 151 "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 | |||
23 | 150 1 definitions found: list follows | 23 | 150 1 definitions found: list follows |
24 | 151 "cyclic" gcide "A mock GCIDE dictionary" | 24 | 151 "cyclic" gcide "A mock GCIDE dictionary for GNU Dico test suite" |
25 | { Cyclic, Cyclical} a. | 25 | { Cyclic, Cyclical} a. |