+/* Check syntax is "(string-literal)". Returns 0 on success. */
+static int
+get__Pragma_string (pfile, string)
+ cpp_reader *pfile;
+ cpp_token *string;
+{
+ cpp_token paren;
+
+ cpp_get_token (pfile, &paren);
+ if (paren.type != CPP_OPEN_PAREN)
+ return 1;
+
+ cpp_get_token (pfile, string);
+ if (string->type != CPP_STRING && string->type != CPP_WSTRING)
+ return 1;
+
+ cpp_get_token (pfile, &paren);
+ return paren.type != CPP_CLOSE_PAREN;
+}
+
+/* Returns a malloced buffer containing a destringized cpp_string by
+ removing the first \ of \" and \\ sequences. */
+static unsigned char *
+destringize (in, len)
+ const cpp_string *in;
+ unsigned int *len;
+{
+ const unsigned char *src, *limit;
+ unsigned char *dest, *result;
+
+ dest = result = (unsigned char *) xmalloc (in->len);
+ for (src = in->text, limit = src + in->len; src < limit;)
+ {
+ /* We know there is a character following the backslash. */
+ if (*src == '\\' && (src[1] == '\\' || src[1] == '"'))
+ src++;
+ *dest++ = *src++;
+ }
+
+ *len = dest - result;
+ return result;
+}
+
+void
+_cpp_do__Pragma (pfile)
+ cpp_reader *pfile;
+{
+ cpp_token string;
+ unsigned char *buffer;
+ unsigned int len;
+
+ if (get__Pragma_string (pfile, &string))
+ {
+ cpp_error (pfile, "_Pragma takes a parenthesized string literal");
+ return;
+ }
+
+ buffer = destringize (&string.val.str, &len);
+ run_directive (pfile, T_PRAGMA, (char *) buffer, len, _("<_Pragma>"));
+ free ((PTR) buffer);
+}
+