Skip to content

Commit df07314

Browse files
author
taku@chasen.org
committed
git-svn-id: http://mecab.googlecode.com/svn/trunk@131 22366562-2668-cd24-d2a3-fd8165afafd9
1 parent e07c2a6 commit df07314

File tree

5 files changed

+34
-54
lines changed

5 files changed

+34
-54
lines changed

mecab/doc/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ <h2>メーリングリスト</h2>
194194

195195
<h2><a name="news">新着情報</a></h2>
196196
<ul>
197-
<li><strong>2013-02-16</strong> MeCab 0.996<br>
197+
<li><strong>2013-02-17</strong> MeCab 0.996<br>
198198
<ul>
199199
<li>configure script の不備によりこiconvへのリンクに失敗する問題を修正
200200
<li>ユーザ辞書用CSVファイルのコストと左/右文脈IDを付与し, 新たなCSVファイルを生成する機能の追加

mecab/libtool

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ old_postuninstall_cmds=""
164164
lock_old_archive_extraction=no
165165

166166
# A C compiler.
167-
LTCC="gcc"
167+
LTCC="clang++ -Weverything"
168168

169169
# LTCC compiler flags.
170170
LTCFLAGS="-O3 -Wall "
@@ -275,7 +275,7 @@ finish_eval=""
275275
hardcode_into_libs=yes
276276

277277
# Compile-time system search path for libraries.
278-
sys_lib_search_path_spec="/usr/lib/gcc/x86_64-linux-gnu/4.6 /usr/lib/x86_64-linux-gnu /usr/lib /lib/x86_64-linux-gnu /lib "
278+
sys_lib_search_path_spec="/usr/lib/gcc/x86_64-linux-gnu/4.6 /usr/lib/x86_64-linux-gnu /lib/x86_64-linux-gnu /lib64 /usr/lib /lib "
279279

280280
# Run-time system search path for libraries.
281281
sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/lib/i386-linux-gnu/mesa /lib/i386-linux-gnu /usr/lib/i386-linux-gnu /lib/i686-linux-gnu /usr/lib/i686-linux-gnu /usr/local/lib /lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/mesa /lib32 /usr/lib32 "
@@ -305,13 +305,13 @@ reload_cmds="\$LD\$reload_flag -o \$output\$reload_objs"
305305
old_archive_cmds="\$AR \$AR_FLAGS \$oldlib\$oldobjs~\$RANLIB \$tool_oldlib"
306306

307307
# A language specific compiler.
308-
CC="gcc"
308+
CC="clang++ -Weverything"
309309

310310
# Is the compiler the GNU compiler?
311311
with_gcc=yes
312312

313313
# Compiler flag to turn off builtin functions.
314-
no_builtin_flag=" -fno-builtin"
314+
no_builtin_flag=" -fno-builtin -fno-rtti -fno-exceptions"
315315

316316
# Additional compiler flags for building library objects.
317317
pic_flag=" -fPIC -DPIC"
@@ -10112,7 +10112,7 @@ reload_cmds="\$LD\$reload_flag -o \$output\$reload_objs"
1011210112
old_archive_cmds="\$AR \$AR_FLAGS \$oldlib\$oldobjs~\$RANLIB \$tool_oldlib"
1011310113

1011410114
# A language specific compiler.
10115-
CC="g++"
10115+
CC="clang++ -Weverything"
1011610116

1011710117
# Is the compiler the GNU compiler?
1011810118
with_gcc=yes
@@ -10233,7 +10233,7 @@ file_list_spec=""
1023310233
hardcode_action=immediate
1023410234

1023510235
# The directories searched by this compiler when creating a shared library.
10236-
compiler_lib_search_dirs="/usr/lib/gcc/x86_64-linux-gnu/4.6 /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib /lib/x86_64-linux-gnu /lib/../lib /usr/lib/x86_64-linux-gnu /usr/lib/../lib /usr/lib/gcc/x86_64-linux-gnu/4.6/../../.."
10236+
compiler_lib_search_dirs="/usr/lib/gcc/x86_64-linux-gnu/4.6 /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu /lib/x86_64-linux-gnu /lib/../lib64 /usr/lib/x86_64-linux-gnu /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu /usr/lib/gcc/x86_64-linux-gnu/4.6/../../.. /lib/x86_64-linux-gnu /lib /usr/lib/x86_64-linux-gnu /usr/lib"
1023710237

1023810238
# Dependencies to place before and after the objects being linked to
1023910239
# create a shared library.
@@ -10244,6 +10244,6 @@ postdeps="-lstdc++ -lm -lgcc_s -lc -lgcc_s"
1024410244

1024510245
# The library search path used internally by the compiler when linking
1024610246
# a shared library.
10247-
compiler_lib_search_path="-L/usr/lib/gcc/x86_64-linux-gnu/4.6 -L/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.6/../../.."
10247+
compiler_lib_search_path="-L/usr/lib/gcc/x86_64-linux-gnu/4.6 -L/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu -L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/4.6/../../.. -L/lib/x86_64-linux-gnu -L/lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib"
1024810248

1024910249
# ### END LIBTOOL TAG CONFIG: CXX

mecab/src/context_id.cpp

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,10 @@ using namespace MeCab;
1414

1515
bool open_map(const char *filename,
1616
std::map<std::string, int> *cmap,
17-
size_t *cmap_size,
1817
Iconv *iconv) {
1918
std::ifstream ifs(WPATH(filename));
2019
CHECK_DIE(ifs) << "no such file or directory: " << filename;
21-
CHECK_DIE(cmap);
22-
CHECK_DIE(cmap_size);
2320
cmap->clear();
24-
*cmap_size = 0;
2521
char *col[2];
2622
std::string line;
2723
while (std::getline(ifs, line)) {
@@ -32,9 +28,8 @@ bool open_map(const char *filename,
3228
if (iconv) {
3329
iconv->convert(&pos);
3430
}
35-
const int id = std::atoi(col[0]);
36-
cmap->insert(std::pair<std::string, int>(pos, id));
37-
*cmap_size = std::max(static_cast<size_t>(id + 1), *cmap_size);
31+
cmap->insert(std::pair<std::string, int>
32+
(pos, std::atoi(col[0])));
3833
}
3934
return true;
4035
}
@@ -44,9 +39,7 @@ bool build(std::map<std::string, int> *cmap,
4439
int id = 1; // for BOS/EOS
4540
for (std::map<std::string, int>::iterator it = cmap->begin();
4641
it != cmap->end();
47-
++it) {
48-
it->second = id++;
49-
}
42+
++it) it->second = id++;
5043
cmap->insert(std::make_pair(bos, 0));
5144
return true;
5245
}
@@ -61,7 +54,7 @@ bool save(const char* filename,
6154
}
6255
return true;
6356
}
64-
} // namespace
57+
}
6558

