ferret 0.9.1 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. data/README +6 -5
  2. data/Rakefile +34 -13
  3. data/TODO +1 -0
  4. data/TUTORIAL +1 -1
  5. data/ext/analysis.c +87 -70
  6. data/ext/analysis.h +18 -6
  7. data/ext/array.c +1 -2
  8. data/ext/array.h +1 -1
  9. data/ext/bitvector.c +10 -6
  10. data/ext/bitvector.h +2 -2
  11. data/ext/compound_io.c +30 -27
  12. data/ext/document.c +15 -15
  13. data/ext/document.h +5 -5
  14. data/ext/except.c +2 -0
  15. data/ext/except.h +25 -23
  16. data/ext/extconf.rb +1 -0
  17. data/ext/ferret.c +10 -8
  18. data/ext/ferret.h +9 -8
  19. data/ext/field.c +29 -25
  20. data/ext/filter.c +52 -14
  21. data/ext/frtio.h +13 -0
  22. data/ext/fs_store.c +115 -170
  23. data/ext/global.c +9 -8
  24. data/ext/global.h +17 -13
  25. data/ext/hash.c +13 -19
  26. data/ext/hash.h +11 -11
  27. data/ext/hashset.c +5 -7
  28. data/ext/hashset.h +9 -8
  29. data/ext/helper.c +1 -1
  30. data/ext/helper.h +2 -1
  31. data/ext/inc/except.h +25 -23
  32. data/ext/inc/lang.h +11 -1
  33. data/ext/ind.c +33 -21
  34. data/ext/index.h +44 -39
  35. data/ext/index_io.c +61 -57
  36. data/ext/index_rw.c +418 -361
  37. data/ext/lang.c +10 -0
  38. data/ext/lang.h +11 -1
  39. data/ext/nix_io.c +135 -0
  40. data/ext/priorityqueue.c +16 -16
  41. data/ext/priorityqueue.h +9 -6
  42. data/ext/q_boolean.c +128 -76
  43. data/ext/q_const_score.c +20 -20
  44. data/ext/q_filtered_query.c +20 -20
  45. data/ext/q_fuzzy.c +37 -23
  46. data/ext/q_match_all.c +15 -19
  47. data/ext/q_multi_phrase.c +87 -46
  48. data/ext/q_parser.c +247 -119
  49. data/ext/q_phrase.c +86 -52
  50. data/ext/q_prefix.c +25 -14
  51. data/ext/q_range.c +59 -14
  52. data/ext/q_span.c +263 -172
  53. data/ext/q_term.c +62 -51
  54. data/ext/q_wildcard.c +24 -13
  55. data/ext/r_analysis.c +328 -80
  56. data/ext/r_doc.c +11 -6
  57. data/ext/r_index_io.c +40 -32
  58. data/ext/r_qparser.c +15 -14
  59. data/ext/r_search.c +270 -152
  60. data/ext/r_store.c +32 -17
  61. data/ext/ram_store.c +38 -22
  62. data/ext/search.c +617 -87
  63. data/ext/search.h +227 -163
  64. data/ext/similarity.c +54 -45
  65. data/ext/similarity.h +3 -3
  66. data/ext/sort.c +132 -53
  67. data/ext/store.c +21 -2
  68. data/ext/store.h +14 -14
  69. data/ext/tags +4322 -232
  70. data/ext/term.c +140 -109
  71. data/ext/termdocs.c +74 -60
  72. data/ext/vector.c +181 -152
  73. data/ext/w32_io.c +150 -0
  74. data/lib/ferret.rb +1 -1
  75. data/lib/ferret/analysis/standard_tokenizer.rb +4 -3
  76. data/lib/ferret/document/field.rb +1 -1
  77. data/lib/ferret/index/field_infos.rb +1 -1
  78. data/lib/ferret/index/term.rb +1 -1
  79. data/lib/ferret/query_parser/query_parser.tab.rb +8 -24
  80. data/lib/ferret/search.rb +1 -0
  81. data/lib/ferret/search/boolean_query.rb +0 -4
  82. data/lib/ferret/search/index_searcher.rb +21 -8
  83. data/lib/ferret/search/multi_phrase_query.rb +7 -0
  84. data/lib/ferret/search/multi_searcher.rb +261 -0
  85. data/lib/ferret/search/phrase_query.rb +1 -1
  86. data/lib/ferret/search/query.rb +34 -5
  87. data/lib/ferret/search/sort.rb +7 -3
  88. data/lib/ferret/search/sort_field.rb +8 -4
  89. data/lib/ferret/store/fs_store.rb +13 -6
  90. data/lib/ferret/store/index_io.rb +0 -14
  91. data/lib/ferret/store/ram_store.rb +3 -2
  92. data/lib/rferret.rb +1 -1
  93. data/test/unit/analysis/ctc_analyzer.rb +131 -0
  94. data/test/unit/analysis/ctc_tokenstream.rb +98 -9
  95. data/test/unit/index/tc_index.rb +40 -1
  96. data/test/unit/index/tc_term.rb +7 -0
  97. data/test/unit/index/th_doc.rb +8 -0
  98. data/test/unit/query_parser/tc_query_parser.rb +6 -4
  99. data/test/unit/search/rtc_sort_field.rb +6 -6
  100. data/test/unit/search/tc_index_searcher.rb +8 -0
  101. data/test/unit/search/tc_multi_searcher.rb +275 -0
  102. data/test/unit/search/tc_multi_searcher2.rb +126 -0
  103. data/test/unit/search/tc_search_and_sort.rb +66 -0
  104. metadata +31 -26
  105. data/test/unit/query_parser/rtc_query_parser.rb +0 -138
