Skip to content

Commit cfe7d00

Browse files
committed
Compiler warnings, rename to ${binary}_main.cc
1 parent a52d97f commit cfe7d00

File tree

11 files changed

+25
-21
lines changed

11 files changed

+25
-21
lines changed

lm/Jamfile

+8-8
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ update-if-changed $(ORDER-LOG) $(max-order) ;
1313

1414
max-order += <dependency>$(ORDER-LOG) ;
1515

16-
fakelib kenlm : bhiksha.cc binary_format.cc config.cc lm_exception.cc model.cc quantize.cc read_arpa.cc search_hashed.cc search_trie.cc sizes.cc trie.cc trie_sort.cc value_build.cc virtual_interface.cc vocab.cc ../util//kenutil : <include>.. $(max-order) : : <include>.. $(max-order) ;
16+
fakelib kenlm : [ glob *.cc : *main.cc *test.cc ] ../util//kenutil : <include>.. $(max-order) : : <include>.. $(max-order) ;
1717

1818
import testing ;
1919

20-
run left_test.cc ../util//kenutil kenlm /top//boost_unit_test_framework : : test.arpa ;
21-
run model_test.cc ../util//kenutil kenlm /top//boost_unit_test_framework : : test.arpa test_nounk.arpa ;
22-
run partial_test.cc ../util//kenutil kenlm /top//boost_unit_test_framework : : test.arpa ;
20+
run left_test.cc kenlm /top//boost_unit_test_framework : : test.arpa ;
21+
run model_test.cc kenlm /top//boost_unit_test_framework : : test.arpa test_nounk.arpa ;
22+
run partial_test.cc kenlm /top//boost_unit_test_framework : : test.arpa ;
2323

24-
exe query : ngram_query.cc kenlm ../util//kenutil ;
25-
exe build_binary : build_binary.cc kenlm ../util//kenutil ;
26-
exe kenlm_max_order : max_order.cc : <include>.. $(max-order) ;
27-
exe fragment : fragment.cc kenlm ;
24+
exe query : query_main.cc kenlm ../util//kenutil ;
25+
exe build_binary : build_binary_main.cc kenlm ../util//kenutil ;
26+
exe kenlm_max_order : kenlm_max_order_main.cc : <include>.. $(max-order) ;
27+
exe fragment : fragment_main.cc kenlm ;
2828

2929
alias programs : query build_binary kenlm_max_order fragment filter//filter : <threading>multi:<source>builder//lmplz ;
File renamed without changes.

lm/builder/Jamfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
fakelib builder : corpus_count.cc adjust_counts.cc initial_probabilities.cc interpolate.cc pipeline.cc print.cc
1+
fakelib builder : [ glob *.cc : *test.cc *main.cc ]
22
../../util//kenutil ../../util/stream//stream ../../util/double-conversion//double-conversion ..//kenlm
33
: : : <library>/top//boost_thread $(timer-link) ;
44

5-
exe lmplz : main.cc builder /top//boost_program_options ;
5+
exe lmplz : lmplz_main.cc builder /top//boost_program_options ;
66

77
import testing ;
88
unit-test corpus_count_test : corpus_count_test.cc builder /top//boost_unit_test_framework ;
File renamed without changes.

lm/filter/Jamfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
fakelib lm_filter : phrase.cc vocab.cc arpa_io.cc ../../util//kenutil : <threading>multi:<library>/top//boost_thread ;
22

3-
obj main : main.cc : <threading>single:<define>NTHREAD <include>../.. ;
3+
obj main : filter_main.cc : <threading>single:<define>NTHREAD <include>../.. ;
44

55
exe filter : main lm_filter ../../util//kenutil ..//kenlm : <threading>multi:<library>/top//boost_thread ;

lm/filter/main.cc renamed to lm/filter/filter_main.cc

+9-10
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ void DisplayHelp(const char *name) {
5353
" stream i.e. /dev/stdout\n";
5454
}
5555

