diff trunk/src/dil/Messages.d @ 391:33b566df6af4

Migrated project to Tango. Decremented the numbers of the format placeholders in the localized messages by one. Replaced all instances of writef/ln with Stdout. Added module common.d with string aliases and a global Layout!(char) instance. Replaced %s format specifiers with index placeholders in html/xml_tags. Changed member Information.arguments to string message. Copied std.metastring, std.uni and std.utf from Phobos.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Sat, 15 Sep 2007 17:12:26 +0200
parents 4d36eea1bbc9
children 6440da4adb07
line wrap: on
line diff
--- a/trunk/src/dil/Messages.d	Wed Sep 12 21:03:41 2007 +0200
+++ b/trunk/src/dil/Messages.d	Sat Sep 15 17:12:26 2007 +0200
@@ -4,7 +4,7 @@
 +/
 module dil.Messages;
 import dil.Settings;
-import std.stdarg;
+import common;
 
 /// Index into table of compiler messages.
 enum MID
@@ -76,41 +76,17 @@
   return GlobalSettings.messages[mid];
 }
 
-char[] format(MID mid, ...)
+char[] FormatMsg(MID mid, ...)
 {
-  auto args = arguments(_arguments, _argptr);
-  return format_args(GetMsg(mid), args);
-}
-
-char[] format(char[] format_str, ...)
-{
-  auto args = arguments(_arguments, _argptr);
-  return format_args(format_str, args);
+  return Format(_arguments, _argptr, GetMsg(mid));
 }
 
-char[] format_args(char[] format_str, char[][] args)
-{
-  char[] result = format_str;
-
-  foreach (i, arg; args)
-    result = std.string.replace(result, std.string.format("{%s}", i+1), arg);
-
-  return result;
-}
-
-char[][] arguments(TypeInfo[] tinfos, void* argptr)
+/+
+char[] FormatArray(char[] format_str, char[][] args)
 {
-  char[][] args;
-  foreach (ti; tinfos)
-  {
-    if (ti == typeid(char[]))
-      args ~= va_arg!(char[])(argptr);
-    else if (ti == typeid(int))
-      args ~= std.string.format(va_arg!(int)(argptr));
-    else if (ti == typeid(dchar))
-      args ~= std.string.format(va_arg!(dchar)(argptr));
-    else
-      assert(0, "argument type not supported yet.");
-  }
-  return args;
+  auto tiinfos = new TypeInfo[args.length];
+  foreach (ref tiinfo; tiinfos)
+    tiinfo = typeid(char[]);
+  return Format(tiinfos, args.ptr, format_str);
 }
++/