Beispiel #1
0
/*
**	initialize the global tolerance
**	should be called only once at the beginning of the program
*/
void
T_initdefault()
{
	static int called_before = 0;

	if (called_before)
	{
		Z_fatal("T_initdefault called more than once\n");
	}

	/*
	**	if the default tolerance was set somewhere else
	**	don't set it here
	*/
	if (T_isnull(_T_gtol))
	{
		T_defatol(_T_ADEF);
		T_defrtol(_T_RDEF);
	}
	called_before = 1;
}
Beispiel #2
0
static void
_Y_doargs(int argc, char **argv, char **file1, char **file2, int *max_d)
{
    char *ptr;

    /*
     **     mark maximum number of tokens as being unset
     */
    *max_d = -1;

    while (argc > 1 && argv[1][0] == '-') {
	switch (argv[1][1]) {
	case 't':
	    _Y_flags |= U_TOKENS;
	    break;
	case 'w':
	    _Y_flags |= U_INCLUDE_WS;
	    break;

	case 'b':
	    _Y_flags |= U_BYTE_COMPARE;
	    break;

	case 'c':
	    _Y_flags |= U_NO_CASE;
	    break;
	case 'd':
	    _Y_flags |= U_NEED_DECIMAL;
	    break;
	case 'm':
	    _Y_flags |= U_INC_SIGN;
	    break;
	case 'a':
	    SETPTR;
	    T_defatol(ptr);
	    break;
	case 'r':
	    SETPTR;
	    T_defrtol(ptr);
	    break;
	case 'i':
	    T_defitol();
	    break;
	case 'e':
	    _Y_eflag = 1;
	    break;
	case 'v':
	    _Y_vflag = 1;
	    break;
	case 'q':
	    Z_setquiet();
	    break;
	case 's':
	    SETPTR;
	    _Y_cmdlines(ptr);
	    break;
	case 'f':
	    {
		extern FILE *fopen(const char *, const char *);
		char buf[Z_LINELEN];
		FILE *cmdfile;
		SETPTR;
		if ((FILE *) NULL == (cmdfile = fopen(ptr, "r"))) {
		    Z_fatal("can't open command file\n");
		}
		while ((char *) NULL !=
		       (char *) fgets(buf, Z_LINELEN, cmdfile)) {
		    C_addcmd(buf);
		}
		(void) fclose(cmdfile);
		break;
	    }
	    /*
	     **     useful commands for
	     **      the C programming language
	     */
	case 'C':
	    C_addcmd("literal  \"   \"    \\ ");
	    C_addcmd("comment  /*  */	 ");
	    C_addcmd("literal  &&		 ");
	    C_addcmd("literal  ||		 ");
	    C_addcmd("literal  <=		 ");
	    C_addcmd("literal  >=		 ");
	    C_addcmd("literal  !=		 ");
	    C_addcmd("literal  ==		 ");
	    C_addcmd("literal  --		 ");
	    C_addcmd("literal  ++		 ");
	    C_addcmd("literal  <<		 ");
	    C_addcmd("literal  >>		 ");
	    C_addcmd("literal  ->		 ");
	    C_addcmd("addalpha _		 ");
	    C_addcmd("tol      a0 		 ");
	    break;
	    /*
	     **     useful commands for
	     **      the Bourne shell programming language
	     */
	case 'S':
	    C_addcmd("literal  '    '    \\	");
	    C_addcmd("comment  #    $	");
	    C_addcmd("tol      a0 		");
	    break;
	    /*
	     **     useful commands for
	     **      the Fortran programming language
	     */
	case 'F':
	    C_addcmd("literal  '	'     ' ");
	    C_addcmd("comment  ^C   $	");
	    C_addcmd("tol      a0 		");
	    break;
	    /*
	     **     useful commands for
	     **      the Lisp programming language
	     */
	case 'L':
	    C_addcmd("literal  \" 	\"	");
	    C_addcmd("comment  ; 	$	");
	    C_addcmd("tol      a0 		");
	    break;
	    /*
	     **     useful commands for
	     **      the Modula-2 programming language
	     */
	case 'M':
	    C_addcmd("literal ' 	'	");
	    C_addcmd("literal \"	\"	");
	    C_addcmd("comment (*	*)	");
	    C_addcmd("literal :=		");
	    C_addcmd("literal <>		");
	    C_addcmd("literal <=		");
	    C_addcmd("literal >=		");
	    C_addcmd("tol      a0 		");
	    break;
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':
	    *max_d = atoi(&argv[1][1]);
	    break;
	default:
	    Z_fatal("don't understand arguments\n");
	}
	++argv;
	--argc;
    }
    if (argc != 3)
	Z_fatal("spiff requires two file names.\n");
    *file1 = argv[1];
    *file2 = argv[2];
}