[Groonga-commit] pgroonga/pgroonga at 8da5020 [master] Fix a bug that pgroonga.match_positions_byte() may return wrong location

Back to archive index

Kouhei Sutou null+****@clear*****
Sat May 21 22:53:56 JST 2016


Kouhei Sutou	2016-05-21 22:53:56 +0900 (Sat, 21 May 2016)

  New Revision: 8da50202c0d61b600cdf8679456786db60856c29
  https://github.com/pgroonga/pgroonga/commit/8da50202c0d61b600cdf8679456786db60856c29

  Message:
    Fix a bug that pgroonga.match_positions_byte() may return wrong location
    
    It's caused when 17 or more keywords are included in text.

  Modified files:
    src/pgrn_match_positions_byte.c

  Modified: src/pgrn_match_positions_byte.c (+3 -1)
===================================================================
--- src/pgrn_match_positions_byte.c    2016-04-24 23:14:57 +0900 (446619e)
+++ src/pgrn_match_positions_byte.c    2016-05-21 22:53:56 +0900 (b8756a0)
@@ -47,6 +47,7 @@ PGrnMatchPositionsByte(text *target)
 	{
 		const char *string;
 		size_t stringLength;
+		int baseOffset = 0;
 
 		string = VARDATA_ANY(target);
 		stringLength = VARSIZE_ANY_EXHDR(target);
@@ -62,11 +63,12 @@ PGrnMatchPositionsByte(text *target)
 								 string, stringLength,
 								 hits, MAX_N_HITS, &rest);
 			for (i = 0; i < nHits; i++) {
-				GRN_UINT32_PUT(ctx, &buffer, hits[i].offset);
+				GRN_UINT32_PUT(ctx, &buffer, hits[i].offset + baseOffset);
 				GRN_UINT32_PUT(ctx, &buffer, hits[i].length);
 			}
 
 			chunkLength = rest - string;
+			baseOffset += chunkLength;
 			stringLength -= chunkLength;
 			string = rest;
 #undef MAX_N_HITS
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index