Merge lp:~zorba-coders/zorba/feature-ft_module into lp:zorba

Proposed by Paul J. Lucas
Status: Merged
Approved by: Matthias Brantner
Approved revision: no longer in the source branch.
Merged at revision: 10828
Proposed branch: lp:~zorba-coders/zorba/feature-ft_module
Merge into: lp:zorba
Diff against target: 93 lines (+21/-20)
2 files modified
src/runtime/full_text/ft_stop_words_set.cpp (+13/-17)
src/runtime/full_text/ft_token_matcher.cpp (+8/-3)
To merge this branch: bzr merge lp:~zorba-coders/zorba/feature-ft_module
Reviewer Review Type Date Requested Status
Matthias Brantner Approve
Paul J. Lucas Approve
Review via email: mp+105023@code.launchpad.net

Commit message

Fixes the stop-words core dump on 64-bit Linux.

Description of the change

Fixes the stop-words core dump on 64-bit Linux.

To post a comment you must log in.
Revision history for this message
Paul J. Lucas (paul-lucas) :
review: Approve
Revision history for this message
Matthias Brantner (matthias-brantner) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job feature-ft_module-2012-05-08T03-04-21.004Z is finished. The final status was:

All tests succeeded!

10828. By Paul J. Lucas

Fixes the stop-words core dump on 64-bit Linux. Approved: Matthias Brantner, Paul J. Lucas

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/runtime/full_text/ft_stop_words_set.cpp'
2--- src/runtime/full_text/ft_stop_words_set.cpp 2012-05-03 12:31:51 +0000
3+++ src/runtime/full_text/ft_stop_words_set.cpp 2012-05-08 02:54:58 +0000
4@@ -17,14 +17,14 @@
5
6 #include <zorba/config.h>
7
8-#include <util/ascii_util.h>
9-#include <util/cxx_util.h>
10-#include <util/mmap_file.h>
11-#include <util/stl_util.h>
12-#include <util/uri_util.h>
13-#include <context/static_context.h>
14-#include <context/uri_resolver.h>
15-#include <zorbautils/locale.h>
16+#include "context/static_context.h"
17+#include "context/uri_resolver.h"
18+#include "util/ascii_util.h"
19+#include "util/cxx_util.h"
20+#include "util/mmap_file.h"
21+#include "util/stl_util.h"
22+#include "util/uri_util.h"
23+#include "zorbautils/locale.h"
24
25 #include "ft_stop_words_set.h"
26
27@@ -57,7 +57,7 @@
28 case LANG(pt);
29 case LANG(sv);
30 default:
31- return 0;
32+ return nullptr;
33 }
34 }
35
36@@ -75,7 +75,6 @@
37 void ft_stop_words_set::apply_word( zstring const &word, word_set_t &word_set,
38 ft_stop_words_unex::type mode ) {
39 // TODO: should "word" be converted to lower-case?
40- std::cout << "applying word " << word << std::endl;
41 switch ( mode ) {
42 case ft_stop_words_unex::union_:
43 word_set.insert( word );
44@@ -106,12 +105,9 @@
45 must_delete = true;
46 break;
47 case ft_stop_words_mode::with_default:
48- word_set = get_default_word_set_for( lang );
49- if ( !word_set ) {
50- // TODO: throw exception?
51- return ptr();
52- }
53- break;
54+ if ( (word_set = get_default_word_set_for( lang )) )
55+ break;
56+ // no break;
57 case ft_stop_words_mode::without:
58 return ptr();
59 }
60@@ -133,7 +129,7 @@
61 dynamic_cast<internal::StreamResource*>( rsrc.get() );
62 if ( !stream_rsrc ) {
63 // Technically this should be thrown during static analysis.
64- throw ZORBA_EXCEPTION( err::FTST0008, ERROR_PARAMS( uri ) );
65+ throw XQUERY_EXCEPTION( err::FTST0008, ERROR_PARAMS( uri ) );
66 }
67 std::istream *const stream = stream_rsrc->getStream();
68
69
70=== modified file 'src/runtime/full_text/ft_token_matcher.cpp'
71--- src/runtime/full_text/ft_token_matcher.cpp 2012-05-03 12:31:51 +0000
72+++ src/runtime/full_text/ft_token_matcher.cpp 2012-05-08 02:54:58 +0000
73@@ -47,12 +47,17 @@
74 return false;
75 }
76
77-inline ft_stop_words_set::ptr
78+//
79+// This returns a raw pointer to work around a bug where ~ft_stop_words_set()
80+// is being called when it shouldn't be due to ~unique_ptr() being called
81+// without transferring ownership properly.
82+//
83+inline ft_stop_words_set const*
84 get_stop_words( ftmatch_options const &options, iso639_1::type lang,
85 static_context const& sctx ) {
86 if ( ftstop_word_option const *const sw = options.get_stop_word_option() )
87- return ft_stop_words_set::construct( *sw, lang, sctx );
88- return ft_stop_words_set::ptr();
89+ return ft_stop_words_set::construct( *sw, lang, sctx ).release();
90+ return nullptr;
91 }
92
93 ///////////////////////////////////////////////////////////////////////////////

Subscribers

People subscribed via source and target branches