Skip to content

Commit b3c0a29

Browse files
author
Jeroen Vermeulen
committed
Modernize "C" includes in lm.
This is one of those little chores in managing a long-lived C++ project: standard C headers like stdio.h and math.h now have their own place in the C++ standard as resp. cstdio, cmath, and so on. In this branch the #include names are updated for the lm/ subdirectory. C++11 adds cstdint, but to support compilation with the previous standard, that change is left for later.
1 parent 536c6e3 commit b3c0a29

25 files changed

+33
-45
lines changed

lm/bhiksha.hh

+1-2
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@
1919
#include "util/sorted_uniform.hh"
2020

2121
#include <algorithm>
22-
2322
#include <stdint.h>
24-
#include <assert.h>
23+
#include <cassert>
2524

2625
namespace lm {
2726
namespace ngram {

lm/blank.hh

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
#define LM_BLANK_H
33

44
#include <limits>
5-
65
#include <stdint.h>
7-
#include <math.h>
6+
#include <cmath>
87

98
namespace lm {
109
namespace ngram {

lm/build_binary_main.cc

+2-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@
99
#include <iostream>
1010
#include <iomanip>
1111
#include <limits>
12-
13-
#include <math.h>
14-
#include <stdlib.h>
12+
#include <cmath>
13+
#include <cstdlib>
1514

1615
#ifdef WIN32
1716
#include "util/getopt.hh"

lm/builder/interpolate.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
#include "util/fixed_array.hh"
99
#include "util/murmur_hash.hh"
1010

11-
#include <assert.h>
12-
#include <math.h>
11+
#include <cassert>
12+
#include <cmath>
1313

1414
namespace lm { namespace builder {
1515
namespace {

lm/builder/joint_order.hh

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <iostream>
1010
#endif
1111

12-
#include <string.h>
12+
#include <cstring>
1313

1414
namespace lm { namespace builder {
1515

lm/builder/ngram.hh

+2-3
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
#include "lm/word_index.hh"
66

77
#include <cstddef>
8-
9-
#include <assert.h>
8+
#include <cassert>
109
#include <stdint.h>
11-
#include <string.h>
10+
#include <cstring>
1211

1312
namespace lm {
1413
namespace builder {

lm/builder/print.cc

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
#include "util/stream/timer.hh"
88

99
#include <sstream>
10-
11-
#include <string.h>
10+
#include <cstring>
1211

1312
namespace lm { namespace builder {
1413

lm/builder/print.hh

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
#include "util/string_piece.hh"
1111

1212
#include <ostream>
13-
14-
#include <assert.h>
13+
#include <cassert>
1514

1615
// Warning: print routines read all unigrams before all bigrams before all
1716
// trigrams etc. So if other parts of the chain move jointly, you'll have to

lm/filter/arpa_io.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
#include <string>
77
#include <vector>
88

9-
#include <ctype.h>
10-
#include <errno.h>
11-
#include <string.h>
9+
#include <cctype>
10+
#include <cerrno>
11+
#include <cstring>
1212

1313
namespace lm {
1414

lm/filter/arpa_io.hh

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include <string>
1515
#include <vector>
1616

17-
#include <string.h>
17+
#include <cstring>
1818
#include <stdint.h>
1919

2020
namespace util { class FilePiece; }

lm/filter/phrase.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <string>
1010
#include <vector>
1111

12-
#include <ctype.h>
12+
#include <cctype>
1313

1414
namespace lm {
1515
namespace phrase {

lm/filter/vocab.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include <istream>
44
#include <iostream>
55

6-
#include <ctype.h>
6+
#include <cctype>
77

88
namespace lm {
99
namespace vocab {

lm/lm_exception.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "lm/lm_exception.hh"
22

3-
#include<errno.h>
4-
#include<stdio.h>
3+
#include <cerrno>
4+
#include <cstdio>
55

66
namespace lm {
77

lm/model.hh

+1-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717

1818
#include <algorithm>
1919
#include <vector>
20-
21-
#include <string.h>
20+
#include <cstring>
2221

2322
namespace util { class FilePiece; }
2423

lm/model_test.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "lm/model.hh"
22

3-
#include <stdlib.h>
4-
#include <string.h>
3+
#include <cstdlib>
4+
#include <cstring>
55

66
#define BOOST_TEST_MODULE ModelTest
77
#include <boost/test/unit_test.hpp>

lm/ngram_query.hh

+1-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
#include <ostream>
1212
#include <istream>
1313
#include <string>
14-
15-
#include <math.h>
14+
#include <cmath>
1615

1716
namespace lm {
1817
namespace ngram {

lm/partial.hh

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
#include "lm/state.hh"
66

77
#include <algorithm>
8-
9-
#include <assert.h>
8+
#include <cassert>
109

1110
namespace lm {
1211
namespace ngram {

lm/read_arpa.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
#include <sstream>
1010
#include <vector>
1111

12-
#include <ctype.h>
13-
#include <string.h>
12+
#include <cctype>
13+
#include <cstring>
1414
#include <stdint.h>
1515

1616
#ifdef WIN32

lm/search_trie.hh

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212

1313
#include <vector>
1414
#include <cstdlib>
15-
16-
#include <assert.h>
15+
#include <cassert>
1716

1817
namespace lm {
1918
namespace ngram {

lm/state.hh

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include "lm/word_index.hh"
66
#include "util/murmur_hash.hh"
77

8-
#include <string.h>
8+
#include <cstring>
99

1010
namespace lm {
1111
namespace ngram {

lm/trie.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include "util/exception.hh"
66
#include "util/sorted_uniform.hh"
77

8-
#include <assert.h>
8+
#include <cassert>
99

1010
namespace lm {
1111
namespace ngram {

lm/virtual_interface.hh

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include "util/string_piece.hh"
77

88
#include <string>
9-
#include <string.h>
9+
#include <cstring>
1010

1111
namespace lm {
1212
namespace base {

lm/vocab.cc

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
#include "util/probing_hash_table.hh"
1313

1414
#include <string>
15-
16-
#include <string.h>
15+
#include <cstring>
1716

1817
namespace lm {
1918
namespace ngram {

lm/word_index.hh

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#ifndef LM_WORD_INDEX_H
33
#define LM_WORD_INDEX_H
44

5-
#include <limits.h>
5+
#include <climits>
66

77
namespace lm {
88
typedef unsigned int WordIndex;

lm/wrappers/nplm.cc

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
#include "util/file.hh"
44

55
#include <algorithm>
6-
7-
#include <string.h>
6+
#include <cstring>
87

98
#include "neuralLM.h"
109

0 commit comments

Comments
 (0)