Address review comments Integer output data editing (I,B,O,Z) Full integer output formatting Stub out some work in progress Progress on E output data editing E, D, EN, and ES output editing done Fw.d output editing Real G output editing G output editing for reals Make environment a distinct module CHARACTER and LOGICAL output editing Minimal decimal representations for E0, F0, G0 editing Move real output editing code into its own file Fix/dodge some GCC build problems Prep work for external I/O statement state External HELLO, WORLD Fix build problem with GCC Add virtual destructors where needed Add new test Original-commit: flang-compiler/f18@c3f1774f8e Reviewed-on: https://github.com/flang-compiler/f18/pull/950
24 lines
886 B
C++
24 lines
886 B
C++
//===-- runtime/buffer.cpp --------------------------------------*- C++ -*-===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "buffer.h"
|
|
#include <algorithm>
|
|
|
|
namespace Fortran::runtime::io {
|
|
|
|
// Here's a very old trick for shifting circular buffer data cheaply
|
|
// without a need for a temporary array.
|
|
void LeftShiftBufferCircularly(
|
|
char *buffer, std::size_t bytes, std::size_t shift) {
|
|
// Assume that we start with "efgabcd" and the left shift is 3.
|
|
std::reverse(buffer, buffer + shift); // "gfeabcd"
|
|
std::reverse(buffer, buffer + bytes); // "dcbaefg"
|
|
std::reverse(buffer, buffer + bytes - shift); // "abcdefg"
|
|
}
|
|
}
|