anchor.diff:  -author('matthias@corelatus.se').
   %% And thanks to Chris Newcombe for a bug fix 
   -export([format/3, print/2, fprint/2, safe/2]).               % interface functions
  +-version("$Id: trunc_io.erl,v 1.11 2009-02-23 12:01:06 matthias Exp $").
  +
  +-ifdef(TEST).
   -export([perf/0, perf/3, perf1/0, test/0, test/2]). % testing functions
  --version("$Id: trunc_io.erl,v 1.11 2009-02-23 12:01:06 matthias Exp $").
  +-include_lib("eunit/include/eunit.hrl").
  +-endif.
   
   format(String, Args, Max) ->
       Parts = re:split(String,
  
positive.code:     %% trunc_io isn't (yet) depth aware, so we can't honor this format string
      %% safely at the moment, so just treat it like a regular ~p
      %% TODO support for depth limiting
      case print(AH1, Max + 2) of
          {_Res, Max} ->
              % this isn't the last argument, but it consumed all available space
              % delay calculating the print size until the end
              format(T, AT, Max + 2, ["~s" | Acc], [{future, AH1} | ArgAcc]);
          {String, Length} ->
              format(T, AT, Max + 2 - Length, ["~s" | Acc], [String | ArgAcc])
      end;
  
negative.code:                         _ ->
                              {String, Length}
                      end,
                      format(T, AT, Max + 2 - RealLen, ["~s" | Acc], [lists:flatten(Value) | ArgAcc])
              end;
          _ ->
              % whatever, just pass them on through
  