data/ext/q_parser.c CHANGED
@@ -1,7 +1,7 @@
1
- /* A Bison parser, made by GNU Bison 2.0. */
1
+ /* A Bison parser, made by GNU Bison 2.1. */
2
2
 
3
3
  /* Skeleton parser for Yacc-like parsing with Bison,
4
- Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
4
+ Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
5
5
 
6
6
  This program is free software; you can redistribute it and/or modify
7
7
  it under the terms of the GNU General Public License as published by
@@ -15,8 +15,8 @@
15
15
 
16
16
  You should have received a copy of the GNU General Public License
17
17
  along with this program; if not, write to the Free Software
18
- Foundation, Inc., 59 Temple Place - Suite 330,
19
- Boston, MA 02111-1307, USA. */
18
+ Foundation, Inc., 51 Franklin Street, Fifth Floor,
19
+ Boston, MA 02110-1301, USA. */
20
20
 
21
21
  /* As a special exception, when this file is copied by Bison into a
22
22
  Bison output file, you may use that output file without restriction.
@@ -36,6 +36,9 @@
36
36
  /* Identify Bison output. */
37
37
  #define YYBISON 1
38
38
 
39
+ /* Bison version. */
40
+ #define YYBISON_VERSION "2.1"
41
+
39
42
  /* Skeleton name. */
40
43
  #define YYSKELETON_NAME "yacc.c"
41
44
 
@@ -63,6 +66,7 @@
63
66
  HIGH = 265
64
67
  };
65
68
  #endif
69
+ /* Tokens. */
66
70
  #define WORD 258
67
71
  #define WILD_STR 259
68
72
  #define LOW 260
