+/* Sets internal flags correctly for a given language, and defines
+ macros if necessary. */
+static void
+set_lang (pfile, lang)
+ cpp_reader *pfile;
+ enum c_lang lang;
+{
+ struct cpp_pending *pend = CPP_OPTION (pfile, pending);
+
+ /* Defaults. */
+ CPP_OPTION (pfile, lang) = lang;
+ CPP_OPTION (pfile, objc) = 0;
+ CPP_OPTION (pfile, cplusplus) = 0;
+ CPP_OPTION (pfile, extended_numbers) = 1; /* Allowed in GNU C and C99. */
+
+ switch (lang)
+ {
+ /* GNU C. */
+ case CLK_GNUC99:
+ CPP_OPTION (pfile, trigraphs) = 0;
+ CPP_OPTION (pfile, dollars_in_ident) = 1;
+ CPP_OPTION (pfile, cplusplus_comments) = 1;
+ CPP_OPTION (pfile, digraphs) = 1;
+ CPP_OPTION (pfile, c99) = 1;
+ new_pending_directive (pend, "__STDC_VERSION__=199901L", cpp_define);
+ break;
+ case CLK_GNUC89:
+ CPP_OPTION (pfile, trigraphs) = 0;
+ CPP_OPTION (pfile, dollars_in_ident) = 1;
+ CPP_OPTION (pfile, cplusplus_comments) = 1;
+ CPP_OPTION (pfile, digraphs) = 1;
+ CPP_OPTION (pfile, c99) = 0;
+ break;
+
+ /* ISO C. */
+ case CLK_STDC94:
+ new_pending_directive (pend, "__STDC_VERSION__=199409L", cpp_define);
+ case CLK_STDC89:
+ CPP_OPTION (pfile, trigraphs) = 1;
+ CPP_OPTION (pfile, dollars_in_ident) = 0;
+ CPP_OPTION (pfile, cplusplus_comments) = 0;
+ CPP_OPTION (pfile, digraphs) = lang == CLK_STDC94;
+ CPP_OPTION (pfile, c99) = 0;
+ CPP_OPTION (pfile, extended_numbers) = 0;
+ new_pending_directive (pend, "__STRICT_ANSI__", cpp_define);
+ break;
+ case CLK_STDC99:
+ CPP_OPTION (pfile, trigraphs) = 1;
+ CPP_OPTION (pfile, dollars_in_ident) = 0;
+ CPP_OPTION (pfile, cplusplus_comments) = 1;
+ CPP_OPTION (pfile, digraphs) = 1;
+ CPP_OPTION (pfile, c99) = 1;
+ new_pending_directive (pend, "__STRICT_ANSI__", cpp_define);
+ new_pending_directive (pend, "__STDC_VERSION__=199901L", cpp_define);
+ break;
+
+ /* Objective C. */
+ case CLK_OBJCXX:
+ new_pending_directive (pend, "__cplusplus", cpp_define);
+ CPP_OPTION (pfile, cplusplus) = 1;
+ case CLK_OBJC:
+ CPP_OPTION (pfile, trigraphs) = 0;
+ CPP_OPTION (pfile, dollars_in_ident) = 1;
+ CPP_OPTION (pfile, cplusplus_comments) = 1;
+ CPP_OPTION (pfile, digraphs) = 1;
+ CPP_OPTION (pfile, c99) = 0;
+ CPP_OPTION (pfile, objc) = 1;
+ new_pending_directive (pend, "__OBJC__", cpp_define);
+ break;
+
+ /* C++. */
+ case CLK_GNUCXX:
+ case CLK_CXX98:
+ CPP_OPTION (pfile, cplusplus) = 1;
+ CPP_OPTION (pfile, trigraphs) = lang == CLK_CXX98;
+ CPP_OPTION (pfile, dollars_in_ident) = lang == CLK_GNUCXX;
+ CPP_OPTION (pfile, cplusplus_comments) = 1;
+ CPP_OPTION (pfile, digraphs) = 1;
+ CPP_OPTION (pfile, c99) = 0;
+ new_pending_directive (pend, "__cplusplus", cpp_define);
+ break;
+
+ /* Assembler. */
+ case CLK_ASM:
+ CPP_OPTION (pfile, trigraphs) = 0;
+ CPP_OPTION (pfile, dollars_in_ident) = 0; /* Maybe not? */
+ CPP_OPTION (pfile, cplusplus_comments) = 1;
+ CPP_OPTION (pfile, digraphs) = 0;
+ CPP_OPTION (pfile, c99) = 0;
+ new_pending_directive (pend, "__ASSEMBLER__", cpp_define);
+ break;
+ }
+}
+
+#ifdef HOST_EBCDIC
+static int opt_comp PARAMS ((const void *, const void *));