56-
typedef enum {MODE_COPY, MODE_SINGLE, MODE_MULTIPLE, MODE_UNION} FilterMode;
56+
typedef enum {MODE_COPY, MODE_SINGLE, MODE_MULTIPLE, MODE_UNION, MODE_UNSET} FilterMode;
5757
typedef enum {FORMAT_ARPA, FORMAT_COUNT} Format;
5858

5959
struct Config {
@@ -162,19 +162,19 @@ int main(int argc, char *argv[]) {
162162
return 1;
163163
}
164164

165-
// I used to have boost::program_options, but some users didn't want to compile boost.
165+
// I used to have boost::program_options, but some users didn't want to compile boost.
166166
lm::Config config;
167-
boost::optional<lm::FilterMode> mode;
167+
config.mode = lm::MODE_UNSET;
168168
for (int i = 1; i < argc - 2; ++i) {
169169
const char *str = argv[i];
170170
if (!std::strcmp(str, "copy")) {
171-
mode = lm::MODE_COPY;
171+
config.mode = lm::MODE_COPY;
172172
} else if (!std::strcmp(str, "single")) {
173-
mode = lm::MODE_SINGLE;
173+
config.mode = lm::MODE_SINGLE;
174174
} else if (!std::strcmp(str, "multiple")) {
175-
mode = lm::MODE_MULTIPLE;
175+
config.mode = lm::MODE_MULTIPLE;
176176
} else if (!std::strcmp(str, "union")) {
177-
mode = lm::MODE_UNION;
177+
config.mode = lm::MODE_UNION;
178178
} else if (!std::strcmp(str, "phrase")) {
179179
config.phrase = true;
180180
} else if (!std::strcmp(str, "context")) {
@@ -203,13 +203,12 @@ int main(int argc, char *argv[]) {
203203
}
204204
}
205205

206-
if (!mode) {
206+
if (config.mode == lm::MODE_UNSET) {
207207
lm::DisplayHelp(argv[0]);
208208
return 1;
209209
}
210-
config.mode = *mode;
211210

212-
if (config.phrase && config.mode != lm::MODE_UNION && mode != lm::MODE_MULTIPLE) {
211+
if (config.phrase && config.mode != lm::MODE_UNION && config.mode != lm::MODE_MULTIPLE) {
213212
std::cerr << "Phrase constraint currently only works in multiple or union mode. If you really need it for single, put everything on one line and use union." << std::endl;
214213
return 1;
215214
}

lm/filter/phrase.hh

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class Substrings {
5757
LM_FILTER_PHRASE_METHOD(Right, right)
5858
LM_FILTER_PHRASE_METHOD(Phrase, phrase)
5959

60+
#pragma GCC diagnostic ignored "-Wuninitialized" // end != finish so there's always an initialization
6061
// sentence_id must be non-decreasing. Iterators are over words in the phrase.
6162
template <class Iterator> void AddPhrase(unsigned int sentence_id, const Iterator &begin, const Iterator &end) {
6263
// Iterate over all substrings.
File renamed without changes.
File renamed without changes.
File renamed without changes.

util/double-conversion/strtod.cc

+4
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,9 @@ float Strtof(Vector<const char> buffer, int exponent) {
506506
double double_previous = Double(double_guess).PreviousDouble();
507507

508508
float f1 = static_cast<float>(double_previous);
509+
#ifndef NDEBUG
509510
float f2 = float_guess;
511+
#endif
510512
float f3 = static_cast<float>(double_next);
511513
float f4;
512514
if (is_correct) {
@@ -515,7 +517,9 @@ float Strtof(Vector<const char> buffer, int exponent) {
515517
double double_next2 = Double(double_next).NextDouble();
516518
f4 = static_cast<float>(double_next2);
517519
}
520+
#ifndef NDEBUG
518521
ASSERT(f1 <= f2 && f2 <= f3 && f3 <= f4);
522+
#endif
519523

520524
// If the guess doesn't lie near a single-precision boundary we can simply
521525
// return its float-value.

0 commit comments

Comments
 (0)