// -*- C++ -*- // Boost general library 'format' --------------------------- // See http://www.boost.org for updates, documentation, and revision history. // (C) Samuel Krempp 2001 // krempp@crans.ens-cachan.fr // Permission to copy, use, modify, sell and // distribute this software is granted provided this copyright notice appears // in all copies. This software is provided "as is" without express or implied // warranty, and with no claim as to its suitability for any purpose. // ideas taken from Rüdiger Loos's format class // and Karl Nelson's ofstream // ---------------------------------------------------------------------------- // internals.hpp : internal structs. included by format.hpp // stream_format_state, and format_item // ---------------------------------------------------------------------------- #ifndef BOOST_FORMAT_INTERNALS_HPP #define BOOST_FORMAT_INTERNALS_HPP #include #include namespace boost { namespace io { namespace detail { // -------------- // set of params that define the format state of a stream struct stream_format_state { typedef std::ios basic_ios; std::streamsize width_; std::streamsize precision_; char fill_; std::ios::fmtflags flags_; stream_format_state() : width_(-1), precision_(-1), fill_(0), flags_(std::ios::dec) {} stream_format_state(basic_ios& os) {set_by_stream(os); } void apply_on(basic_ios & os) const; //- applies format_state to the stream template void apply_manip(T manipulator) //- modifies state by applying manipulator. { apply_manip_body( *this, manipulator) ; } void reset(); //- sets to default state. void set_by_stream(const basic_ios& os); //- sets to os's state. }; // -------------- // format_item : stores all parameters that can be defined by directives in the format-string struct format_item { enum pad_values { zeropad = 1, spacepad =2, centered=4, tabulation = 8 }; enum arg_values { argN_no_posit = -1, // non-positional directive. argN will be set later. argN_tabulation = -2, // tabulation directive. (no argument read) argN_ignored = -3 // ignored directive. (no argument read) }; typedef BOOST_IO_STD ios basic_ios; typedef detail::stream_format_state stream_format_state; typedef std::string string_t; typedef BOOST_IO_STD ostringstream internal_stream_t; int argN_; //- argument number (starts at 0, eg : %1 => argN=0) // negative values are used for items that don't process // an argument string_t res_; //- result of the formatting of this item string_t appendix_; //- piece of string between this item and the next stream_format_state ref_state_;// set by parsing the format_string, is only affected by modify_item stream_format_state state_; // always same as ref_state, _unless_ modified by manipulators 'group(..)' // non-stream format-state parameters signed int truncate_; //- is >=0 for directives like %.5s (take 5 chars from the string) unsigned int pad_scheme_; //- several possible padding schemes can mix. see pad_values format_item() : argN_(argN_no_posit), truncate_(-1), pad_scheme_(0) {} void compute_states(); // sets states according to truncate and pad_scheme. }; // ----------------------------------------------------------- // Definitions // ----------------------------------------------------------- // --- stream_format_state:: ------------------------------------------- inline void stream_format_state::apply_on(basic_ios & os) const // set the state of this stream according to our params { if(width_ != -1) os.width(width_); if(precision_ != -1) os.precision(precision_); if(fill_ != 0) os.fill(fill_); os.flags(flags_); } inline void stream_format_state::set_by_stream(const basic_ios& os) // set our params according to the state of this stream { flags_ = os.flags(); width_ = os.width(); precision_ = os.precision(); fill_ = os.fill(); } template inline void apply_manip_body( stream_format_state& self, T manipulator) // modify our params according to the manipulator { BOOST_IO_STD stringstream ss; self.apply_on( ss ); ss << manipulator; self.set_by_stream( ss ); } inline void stream_format_state::reset() // set our params to standard's default state { width_=-1; precision_=-1; fill_=0; flags_ = std::ios::dec; } // --- format_items:: ------------------------------------------- inline void format_item::compute_states() // reflect pad_scheme_ on state_ and ref_state_ // because some pad_schemes has complex consequences on several state params. { if(pad_scheme_ & zeropad) { if(ref_state_.flags_ & std::ios::left) { pad_scheme_ = pad_scheme_ & (~zeropad); // ignore zeropad in left alignment } else { ref_state_.fill_='0'; ref_state_.flags_ |= std::ios::internal; } } state_ = ref_state_; } } } } // namespaces boost :: io :: detail #endif // BOOST_FORMAT_INTERNALS_HPP m?id=324a2ba56c2f4c0d91567ed08024ae2c492f3b23'>tests: Adjust 'url-fetch' mocks to TLS changes....This is a followup to bc3c41ce36349ed4ec758c70b48a7059e363043a. * tests/cpan.scm ("cpan->guix-package"): Add #:verify-certificate? parameter in 'url-fetch' mock. * tests/cran.scm ("description->package"): Likewise. Ludovic Courtès 2016-04-03build: Add a Guile custom test driver using SRFI-64....Before that '.log' files for scheme tests were fragmented and not included in test-suite.log. This unifies the semantics of SRFI-64 API with Automake test suite. * build-aux/test-driver.scm: New file. * Makefile.am (SCM_LOG_DRIVER, AM_SCM_LOG_DRIVER_FLAGS): New variables. (SCM_LOG_COMPILER, AM_SCM_LOG_FLAGS): Delete variables. (AM_TESTS_ENVIRONMENT): Set GUILE_AUTO_COMPILE to 0. * test-env.in: Silence guix-daemon. * doc/guix.texi (Running the Test Suite): Describe how to display the detailed results. Bug reports require only 'test-suite.log' file. * tests/base32.scm, tests/build-utils.scm, tests/builders.scm, tests/challenge.scm, tests/cpan.scm, tests/cpio.scm, tests/cran.scm, tests/cve.scm, tests/derivations.scm, tests/elpa.scm, tests/file-systems.scm, tests/gem.scm, tests/gexp.scm, tests/gnu-maintenance.scm, tests/grafts.scm, tests/graph.scm, tests/gremlin.scm, tests/hackage.scm, tests/hash.scm, tests/import-utils.scm, tests/lint.scm, tests/monads.scm, tests/nar.scm, tests/packages.scm, tests/pk-crypto.scm, tests/pki.scm, tests/profiles.scm, tests/publish.scm, tests/pypi.scm, tests/records.scm, tests/scripts-build.scm, tests/scripts.scm, tests/services.scm, tests/sets.scm, tests/size.scm, tests/snix.scm, tests/store.scm, tests/substitute.scm, tests/syscalls.scm, tests/system.scm, tests/ui.scm, tests/union.scm, tests/upstream.scm, tests/utils.scm: Don't exit at the end of test groups. * tests/containers.scm: Likewise. Use 'test-skip' instead of exiting with error code 77. Mathieu Lirzin