Changeset 44574f2


Ignore:
Timestamp:
Jan 25, 2018, 10:27:41 PM (7 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
728df66
Parents:
b2052f7
Message:

add _Bool read and read endl-manipulator to skip whitespace

Location:
src/libcfa
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/iostream

    rb2052f7 r44574f2  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Dec 21 13:55:41 2017
    13 // Update Count     : 145
     12// Last Modified On : Thu Jan 25 13:08:39 2018
     13// Update Count     : 149
    1414//
    1515
     
    124124}; // readable
    125125
     126forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, _Bool & );
     127
    126128forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, char & );
    127129forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, signed char & );
     
    145147forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, long double _Complex & );
    146148
     149// manipulators
     150forall( dtype istype | istream( istype ) ) istype & ?|?( istype &, istype & (*)( istype & ) );
     151forall( dtype istype | istream( istype ) ) istype & endl( istype & is );
     152
    147153struct _Istream_cstrUC { char * s; };
    148154_Istream_cstrUC cstr( char * );
  • src/libcfa/iostream.c

    rb2052f7 r44574f2  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Dec 21 13:55:09 2017
    13 // Update Count     : 427
     12// Last Modified On : Thu Jan 25 13:09:28 2018
     13// Update Count     : 467
    1414//
    1515
     
    1919#include <stdio.h>
    2020#include <stdbool.h>                                                                    // true/false
    21 #include <string.h>                                                                             // strlen
     21//#include <string.h>                                                                           // strlen, strcmp
     22extern int strcmp (const char *__s1, const char *__s2) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
     23extern size_t strlen (const char *__s) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
    2224#include <float.h>                                                                              // DBL_DIG, LDBL_DIG
    2325#include <complex.h>                                                                    // creal, cimag
     
    301303
    302304forall( dtype istype | istream( istype ) )
     305istype & ?|?( istype & is, _Bool & b ) {
     306        char val[6];
     307        fmt( is, "%5s", val );
     308        if ( strcmp( val, "true" ) == 0 ) b = true;
     309        else if ( strcmp( val, "false" ) == 0 ) b = false;
     310        else {
     311                fprintf( stderr, "invalid _Bool constant\n" );
     312                abort();
     313        } // if
     314        return is;
     315} // ?|?
     316
     317forall( dtype istype | istream( istype ) )
    303318istype & ?|?( istype & is, char & c ) {
    304319        fmt( is, "%c", &c );                                                            // must pass pointer through varg to fmt
     
    410425} // ?|?
    411426
     427forall( dtype istype | istream( istype ) )
     428istype & ?|?( istype & is, istype & (* manip)( istype & ) ) {
     429        return manip( is );
     430} // ?|?
     431
     432forall( dtype istype | istream( istype ) )
     433istype & endl( istype & is ) {
     434        fmt( is, "%*[ \t\f\n\r\v]" );                                           // ignore whitespace
     435        return is;
     436} // endl
     437
    412438_Istream_cstrUC cstr( char * str ) { return (_Istream_cstrUC){ str }; }
    413439forall( dtype istype | istream( istype ) )
Note: See TracChangeset for help on using the changeset viewer.