changeset 742:fc8f0e61bc42

Fixed building of time_str.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Sat, 09 Feb 2008 18:53:59 +0100
parents 35184354a502
children 764f660e3909
files trunk/src/cmd/DDoc.d trunk/src/dil/lexer/Lexer.d
diffstat 2 files changed, 7 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/trunk/src/cmd/DDoc.d	Sat Feb 09 16:18:53 2008 +0100
+++ b/trunk/src/cmd/DDoc.d	Sat Feb 09 18:53:59 2008 +0100
@@ -60,12 +60,14 @@
 
     // Generate documentation.
     auto dest = new FilePath(destDir);
-    generateDocumentation(dest, mod, mtable, incUndoc, verbose);
+    dest.append(mod.getFQN() ~ ".html");
+    if (verbose)
+      Stdout.formatln("{} > {}", mod.filePath, dest);
+    writeDocFile(dest, mod, mtable, incUndoc);
   }
 }
 
-void generateDocumentation(FilePath dest, Module mod, MacroTable mtable,
-                           bool incUndoc, bool verbose)
+void writeDocFile(string dest, Module mod, MacroTable mtable, bool incUndoc)
 {
   // Create a macro environment for this module.
   mtable = new MacroTable(mtable);
@@ -76,7 +78,7 @@
   time_t time_val;
   time(&time_val);
   char* str = ctime(&time_val);
-  char[] time_str = str[0 .. strlen(str)];
+  char[] time_str = str[0 .. strlen(str)-1]; // -1 removes trailing '\n'.
   mtable.insert("DATETIME", time_str.dup);
   mtable.insert("YEAR", time_str[20..24].dup);
 
@@ -87,9 +89,6 @@
   // Do the macro expansion pass.
   auto fileText = expandMacros(mtable, "$(DDOC)");
   // Finally write the file out to the harddisk.
-  dest.append(mod.getFQN() ~ ".html");
-  if (verbose)
-    Stdout.formatln("{} > {}", mod.filePath, dest);
   auto file = new File(dest);
   file.write(fileText);
 }
--- a/trunk/src/dil/lexer/Lexer.d	Sat Feb 09 16:18:53 2008 +0100
+++ b/trunk/src/dil/lexer/Lexer.d	Sat Feb 09 18:53:59 2008 +0100
@@ -142,7 +142,7 @@
       time_t time_val;
       time(&time_val);
       char* str = ctime(&time_val);
-      char[] time_str = str[0 .. strlen(str)];
+      char[] time_str = str[0 .. strlen(str)-1]; // -1 removes trailing '\n'.
       switch (t.kind)
       {
       case TOK.DATE: