Skip to content

Commit

Permalink
Removed -std=gnu++0x options.
Browse files Browse the repository at this point in the history
Replaced c++0x features with tr1 features.
  std::uintXX_t -> ::uintXX_t
  std::shared_ptr -> std::tr1::shared_ptr
  std::unordered_set -> std::tr1::unordered_set
  std::unordered_map -> std::tr1::unordered_map
  • Loading branch information
susumu.yata committed Oct 26, 2010
1 parent 2b60a05 commit 8bd72a5
Show file tree
Hide file tree
Showing 15 changed files with 33 additions and 36 deletions.
4 changes: 2 additions & 2 deletions include/nwc-toolkit/input-file.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#define NWC_TOOLKIT_INPUT_FILE_H_

#include <cstdio>
#include <memory>
#include <tr1/memory>

#include "./bzip2-coder.h"
#include "./gzip-coder.h"
Expand Down Expand Up @@ -50,7 +50,7 @@ class InputFile {

private:
FILE *file_;
std::shared_ptr<Coder> coder_;
std::tr1::shared_ptr<Coder> coder_;
StringBuilder io_buf_;
StringBuilder coder_buf_;
const char *next_;
Expand Down
4 changes: 2 additions & 2 deletions include/nwc-toolkit/output-file.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#define NWC_TOOLKIT_OUTPUT_FILE_H_

#include <cstdio>
#include <memory>
#include <tr1/memory>

#include "./bzip2-coder.h"
#include "./gzip-coder.h"
Expand Down Expand Up @@ -36,7 +36,7 @@ class OutputFile {

private:
FILE *file_;
std::shared_ptr<Coder> coder_;
std::tr1::shared_ptr<Coder> coder_;
StringBuilder io_buf_;

// Disallows copy and assignment.
Expand Down
4 changes: 2 additions & 2 deletions include/nwc-toolkit/token-map.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#ifndef NWC_TOOLKIT_TOKEN_MAP_H_
#define NWC_TOOLKIT_TOKEN_MAP_H_

#include <unordered_map>
#include <tr1/unordered_map>
#include <vector>

#include "./string-hash.h"
Expand Down Expand Up @@ -48,7 +48,7 @@ class TokenMap {
}

private:
typedef std::unordered_map<String, int, StringHash> MapType;
typedef std::tr1::unordered_map<String, int, StringHash> MapType;

StringPool pool_;
MapType map_;
Expand Down
6 changes: 2 additions & 4 deletions include/nwc-toolkit/xz-coder.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
#ifndef NWC_TOOLKIT_XZ_CODER_H_
#define NWC_TOOLKIT_XZ_CODER_H_

#include <cstdint>

#include <lzma.h>

#include "./coder.h"
Expand Down Expand Up @@ -63,13 +61,13 @@ class XzCoder : public Coder {
}

void set_next_in(const void *next_in) {
stream_.next_in = static_cast<const std::uint8_t *>(next_in);
stream_.next_in = static_cast<const ::uint8_t *>(next_in);
}
void set_avail_in(std::size_t avail_in) {
stream_.avail_in = avail_in;
}
void set_next_out(void *next_out) {
stream_.next_out = static_cast<std::uint8_t *>(next_out);
stream_.next_out = static_cast< ::uint8_t *>(next_out);
}
void set_avail_out(std::size_t avail_out) {
stream_.avail_out = avail_out;
Expand Down
2 changes: 1 addition & 1 deletion lib/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
AM_CXXFLAGS = -Wall -Weffc++ -std=gnu++0x -I../include
AM_CXXFLAGS = -Wall -Weffc++ -I../include

lib_LIBRARIES = libnwc-toolkit.a

Expand Down
2 changes: 1 addition & 1 deletion lib/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AM_CXXFLAGS = -Wall -Weffc++ -std=gnu++0x -I../include
AM_CXXFLAGS = -Wall -Weffc++ -I../include
lib_LIBRARIES = libnwc-toolkit.a
libnwc_toolkit_a_SOURCES = \
bzip2-coder.cc \
Expand Down
11 changes: 6 additions & 5 deletions lib/html-document.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <nwc-toolkit/html-document.h>

#include <unordered_set>
#include <tr1/unordered_set>

#include <nwc-toolkit/character-encoding.h>
#include <nwc-toolkit/character-reference.h>
Expand All @@ -11,7 +11,9 @@
namespace nwc_toolkit {
namespace {

const std::unordered_set<String, StringHash> &GetBlockTagNameSet() {
typedef std::tr1::unordered_set<String, StringHash> TagNameSet;

const TagNameSet &GetBlockTagNameSet() {
const char *tag_names[] = {
"address", "article", "aside", "blockquote", "br", "caption", "center",
"dd", "dialog", "dir", "div", "dl", "dt", "fieldset", "figure",
Expand All @@ -22,7 +24,7 @@ const std::unordered_set<String, StringHash> &GetBlockTagNameSet() {
};

static bool is_initialized = false;
static std::unordered_set<String, StringHash> tag_name_set;
static TagNameSet tag_name_set;

if (!is_initialized) {
std::size_t num_keys = sizeof(tag_names) / sizeof(tag_names[0]);
Expand Down Expand Up @@ -121,8 +123,7 @@ void HtmlDocument::ExtractText(StringBuilder *dest) {
}

bool HtmlDocument::IsBlockTag(const String &tag_name) {
static const std::unordered_set<String, StringHash> block_tag_name_set =
GetBlockTagNameSet();
static const TagNameSet &block_tag_name_set = GetBlockTagNameSet();
return block_tag_name_set.find(tag_name) != block_tag_name_set.end();
}

Expand Down
10 changes: 4 additions & 6 deletions lib/unicode-normalizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

#include <nwc-toolkit/unicode-normalizer.h>

#include <cstdint>

#include <unicode/normlzr.h>
#include <unicode/unistr.h>

Expand Down Expand Up @@ -36,7 +34,7 @@ ::UNormalizationMode ConvertFormToMode(
}

void ExtractStringFromUnicodeString(const UnicodeString &unistr,
std::int32_t begin, std::int32_t end, StringBuilder *dest) {
::int32_t begin, ::int32_t end, StringBuilder *dest) {
if (begin >= end) {
return;
}
Expand All @@ -50,7 +48,7 @@ void ExtractStringFromUnicodeString(const UnicodeString &unistr,
dest->Resize(dest->size());
std::size_t avail = dest->length() - offset;

std::int32_t length = unistr.extract(begin, end - begin,
::int32_t length = unistr.extract(begin, end - begin,
dest->buf() + offset, avail, "UTF-8");
dest->Resize(offset + length);
if (static_cast<std::size_t>(length) > avail) {
Expand All @@ -76,9 +74,9 @@ bool UnicodeNormalizer::Normalize(NormalizationForm form,
return false;
}

std::int32_t last_pos = 0;
::int32_t last_pos = 0;
if (illegal_input_handler == REMOVE_REPLACEMENT_CHARACTERS) {
for (std::int32_t pos = 0; pos < unicode_dest.length(); ++pos) {
for (::int32_t pos = 0; pos < unicode_dest.length(); ++pos) {
// ICU replaces illegal input with U+FFFDs, and the U+FFFDs are
// skipped here if `REMOVE_REPLACEMENT_CHARACTERS' is given.
if (unicode_dest[pos] == 0xFFFD) {
Expand Down
2 changes: 1 addition & 1 deletion tests/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
AM_CXXFLAGS = -Wall -Weffc++ -std=gnu++0x -I../include `icu-config --cppflags`
AM_CXXFLAGS = -Wall -Weffc++ -I../include `icu-config --cppflags`
AM_LDFLAGS = `icu-config --ldflags`

TESTS = \
Expand Down
2 changes: 1 addition & 1 deletion tests/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AM_CXXFLAGS = -Wall -Weffc++ -std=gnu++0x -I../include `icu-config --cppflags`
AM_CXXFLAGS = -Wall -Weffc++ -I../include `icu-config --cppflags`
AM_LDFLAGS = `icu-config --ldflags`
test_char_cond_SOURCES = test-char-cond.cc
test_char_cond_LDADD = ../lib/libnwc-toolkit.a
Expand Down
10 changes: 5 additions & 5 deletions tests/test-string-hash.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
#include <cassert>
#include <cstdlib>
#include <ctime>
#include <memory>
#include <string>
#include <unordered_set>
#include <tr1/memory>
#include <tr1/unordered_set>
#include <vector>

#include <nwc-toolkit/string-hash.h>

int main() {
enum { KEY_LENGTH = 16, MAX_NUM_KEYS = 4096 };

typedef std::unordered_set<nwc_toolkit::String,
typedef std::tr1::unordered_set<nwc_toolkit::String,
nwc_toolkit::StringHash> KeySet;

std::srand(static_cast<unsigned int>(std::time(NULL)));

std::vector<std::shared_ptr<std::string> > key_pool;
std::vector<std::tr1::shared_ptr<std::string> > key_pool;
std::vector<nwc_toolkit::String> keys;
KeySet key_set;

Expand All @@ -30,7 +30,7 @@ int main() {
}
KeySet::iterator it = key_set.find(key);
if (it == key_set.end()) {
std::shared_ptr<std::string> key_str(new std::string(
std::tr1::shared_ptr<std::string> key_str(new std::string(
key.ptr(), key.length()));
key_pool.push_back(key_str);

Expand Down
2 changes: 1 addition & 1 deletion tools/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
AM_CXXFLAGS = -Wall -Weffc++ -std=gnu++0x -I../include `icu-config --cppflags`
AM_CXXFLAGS = -Wall -Weffc++ -I../include `icu-config --cppflags`
AM_LDFLAGS = `icu-config --ldflags`

bin_SCRIPTS = \
Expand Down
2 changes: 1 addition & 1 deletion tools/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AM_CXXFLAGS = -Wall -Weffc++ -std=gnu++0x -I../include `icu-config --cppflags`
AM_CXXFLAGS = -Wall -Weffc++ -I../include `icu-config --cppflags`
AM_LDFLAGS = `icu-config --ldflags`
bin_SCRIPTS = \
nwc-toolkit-config
Expand Down
4 changes: 2 additions & 2 deletions tools/nwc-toolkit-ngram-merger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ bool Merge(int num_file_names, char *file_names[],
std::cerr << '\r' << "input: " << input_count
<< ", output: " << output_count << " ("
<< std::fixed << std::setprecision(2)
<< (100.0 * output_count / input_count) << "%)"
<< " (" << (std::time(NULL) - start_time) << "sec)" << std::endl;
<< ((input_count != 0) ? (100.0 * output_count / input_count) : 0.0)
<< "%) (" << (std::time(NULL) - start_time) << "sec)" << std::endl;
delete [] pairs;
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions tools/nwc-toolkit-text-extractor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,10 @@ void ExtractTextFromHtmlArchvie(nwc_toolkit::InputFile *input_file,
}
std::cerr << '\r' << status_error_count << " ("
<< std::fixed << std::setw(5) << std::setprecision(2)
<< (100.0 * status_error_count / num_entries)
<< ((num_entries != 0) ? (100.0 * status_error_count / num_entries) : 0.0)
<< "%) / " << parse_error_count << " ("
<< std::fixed << std::setw(5) << std::setprecision(2)
<< (100.0 * parse_error_count / num_entries)
<< ((num_entries != 0) ? (100.0 * parse_error_count / num_entries) : 0.0)
<< "%) / " << num_entries
<< " (" << (std::time(NULL) - start_time) << "sec)" << std::endl;
}
Expand Down

0 comments on commit 8bd72a5

Please sign in to comment.