📄 cccp.i
字号:
in_fname = 0L; out_fname = 0L; dollars_in_ident = 1; initialize_char_syntax (); dollars_in_ident = 1 > 0; no_line_commands = 0; no_trigraphs = 1; dump_macros = dump_none; no_output = 0; cplusplus = 0; cplusplus_comments = 0; bzero (pend_files, argc * sizeof (char *)); bzero (pend_defs, argc * sizeof (char *)); bzero (pend_undefs, argc * sizeof (char *)); bzero (pend_assertions, argc * sizeof (char *)); bzero (pend_includes, argc * sizeof (char *)); for (i = 1; i < argc; i++) { if (argv[i][0] != '-') { if (out_fname != 0L) fatal ("Usage: %s [switches] input output", argv[0]); else if (in_fname != 0L) out_fname = argv[i]; else in_fname = argv[i]; } else { switch (argv[i][1]) { case 'i': if (!strcmp (argv[i], "-include")) { if (i + 1 == argc) fatal ("Filename missing after -include option"); else pend_includes[i] = argv[i+1], i++; } if (!strcmp (argv[i], "-imacros")) { if (i + 1 == argc) fatal ("Filename missing after -imacros option"); else pend_files[i] = argv[i+1], i++; } if (!strcmp (argv[i], "-iprefix")) { if (i + 1 == argc) fatal ("Filename missing after -iprefix option"); else include_prefix = argv[++i]; } if (!strcmp (argv[i], "-idirafter")) { struct file_name_list *dirtmp; dirtmp = (struct file_name_list *) xmalloc (sizeof (struct file_name_list)); dirtmp->next = 0; dirtmp->control_macro = 0; if (i + 1 == argc) fatal ("Directory name missing after -idirafter option"); else dirtmp->fname = argv[++i]; if (after_include == 0) after_include = dirtmp; else last_after_include->next = dirtmp; last_after_include = dirtmp; } break; case 'o': if (out_fname != 0L) fatal ("Output filename specified twice"); if (i + 1 == argc) fatal ("Filename missing after -o option"); out_fname = argv[++i]; if (!strcmp (out_fname, "-")) out_fname = ""; break; case 'p': if (!strcmp (argv[i], "-pedantic")) pedantic = 1; else if (!strcmp (argv[i], "-pedantic-errors")) { pedantic = 1; pedantic_errors = 1; } else if (!strcmp (argv[i], "-pcp")) { char *pcp_fname = argv[++i]; pcp_outfile = ((pcp_fname[0] != '-' || pcp_fname[1] != '\0') ? fopen (pcp_fname, "w") : fdopen (dup ((((&_iob[1]))->_file)), "w")); if (pcp_outfile == 0) pfatal_with_name (pcp_fname); no_precomp = 1; } break; case 't': if (!strcmp (argv[i], "-traditional")) { traditional = 1; if (dollars_in_ident > 0) dollars_in_ident = 1; } else if (!strcmp (argv[i], "-trigraphs")) { no_trigraphs = 0; } break; case 'l': if (! strcmp (argv[i], "-lang-c")) cplusplus = 0, cplusplus_comments = 0, objc = 0; if (! strcmp (argv[i], "-lang-c++")) cplusplus = 1, cplusplus_comments = 1, objc = 0; if (! strcmp (argv[i], "-lang-objc")) objc = 1, cplusplus = 0, cplusplus_comments = 1; if (! strcmp (argv[i], "-lang-objc++")) objc = 1, cplusplus = 1, cplusplus_comments = 1; if (! strcmp (argv[i], "-lang-asm")) lang_asm = 1; if (! strcmp (argv[i], "-lint")) lint = 1; break; case '+': cplusplus = 1, cplusplus_comments = 1; break; case 'w': inhibit_warnings = 1; break; case 'W': if (!strcmp (argv[i], "-Wtrigraphs")) warn_trigraphs = 1; else if (!strcmp (argv[i], "-Wno-trigraphs")) warn_trigraphs = 0; else if (!strcmp (argv[i], "-Wcomment")) warn_comments = 1; else if (!strcmp (argv[i], "-Wno-comment")) warn_comments = 0; else if (!strcmp (argv[i], "-Wcomments")) warn_comments = 1; else if (!strcmp (argv[i], "-Wno-comments")) warn_comments = 0; else if (!strcmp (argv[i], "-Wtraditional")) warn_stringify = 1; else if (!strcmp (argv[i], "-Wno-traditional")) warn_stringify = 0; else if (!strcmp (argv[i], "-Wimport")) warn_import = 1; else if (!strcmp (argv[i], "-Wno-import")) warn_import = 0; else if (!strcmp (argv[i], "-Werror")) warnings_are_errors = 1; else if (!strcmp (argv[i], "-Wno-error")) warnings_are_errors = 0; else if (!strcmp (argv[i], "-Wall")) { warn_trigraphs = 1; warn_comments = 1; } break; case 'M': if (!strcmp (argv[i], "-M")) print_deps = 2; else if (!strcmp (argv[i], "-MM")) print_deps = 1; else if (!strcmp (argv[i], "-MD")) print_deps = 2; else if (!strcmp (argv[i], "-MMD")) print_deps = 1; if (!strcmp (argv[i], "-MD") || !strcmp (argv[i], "-MMD")) { i++; deps_file = argv[i]; } else { deps_stream = (&_iob[1]); inhibit_output = 1; } break; case 'd': { char *p = argv[i] + 2; char c; while (c = *p++) { switch (c) { case 'M': dump_macros = dump_only; no_output = 1; break; case 'N': dump_macros = dump_names; break; case 'D': dump_macros = dump_definitions; break; } } } break; case 'g': if (argv[i][2] == '3') debug_output = 1; break; case 'v': fprintf ((&_iob[2]), "GNU CPP version %s", version_string); ; fprintf ((&_iob[2]), "\n"); break; case 'H': print_include_names = 1; break; case 'D': { char *p, *p1; if (argv[i][2] != 0) p = argv[i] + 2; else if (i + 1 == argc) fatal ("Macro name missing after -D option"); else p = argv[++i]; pend_defs[i] = p; } break; case 'A': { char *p, *p1; if (argv[i][2] != 0) p = argv[i] + 2; else if (i + 1 == argc) fatal ("Assertion missing after -A option"); else p = argv[++i]; if (!strcmp (p, "-")) { int j; inhibit_predefs = 1; for (j = 0; j < i; j++) pend_defs[j] = pend_assertions[j] = 0; } else { pend_assertions[i] = p; pend_assertion_options[i] = "-A"; } } break; case 'U': if (argv[i][2] != 0) pend_undefs[i] = argv[i] + 2; else if (i + 1 == argc) fatal ("Macro name missing after -U option"); else pend_undefs[i] = argv[i+1], i++; break; case 'C': put_out_comments = 1; break; case 'E': break; case 'P': no_line_commands = 1; break; case '$': dollars_in_ident = 0; break; case 'I': { struct file_name_list *dirtmp; if (! ignore_srcdir && !strcmp (argv[i] + 2, "-")) { ignore_srcdir = 1; first_bracket_include = 0; } else { dirtmp = (struct file_name_list *) xmalloc (sizeof (struct file_name_list)); dirtmp->next = 0; dirtmp->control_macro = 0; if (argv[i][2] != 0) dirtmp->fname = argv[i] + 2; else if (i + 1 == argc) fatal ("Directory name missing after -I option"); else dirtmp->fname = argv[++i]; append_include_chain (dirtmp, dirtmp); } } break; case 'n': if (!strcmp (argv[i], "-nostdinc")) no_standard_includes = 1; else if (!strcmp (argv[i], "-nostdinc++")) no_standard_cplusplus_includes = 1; else if (!strcmp (argv[i], "-noprecomp")) no_precomp = 1; break; case 'u': inhibit_predefs = 1; break; case '\0': if (in_fname == 0L) { in_fname = ""; break; } else if (out_fname == 0L) { out_fname = ""; break; } default: fatal ("Invalid option `%s'", argv[i]); } } } p = (char *) getenv ("CPATH"); if (p != 0 && ! no_standard_includes) path_include (p); initialize_char_syntax (); outbuf.buf = (U_CHAR *) xmalloc (10 ); outbuf.bufp = outbuf.buf; outbuf.length = 10 ; fp = &instack[++indepth]; if (in_fname == 0L) in_fname = ""; fp->nominal_fname = fp->fname = in_fname; fp->lineno = 0; initialize_builtins (fp, &outbuf); if (!inhibit_predefs) { char *p = (char *) alloca (strlen (predefs) + 1); strcpy (p, predefs); while (*p) { char *q; while (*p == ' ' || *p == '\t') p++; if (p[0] == '-' && p[1] == 'D') { q = &p[2]; while (*p && *p != ' ' && *p != '\t') p++; if (*p != 0) *p++= 0; if (debug_output) output_line_command (fp, &outbuf, 0, same_file); make_definition (q, &outbuf); while (*p == ' ' || *p == '\t') p++; } else if (p[0] == '-' && p[1] == 'A') { char *assertion; char *past_name; char *value; char *past_value; char *termination; int save_char; assertion = &p[2]; past_name = assertion; while (*past_name && *past_name != ' ' && *past_name != '\t' && *past_name != '(') past_name++; value = past_name; while (*value && (*value == ' ' || *value == '\t')) value++; if (*value++ != '(') abort (); while (*value && (*value == ' ' || *value == '\t')) value++; past_value = value; while (*past_value && *past_value != ' ' && *past_value != '\t' && *past_value != ')') past_value++; termination = past_value; while (*termination && (*termination == ' ' || *termination == '\t')) termination++; if (*termination++ != ')') abort (); if (*termination && *termination != ' ' && *termination != '\t') abort (); save_char = *termination; *termination = '\0'; make_assertion ("-A", assertion); *termination = (char) save_char; p = termination; while (*p == ' ' || *p == '\t') p++; } else { abort (); } } } for (i = 1; i < argc; i++) { if (pend_undefs[i]) { if (debug_output) output_line_command (fp, &outbuf, 0, same_file); make_undef (pend_undefs[i], &outbuf); } if (pend_defs[i]) { if (debug_output) output_line_command (fp, &outbuf, 0, same_file); make_definition (pend_defs[i], &outbuf); } if (pend_assertions[i]) make_assertion (pend_assertion_options[i], pend_assertions[i]); } done_initializing = 1; { char *epath = 0; switch ((objc << 1) + cplusplus) { case 0: epath = getenv ("C_INCLUDE_PATH"); break; case 1: epath = getenv ("CPLUS_INCLUDE_PATH"); break; case 2: epath = getenv ("OBJC_INCLUDE_PATH"); break; case 3: epath = getenv ("OBJCPLUS_INCLUDE_PATH"); break; } if (epath) { char *nstore = (char *) alloca (strlen (epath) + 2); int num_dirs; char *startp, *endp; for (num_dirs = 1, startp = epath; *startp; startp++) if (*startp == ':') num_dirs++; include_defaults = (struct default_include *) xmalloc ((num_dirs * sizeof (struct default_include)) + sizeof (include_defaults_array)); startp = endp = epath; num_dirs = 0; while (1) { if ((*endp == ':' ) || *endp == 0) { strncpy (nstore, startp, endp-startp); if (endp == startp) strcpy (nstore, "."); else nstore[endp-startp] = '\0'; include_defaults[num_dirs].fname = savestring (nstore); include_defaults[num_dirs].cplusplus = cplusplus; num_dirs++; if (*endp == '\0') break; endp = startp = endp + 1; } else endp++; } bcopy (include_defaults_array, &include_defaults[num_dirs], sizeof (include_defaults_array)); } } first_system_include = 0; if (!no_standard_includes) { struct default_include *p = include_defaults; char *specd_prefix = include_prefix; char *default_prefix = savestring ("/usr/local/bin"); int default_len = 0; if (!strcmp (default_prefix + strlen (default_prefix) - 8, "/include")) { default_len = strlen (default_prefix) - 7; default_prefix[default_len] = 0; } if (specd_prefix != 0 && default_len != 0) for (p = include_defaults; p->fname; p++) { if (!p->cplusplus || (cplusplus && !no_standard_cplusplus_includes)) { if (!strncmp (p->fname, default_prefix, default_len)) { struct file_name_list *new = (struct file_name_list *) xmalloc (sizeof (struct file_name_list)); int this_len = strlen (specd_prefix) + strlen (p->fname) - default_len; char *str = (char *) xmalloc (this_len + 1); strcpy (str, specd_prefix); strcat (str, p->fname + default_len); new->fname = str; new->control_macro = 0; append_include_chain (new, new); if (first_system_include == 0) first_system_include = new; } } } for (p = include_defaults; p->fname; p++) { if (!p->cplusplus || (cplusplus && !no_standard_cplusplus_includes)) { struct file_name_list *new = (struct file_name_list *) xmalloc (sizeof (struct file_name_list)); new->control_macro = 0; new->fname = p->fname; append_include_chain (new, new); if (first_system_include == 0) first_system_include = new; } } } append_include_chain (after_include, last_after_include); if (first_system_include == 0) first_system_include = after_include; no_output++; for (i = 1; i < argc; i++) if (pend_files[i]) { int fd = open (pend_files[i], 0, 0666); if (fd < 0) { perror_with_name (pend_files[i]); return 33 ; } finclude (fd, pend_files[i], &outbuf, 0, ((char *)0)); } no_output--; if (in_fname == 0L || *in_fname == 0) { in_fname = ""; f = 0; } else if ((f = open (in_fname, 0, 0666)) < 0) goto perror; if (print_deps == 0 && (getenv ("SUNPRO_DEPENDENCIES") != 0 || getenv ("DEPENDENCIES_OUTPUT") != 0)) { char *spec = getenv ("DEPENDENCIES_OUTPUT"); char *s; char *output_file; if (spec == 0) { spec = getenv ("SUNPRO_DEPENDENCIES"); print_deps = 2; } else print_deps = 1; s = spec; while (*s != 0 && *s != ' ') s++; if (*s != 0) { deps_target = s + 1; output_file = (char *) xmalloc (s - spec + 1); bcopy (spec, output_file, s - spec);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -