コード例 #1
0
ファイル: diffh.c プロジェクト: AlainODea/illumos-gate
static int
output(int a, int b)
{
	int i;
	char *s;

	if (a < 0)
		change(n0-1, 0, n1, b, "a");
	else if (b < 0)
		change(n0, a, n1-1, 0, "d");
	else
		change(n0, a, n1, b, "c");
	for (i = 0; i <= a; i++) {
		s = getl(0, n0+i);
		if (s == NULL)
			break;
		(void) printf("< %s", s);
		clrl(0, n0+i);
	}
	n0 += i-1;
	if (a >= 0 && b >= 0)
		(void) printf("---\n");
	for (i = 0; i <= b; i++) {
		s = getl(1, n1+i);
		if (s == NULL)
			break;
		(void) printf("> %s", s);
		clrl(1, n1+i);
	}
	diffFound = 1;
	n1 += i-1;
	return (1);
}
コード例 #2
0
ファイル: diffh.c プロジェクト: AlainODea/illumos-gate
int
main(int argc, char **argv)
{
	char *s0, *s1;

	if ((argc > 1) && (*argv[1] == '-')) {
		argc--;
		argv++;
		while (*++argv[0])
			if (*argv[0] == 'b')
				bflag++;
	}

	(void) setlocale(LC_ALL, "");
#if !defined(TEXT_DOMAIN)		/* Should be defined by cc -D */
#define	TEXT_DOMAIN	"SYS_TEST"	/* Use this only if it weren't */
#endif
	(void) textdomain(TEXT_DOMAIN);

	if (argc != 3)
		error(gettext("must have 2 file arguments"));
	file[0] = dopen(argv[1], argv[2]);
	file[1] = dopen(argv[2], argv[1]);
	for (;;) {
		s0 = getl(0, ++n0);
		s1 = getl(1, ++n1);
		if (s0 == NULL || s1 == NULL)
			break;
		if (cmp(s0, s1) != 0) {
			if (!easysynch() && !hardsynch())
				progerr("5");
		} else {
			clrl(0, n0);
			clrl(1, n1);
		}
	}
	/* diff is expected to return 1 if the files differ */
	if (s0 == NULL && s1 == NULL)
		return (diffFound);
	if (s0 == NULL) {
		(void) output(-1, INF);
		return (1);
	}
	if (s1 == NULL) {
		(void) output(INF, -1);
		return (1);
	}
	/* NOTREACHED */
	return (0);
}
コード例 #3
0
ファイル: tty.c プロジェクト: weixu8/joes-sandbox
void ttyout(unsigned char c)
{
    switch(mode)
    {
    /* Print mode */
    case 5:
        if(c==6) break;
        pp(c);
        return;

    /* No prefix characters */
    case 0:
        switch(c)
        {
        case 6:
            mode=5;
            return;         /* Pass-thru printing */
        case 7:
            bell();
            break;
        case 8:
            dowrap=0;
            bs();
            break;
        case 9:
            tab();
            break;
        case 10:
        case 11:
        case 12:
            dowrap=0;
            if(mnl) cr();
            lf();
            break;
        case 13:
            dowrap=0;
            cr();
            break;
        case 27:
            mode=1;
            return;
        case 0x84:
            dowrap=0;
            lf();
            break;
        case 0x85:
            dowrap=0;
            cr();
            lf();
            break;
        case 0x88:
            settab();
            break;
        case 0x8d:
            dowrap=0;
            ups();
            break;
        case 0x9b:
            begin();
            mode=2;
            return;
        default:
            if(minsert) insc(c);
            else type(c);
        }
        break;

    /* ESC has been received */
    case 1:
        switch(c)
        {
        case 27:
            return;
        case '[':
            begin();
            mode=2;
            return;
        case 'D':
            dowrap=0;
            lf();
            break;
        case 'E':
            dowrap=0;
            cr();
            lf();
            break;
        case 'H':
            settab();
            break;
        case 'M':
            dowrap=0;
            ups();
            break;
        case '#':
            mode=3;
            return;
        }
        break;

    /* ESC [ or 0x9B has been received */
    case 2:
        /* Enter numbers */
        switch(c)
        {
        case '0':
        case '1':
        case '2':
        case '3':
        case '4':
        case '5':
        case '6':
        case '7':
        case '8':
        case '9':
            parry[nptr]=parry[nptr]*10+c-'0';
            return;
        case ';':
            if(MAXPARMS== ++nptr) break;
            else return;
        case 27:
            mode=1;
            return;
        case '[':
            begin();
            return;
        case 'c':
            ttyinit();
            break;
        case 'p':
            dowrap=0;
            break;  /* Reset what? */
        case 'r':
            dowrap=0;
            setregn();
            break;
        case 'm':
            setattrib();
            break;
        case 'J':
            clrs();
            break;
        case 'K':
            clrl();
            break;
        case 'X':
            clrc();
            break;
        case 'H':
            dowrap=0;
            pos();
            break;
        case 'C':
            dowrap=0;
            right();
            break;
        case 'D':
            dowrap=0;
            left();
            break;
        case 'A':
            dowrap=0;
            up();
            break;
        case 'B':
            dowrap=0;
            down();
            break;
        case 'g':
            clrt();
            break;
        case 'M':
            dell();
            break;
        case 'L':
            insl();
            break;
        case 'P':
            delc();
            break;
        case '@':
            inss();
            break;
        case 'h':
            hmode();
            break;
        case 'l':
            lmode();
            break;
        case '!':
        case '?':
            return;
        }
        break;

    /* ESC # has been received */
    case 3:
        switch(c)
        {
        case 27:
            mode=1;
            return;
        case '[':
            begin();
            mode=2;
            return;
        }
        break;
    }
    mode=0;
}