@@ -104,6 +108,11 @@ typedef struct Phrase {
104
108
  # define YYERROR_VERBOSE 0
105
109
  #endif
106
110
 
111
+ /* Enabling the token table. */
112
+ #ifndef YYTOKEN_TABLE
113
+ # define YYTOKEN_TABLE 0
114
+ #endif
115
+
107
116
  #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
108
117
  #line 14 "src/query_parser/q_parser.y"
109
118
  typedef union YYSTYPE {
@@ -114,8 +123,8 @@ typedef union YYSTYPE {
114
123
  Phrase *phrase;
115
124
  char *str;
116
125
  } YYSTYPE;
117
- /* Line 190 of yacc.c. */
118
- #line 119 "y.tab.c"
126
+ /* Line 196 of yacc.c. */
127
+ #line 128 "y.tab.c"
119
128
  # define yystype YYSTYPE /* obsolescent; will be withdrawn */
120
129
  # define YYSTYPE_IS_DECLARED 1
121
130
  # define YYSTYPE_IS_TRIVIAL 1
@@ -174,17 +183,36 @@ Query *get_range_q(char *field, char *from, char *to,
174
183
  } while (0)
175
184
 
176
185
 
177
- /* Line 213 of yacc.c. */
178
- #line 179 "y.tab.c"
186
+ /* Line 219 of yacc.c. */
187
+ #line 188 "y.tab.c"
179
188
 
180
- #if ! defined (yyoverflow) || YYERROR_VERBOSE
189
+ #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
190
+ # define YYSIZE_T __SIZE_TYPE__
191
+ #endif
192
+ #if ! defined (YYSIZE_T) && defined (size_t)
193
+ # define YYSIZE_T size_t
194
+ #endif
195
+ #if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
196
+ # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
197
+ # define YYSIZE_T size_t
198
+ #endif
199
+ #if ! defined (YYSIZE_T)
200
+ # define YYSIZE_T unsigned int
201
+ #endif
181
202
 
182
- # ifndef YYFREE
183
- # define YYFREE free
203
+ #ifndef YY_
204
+ # if YYENABLE_NLS
205
+ # if ENABLE_NLS
206
+ # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
207
+ # define YY_(msgid) dgettext ("bison-runtime", msgid)
208
+ # endif
184
209
  # endif
185
- # ifndef YYMALLOC
186
- # define YYMALLOC malloc
210
+ # ifndef YY_
211
+ # define YY_(msgid) msgid
187
212
  # endif
213
+ #endif
214
+
215
+ #if ! defined (yyoverflow) || YYERROR_VERBOSE
188
216
 
189
217
  /* The parser invokes alloca or malloc; define the necessary symbols. */
190
218
 
@@ -194,6 +222,10 @@ Query *get_range_q(char *field, char *from, char *to,
194
222
  # define YYSTACK_ALLOC __builtin_alloca
195
223
  # else
196
224
  # define YYSTACK_ALLOC alloca
225
+ # if defined (__STDC__) || defined (__cplusplus)
226
+ # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
227
+ # define YYINCLUDED_STDLIB_H
228
+ # endif
197
229
  # endif
198
230
  # endif
199
231
  # endif
@@ -201,13 +233,39 @@ Query *get_range_q(char *field, char *from, char *to,
201
233
  # ifdef YYSTACK_ALLOC
202
234
  /* Pacify GCC's `empty if-body' warning. */
203
235
  # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
204
- # else
205
- # if defined (__STDC__) || defined (__cplusplus)
206
- # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
207
- # define YYSIZE_T size_t
236
+ # ifndef YYSTACK_ALLOC_MAXIMUM
237
+ /* The OS might guarantee only one guard page at the bottom of the stack,
238
+ and a page size can be as small as 4096 bytes. So we cannot safely
239
+ invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
240
+ to allow for a few compiler-allocated temporary stack slots. */
241
+ # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */
208
242
  # endif
243
+ # else
209
244
  # define YYSTACK_ALLOC YYMALLOC
210
245
  # define YYSTACK_FREE YYFREE
246
+ # ifndef YYSTACK_ALLOC_MAXIMUM
247
+ # define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1)
248
+ # endif
249
+ # ifdef __cplusplus
250
+ extern "C" {
251
+ # endif
252
+ # ifndef YYMALLOC
253
+ # define YYMALLOC malloc
254
+ # if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \
255
+ && (defined (__STDC__) || defined (__cplusplus)))
256
+ void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
257
+ # endif
258
+ # endif
259
+ # ifndef YYFREE
260
+ # define YYFREE free
261
+ # if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \
262
+ && (defined (__STDC__) || defined (__cplusplus)))
263
+ void free (void *); /* INFRINGES ON USER NAME SPACE */
264
+ # endif
265
+ # endif
266
+ # ifdef __cplusplus
267
+ }
268
+ # endif
211
269
  # endif
212
270
  #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
213
271
 
@@ -242,7 +300,7 @@ union yyalloc
242
300
  # define YYCOPY(To, From, Count) \
243
301
  do \
244
302
  { \
245
- register YYSIZE_T yyi; \
303
+ YYSIZE_T yyi; \
246
304
  for (yyi = 0; yyi < (Count); yyi++) \
247
305
  (To)[yyi] = (From)[yyi]; \
248
306
  } \
@@ -292,7 +350,7 @@ union yyalloc
292
350
  #define YYUNDEFTOK 2
293
351
  #define YYMAXUTOK 265
294
352
 
295
- #define YYTRANSLATE(YYX) \
353
+ #define YYTRANSLATE(YYX) \
296
354
  ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
297
355
 
298
356
  /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
@@ -374,8 +432,8 @@ static const unsigned char yyrline[] =
374
432
  };
375
433
  #endif
376
434
 
377
- #if YYDEBUG || YYERROR_VERBOSE
378
- /* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
435
+ #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
436
+ /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
379
437
  First, the terminals, then, starting at YYNTOKENS, nonterminals. */
380
438
  static const char *const yytname[] =
381
439
  {
@@ -511,22 +569,6 @@ static const unsigned char yystos[] =
511
569
  15, 20, 22, 23, 22, 23, 35, 37, 3
512
570
  };
513
571
 
514
- #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
515
- # define YYSIZE_T __SIZE_TYPE__
516
- #endif
517
- #if ! defined (YYSIZE_T) && defined (size_t)
518
- # define YYSIZE_T size_t
519
- #endif
520
- #if ! defined (YYSIZE_T)
521
- # if defined (__STDC__) || defined (__cplusplus)
522
- # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
523
- # define YYSIZE_T size_t
524
- # endif
525
- #endif
526
- #if ! defined (YYSIZE_T)
527
- # define YYSIZE_T unsigned int
528
- #endif
529
-
530
572
  #define yyerrok (yyerrstatus = 0)
531
573
  #define yyclearin (yychar = YYEMPTY)
532
574
  #define YYEMPTY (-2)
@@ -556,8 +598,8 @@ do \
556
598
  goto yybackup; \
557
599
  } \
