Codegen_C::Codegen_C() : on( &main_os ), os( &main_os ) { disp_inst_graph = false; disp_inst_graph_wo_phi = false; add_include( "<stdint.h>" ); add_include( "<stdlib.h>" ); add_include( "<unistd.h>" ); add_include( "<time.h>" ); add_prel( "#pragma cpp_flag -std=c++11" ); }
MethodWriter::MethodWriter( MethodWriter *parent ) : n( parent ? parent->n.string : code ), parent( parent ) { for( int i = 0; i < nb_args_max; ++i ) type[ i ] = 0; ret_ins = "return "; machine_type = MachineId::Cpu; add_include( "Metil/Level1/Type.h" ); }
void push_include (umlclassnode *node) { if (node->key->package != NULL) { umlpackagelist pkglist = make_package_list (node->key->package); ////////////////////////////////////// // on cache pour ne pas inclure si c'est un package... // add_include (pkglist->key->name); ////////////////////////////////////// } else { add_include (node->key->name); } }
void MethodWriter::add_type_decl( const String &name ) { if ( parent ) parent->add_type_decl( name ); else { if ( ext_types.contains( name ) ) return; ST p = name.find( '_' ); String cons = p >= 0 ? name.beg_upto( p ) : name; ext_types << name; add_include( "Metil/Level1/TypeConstructor_" + cons + ".h" ); add_preliminary( "DECL_AND_DEFI_TYPE( " + cons + ", " + name + " );\n" ); } }
/******************************************************************* * parse_file */ static void parse_file( INCL_FILE *pFile, int src ) { char buffer[1024]; char *include; int line = 0; FILE *file; if (is_generated( pFile->name )) { /* file is generated during make, don't try to open it */ pFile->filename = xstrdup( pFile->name ); return; } file = src ? open_src_file( pFile ) : open_include_file( pFile ); if (!file) return; while (fgets( buffer, sizeof(buffer)-1, file )) { char quote; char *p = buffer; line++; while (*p && isspace(*p)) p++; if (*p++ != '#') continue; while (*p && isspace(*p)) p++; if (strncmp( p, "include", 7 )) continue; p += 7; while (*p && isspace(*p)) p++; if (*p != '\"' && *p != '<' ) continue; quote = *p++; if (quote == '<') quote = '>'; include = p; while (*p && (*p != quote)) p++; if (!*p) { fprintf( stderr, "%s:%d: Malformed #include directive\n", pFile->filename, line ); exit(1); } *p = 0; add_include( pFile, include, line, (quote == '>') ); } fclose(file); }
int find_includes(struct filepointer *filep, struct inclist *file, struct inclist *file_red, int recursion, boolean failOK, struct IncludesCollection* incCollection, struct symhash *symbols) { char *line; int type; boolean recfailOK; while ((line = get_line(filep))) { switch(type = deftype(line, filep, file_red, file, TRUE, symbols)) { case IF: doif: type = find_includes(filep, file, file_red, recursion+1, failOK, incCollection, symbols); while ((type == ELIF) || (type == ELIFFALSE) || (type == ELIFGUESSFALSE)) type = gobble(filep, file, file_red, symbols); if (type == ELSE) gobble(filep, file, file_red, symbols); break; case IFFALSE: case IFGUESSFALSE: doiffalse: if (type == IFGUESSFALSE || type == ELIFGUESSFALSE) recfailOK = TRUE; else recfailOK = failOK; type = gobble(filep, file, file_red, symbols); if (type == ELSE) find_includes(filep, file, file_red, recursion+1, recfailOK, incCollection, symbols); else if (type == ELIF) goto doif; else if ((type == ELIFFALSE) || (type == ELIFGUESSFALSE)) goto doiffalse; break; case IFDEF: case IFNDEF: if ((type == IFDEF && hash_lookup(line, symbols)) || (type == IFNDEF && !hash_lookup(line, symbols))) { debug(1,(type == IFNDEF ? "line %d: %s !def'd in %s via %s%s\n" : "", filep->f_line, line, file->i_file, file_red->i_file, ": doit")); type = find_includes(filep, file, file_red, recursion+1, failOK, incCollection, symbols); while (type == ELIF || type == ELIFFALSE || type == ELIFGUESSFALSE) type = gobble(filep, file, file_red, symbols); if (type == ELSE) gobble(filep, file, file_red, symbols); } else { debug(1,(type == IFDEF ? "line %d: %s !def'd in %s via %s%s\n" : "", filep->f_line, line, file->i_file, file_red->i_file, ": gobble")); type = gobble(filep, file, file_red, symbols); if (type == ELSE) find_includes(filep, file, file_red, recursion + 1, failOK, incCollection, symbols); else if (type == ELIF) goto doif; else if (type == ELIFFALSE || type == ELIFGUESSFALSE) goto doiffalse; } break; case ELSE: case ELIFFALSE: case ELIFGUESSFALSE: case ELIF: if (!recursion) gobble(filep, file, file_red, symbols); /*fall-through*/ case ENDIF: if (recursion) return type; /*fall-through*/ case DEFINE: define(line, &symbols); break; case UNDEF: if (!*line) { warning("%s, line %d: incomplete undef == \"%s\"\n", file_red->i_file, filep->f_line, line); break; } hash_undefine(line, symbols); break; case INCLUDE: add_include(filep, file, file_red, line, FALSE, failOK, incCollection, symbols); break; case INCLUDEDOT: add_include(filep, file, file_red, line, TRUE, failOK, incCollection, symbols); break; case ERROR: warning("%s: %d: %s\n", file_red->i_file, filep->f_line, line); break; case PRAGMA: case IDENT: case SCCS: case EJECT: break; case -1: warning("%s", file_red->i_file); if (file_red != file) warning1(" (reading %s)", file->i_file); warning1(", line %d: unknown directive == \"%s\"\n", filep->f_line, line); break; case -2: warning("%s", file_red->i_file); if (file_red != file) warning1(" (reading %s)", file->i_file); warning1(", line %d: incomplete include == \"%s\"\n", filep->f_line, line); break; } } return -1; }
/* Open the file to be processed. The handle variable holds internal info for the cpp emulator. Return integer status */ int cpp_open_file(const char *filenm, gmx_cpp_t *handle, char **cppopts) { gmx_cpp_t cpp; char *buf, *pdum; char *ptr, *ptr2; int i; unsigned int i1; /* First process options, they might be necessary for opening files (especially include statements). */ i = 0; if (cppopts) { while (cppopts[i]) { if (strstr(cppopts[i], "-I") == cppopts[i]) { add_include(cppopts[i]+2); } if (strstr(cppopts[i], "-D") == cppopts[i]) { /* If the option contains a =, split it into name and value. */ ptr = strchr(cppopts[i], '='); if (ptr) { buf = gmx_strndup(cppopts[i] + 2, ptr - cppopts[i] - 2); add_define(buf, ptr + 1); sfree(buf); } else { add_define(cppopts[i] + 2, NULL); } } i++; } } if (debug) { fprintf(debug, "GMXCPP: added %d command line arguments\n", i); } snew(cpp, 1); *handle = cpp; cpp->fn = NULL; /* Find the file. First check whether it is in the current directory. */ if (gmx_fexist(filenm)) { cpp->fn = gmx_strdup(filenm); } else { /* If not, check all the paths given with -I. */ for (i = 0; i < nincl; ++i) { snew(buf, strlen(incl[i]) + strlen(filenm) + 2); sprintf(buf, "%s/%s", incl[i], filenm); if (gmx_fexist(buf)) { cpp->fn = buf; break; } sfree(buf); } /* If still not found, check the Gromacs library search path. */ if (!cpp->fn) { cpp->fn = low_gmxlibfn(filenm, FALSE, FALSE); } } if (!cpp->fn) { gmx_fatal(FARGS, "Topology include file \"%s\" not found", filenm); } if (NULL != debug) { fprintf(debug, "GMXCPP: cpp file open %s\n", cpp->fn); } /* If the file name has a path component, we need to change to that * directory. Note that we - just as C - always use UNIX path separators * internally in include file names. */ ptr = strrchr(cpp->fn, '/'); ptr2 = strrchr(cpp->fn, DIR_SEPARATOR); if (ptr == NULL || (ptr2 != NULL && ptr2 > ptr)) { ptr = ptr2; } if (ptr == NULL) { cpp->path = NULL; cpp->cwd = NULL; } else { cpp->path = cpp->fn; *ptr = '\0'; cpp->fn = gmx_strdup(ptr+1); snew(cpp->cwd, STRLEN); gmx_getcwd(cpp->cwd, STRLEN); if (NULL != debug) { fprintf(debug, "GMXCPP: cwd %s\n", cpp->cwd); } gmx_chdir(cpp->path); if (NULL != debug) { fprintf(debug, "GMXCPP: chdir to %s\n", cpp->path); } } cpp->line_len = 0; cpp->line = NULL; cpp->line_nr = 0; cpp->nifdef = 0; cpp->ifdefs = NULL; cpp->child = NULL; cpp->parent = NULL; if (cpp->fp == NULL) { if (NULL != debug) { fprintf(debug, "GMXCPP: opening file %s\n", cpp->fn); } cpp->fp = fopen(cpp->fn, "r"); } if (cpp->fp == NULL) { switch (errno) { case EINVAL: default: return eCPP_UNKNOWN; } } return eCPP_OK; }
int find_includes (struct filepointer *filep, struct inclist *file, struct inclist *file_red, int recursion, bool failOK) { register char *line; register int type; bool recfailOK; while ((line = getline (filep))) { switch (type = deftype (line, filep, file_red, file, true)) { case IF: doif: type = find_includes (filep, file, file_red, recursion + 1, failOK); while ((type == ELIF) || (type == ELIFFALSE) || (type == ELIFGUESSFALSE)) type = gobble (filep, file, file_red); if (type == ELSE) gobble (filep, file, file_red); break; case IFFALSE: case IFGUESSFALSE: doiffalse: if (type == IFGUESSFALSE || type == ELIFGUESSFALSE) recfailOK = true; else recfailOK = failOK; type = gobble (filep, file, file_red); if (type == ELSE) find_includes (filep, file, file_red, recursion + 1, recfailOK); else if (type == ELIF) goto doif; else if ((type == ELIFFALSE) || (type == ELIFGUESSFALSE)) goto doiffalse; break; case IFDEF: case IFNDEF: if ((type == IFDEF && isdefined (line, file_red, NULL)) || (type == IFNDEF && !isdefined (line, file_red, NULL))) { debug (1, (type == IFNDEF ? "line %d: %s !def'd in %s via %s%s\n" : "", filep->f_line, line, file->i_file, file_red->i_file, ": doit")); type = find_includes (filep, file, file_red, recursion + 1, failOK); while (type == ELIF || type == ELIFFALSE || type == ELIFGUESSFALSE) type = gobble (filep, file, file_red); if (type == ELSE) gobble (filep, file, file_red); } else { debug (1, (type == IFDEF ? "line %d: %s !def'd in %s via %s%s\n" : "", filep->f_line, line, file->i_file, file_red->i_file, ": gobble")); type = gobble (filep, file, file_red); if (type == ELSE) find_includes (filep, file, file_red, recursion + 1, failOK); else if (type == ELIF) goto doif; else if (type == ELIFFALSE || type == ELIFGUESSFALSE) goto doiffalse; } break; case ELSE: case ELIFFALSE: case ELIFGUESSFALSE: case ELIF: if (!recursion) gobble (filep, file, file_red); case ENDIF: if (recursion) return (type); case DEFINE: define (line, file); break; case UNDEF: if (!*line) { warning ("%s, line %d: incomplete undef == \"%s\"\n", file->i_file, filep->f_line, line); display_included (file_red, file); break; } undefine (line, file_red); break; case INCLUDE: add_include (filep, file, file_red, line, false, failOK); break; case INCLUDEDOT: add_include (filep, file, file_red, line, true, failOK); break; case ERROR: case WARNING: warning ("%s: %d: %s\n", file->i_file, filep->f_line, line); display_included (file_red, file); break; case PRAGMA: case IDENT: case SCCS: case EJECT: break; case -1: warning ("%s", file_red->i_file); if (file_red != file) warning1 (" (reading %s)", file->i_file); warning1 (", line %d: unknown directive == \"%s\"\n", filep->f_line, line); break; case -2: warning ("%s", file_red->i_file); if (file_red != file) warning1 (" (reading %s)", file->i_file); warning1 (", line %d: incomplete include == \"%s\"\n", filep->f_line, line); break; } } file->i_flags |= FINISHED; return (-1); }
/* * routine: * main * * purpose: * argument processing and primary dispatch * * returns: * error codes per filesync.1 (ERR_* in filesync.h) * * notes: * read filesync.1 in order to understand the argument processing * * most of the command line options just set some opt_ global * variable that is later looked at by the code that actually * implements the features. Only file names are really processed * in this routine. */ int main(int argc, char **argv) { int i; int c; errmask_t errs = ERR_OK; int do_prune = 0; char *srcname = 0; char *dstname = 0; struct base *bp; /* keep the error messages simple */ argv[0] = "filesync"; /* gather together all of the options */ while ((c = getopt(argc, argv, "AaehmnqvyD:E:r:s:d:f:o:")) != EOF) switch (c) { case 'a': /* always scan for acls */ opt_acls = TRUE; break; case 'e': /* everything agrees */ opt_everything = TRUE; break; case 'h': /* halt on error */ opt_halt = TRUE; break; case 'm': /* preserve modtimes */ opt_mtime = TRUE; break; case 'n': /* notouch */ opt_notouch = TRUE; break; case 'q': /* quiet */ opt_quiet = TRUE; break; case 'v': /* verbose */ opt_verbose = TRUE; break; case 'y': /* yes */ opt_yes = TRUE; break; case 'D': /* debug options */ if (!isdigit(optarg[0])) { dbg_usage(); exit(ERR_INVAL); } opt_debug |= strtol(optarg, (char **)NULL, 0); break; case 'E': /* error simulation */ if (dbg_set_error(optarg)) { err_usage(); exit(ERR_INVAL); } opt_errors = TRUE; break; case 'f': /* force conflict resolution */ switch (optarg[0]) { case 's': opt_force = OPT_SRC; break; case 'd': opt_force = OPT_DST; break; case 'o': opt_force = OPT_OLD; break; case 'n': opt_force = OPT_NEW; break; default: fprintf(stderr, gettext(ERR_badopt), c, optarg); errs |= ERR_INVAL; break; } break; case 'o': /* one way propagation */ switch (optarg[0]) { case 's': opt_oneway = OPT_SRC; break; case 'd': opt_oneway = OPT_DST; break; default: fprintf(stderr, gettext(ERR_badopt), c, optarg); errs |= ERR_INVAL; break; } break; case 'r': /* restricted reconciliation */ if (num_restrs < MAX_RLIST) rlist[ num_restrs++ ] = optarg; else { fprintf(stderr, gettext(ERR_tomany), MAX_RLIST); errs |= ERR_INVAL; } break; case 's': if ((srcname = qualify(optarg)) == 0) errs |= ERR_MISSING; break; case 'd': if ((dstname = qualify(optarg)) == 0) errs |= ERR_MISSING; break; default: case '?': errs |= ERR_INVAL; break; } if (opt_debug & DBG_MISC) fprintf(stderr, "MISC: DBG=%s\n", showflags(dbgmap, opt_debug)); /* if we have file names, we need a source and destination */ if (optind < argc) { if (srcname == 0) { fprintf(stderr, gettext(ERR_nosrc)); errs |= ERR_INVAL; } if (dstname == 0) { fprintf(stderr, gettext(ERR_nodst)); errs |= ERR_INVAL; } } /* check for simple usage errors */ if (errs & ERR_INVAL) { usage(); exit(errs); } /* locate our baseline and rules files */ if (c = findfiles()) exit(c); /* figure out file creation defaults */ whoami(); /* read in our initial baseline */ if (!new_baseline && (c = read_baseline(file_base))) errs |= c; /* read in the rules file if we need or have rules */ if (optind >= argc && new_rules) { fprintf(stderr, ERR_nonames); errs |= ERR_INVAL; } else if (!new_rules) errs |= read_rules(file_rules); /* if anything has failed with our setup, go no further */ if (errs) { cleanup(errs); exit(errs); } /* * figure out whether or not we are willing to do a one-sided * analysis (where we don't even look at the other side. This * is an "I'm just curious what has changed" query, and we are * only willing to do it if: * we aren't actually going to do anything * we have a baseline we can compare against * otherwise, we are going to insist on being able to access * both the source and destination. */ if (opt_notouch && !new_baseline) opt_onesided = opt_oneway; /* * there are two interested usage scenarios: * file names specified * create new rules for the specified files * evaulate and reconcile only the specified files * no file names specified * use already existing rules * consider restricting them to specified subdirs/files */ if (optind < argc) { /* figure out what base pair we're working on */ bp = add_base(srcname, dstname); /* perverse default rules to avoid trouble */ if (new_rules) { errs |= add_ignore(0, SUFX_RULES); errs |= add_ignore(0, SUFX_BASE); } /* create include rules for each file/dir arg */ while (optind < argc) errs |= add_include(bp, argv[ optind++ ]); /* * evaluate the specified base on each side, * being careful to limit evaulation to new rules */ errs |= evaluate(bp, OPT_SRC, TRUE); errs |= evaluate(bp, OPT_DST, TRUE); } else { /* note any possible evaluation restrictions */ for (i = 0; i < num_restrs; i++) errs |= add_restr(rlist[i]); /* * we can only prune the baseline file if we have done * a complete (unrestricted) analysis. */ if (i == 0) do_prune = 1; /* evaulate each base on each side */ for (bp = bases; bp; bp = bp->b_next) { errs |= evaluate(bp, OPT_SRC, FALSE); errs |= evaluate(bp, OPT_DST, FALSE); } } /* if anything serious happened, skip reconciliation */ if (errs & ERR_FATAL) { cleanup(errs); exit(errs); } /* analyze and deal with the differenecs */ errs |= analyze(); /* see if there is any dead-wood in the baseline */ if (do_prune) { c = prune(); if (c > 0 && opt_verbose) fprintf(stdout, V_prunes, c); } /* print out a final summary */ summary(); /* update the rules and baseline files (if needed) */ (void) umask(my_umask); errs |= write_baseline(file_base); errs |= write_rules(file_rules); if (opt_debug & DBG_MISC) fprintf(stderr, "MISC: EXIT=%s\n", showflags(errmap, errs)); /* just returning ERR_RESOLVABLE upsets some people */ if (errs == ERR_RESOLVABLE && !opt_notouch) errs = 0; /* all done */ cleanup(0); return (errs); }
int find_includes(struct filepointer *filep, struct inclist *file, struct inclist *file_red, int recursion, boolean failOK) { struct inclist *inclistp; char **includedirsp; register char *line; register int type; boolean recfailOK; while ((line = getnextline(filep))) { switch(type = deftype(line, filep, file_red, file, TRUE)) { case IF: doif: type = find_includes(filep, file, file_red, recursion+1, failOK); while ((type == ELIF) || (type == ELIFFALSE) || (type == ELIFGUESSFALSE)) type = gobble(filep, file, file_red); if (type == ELSE) gobble(filep, file, file_red); break; case IFFALSE: case IFGUESSFALSE: doiffalse: if (type == IFGUESSFALSE || type == ELIFGUESSFALSE) recfailOK = TRUE; else recfailOK = failOK; type = gobble(filep, file, file_red); if (type == ELSE) find_includes(filep, file, file_red, recursion+1, recfailOK); else if (type == ELIF) goto doif; else if ((type == ELIFFALSE) || (type == ELIFGUESSFALSE)) goto doiffalse; break; case IFDEF: case IFNDEF: { int isdef = (isdefined(line, file_red, NULL) != NULL); if (type == IFNDEF) isdef = !isdef; if (isdef) { debug(1,(type == IFNDEF ? "line %d: %s !def'd in %s via %s%s\n" : "", filep->f_line, line, file->i_file, file_red->i_file, ": doit")); type = find_includes(filep, file, file_red, recursion+1, failOK); while (type == ELIF || type == ELIFFALSE || type == ELIFGUESSFALSE) type = gobble(filep, file, file_red); if (type == ELSE) gobble(filep, file, file_red); } else { debug(1,(type == IFDEF ? "line %d: %s !def'd in %s via %s%s\n" : "", filep->f_line, line, file->i_file, file_red->i_file, ": gobble")); type = gobble(filep, file, file_red); if (type == ELSE) find_includes(filep, file, file_red, recursion+1, failOK); else if (type == ELIF) goto doif; else if (type == ELIFFALSE || type == ELIFGUESSFALSE) goto doiffalse; } } break; case ELSE: case ELIFFALSE: case ELIFGUESSFALSE: case ELIF: if (!recursion) gobble(filep, file, file_red); case ENDIF: if (recursion) return(type); case DEFINE: define(line, file); break; case UNDEF: if (!*line) { warning("%s", file_red->i_file); if (file_red != file) warning1(" (reading %s)", file->i_file); warning1(", line %d: incomplete undef == \"%s\"\n", filep->f_line, line); break; } undefine(line, file_red); break; case INCLUDE: case INCLUDEDOT: case INCLUDENEXT: case INCLUDENEXTDOT: inclistp = inclistnext; includedirsp = includedirsnext; debug(2,("%s, reading %s, includes %s\n", file_red->i_file, file->i_file, line)); add_include(filep, file, file_red, line, type, failOK); inclistnext = inclistp; includedirsnext = includedirsp; break; case ERROR: case WARNING: warning("%s", file_red->i_file); if (file_red != file) warning1(" (reading %s)", file->i_file); warning1(", line %d: %s\n", filep->f_line, line); break; case PRAGMA: case IDENT: case SCCS: case EJECT: break; case -1: warning("%s", file_red->i_file); if (file_red != file) warning1(" (reading %s)", file->i_file); warning1(", line %d: unknown directive == \"%s\"\n", filep->f_line, line); break; case -2: warning("%s", file_red->i_file); if (file_red != file) warning1(" (reading %s)", file->i_file); warning1(", line %d: incomplete include == \"%s\"\n", filep->f_line, line); break; } } file->i_flags |= FINISHED; debug(2,("finished with %s\n", file->i_file)); return(-1); }
int main (int argc, char **argv) { register char **fp = filelist; register char **incp = includedirs; register char *p; register struct inclist *ip; char *makefile = NULL; struct filepointer *filecontent; struct symtab *psymp = predefs; const char *endmarker = NULL; char *defincdir = NULL; char **undeflist = NULL; int i, numundefs = 0; #if defined (INITIALIZE) // initialization code INITIALIZE; #endif ProgramName = argv[0]; while (psymp->s_name) { define2 (psymp->s_name, psymp->s_value, &maininclist); psymp++; } if (argc == 2 && argv[1][0] == '@') { struct stat ast; int afd; char *args; char **nargv; int nargc; char quotechar = '\0'; nargc = 1; if ((afd = open (argv[1] + 1, O_RDONLY)) < 0) fatalerr ("cannot open \"%s\"\n", argv[1] + 1); fstat (afd, &ast); args = (char *) malloc (ast.st_size + 1); if ((ast.st_size = read (afd, args, ast.st_size)) < 0) fatalerr ("failed to read %s\n", argv[1] + 1); args[ast.st_size] = '\0'; close (afd); for (p = args; *p; p++) { if (quotechar) { if (quotechar == '\\' || (*p == quotechar && p[-1] != '\\')) quotechar = '\0'; continue; } switch (*p) { case '\\': case '"': case '\'': quotechar = *p; break; case ' ': case '\n': *p = '\0'; if (p > args && p[-1]) nargc++; break; } } if (p[-1]) nargc++; nargv = (char **) malloc (nargc * sizeof (char *)); nargv[0] = argv[0]; argc = 1; for (p = args; argc < nargc; p += strlen (p) + 1) if (*p) nargv[argc++] = p; argv = nargv; } for (argc--, argv++; argc; argc--, argv++) { /* if looking for endmarker then check before parsing */ if (endmarker && strcmp (endmarker, *argv) == 0) { endmarker = NULL; continue; } if (**argv != '-') { /* treat +thing as an option for C++ */ if (endmarker && **argv == '+') continue; *fp++ = argv[0]; continue; } switch (argv[0][1]) { case '-': endmarker = &argv[0][2]; if (endmarker[0] == '\0') endmarker = "--"; break; case 'D': if (argv[0][2] == '\0') { argv++; argc--; } for (p = argv[0] + 2; *p; p++) if (*p == '=') { *p = ' '; break; } define (argv[0] + 2, &maininclist); break; case 'I': if (incp >= includedirs + MAXDIRS) fatalerr ("Too many -I flags.\n"); *incp++ = argv[0] + 2; if (**(incp - 1) == '\0') { *(incp - 1) = *(++argv); argc--; } break; case 'U': /* Undef's override all -D's so save them up */ numundefs++; if (numundefs == 1) undeflist = (char **)malloc (sizeof (char *)); else undeflist = (char **)realloc (undeflist, numundefs * sizeof (char *)); if (argv[0][2] == '\0') { argv++; argc--; } undeflist[numundefs - 1] = argv[0] + 2; break; case 'Y': defincdir = argv[0] + 2; break; /* do not use if endmarker processing */ case 'a': if (endmarker) break; opt_append = true; break; case 'b': if (endmarker) break; opt_backup = true; break; case 'c': if (endmarker) break; opt_create = true; break; case 'r': if (endmarker) break; opt_remove_prefix = true; break; case 'w': if (endmarker) break; if (argv[0][2] == '\0') { argv++; argc--; width = atoi (argv[0]); } else width = atoi (argv[0] + 2); break; case 'o': if (endmarker) break; if (argv[0][2] == '\0') { argv++; argc--; objsuffix = argv[0]; } else objsuffix = argv[0] + 2; break; case 'p': if (endmarker) break; if (argv[0][2] == '\0') { argv++; argc--; objprefix = argv[0]; } else objprefix = argv[0] + 2; break; case 'S': if (endmarker) break; opt_sysincludes = true; break; case 'v': if (endmarker) break; opt_verbose = true; #ifdef CS_DEBUG if (argv[0][2]) _debugmask = atoi (argv[0] + 2); #endif break; case 's': if (endmarker) break; startat = argv[0] + 2; if (*startat == '\0') { startat = *(++argv); argc--; } if (*startat != '#') fatalerr ("-s flag's value should start %s\n", "with '#'."); break; case 'f': if (endmarker) break; makefile = argv[0] + 2; if (*makefile == '\0') { makefile = *(++argv); argc--; } break; case 'm': opt_warn_multiple = true; break; /* Ignore -O, -g so we can just pass ${CFLAGS} to makedepend */ case 'O': case 'g': break; case 'h': if (endmarker) break; display_help (); return 0; case 'V': if (endmarker) break; display_version (); return 0; default: if (endmarker) break; /* fatalerr("unknown opt = %s\n", argv[0]); */ warning ("ignoring option %s\n", argv[0]); } } /* Now do the undefs from the command line */ for (i = 0; i < numundefs; i++) undefine (undeflist[i], &maininclist); if (numundefs > 0) free (undeflist); if (!defincdir) { #ifdef PREINCDIR add_include (PREINCDIR, incp); #endif #if defined (__GNUC__) || defined (_WIN32) add_include ( # if defined (__GNUC__) getenv ("C_INCLUDE_PATH"), # else getenv ("INCLUDE"), # endif incp); #else /* !__GNUC__, does not use INCLUDEDIR at all */ if (incp >= includedirs + MAXDIRS) fatalerr ("Too many -I flags.\n"); *incp++ = INCLUDEDIR; #endif #ifdef POSTINCDIR add_include (POSTINCDIR, incp); #endif } else if (*defincdir) add_include (defincdir, incp); /* if nothing to do, abort */ if (!*filelist) fatalerr ("No files specified, try \"makedep -h\"\n"); redirect (startat, makefile); /* catch signals */ #ifdef USGISH /* should really reset SIGINT to SIG_IGN if it was. */ #ifdef SIGHUP signal (SIGHUP, sighandler); #endif signal (SIGINT, sighandler); #ifdef SIGQUIT signal (SIGQUIT, sighandler); #endif signal (SIGILL, sighandler); #ifdef SIGBUS signal (SIGBUS, sighandler); #endif signal (SIGSEGV, sighandler); #ifdef SIGSYS signal (SIGSYS, sighandler); #endif #else sig_act.sa_handler = sighandler; #ifdef _POSIX_SOURCE sigemptyset (&sig_act.sa_mask); sigaddset (&sig_act.sa_mask, SIGINT); sigaddset (&sig_act.sa_mask, SIGQUIT); #ifdef SIGBUS sigaddset (&sig_act.sa_mask, SIGBUS); #endif sigaddset (&sig_act.sa_mask, SIGILL); sigaddset (&sig_act.sa_mask, SIGSEGV); sigaddset (&sig_act.sa_mask, SIGHUP); sigaddset (&sig_act.sa_mask, SIGPIPE); #ifdef SIGSYS sigaddset (&sig_act.sa_mask, SIGSYS); #endif #else sig_act.sa_mask = ((1 << (SIGINT - 1)) #ifdef SIGQUIT | (1 << (SIGQUIT - 1)) #endif #ifdef SIGBUS | (1 << (SIGBUS - 1)) #endif | (1 << (SIGILL - 1)) | (1 << (SIGSEGV - 1)) #ifdef SIGHUP | (1 << (SIGHUP - 1)) #endif #ifdef SIGPIPE | (1 << (SIGPIPE - 1)) #endif #ifdef SIGSYS | (1 << (SIGSYS - 1)) #endif ); #endif /* _POSIX_SOURCE */ sig_act.sa_flags = 0; #ifdef SIGHUP sigaction (SIGHUP, &sig_act, (struct sigaction *) 0); #endif sigaction (SIGINT, &sig_act, (struct sigaction *) 0); #ifdef SIGQUIT sigaction (SIGQUIT, &sig_act, (struct sigaction *) 0); #endif sigaction (SIGILL, &sig_act, (struct sigaction *) 0); #ifdef SIGBUS sigaction (SIGBUS, &sig_act, (struct sigaction *) 0); #endif sigaction (SIGSEGV, &sig_act, (struct sigaction *) 0); #ifdef SIGSYS sigaction (SIGSYS, &sig_act, (struct sigaction *) 0); #endif #endif /* USGISH */ /* * now peruse through the list of files. */ for (fp = filelist; *fp; fp++) { filecontent = getfile (*fp); ip = newinclude (*fp, (char *) NULL); find_includes (filecontent, ip, ip, 0, false); freefile (filecontent); recursive_pr_include (ip, ip->i_file, base_name (*fp)); inc_clean (); } if (opt_printed) printf ("\n"); return 0; }