6659
namespace MeCab {
6760

@@ -70,8 +63,6 @@ void ContextID::clear() {
7063
right_.clear();
7164
left_bos_.clear();
7265
right_bos_.clear();
73-
left_size_ = 0;
74-
right_size_ = 0;
7566
}
7667

7768
void ContextID::add(const char *l, const char *r) {
@@ -92,8 +83,8 @@ bool ContextID::save(const char* lfile,
9283
bool ContextID::open(const char *lfile,
9384
const char *rfile,
9485
Iconv *iconv) {
95-
return (::open_map(lfile, &left_, &left_size_, iconv) &&
96-
::open_map(rfile, &right_, &right_size_, iconv));
86+
return (::open_map(lfile, &left_, iconv) &&
87+
::open_map(rfile, &right_, iconv));
9788
}
9889

9990
bool ContextID::build() {

mecab/src/context_id.h

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ class Param;
1616
class Iconv;
1717

1818
class ContextID {
19+
private:
20+
std::map<std::string, int> left_;
21+
std::map<std::string, int> right_;
22+
std::string left_bos_;
23+
std::string right_bos_;
24+
1925
public:
2026
void clear();
2127
void add(const char *l, const char *r);
@@ -29,8 +35,8 @@ class ContextID {
2935
int lid(const char *l) const;
3036
int rid(const char *r) const;
3137

32-
size_t left_size() const { return left_size_; }
33-
size_t right_size() const { return right_size_; }
38+
size_t left_size() const { return left_.size(); }
39+
size_t right_size() const { return right_.size(); }
3440

3541
const std::map<std::string, int>& left_ids() const { return left_; }
3642
const std::map<std::string, int>& right_ids() const { return right_; }
@@ -39,16 +45,6 @@ class ContextID {
3945
return (lid >= 0 && lid < left_size() &&
4046
rid >= 0 && rid < right_size());
4147
}
42-
43-
ContextID() : left_size_(0), right_size_(0) {}
44-
45-
private:
46-
std::map<std::string, int> left_;
47-
std::map<std::string, int> right_;
48-
std::string left_bos_;
49-
std::string right_bos_;
50-
size_t left_size_;
51-
size_t right_size_;
5248
};
5349
}
5450
#endif

mecab/src/mmap.h

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,6 @@ extern "C" {
5454
#define O_BINARY 0
5555
#endif
5656

57-
#if !defined(_WIN32) || defined(__CYGWIN__)
58-
namespace {
59-
int open__(const char* name, int flag) { return open(name, flag); }
60-
int close__(int fd) { return close(fd); }
61-
}
62-
#endif
63-
6457
namespace MeCab {
6558

6659
template <class T> class Mmap {
@@ -156,10 +149,10 @@ template <class T> class Mmap {
156149
else
157150
CHECK_FALSE(false) << "unknown open mode: " << filename;
158151

159-
CHECK_FALSE((fd = open__(filename, flag | O_BINARY)) >= 0)
152+
CHECK_FALSE((fd = ::open(filename, flag | O_BINARY)) >= 0)
160153
<< "open failed: " << filename;
161154

162-
CHECK_FALSE(fstat(fd, &st) >= 0)
155+
CHECK_FALSE(::fstat(fd, &st) >= 0)
163156
<< "failed to get file size: " << filename;
164157

165158
length = st.st_size;
@@ -169,38 +162,38 @@ template <class T> class Mmap {
169162
if (flag == O_RDWR) prot |= PROT_WRITE;
170163
char *p;
171164
CHECK_FALSE((p = reinterpret_cast<char *>
172-
(mmap(0, length, prot, MAP_SHARED, fd, 0)))
173-
!= MAP_FAILED)
165+
(::mmap(0, length, prot, MAP_SHARED, fd, 0)))
166+
!= MAP_FAILED)
174167
<< "mmap() failed: " << filename;
175168

176169
text = reinterpret_cast<T *>(p);
177170
#else
178171
text = new T[length];
179-
CHECK_FALSE(read(fd, text, length) >= 0)
172+
CHECK_FALSE(::read(fd, text, length) >= 0)
180173
<< "read() failed: " << filename;
181174
#endif
182-
close__(fd);
175+
::close(fd);
183176
fd = -1;
184177

185178
return true;
186179
}
187180

188181
void close() {
189182
if (fd >= 0) {
190-
close__(fd);
183+
::close(fd);
191184
fd = -1;
192185
}
193186

194187
if (text) {
195188
#ifdef HAVE_MMAP
196-
munmap(reinterpret_cast<char *>(text), length);
189+
::munmap(reinterpret_cast<char *>(text), length);
197190
text = 0;
198191
#else
199192
if (flag == O_RDWR) {
200193
int fd2;
201-
if ((fd2 = open__(fileName.c_str(), O_RDWR)) >= 0) {
202-
write(fd2, text, length);
203-
close__(fd2);
194+
if ((fd2 = ::open(fileName.c_str(), O_RDWR)) >= 0) {
195+
::write(fd2, text, length);
196+
::close(fd2);
204197
}
205198
}
206199
delete [] text;
@@ -210,7 +203,7 @@ template <class T> class Mmap {
210203
text = 0;
211204
}
212205

213-
Mmap(): text(0), fd(-1) {}
206+
Mmap() : text(0), fd(-1) {}
214207
#endif
215208

216209
virtual ~Mmap() { this->close(); }

0 commit comments

Comments
 (0)