558
600
  else \
559
- { \
560
- yyerror (qp, "syntax error: cannot back up");\
601
+ { \
602
+ yyerror (qp, YY_("syntax error: cannot back up")); \
561
603
  YYERROR; \
562
604
  } \
563
605
  while (0)
@@ -636,7 +678,7 @@ do { \
636
678
  if (yydebug) \
637
679
  { \
638
680
  YYFPRINTF (stderr, "%s ", Title); \
639
- yysymprint (stderr, \
681
+ yysymprint (stderr, \
640
682
  Type, Value); \
641
683
  YYFPRINTF (stderr, "\n"); \
642
684
  } \
@@ -684,13 +726,13 @@ yy_reduce_print (yyrule)
684
726
  #endif
685
727
  {
686
728
  int yyi;
687
- unsigned int yylno = yyrline[yyrule];
688
- YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
729
+ unsigned long int yylno = yyrline[yyrule];
730
+ YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ",
689
731
  yyrule - 1, yylno);
690
732
  /* Print the symbols being reduced, and their result. */
691
733
  for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
692
- YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
693
- YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]);
734
+ YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
735
+ YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]);
694
736
  }
695
737
 
696
738
  # define YY_REDUCE_PRINT(Rule) \
@@ -719,7 +761,7 @@ int yydebug;
719
761
  if the built-in stack extension method is used).
720
762
 
721
763
  Do not make this value too large; the results are undefined if
722
- SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
764
+ YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
723
765
  evaluated with infinite-precision integer arithmetic. */
724
766
 
725
767
  #ifndef YYMAXDEPTH
@@ -743,7 +785,7 @@ yystrlen (yystr)
743
785
  const char *yystr;
744
786
  # endif
