Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into aseprite
Browse files Browse the repository at this point in the history
  • Loading branch information
dacap committed Sep 14, 2018
2 parents 0687587 + fe082fa commit c94997d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 12 deletions.
13 changes: 13 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
language: cpp

os:
- linux
- osx

compiler:
- gcc
- clang

script:
- make all
- make test
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
simpleini
=========

[![TravisCI Status](https://travis-ci.org/brofield/simpleini.svg?branch=master)](https://travis-ci.org/brofield/simpleini)

A cross-platform library that provides a simple API to read and write INI-style configuration files. It supports data files in ASCII, MBCS and Unicode. It is designed explicitly to be portable to any platform and has been tested on Windows, WinCE and Linux. Released as open-source and free using the MIT licence.

# Feature Summary
Expand Down
29 changes: 17 additions & 12 deletions SimpleIni.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
@section features FEATURES
- MIT Licence allows free use in all software (including GPL and commercial)
- multi-platform (Windows 95/98/ME/NT/2K/XP/2003, Windows CE, Linux, Unix)
- multi-platform (Windows CE/9x/NT..10/etc, Linux, MacOSX, Unix)
- loading and saving of INI-style configuration files
- configuration files can have any newline format on all platforms
- liberal acceptance of file format
Expand Down Expand Up @@ -328,15 +328,15 @@ class CSimpleIniTempl
#endif

/** Strict less ordering by name of key only */
struct KeyOrder : std::binary_function<Entry, Entry, bool> {
struct KeyOrder {
bool operator()(const Entry & lhs, const Entry & rhs) const {
const static SI_STRLESS isLess = SI_STRLESS();
return isLess(lhs.pItem, rhs.pItem);
}
};

/** Strict less ordering by order, and then name of key */
struct LoadOrder : std::binary_function<Entry, Entry, bool> {
struct LoadOrder {
bool operator()(const Entry & lhs, const Entry & rhs) const {
if (lhs.nOrder != rhs.nOrder) {
return lhs.nOrder < rhs.nOrder;
Expand Down Expand Up @@ -1414,21 +1414,26 @@ CSimpleIniTempl<SI_CHAR,SI_STRLESS,SI_CONVERTER>::LoadData(
size_t a_uDataLen
)
{
SI_CONVERTER converter(m_bStoreIsUtf8);

if (a_uDataLen == 0) {
if (!a_pData) {
return SI_OK;
}

// if the UTF-8 BOM exists, consume it and set mode to unicode, if we have
// already loaded data and try to change mode half-way through then this will
// be ignored and we will assert in debug versions
if (a_uDataLen >= 3 && memcmp(a_pData, SI_UTF8_SIGNATURE, 3) == 0) {
a_pData += 3;
a_uDataLen -= 3;
SI_ASSERT(m_bStoreIsUtf8 || !m_pData); // we don't expect mixed mode data
SetUnicode();
}

// consume the UTF-8 BOM if it exists
if (m_bStoreIsUtf8 && a_uDataLen >= 3) {
if (memcmp(a_pData, SI_UTF8_SIGNATURE, 3) == 0) {
a_pData += 3;
a_uDataLen -= 3;
}
if (a_uDataLen == 0) {
return SI_OK;
}

// determine the length of the converted data
SI_CONVERTER converter(m_bStoreIsUtf8);
size_t uLen = converter.SizeFromStore(a_pData, a_uDataLen);
if (uLen == (size_t)(-1)) {
return SI_FAIL;
Expand Down

0 comments on commit c94997d

Please sign in to comment.