aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2018-09-11 12:13:58 +0300
committerSergey Poznyakoff <gray@gnu.org>2018-09-11 12:13:58 +0300
commit84e5fa19906456fce03066639b34230ade3cf91d (patch)
treee6036cd62f5b6fcf005f8d4422a0d7574e5aa978
parent7df9535cc5c758a46994311887bcfb3b5071526b (diff)
downloaddico-84e5fa19906456fce03066639b34230ade3cf91d.tar.gz
dico-84e5fa19906456fce03066639b34230ade3cf91d.tar.bz2
Support for old dictord special index keywords (prefixed with "00database")
* NEWS: Version 2.6.92 * configure.boot: Version 2.6.92 * modules/dict.org/dictorg.c (parse_index_entry): Translate old special entries (00database prefix) into new ones (00-database- prefix). * modules/dict.org/dictorg.h (DICTORG_ALT_ENTRY_PREFIX) (DICTORG_ALT_ENTRY_PREFIX_LEN): New define.
-rw-r--r--NEWS2
-rw-r--r--configure.boot2
-rw-r--r--modules/dict.org/dictorg.c44
-rw-r--r--modules/dict.org/dictorg.h7
4 files changed, 50 insertions, 5 deletions
diff --git a/NEWS b/NEWS
index 2afe6c3..c04f148 100644
--- a/NEWS
+++ b/NEWS
@@ -4,7 +4,7 @@ See the end of file for copying conditions.
Please send Dico bug reports to <bug-dico@gnu.org.ua>
-Version 2.6.91 (git)
+Version 2.6.92 (git)
* Support for virtual databases
diff --git a/configure.boot b/configure.boot
index efd089c..f59b6a8 100644
--- a/configure.boot
+++ b/configure.boot
@@ -28,7 +28,7 @@ dnl Process this file with -*- autoconf -*- to produce a configure script.
# along with GNU Dico. If not, see <http://www.gnu.org/licenses/>.
AC_PREREQ(2.63)
-AC_INIT([GNU dico], 2.6.91, [bug-dico@gnu.org])
+AC_INIT([GNU dico], 2.6.92, [bug-dico@gnu.org])
AC_CONFIG_SRCDIR([dicod/main.c])
AM_CONFIG_HEADER(config.h)
AC_CONFIG_AUX_DIR([build-aux])
diff --git a/modules/dict.org/dictorg.c b/modules/dict.org/dictorg.c
index 6a6e282..1febeb2 100644
--- a/modules/dict.org/dictorg.c
+++ b/modules/dict.org/dictorg.c
@@ -128,6 +128,35 @@ b64_decode(const char *val, size_t len, size_t *presult)
return 0;
}
+struct special_headword_trans {
+ char *old;
+ size_t len;
+ char *new;
+};
+
+#define S(s) #s, sizeof(#s)-1
+static struct special_headword_trans special_headword_trans[] = {
+ { S(00databaseallchars), DICTORG_FLAG_ALLCHARS },
+ { S(00databasedefaultstrategy), DICTORG_FLAG_DEFAULT_STRAT },
+ { S(00databaseurl), "00-database-url" },
+ { S(00databaseshort), DICTORG_SHORT_ENTRY_NAME },
+ { S(00databaseinfo), DICTORG_INFO_ENTRY_NAME },
+ { S(00databaseutf8), DICTORG_FLAG_UTF8 },
+ { NULL }
+};
+#undef S
+
+static char const *
+special_translate(char const *in, size_t len)
+{
+ struct special_headword_trans *tp = special_headword_trans;
+ while (tp->old) {
+ if (len == tp->len && memcmp(tp->old, in, tp->len) == 0)
+ return tp->new;
+ tp++;
+ }
+ return NULL;
+}
static int
parse_index_entry(const char *filename, size_t line,
@@ -155,7 +184,8 @@ parse_index_entry(const char *filename, size_t line,
is used.
*/
for (nfield = 0; nfield < 4; nfield++) {
- char *start, *end;
+ char const *start;
+ char const *end;
size_t len;
/* Skip whitespace */
@@ -181,11 +211,23 @@ parse_index_entry(const char *filename, size_t line,
while (len > 0 && start[len-1] == ' ')
--len;
}
+
+ if (len > DICTORG_ALT_ENTRY_PREFIX_LEN
+ && memcmp(start, DICTORG_ALT_ENTRY_PREFIX,
+ DICTORG_ALT_ENTRY_PREFIX_LEN) == 0) {
+ char const *p = special_translate(start, len);
+ if (p) {
+ start = p;
+ len = strlen(p);
+ }
+ }
+
idx.word = malloc(len + 1);
if (!idx.word) {
memerr("parse_index_entry");
return 1;
}
+
memcpy(idx.word, start, len);
idx.word[len] = 0;
idx.length = len;
diff --git a/modules/dict.org/dictorg.h b/modules/dict.org/dictorg.h
index 38604e1..25dd559 100644
--- a/modules/dict.org/dictorg.h
+++ b/modules/dict.org/dictorg.h
@@ -50,6 +50,9 @@
#define DICTORG_ENTRY_MIME_HEADER DICTORG_ENTRY_PREFIX"-mime-header"
+#define DICTORG_ALT_ENTRY_PREFIX "00database"
+#define DICTORG_ALT_ENTRY_PREFIX_LEN sizeof(DICTORG_ALT_ENTRY_PREFIX)-1
+
#define DICTORG_UNKNOWN 0
#define DICTORG_TEXT 1
#define DICTORG_GZIP 2
@@ -112,8 +115,8 @@
struct index_entry {
char *word; /* Word */
char *orig; /* Original headword (for four-column indices) */
- size_t length; /* Its length in bytes */
- size_t wordlen; /* Its length in characters */
+ size_t length; /* Word length in bytes */
+ size_t wordlen; /* Word length in characters */
off_t offset; /* Offset of the corresponding article in file */
size_t size; /* Size of the article */
};

Return to:

Send suggestions and report system problems to the System administrator.