Edit

kc3-lang/angle/src/compiler/preprocessor/Input.cpp

Branch :

  • Show log

    Commit

  • Author : Jamie Madill
    Date : 2015-08-17 16:51:33
    Hash : 3b040eb8
    Message : Revert "Add full support for line continuation in the preprocessor" Warning in the Linux/Mac builders: In file included from ../../third_party/angle/src/tests/preprocessor_tests/input_test.cpp:7: In file included from ../../third_party/angle/src/tests/preprocessor_tests/PreprocessorTest.h:7: ../../testing/gtest/include/gtest/gtest.h:1392:16: error: comparison of integers of different signs: 'const int' and 'const unsigned long' [-Werror,-Wsign-compare] if (expected == actual) { ~~~~~~~~ ^ ~~~~~~ ../../testing/gtest/include/gtest/gtest.h:1422:12: note: in instantiation of function template specialization 'testing::internal::CmpHelperEQ<int, unsigned long>' requested here return CmpHelperEQ(expected_expression, actual_expression, expected, ^ ../../third_party/angle/src/tests/preprocessor_tests/input_test.cpp:171:5: note: in instantiation of function template specialization 'testing::internal::EqHelper<false>::Compare<int, unsigned long>' requested here EXPECT_EQ(3, input.read(buf, maxSize, &lineNo)); ^ BUG=angleproject:1125 This reverts commit c1157d1963170c7411eb6c32e2b2fbce02c5a170. Change-Id: Ic6fa286d190b006cccc5154d86e21ecc03175763 Reviewed-on: https://chromium-review.googlesource.com/294080 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>

  • src/compiler/preprocessor/Input.cpp
  • //
    // Copyright (c) 2011 The ANGLE Project Authors. All rights reserved.
    // Use of this source code is governed by a BSD-style license that can be
    // found in the LICENSE file.
    //
    
    #include "Input.h"
    
    #include <algorithm>
    #include <cassert>
    #include <cstring>
    
    namespace pp
    {
    
    Input::Input() : mCount(0), mString(0)
    {
    }
    
    Input::Input(size_t count, const char *const string[], const int length[]) :
        mCount(count),
        mString(string)
    {
        mLength.reserve(mCount);
        for (size_t i = 0; i < mCount; ++i)
        {
            int len = length ? length[i] : -1;
            mLength.push_back(len < 0 ? std::strlen(mString[i]) : len);
        }
    }
    
    size_t Input::read(char *buf, size_t maxSize)
    {
        size_t nRead = 0;
        while ((nRead < maxSize) && (mReadLoc.sIndex < mCount))
        {
            size_t size = mLength[mReadLoc.sIndex] - mReadLoc.cIndex;
            size = std::min(size, maxSize);
            std::memcpy(buf + nRead, mString[mReadLoc.sIndex] + mReadLoc.cIndex, size);
            nRead += size;
            mReadLoc.cIndex += size;
    
            // Advance string if we reached the end of current string.
            if (mReadLoc.cIndex == mLength[mReadLoc.sIndex])
            {
                ++mReadLoc.sIndex;
                mReadLoc.cIndex = 0;
            }
        }
        return nRead;
    }
    
    }  // namespace pp