diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 49d41e153e359b40e0fbe4b939241eed5107b220..722318fdaec934d84357151eea71821ac93ec9b6 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2005-11-03  Andrew Pinski  <pinskia@physics.uc.edu>
+
+	PR preprocessor/22042
+	* gcc.dg/cpp/strify4.c: New test.
+
 2005-11-03  Joseph S. Myers  <joseph@codesourcery.com>
 
 	PR c++/17964
diff --git a/gcc/testsuite/gcc.dg/cpp/strify4.c b/gcc/testsuite/gcc.dg/cpp/strify4.c
new file mode 100644
index 0000000000000000000000000000000000000000..b8b2f11e9d112546225c4d055ea45f0785356b59
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/cpp/strify4.c
@@ -0,0 +1,25 @@
+/* { dg-do run } */
+/* Tests we stringify without changing unprintable characts.  
+
+   Andrew Pinski */
+
+extern int strcmp (const char *, const char *);
+extern int puts (const char *);
+extern void abort (void);
+#define err(str) do { puts(str); abort(); } while (0)
+
+
+#define S(X) S2(X)
+#define S2(X) #X
+#define TAB "	" /* Note there is a tab character here. */
+
+int main (int argc, char *argv[])
+{
+  /* The space before "bar" here is vital.  */
+  char a[] = S(S(TAB));
+
+  if (strcmp (a, "\"\\\"	\\\"\""))
+    err ("stringification caused octal");
+
+  return 0;
+}
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
index c0364802678bf1667851b2b831900d092188d6b3..3a489b4c1c0bc139bb0c856e237e5059598adec9 100644
--- a/libcpp/ChangeLog
+++ b/libcpp/ChangeLog
@@ -1,3 +1,11 @@
+2005-11-03  Andrew Pinski  <pinskia@physics.uc.edu>
+
+	PR preprocessor/22042
+	* macro.c (_cpp_builtin_macro_text): Lower the needed max
+	buffer size.
+	(cpp_quote_string): Don't octalify non printable
+	charactors.
+
 2005-11-03  Joseph S. Myers  <joseph@codesourcery.com>
 
 	PR c++/17964
diff --git a/libcpp/macro.c b/libcpp/macro.c
index 13f5c76809024c6f775ce024abdcfa545ce51520..a0aa93ea994acbd5cccc23f02c862bb4ed4bb0a0 100644
--- a/libcpp/macro.c
+++ b/libcpp/macro.c
@@ -139,7 +139,7 @@ _cpp_builtin_macro_text (cpp_reader *pfile, cpp_hashnode *node)
 
 	name = map->to_file;
 	len = strlen (name);
-	buf = _cpp_unaligned_alloc (pfile, len * 4 + 3);
+	buf = _cpp_unaligned_alloc (pfile, len * 2 + 3);
 	result = buf;
 	*buf = '"';
 	buf = cpp_quote_string (buf + 1, (const unsigned char *) name, len);
@@ -292,9 +292,8 @@ builtin_macro (cpp_reader *pfile, cpp_hashnode *node)
 }
 
 /* Copies SRC, of length LEN, to DEST, adding backslashes before all
-   backslashes and double quotes.  Non-printable characters are
-   converted to octal.  DEST must be of sufficient size.  Returns
-   a pointer to the end of the string.  */
+   backslashes and double quotes. DEST must be of sufficient size.
+   Returns a pointer to the end of the string.  */
 uchar *
 cpp_quote_string (uchar *dest, const uchar *src, unsigned int len)
 {
@@ -308,15 +307,7 @@ cpp_quote_string (uchar *dest, const uchar *src, unsigned int len)
 	  *dest++ = c;
 	}
       else
-	{
-	  if (ISPRINT (c))
-	    *dest++ = c;
-	  else
-	    {
-	      sprintf ((char *) dest, "\\%03o", c);
-	      dest += 4;
-	    }
-	}
+	  *dest++ = c;
     }
 
   return dest;