Skip to content

Commit

Permalink
- Add explicit initialization to silence false positive valgrind repo…
Browse files Browse the repository at this point in the history
…rt in compressor_save.cpp

- Drop C++11 specification in Makevars
- Remove use of std::iterator by incorporating fixes of ufal/nametag@2aa1d1d in utf8.h and utf16.h
  • Loading branch information
jwijffels committed Sep 13, 2023
1 parent eba1ae8 commit d9a78c6
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 10 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: nametagger
Type: Package
Title: Named Entity Recognition in Texts using 'NameTag'
Version: 0.1.2
Version: 0.1.3
Authors@R: c(
person('Jan', 'Wijffels', role = c('aut', 'cre', 'cph'), email = '[email protected]'),
person('BNOSAC', role = 'cph'),
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## CHANGES IN nametagger VERSION 0.1.3

- Add explicit initialization to silence false positive valgrind report in compressor_save.cpp
- Drop C++11 specification in Makevars
- Remove use of std::iterator by incorporating fixes of https://github.com/ufal/nametag/commit/2aa1d1de78d2f562c0770423f94cc7d7e1347ff7 in utf8.h and utf16.h

## CHANGES IN nametagger VERSION 0.1.2

- use snprintf instead of sprintf to handle the R CMD check deprecating note on M1mac
Expand Down
1 change: 0 additions & 1 deletion src/Makevars
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
CXX_STD = CXX11
PKG_CPPFLAGS = -DSTRICT_R_HEADERS -I./nametag/src

SOURCES_NAMETAG = nametag/src/bilou/bilou_probabilities.cpp \
Expand Down
18 changes: 14 additions & 4 deletions src/nametag/src/unilib/utf16.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//
// UniLib version: 3.1.1
// Unicode version: 8.0.0
// UniLib version: 3.3.1
// Unicode version: 15.0.0

#pragma once

Expand Down Expand Up @@ -113,8 +113,13 @@ void utf16::decode(const std::u16string& str, std::u32string& decoded) {
decode(str.c_str(), decoded);
}

class utf16::string_decoder::iterator : public std::iterator<std::input_iterator_tag, char32_t> {
class utf16::string_decoder::iterator {
public:
using iterator_category = std::input_iterator_tag;
using value_type = char32_t;
using difference_type = ptrdiff_t;
using pointer = char32_t*;
using reference = char32_t&;
iterator(const char16_t* str) : codepoint(0), next(str) { operator++(); }
iterator(const iterator& it) : codepoint(it.codepoint), next(it.next) {}
iterator& operator++() { if (next) { codepoint = decode(next); if (!codepoint) next = nullptr; } return *this; }
Expand Down Expand Up @@ -145,8 +150,13 @@ utf16::string_decoder utf16::decoder(const std::u16string& str) {
return string_decoder(str.c_str());
}

class utf16::buffer_decoder::iterator : public std::iterator<std::input_iterator_tag, char32_t> {
class utf16::buffer_decoder::iterator {
public:
using iterator_category = std::input_iterator_tag;
using value_type = char32_t;
using difference_type = ptrdiff_t;
using pointer = char32_t*;
using reference = char32_t&;
iterator(const char16_t* str, size_t len) : codepoint(0), next(str), len(len) { operator++(); }
iterator(const iterator& it) : codepoint(it.codepoint), next(it.next), len(it.len) {}
iterator& operator++() { if (!len) next = nullptr; if (next) codepoint = decode(next, len); return *this; }
Expand Down
18 changes: 14 additions & 4 deletions src/nametag/src/unilib/utf8.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//
// UniLib version: 3.1.1
// Unicode version: 8.0.0
// UniLib version: 3.3.1
// Unicode version: 15.0.0

#pragma once

Expand Down Expand Up @@ -145,8 +145,13 @@ void utf8::decode(const std::string& str, std::u32string& decoded) {
decode(str.c_str(), decoded);
}

class utf8::string_decoder::iterator : public std::iterator<std::input_iterator_tag, char32_t> {
class utf8::string_decoder::iterator {
public:
using iterator_category = std::input_iterator_tag;
using value_type = char32_t;
using difference_type = ptrdiff_t;
using pointer = char32_t*;
using reference = char32_t&;
iterator(const char* str) : codepoint(0), next(str) { operator++(); }
iterator(const iterator& it) : codepoint(it.codepoint), next(it.next) {}
iterator& operator++() { if (next) { codepoint = decode(next); if (!codepoint) next = nullptr; } return *this; }
Expand Down Expand Up @@ -177,8 +182,13 @@ utf8::string_decoder utf8::decoder(const std::string& str) {
return string_decoder(str.c_str());
}

class utf8::buffer_decoder::iterator : public std::iterator<std::input_iterator_tag, char32_t> {
class utf8::buffer_decoder::iterator {
public:
using iterator_category = std::input_iterator_tag;
using value_type = char32_t;
using difference_type = ptrdiff_t;
using pointer = char32_t*;
using reference = char32_t&;
iterator(const char* str, size_t len) : codepoint(0), next(str), len(len) { operator++(); }
iterator(const iterator& it) : codepoint(it.codepoint), next(it.next), len(it.len) {}
iterator& operator++() { if (!len) next = nullptr; if (next) codepoint = decode(next, len); return *this; }
Expand Down
2 changes: 2 additions & 0 deletions src/nametag/src/utils/compressor_save.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,8 @@ void MatchFinder_Construct(CMatchFinder *p)
p->bufferBase = 0;
p->directInput = 0;
p->hash = 0;
p->hashSizeSum = 0;
p->numSons = 0;
MatchFinder_SetDefaultSettings(p);

for (i = 0; i < 256; i++)
Expand Down

0 comments on commit d9a78c6

Please sign in to comment.