745
787
  {
746
- register const char *yys = yystr;
788
+ const char *yys = yystr;
747
789
 
748
790
  while (*yys++ != '\0')
749
791
  continue;
@@ -768,8 +810,8 @@ yystpcpy (yydest, yysrc)
768
810
  const char *yysrc;
769
811
  # endif
770
812
  {
771
- register char *yyd = yydest;
772
- register const char *yys = yysrc;
813
+ char *yyd = yydest;
814
+ const char *yys = yysrc;
773
815
 
774
816
  while ((*yyd++ = *yys++) != '\0')
775
817
  continue;
@@ -779,7 +821,55 @@ yystpcpy (yydest, yysrc)
779
821
  # endif
780
822
  # endif
781
823
 
782
- #endif /* !YYERROR_VERBOSE */
824
+ # ifndef yytnamerr
825
+ /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
826
+ quotes and backslashes, so that it's suitable for yyerror. The
827
+ heuristic is that double-quoting is unnecessary unless the string
828
+ contains an apostrophe, a comma, or backslash (other than
829
+ backslash-backslash). YYSTR is taken from yytname. If YYRES is
830
+ null, do not copy; instead, return the length of what the result
831
+ would have been. */
832
+ static YYSIZE_T
833
+ yytnamerr (char *yyres, const char *yystr)
834
+ {
835
+ if (*yystr == '"')
836
+ {
837
+ size_t yyn = 0;
838
+ char const *yyp = yystr;
839
+
840
+ for (;;)
841
+ switch (*++yyp)
842
+ {
843
+ case '\'':
844
+ case ',':
845
+ goto do_not_strip_quotes;
846
+
847
+ case '\\':
848
+ if (*++yyp != '\\')
849
+ goto do_not_strip_quotes;
850
+ /* Fall through. */
851
+ default:
852
+ if (yyres)
853
+ yyres[yyn] = *yyp;
854
+ yyn++;
855
+ break;
856
+
857
+ case '"':
858
+ if (yyres)
859
+ yyres[yyn] = '\0';
860
+ return yyn;
861
+ }
862
+ do_not_strip_quotes: ;
863
+ }
864
+
865
+ if (! yyres)
866
+ return yystrlen (yystr);
867
+
868
+ return yystpcpy (yyres, yystr) - yyres;
869
+ }
870
+ # endif
871
+
872
+ #endif /* YYERROR_VERBOSE */
783
873
 
784
874
 
785
875
 
@@ -904,8 +994,8 @@ YYSTYPE yylval;
904
994
  /* Number of syntax errors so far. */
905
995
  int yynerrs;
906
996
 
907
- register int yystate;
908
- register int yyn;
997
+ int yystate;
998
+ int yyn;
909
999
  int yyresult;
910
1000
  /* Number of tokens to shift before error messages enabled. */
911
1001
  int yyerrstatus;
@@ -923,12 +1013,12 @@ int yynerrs;
923
1013
  /* The state stack. */
924
1014
  short int yyssa[YYINITDEPTH];
925
1015
  short int *yyss = yyssa;
926
- register short int *yyssp;
1016
+ short int *yyssp;
927
1017
 
928
1018
  /* The semantic value stack. */
929
1019
  YYSTYPE yyvsa[YYINITDEPTH];
930
1020
  YYSTYPE *yyvs = yyvsa;
931
- register YYSTYPE *yyvsp;
1021
+ YYSTYPE *yyvsp;
932
1022
 
933
1023
 
934
1024
 
@@ -960,9 +1050,6 @@ int yynerrs;
960
1050
  yyssp = yyss;
961
1051
  yyvsp = yyvs;
962
1052
 
963
-
964
- yyvsp[0] = yylval;
965
-
966
1053
  goto yysetstate;
967
1054
 
968
1055
  /*------------------------------------------------------------.
@@ -995,7 +1082,7 @@ int yynerrs;
995
1082
  data in use in that stack, in bytes. This used to be a
996
1083
  conditional around just the two extra args, but that might
997
1084
  be undefined if yyoverflow is a macro. */
998
- yyoverflow ("parser stack overflow",
1085
+ yyoverflow (YY_("memory exhausted"),
999
1086
  &yyss1, yysize * sizeof (*yyssp),
1000
1087
  &yyvs1, yysize * sizeof (*yyvsp),
1001
1088
 
@@ -1006,11 +1093,11 @@ int yynerrs;
1006
1093
  }
1007
1094
  #else /* no yyoverflow */
1008
1095
  # ifndef YYSTACK_RELOCATE
1009
- goto yyoverflowlab;
1096
+ goto yyexhaustedlab;
1010
1097
  # else
1011
1098
  /* Extend the stack our own way. */
1012
1099
  if (YYMAXDEPTH <= yystacksize)
1013
- goto yyoverflowlab;
1100
+ goto yyexhaustedlab;
1014
1101
  yystacksize *= 2;
1015
1102
  if (YYMAXDEPTH < yystacksize)
1016
1103
  yystacksize = YYMAXDEPTH;
@@ -1020,7 +1107,7 @@ int yynerrs;
1020
1107
  union yyalloc *yyptr =
1021
1108
  (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1022
1109
  if (! yyptr)
1023
- goto yyoverflowlab;
1110
+ goto yyexhaustedlab;
1024
1111
  YYSTACK_RELOCATE (yyss);
1025
1112
  YYSTACK_RELOCATE (yyvs);
1026
1113
 
@@ -1364,10 +1451,11 @@ yyreduce:
1364
1451
  break;
1365
1452
 
1366
1453
 
1454
+ default: break;
1367
1455
  }
1368
1456
 
1369
- /* Line 1037 of yacc.c. */
1370
- #line 1371 "y.tab.c"
1457
+ /* Line 1126 of yacc.c. */
1458
+ #line 1459 "y.tab.c"
1371
1459
 
1372
1460
  yyvsp -= yylen;
1373
1461
  yyssp -= yylen;
@@ -1406,12 +1494,36 @@ yyerrlab:
1406
1494
 
1407
1495
  if (YYPACT_NINF < yyn && yyn < YYLAST)
1408
1496
  {
1409
- YYSIZE_T yysize = 0;
1410
1497
  int yytype = YYTRANSLATE (yychar);
1411
- const char* yyprefix;
1412
- char *yymsg;
1498
+ YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
1499
+ YYSIZE_T yysize = yysize0;
1500
+ YYSIZE_T yysize1;
1501
+ int yysize_overflow = 0;
1502
+ char *yymsg = 0;
1503
+ # define YYERROR_VERBOSE_ARGS_MAXIMUM 5
1504
+ char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1413
1505
  int yyx;
1414
1506
 
1507
+ #if 0
1508
+ /* This is so xgettext sees the translatable formats that are
1509
+ constructed on the fly. */
1510
+ YY_("syntax error, unexpected %s");
1511
+ YY_("syntax error, unexpected %s, expecting %s");
1512
+ YY_("syntax error, unexpected %s, expecting %s or %s");
1513
+ YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1514
+ YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1515
+ #endif
1516
+ char *yyfmt;
1517
+ char const *yyf;
1518
+ static char const yyunexpected[] = "syntax error, unexpected %s";
1519
+ static char const yyexpecting[] = ", expecting %s";
1520
+ static char const yyor[] = " or %s";
1521
+ char yyformat[sizeof yyunexpected
1522
+ + sizeof yyexpecting - 1
1523
+ + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
1524
+ * (sizeof yyor - 1))];
1525
+ char const *yyprefix = yyexpecting;
1526
+
1415
1527
  /* Start YYX at -YYN if negative to avoid negative indexes in
1416
1528
  YYCHECK. */
1417
1529
  int yyxbegin = yyn < 0 ? -yyn : 0;
@@ -1419,48 +1531,68 @@ yyerrlab:
1419
1531
  /* Stay within bounds of both yycheck and yytname. */
1420
1532
  int yychecklim = YYLAST - yyn;
1421
1533
  int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1422
- int yycount = 0;
1534
+ int yycount = 1;
1535
+
1536
+ yyarg[0] = yytname[yytype];
1537
+ yyfmt = yystpcpy (yyformat, yyunexpected);
1423
1538
 
1424
- yyprefix = ", expecting ";
1425
1539
  for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1426
1540
  if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1427
1541
  {
1428
- yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]);
1429
- yycount += 1;
1430
- if (yycount == 5)
1542
+ if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1431
1543
  {
1432
- yysize = 0;
1544
+ yycount = 1;
1545
+ yysize = yysize0;
1546
+ yyformat[sizeof yyunexpected - 1] = '\0';
1433
1547
  break;
1434
1548
  }
1549
+ yyarg[yycount++] = yytname[yyx];
1550
+ yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1551
+ yysize_overflow |= yysize1 < yysize;
1552
+ yysize = yysize1;
1553
+ yyfmt = yystpcpy (yyfmt, yyprefix);
1554
+ yyprefix = yyor;
1435
1555
  }
1436
- yysize += (sizeof ("syntax error, unexpected ")
1437
- + yystrlen (yytname[yytype]));
1438
- yymsg = (char *) YYSTACK_ALLOC (yysize);
1439
- if (yymsg != 0)
1440
- {
1441
- char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
1442
- yyp = yystpcpy (yyp, yytname[yytype]);
1443
1556
 
1444
- if (yycount < 5)
1557
+ yyf = YY_(yyformat);
1558
+ yysize1 = yysize + yystrlen (yyf);
1559
+ yysize_overflow |= yysize1 < yysize;
1560
+ yysize = yysize1;
1561
+
1562
+ if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM)
1563
+ yymsg = (char *) YYSTACK_ALLOC (yysize);
1564
+ if (yymsg)
1565
+ {
1566
+ /* Avoid sprintf, as that infringes on the user's name space.
1567
+ Don't have undefined behavior even if the translation
1568
+ produced a string with the wrong number of "%s"s. */
1569
+ char *yyp = yymsg;
1570
+ int yyi = 0;
1571
+ while ((*yyp = *yyf))
1445
1572
  {
1446
- yyprefix = ", expecting ";
1447
- for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1448
- if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1449
- {
1450
- yyp = yystpcpy (yyp, yyprefix);
1451
- yyp = yystpcpy (yyp, yytname[yyx]);
1452
- yyprefix = " or ";
1453
- }
1573
+ if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1574
+ {
1575
+ yyp += yytnamerr (yyp, yyarg[yyi++]);
1576
+ yyf += 2;
1577
+ }
1578
+ else
1579
+ {
1580
+ yyp++;
1581
+ yyf++;
1582
+ }
1454
1583
  }
1455
1584
  yyerror (qp, yymsg);
1456
1585
  YYSTACK_FREE (yymsg);
1457
1586
  }
1458
1587
  else
1459
- yyerror (qp, "syntax error; also virtual memory exhausted");
1588
+ {
1589
+ yyerror (qp, YY_("syntax error"));
1590
+ goto yyexhaustedlab;
1591
+ }
1460
1592
  }
