Ejemplo n.º 1
0
extern int main (int __unused__ argc, char **argv)
{
	cookedArgs *args;
#ifdef VMS
	extern int getredirection (int *ac, char ***av);

	/* do wildcard expansion and I/O redirection */
	getredirection (&argc, &argv);
#endif

#ifdef AMIGA
	/* This program doesn't work when started from the Workbench */
	if (argc == 0)
		exit (1);
#endif

#ifdef __EMX__
	_wildcard (&argc, &argv);  /* expand wildcards in argument list */
#endif

#if defined (macintosh) && BUILD_MPW_TOOL == 0
	argc = ccommand (&argv);
#endif

	setCurrentDirectory ();
	setExecutableName (*argv++);
	sanitizeEnviron ();
	checkRegex ();

	args = cArgNewFromArgv (argv);
	previewFirstOption (args);
	testEtagsInvocation ();
	initializeParsing ();
	initOptions ();
	readOptionConfiguration ();
	verbose ("Reading initial options from command line\n");
	parseOptions (args);
	checkOptions ();
	unifyLanguageMaps ();
	makeTags (args);

	/*  Clean up.
	 */
	cArgDelete (args);
	freeKeywordTable ();
	freeRoutineResources ();
	freeSourceFileResources ();
	freeTagFileResources ();
	freeOptionResources ();
	freeParserResources ();
	freeRegexResources ();
	freeXcmdResources ();

	if (Option.guessParser)
		return (Option.guessParser == TRUE)? 0: 1;

	exit (0);
	return 0;
}
Ejemplo n.º 2
0
static const char *
vmsProgname(int * const argcP, char * argv[]) {   
    char **temp_argv = argv;
    int old_argc = *argcP;
    int i;
    const char * retval;
    
    getredirection( argcP, &temp_argv );
    if (*argcP > old_argc) {
        /* Number of command line arguments has increased */
        fprintf( stderr, "Sorry!! getredirection() for VMS has "
                 "changed the argument list!!!\n");
        fprintf( stderr, "This is intolerable at the present time, "
                 "so we must stop!!!\n");
        exit(1);
    }
    for (i=0; i<*argcP; i++)
        argv[i] = temp_argv[i];
    retval = strrchr( argv[0], '/');
    if ( retval == NULL ) retval = rindex( argv[0], ']');
    if ( retval == NULL ) retval = rindex( argv[0], '>');

    return retval;
}
Ejemplo n.º 3
0
int MAIN(int argc, char** argv)
{
    int    i;
    char** useargv;
    char** pfargv;

    if( nRunde == 0 )
    {
        pCppIn = stdin;
        pCppOut = stdout;
    }

    nRunde++;
    InitCpp1();
    InitCpp2();
    InitCpp3();
    InitCpp4();
    InitCpp5();
    InitCpp6();

#if HOST == SYS_VMS
    argc = getredirection(argc, argv);      /* vms >file and <file  */
#endif
    initdefines();                          /* O.S. specific def's  */
    if ( argv[argc-1][0] == '@' )
    {
        i = readoptions( argv[1], &pfargv );    /* Command file */
        useargv=pfargv;
    }
    else
    {
        i = dooptions(argc, argv);              /* Command line -flags  */
        useargv=argv;
    }
    switch (i)
    {
#if OSL_DEBUG_LEVEL > 1
    case 4:
        if ( bDumpDefs )
        {
            /*
             * Get defBase file, "-" means use stdout.
             */
            if (!streq(useargv[3], "-"))
            {
#if HOST == SYS_VMS
                /*
                 * On vms, reopen stdout with "vanilla rms" attributes.
                 */
                if ((i = creat(useargv[3], 0, "rat=cr", "rfm=var")) == -1
                    || dup2(i, fileno(stdout)) == -1)
#else
                pDefOut = fopen( useargv[3], "w" );
                if( pDefOut == NULL )
#endif
                {
                    perror(useargv[3]);
                    cerror("Can't open output file \"%s\"", useargv[3]);
                    exit(IO_ERROR);
                }
            }                           /* Continue by opening output    */
        }
#endif
    case 3:
        /*
         * Get output file, "-" means use stdout.
         */
        if (!streq(useargv[2], "-"))
        {
#if HOST == SYS_VMS
            /*
             * On vms, reopen stdout with "vanilla rms" attributes.
             */
            if ((i = creat(useargv[2], 0, "rat=cr", "rfm=var")) == -1
                || dup2(i, fileno(stdout)) == -1)
#else
            pCppOut = fopen( useargv[2], "w" );
            if( pCppOut == NULL )
#endif
            {
                perror(useargv[2]);
                cerror("Can't open output file \"%s\"", useargv[2]);
                exit(IO_ERROR);
            }
        }                           /* Continue by opening input    */
    case 2:                         /* One file -> stdin            */
        /*
         * Open input file, "-" means use stdin.
         */
        if (!streq(useargv[1], "-"))
        {
            pCppIn = fopen( useargv[1], "r" );
            if( pCppIn == NULL)
            {
                perror(useargv[1]);
                cerror("Can't open input file \"%s\"", useargv[1]);
                exit(IO_ERROR);
            }
            strncpy(work, useargv[1], NWORK);  /* Remember input filename      */
            break;
        }                           /* Else, just get stdin         */
    case 0:                         /* No args?                     */
    case 1:                         /* No files, stdin -> stdout    */
#if (HOST == SYS_UNIX) || (HOST == SYS_UNKNOWN)
        work[0] = EOS;              /* Unix can't find stdin name   */
#else
        fgetname(stdin, work);      /* Vax-11C, Decus C know name   */
#endif
        break;

    default:
        exit(IO_ERROR);             /* Can't happen                 */
    }

    setincdirs();                   /* Setup -I include directories */
    addfile( pCppIn, work);           /* "open" main input file       */
#if OSL_DEBUG_LEVEL > 1
    if (debug > 0 || bDumpDefs)
        dumpdef("preset #define symbols");
#endif
    if( pCppIn != stdin )
        rewind( pCppIn );

    cppmain();                      /* Process main file            */

    if ((i = (ifptr - &ifstack[0])) != 0)
    {
#if OLD_PREPROCESSOR
        ciwarn("Inside #ifdef block at end of input, depth = %d", i);
#else
        cierror("Inside #ifdef block at end of input, depth = %d", i);
#endif
    }
#if OSL_DEBUG_LEVEL > 1
    if( pDefOut != stdout && pDefOut != stderr )
        fclose( pDefOut );
#endif
    if( pCppOut != stdout && pCppOut != stderr )
        fclose( pCppOut );

    if (errors > 0)
    {
        fprintf(stderr, (errors == 1)
                ? "%d error in preprocessor\n"
                : "%d errors in preprocessor\n", errors);
        if (!eflag)
            exit(IO_ERROR);
    }
#ifdef NOMAIN                  /* BP */ /* kein exit im der LIB-Version */
    return( IO_NORMAL );
#else
    exit(IO_NORMAL);                /* No errors or -E option set   */
#endif

}