MCPcopy Create free account
hub / github.com/buggins/coolreader / read

Method read

tinydict/tinydict.cpp:328–355  ·  view source on GitHub ↗

factory - reading from index file

Source from the content-addressed store, hash-verified

326
327/// factory - reading from index file
328TinyDictWord * TinyDictWord::read( FILE * f, unsigned index )
329{
330 if ( !f || feof(f) )
331 return NULL;
332 char buf[1024];
333 unsigned indexpos = ftell( f );
334 int sz = my_fgets( buf, 1023, f );
335 if ( !sz )
336 return NULL;
337 int tabc = 0;
338 int tabs[2];
339 for ( int i=0; buf[i]; i++ ) {
340 if ( buf[i] == '\t' && tabc<2 )
341 tabs[tabc++] = i;
342 }
343 if ( tabc!=2 )
344 return NULL;
345 const char * word = buf;
346 const char * pos_str = buf + tabs[0] + 1;
347 const char * len_str = buf + tabs[1] + 1;
348 buf[tabs[0]] = 0;
349 buf[tabs[1]] = 0;
350 unsigned start = parseBase64( pos_str );
351 unsigned len = parseBase64( len_str );
352 if ( start==(unsigned)-1 || len==(unsigned)-1 )
353 return NULL;
354 return new TinyDictWord( index, indexpos, start, len, word );
355}
356
357int TinyDictWordList::find( const char * prefix )
358{

Callers 2

getArticleMethod · 0.45
mainFunction · 0.45

Calls 4

my_fgetsFunction · 0.85
parseBase64Function · 0.85
getStartMethod · 0.45
getSizeMethod · 0.45

Tested by

no test coverage detected