add null-terminated note to dawg header and modify linux client to

accept it if present.  Android client will successfully ignore it and
will need to be modified to capture and display it if present.  Idea's
to display information about copyright, source, etc. of wordlists.
This commit is contained in:
Eric House 2012-08-25 10:20:52 -07:00
parent c6ce5da5a5
commit b29df8512a
4 changed files with 22 additions and 6 deletions

View file

@ -18,6 +18,7 @@
XWLANG=BasEnglish
LANGCODE=en_US
DICT2DAWGARGS = -r -nosort
DICTNOTE = "Built on $(shell date)"
TARGET_TYPE ?= WINCE

View file

@ -276,10 +276,17 @@ $(XWLANG)_charcount.bin: table.bin ../xloc.pl
cat $$TMP >> $@; \
rm -f $$TMP
$(XWLANG)%_newheader.bin: $(XWLANG)%_wordcount.bin
SIZ=$$(ls -l $< | awk '{print $$5}'); \
$(XWLANG)%_note.bin:
echo -n $(DICTNOTE) > $@
perl -e "print pack(\"c\",0)" >> $@
$(XWLANG)%_newheader.bin: $(XWLANG)%_wordcount.bin $(XWLANG)%_note.bin
SIZ=0; \
for FILE in $+; do \
SIZ=$$(($$SIZ + $$(ls -l $$FILE | awk '{print $$5}'))); \
done; \
perl -e "print pack(\"n\",$$SIZ)" > $@
cat $< >> $@
cat $+ >> $@
%.dict: %.dict.gz
zcat $< > $@

View file

@ -290,13 +290,21 @@ initFromDictFile( LinuxDictionaryCtxt* dctx, const char* fileName )
memcpy( &headerLen, ptr, sizeof(headerLen) );
ptr += sizeof(headerLen);
headerLen = ntohs( headerLen );
if ( headerLen != sizeof(wordCount) ) { /* the only case we know right now */
goto closeAndExit;
}
memcpy( &wordCount, ptr, sizeof(wordCount) );
ptr += sizeof(wordCount);
headerLen -= sizeof(wordCount);
dctx->super.nWords = ntohl( wordCount );
XP_DEBUGF( "dict contains %ld words", dctx->super.nWords );
if ( 0 < headerLen ) {
XP_UCHAR buf[headerLen];
XP_MEMCPY( buf, ptr, headerLen );
XP_LOGF( "%s: got note of len %d: \"%s\"", __func__, headerLen-1, buf );
} else {
XP_LOGF( "%s: no note", __func__ );
}
ptr += headerLen;
}
if ( isUTF8 ) {