[cfe-commits] r82043 - /cfe/trunk/lib/Lex/PPMacroExpansion.cpp

Benjamin Kramer benny.kra at googlemail.com
Wed Sep 16 06:10:04 PDT 2009


Author: d0k
Date: Wed Sep 16 08:10:04 2009
New Revision: 82043

URL: http://llvm.org/viewvc/llvm-project?rev=82043&view=rev
Log:
PR4991: Properly remove trailing newline from __TIMESTAMP__.
Replace strcpy with memcpy while at it.

Modified:
    cfe/trunk/lib/Lex/PPMacroExpansion.cpp

Modified: cfe/trunk/lib/Lex/PPMacroExpansion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPMacroExpansion.cpp?rev=82043&r1=82042&r2=82043&view=diff

==============================================================================
--- cfe/trunk/lib/Lex/PPMacroExpansion.cpp (original)
+++ cfe/trunk/lib/Lex/PPMacroExpansion.cpp Wed Sep 16 08:10:04 2009
@@ -622,9 +622,9 @@
       Result = "??? ??? ?? ??:??:?? ????\n";
     }
     TmpBuffer[0] = '"';
-    strcpy(TmpBuffer+1, Result);
-    unsigned Len = strlen(TmpBuffer);
-    TmpBuffer[Len] = '"';  // Replace the newline with a quote.
+    unsigned Len = strlen(Result);
+    memcpy(TmpBuffer+1, Result, Len-1); // Copy string without the newline.
+    TmpBuffer[Len] = '"';
     Tok.setKind(tok::string_literal);
     CreateString(TmpBuffer, Len+1, Tok, Tok.getLocation());
   } else if (II == Ident__COUNTER__) {





More information about the cfe-commits mailing list