From 3f75b57b9e8f799351352af34bdcdae91d6cffc5 Mon Sep 17 00:00:00 2001 From: Kiith-Sa Date: Thu, 27 Dec 2012 22:20:45 +0100 Subject: [PATCH] yaml_stats example DMD 2.061 compatibility. --- examples/yaml_stats/yaml_stats.d | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/examples/yaml_stats/yaml_stats.d b/examples/yaml_stats/yaml_stats.d index 8e60c58..2107d39 100644 --- a/examples/yaml_stats/yaml_stats.d +++ b/examples/yaml_stats/yaml_stats.d @@ -57,16 +57,20 @@ string statistics(ref Node document) string tagStats = "\nTag statistics:\n"; foreach(tag, count; tags) { - tagStats ~= format("\n", tag, " : ", count); + tagStats ~= format("\n%s : %s", tag, count); } - return format( "\nNodes: ", nodes, - "\n\nScalars: ", scalars, - "\nSequences: ", sequences, - "\nMappings: ", mappings, - "\n\nAverage sequence length: ", cast(real)seqItems / sequences, - "\nAverage mapping length: ", cast(real)mapPairs / mappings, - "\n\n", tagStats); + return format( "\nNodes: %s" ~ + "\n\nScalars: %s" ~ + "\nSequences: %s" ~ + "\nMappings: %s" ~ + "\n\nAverage sequence length: %s" ~ + "\nAverage mapping length: %s" ~ + "\n\n%s", + nodes, scalars, sequences, mappings, + sequences == 0.0 ? 0.0 : cast(real)seqItems / sequences, + mappings == 0.0 ? 0.0 : cast(real)mapPairs / mappings, + tagStats); } void main(string[] args)