Skip to content

Commit

Permalink
Fix for lines ending with EOF
Browse files Browse the repository at this point in the history
  • Loading branch information
vaeth committed Sep 18, 2014
1 parent db802fb commit 03cb4f2
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 27 deletions.
2 changes: 2 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

*eix-0.30.4
Martin Väth <martin at mvath.de>:
- Fix for lines ending with EOF (regression introduced in eix-0.30.3),
see https://github.com/vaeth/eix/issues/3
- Support PORTAGE_REPOSITORIES
- internal: Support parsing from mem for varsreader.cc

Expand Down
8 changes: 4 additions & 4 deletions po/de.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: eix\n"
"Report-Msgid-Bugs-To: https://github.com/vaeth/eix/issues/\n"
"POT-Creation-Date: 2014-09-12 21:03+0200\n"
"POT-Creation-Date: 2014-09-18 07:02+0200\n"
"PO-Revision-Date: 2013-05-01 11:40+0200\n"
"Last-Translator: Martin Vaeth <martin@mvath.de>\n"
"Language-Team: German\n"
Expand Down Expand Up @@ -2114,7 +2114,7 @@ msgstr "kann Version von '%s' nicht bestimmen"
msgid "unknown cache %r for directory %r"
msgstr "Unbekannter Cache %r für Ordner %r"

#: src/cache/common/assign_reader.cc:83 src/cache/common/assign_reader.cc:101
#: src/cache/common/assign_reader.cc:82 src/cache/common/assign_reader.cc:100
#: src/cache/common/flat_reader.cc:38
#, c-format
msgid "cannot read cache file %s: %s"
Expand Down Expand Up @@ -2390,12 +2390,12 @@ msgstr "Interner Fehler: Trying to shortcut non-hashed string."
msgid "Database corrupt: Nonexistent hash required"
msgstr "Datenbank defekt: Nichtexistierender Hash angefordert"

#: src/eixTk/utils.cc:116
#: src/eixTk/utils.cc:118
#, c-format
msgid "Error reading %s: %s"
msgstr "Lesefehler in %s: %s "

#: src/eixTk/utils.cc:137
#: src/eixTk/utils.cc:139
msgid "Nesting level too deep in %r"
msgstr "Zu tiefe Verschachtelung in %r"

Expand Down
8 changes: 4 additions & 4 deletions po/ru.po
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ msgid ""
msgstr ""
"Project-Id-Version: eix\n"
"Report-Msgid-Bugs-To: https://github.com/vaeth/eix/issues/\n"
"POT-Creation-Date: 2014-09-12 21:03+0200\n"
"POT-Creation-Date: 2014-09-18 07:02+0200\n"
"PO-Revision-Date: 2013-05-20 00:30+0200\n"
"Last-Translator: Artem Vorotnikov <skybon@gmail.com>\n"
"Language-Team: русский <>\n"
Expand Down Expand Up @@ -2074,7 +2074,7 @@ msgstr "Невозможно определить версию %s"
msgid "unknown cache %r for directory %r"
msgstr "Неизвестный кэш %r для каталога %r"

#: src/cache/common/assign_reader.cc:83 src/cache/common/assign_reader.cc:101
#: src/cache/common/assign_reader.cc:82 src/cache/common/assign_reader.cc:100
#: src/cache/common/flat_reader.cc:38
#, c-format
msgid "cannot read cache file %s: %s"
Expand Down Expand Up @@ -2353,12 +2353,12 @@ msgstr "Внутренняя ошибка: Попытка создать ярл
msgid "Database corrupt: Nonexistent hash required"
msgstr "База данных испорчена: требуется несуществующий хеш"

#: src/eixTk/utils.cc:116
#: src/eixTk/utils.cc:118
#, c-format
msgid "Error reading %s: %s"
msgstr "Ошибка чтения %s: %s"

#: src/eixTk/utils.cc:137
#: src/eixTk/utils.cc:139
msgid "Nesting level too deep in %r"
msgstr "Уровень гнездования слишком глубок в %r"

Expand Down
13 changes: 6 additions & 7 deletions src/cache/common/assign_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,14 @@ static WordMap *get_map_from_cache(const char *file) {
return NULLPTR;
}

if(likely(is.good())) {
while(likely(is.good())) {
string lbuf;
while(getline(is, lbuf), likely(is.good())) {
string::size_type p(lbuf.find('='));
if(p == string::npos) {
continue;
}
(*cf)[lbuf.substr(0, p)].assign(lbuf, p + 1, string::npos);
getline(is, lbuf);
string::size_type p(lbuf.find('='));
if(p == string::npos) {
continue;
}
(*cf)[lbuf.substr(0, p)].assign(lbuf, p + 1, string::npos);
}
is.close();
return cf;
Expand Down
26 changes: 14 additions & 12 deletions src/eixTk/utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,22 +91,24 @@ static bool pushback_lines_file(const char *file, LineVec *v, bool keep_empty, e
}
return false;
}
if(likely(ifstr.good())) {
while(getline(ifstr, line), likely(ifstr.good())) {
if(keep_comments <= 0) {
string::size_type x(line.find('#'));
if(unlikely(x != string::npos)) {
if(likely((keep_comments == 0) || (x != 0))) {
line.erase(x);
}
while(likely(ifstr.good())) {
getline(ifstr, line);
if(unlikely(line.empty() && unlikely(!ifstr.good()))) {
break;
}
if(keep_comments <= 0) {
string::size_type x(line.find('#'));
if(unlikely(x != string::npos)) {
if(likely((keep_comments == 0) || (x != 0))) {
line.erase(x);
}
}
}

trim(&line);
trim(&line);

if(keep_empty || (!line.empty())) {
v->push_back(line);
}
if(keep_empty || (!line.empty())) {
v->push_back(line);
}
}
if(likely(ifstr.eof())) { // if we have eof, everything went well
Expand Down

0 comments on commit 03cb4f2

Please sign in to comment.