From a99143506dedc4432b33f11418a5f57817cae268 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 24 Jan 2017 12:59:13 +0100 Subject: [PATCH] BUG: not incrementing when reading via singly-linked list --- applications/test/List/Test-List.C | 21 +++++++++++++++++-- src/OpenFOAM/containers/Lists/List/ListIO.C | 2 +- src/OpenFOAM/containers/Lists/UList/UList.C | 2 +- src/OpenFOAM/containers/Lists/UList/UListIO.C | 14 ++++++------- 4 files changed, 28 insertions(+), 11 deletions(-) diff --git a/applications/test/List/Test-List.C b/applications/test/List/Test-List.C index 65073700ab..fc8fab5178 100644 --- a/applications/test/List/Test-List.C +++ b/applications/test/List/Test-List.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -42,7 +42,11 @@ See also #include "vector.H" #include "ListOps.H" -#include +#include "labelRange.H" +#include "ListOps.H" +#include "SubList.H" + +#include using namespace Foam; @@ -61,6 +65,19 @@ int main(int argc, char *argv[]) #include "setRootCase.H" + if (false) + { + labelList intlist(IStringStream("(0 1 2)")()); + Info<<"construct from Istream: " << intlist << endl; + + IStringStream("(3 4 5)")() >> static_cast(intlist); + Info<<"is >>: " << intlist << endl; + + IStringStream("(6 7 8)")() >> intlist; + Info<<"is >>: " << intlist << endl; + } + + List list1(IStringStream("1 ((0 1 2))")()); Info<< "list1: " << list1 << endl; diff --git a/src/OpenFOAM/containers/Lists/List/ListIO.C b/src/OpenFOAM/containers/Lists/List/ListIO.C index bbc55ec10d..6229cb9490 100644 --- a/src/OpenFOAM/containers/Lists/List/ListIO.C +++ b/src/OpenFOAM/containers/Lists/List/ListIO.C @@ -64,7 +64,7 @@ Foam::Istream& Foam::operator>>(Istream& is, List& L) } else if (firstToken.isLabel()) { - label s = firstToken.labelToken(); + const label s = firstToken.labelToken(); // Set list length to that read L.setSize(s); diff --git a/src/OpenFOAM/containers/Lists/UList/UList.C b/src/OpenFOAM/containers/Lists/UList/UList.C index 52177d79bc..320b22f68f 100644 --- a/src/OpenFOAM/containers/Lists/UList/UList.C +++ b/src/OpenFOAM/containers/Lists/UList/UList.C @@ -183,7 +183,7 @@ bool Foam::UList::operator<(const UList& a) const ( const_iterator vi = begin(), ai = a.begin(); vi < end() && ai < a.end(); - vi++, ai++ + ++vi, ++ai ) { if (*vi < *ai) diff --git a/src/OpenFOAM/containers/Lists/UList/UListIO.C b/src/OpenFOAM/containers/Lists/UList/UListIO.C index a4648137cf..0559a63adc 100644 --- a/src/OpenFOAM/containers/Lists/UList/UListIO.C +++ b/src/OpenFOAM/containers/Lists/UList/UListIO.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -165,7 +165,7 @@ Foam::Istream& Foam::operator>>(Istream& is, UList& L) ) ); // Check list length - label s = elems.size(); + const label s = elems.size(); if (s != L.size()) { @@ -174,14 +174,14 @@ Foam::Istream& Foam::operator>>(Istream& is, UList& L) << " expected " << L.size() << exit(FatalIOError); } - for (label i=0; i>(Istream& is, UList& L) { if (delimiter == token::BEGIN_LIST) { - for (label i=0; i> L[i]; @@ -226,7 +226,7 @@ Foam::Istream& Foam::operator>>(Istream& is, UList& L) "reading the single entry" ); - for (label i=0; i>(Istream& is, UList& L) ( typename SLList::const_iterator iter = sll.begin(); iter != sll.end(); - ++iter + ++iter, ++i ) { L[i] = iter();