1461
1593
  else
1462
1594
  #endif /* YYERROR_VERBOSE */
1463
- yyerror (qp, "syntax error");
1595
+ yyerror (qp, YY_("syntax error"));
1464
1596
  }
1465
1597
 
1466
1598
 
@@ -1472,18 +1604,9 @@ yyerrlab:
1472
1604
 
1473
1605
  if (yychar <= YYEOF)
1474
1606
  {
1475
- /* If at end of input, pop the error token,
1476
- then the rest of the stack, then return failure. */
1607
+ /* Return failure if at end of input. */
1477
1608
  if (yychar == YYEOF)
1478
- for (;;)
1479
- {
1480
-
1481
- YYPOPSTACK;
1482
- if (yyssp == yyss)
1483
- YYABORT;
1484
- yydestruct ("Error: popping",
1485
- yystos[*yyssp], yyvsp);
1486
- }
1609
+ YYABORT;
1487
1610
  }
1488
1611
  else
1489
1612
  {
@@ -1502,12 +1625,11 @@ yyerrlab:
1502
1625
  `---------------------------------------------------*/
1503
1626
  yyerrorlab:
1504
1627
 
1505
- #ifdef __GNUC__
1506
- /* Pacify GCC when the user code never invokes YYERROR and the label
1507
- yyerrorlab therefore never appears in user code. */
1628
+ /* Pacify compilers like GCC when the user code never invokes
1629
+ YYERROR and the label yyerrorlab therefore never appears in user
1630
+ code. */
1508
1631
  if (0)
1509
1632
  goto yyerrorlab;
1510
- #endif
1511
1633
 
1512
1634
  yyvsp -= yylen;
1513
1635
  yyssp -= yylen;
@@ -1570,23 +1692,29 @@ yyacceptlab:
1570
1692
  | yyabortlab -- YYABORT comes here. |
1571
1693
  `-----------------------------------*/
1572
1694
  yyabortlab:
1573
- yydestruct ("Error: discarding lookahead",
1574
- yytoken, &yylval);
1575
- yychar = YYEMPTY;
1576
1695
  yyresult = 1;
1577
1696
  goto yyreturn;
1578
1697
 
1579
1698
  #ifndef yyoverflow
1580
- /*----------------------------------------------.
1581
- | yyoverflowlab -- parser overflow comes here. |
1582
- `----------------------------------------------*/
1583
- yyoverflowlab:
1584
- yyerror (qp, "parser stack overflow");
1699
+ /*-------------------------------------------------.
1700
+ | yyexhaustedlab -- memory exhaustion comes here. |
1701
+ `-------------------------------------------------*/
1702
+ yyexhaustedlab:
1703
+ yyerror (qp, YY_("memory exhausted"));
1585
1704
  yyresult = 2;
1586
1705
  /* Fall through. */
1587
1706
  #endif
1588
1707
 
1589
1708
  yyreturn:
1709
+ if (yychar != YYEOF && yychar != YYEMPTY)
1710
+ yydestruct ("Cleanup: discarding lookahead",
1711
+ yytoken, &yylval);
1712
+ while (yyssp != yyss)
1713
+ {
1714
+ yydestruct ("Cleanup: popping",
1715
+ yystos[*yyssp], yyvsp);
1716
+ YYPOPSTACK;
1717
+ }
1590
1718
  #ifndef yyoverflow
1591
1719
  if (yyss != yyssa)
1592
1720
  YYSTACK_FREE (yyss);
@@ -1632,7 +1760,7 @@ int get_word(YYSTYPE *lvalp, QParser *qp)
1632
1760
  /* check for keywords. There are only four so we have a bit of a hack which
1633
1761
  * just checks for all of them. */
1634
1762
  *bufp = '\0';
1635
- len = bufp - buf;
1763
+ len = (int)(bufp - buf);
1636
1764
  if (len == 3) {
1637
1765
  if (buf[0] == 'A' && buf[1] == 'N' && buf[2] == 'D') return AND;
1638
1766
  if (buf[0] == 'N' && buf[1] == 'O' && buf[2] == 'T') return NOT;
@@ -1814,7 +1942,7 @@ Query *get_wild_q(QParser *qp, char *field, char *pattern)
1814
1942
  Query *q;
1815
1943
  bool is_prefix = false;
1816
1944
  char *p;
1817
- int len = strlen(pattern);
1945
+ int len = (int)strlen(pattern);
1818
1946
 
1819
1947
  if (qp->wild_lower) lower_str(pattern);
1820
1948
 
@@ -2048,12 +2176,12 @@ Query *get_range_q(char *field, char *from, char *to, bool inc_lower, bool inc_u
2048
2176
  return rq_create(field, from, to, inc_lower, inc_upper);
2049
2177
  }
2050
2178
 
2051
- void qp_destroy(void *p)
2179
+ void qp_destroy(QParser *self)
2052
2180
  {
2053
- QParser *self = (QParser *)p;
2054
2181
  if (self->close_def_fields) hs_destroy_all(self->def_fields);
2055
2182
  hs_destroy_all(self->all_fields);
2056
2183
  hs_destroy(self->fields_buf);
2184
+ a_deref(self->analyzer);
2057
2185
  free(self);
2058
2186
  }
2059
2187
 
@@ -2111,7 +2239,7 @@ char *qp_clean_str(char *str)
2111
2239
  b = *sp;
2112
2240
  /* ignore escaped characters */
2113
2241
  if (pb == '\\') {
2114
- if (quote_open && index(PHRASE_CHARS, b)) {
2242
+ if (quote_open && strrchr(PHRASE_CHARS, b)) {
2115
2243
  *nsp++ = '\\'; /* this was left off the first time through */
2116
2244
  }
2117
2245
 
@@ -2140,7 +2268,7 @@ char *qp_clean_str(char *str)
2140
2268
  case ')':
2141
2269
  if (!quote_open) {
2142
2270
  if (br_cnt == 0) {
2143
- str_insert(new_str, nsp - new_str, '(');
2271
+ str_insert(new_str, (int)(nsp - new_str), '(');
2144
2272
  nsp++;
2145
2273
  } else {
2146
2274
  br_cnt--;
@@ -2164,7 +2292,7 @@ char *qp_clean_str(char *str)
2164
2292
  break;
2165
2293
  default:
2166
2294
  if (quote_open) {
2167
- if (index(special_char, b) && b != '|') {
2295
+ if (strrchr(special_char, b) && b != '|') {
2168
2296
  *nsp++ = '\\';
2169
2297
  }
2170
2298
  }