Sophie

Sophie

distrib > Mageia > 7 > armv7hl > media > core-updates > by-pkgid > 2fee571c8ff7f751b8ffd67176c1660f > files > 74

re2c-2.0.3-1.mga7.armv7hl.rpm

/* Generated by re2c */
// re2c $INPUT -o $OUTPUT -i
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>

#define YYMAXFILL 4


static int lex(const char *YYCURSOR)
{
    const char *YYMARKER, *n, *p, *u, *g, *f, *h, *c;
    const char *yyt1;const char *yyt2;const char *yyt3;const char *yyt4;const char *yyt5;const char *yyt6;const char *yyt7;
loop:
    
{
	char yych;
	yych = *YYCURSOR;
	switch (yych) {
	case 0x00:	goto yy2;
	case '\n':
	case ':':	goto yy6;
	default:
		yyt1 = YYCURSOR;
		goto yy4;
	}
yy2:
	++YYCURSOR;
	{ return 0; }
yy4:
	yych = *(YYMARKER = ++YYCURSOR);
	switch (yych) {
	case 0x00:
	case '\n':	goto yy5;
	default:	goto yy8;
	}
yy5:
	{ fprintf(stderr, "error\n"); return 1; }
yy6:
	++YYCURSOR;
	goto yy5;
yy7:
	yych = *++YYCURSOR;
yy8:
	switch (yych) {
	case 0x00:
	case '\n':	goto yy9;
	case ':':	goto yy10;
	default:	goto yy7;
	}
yy9:
	YYCURSOR = YYMARKER;
	goto yy5;
yy10:
	yych = *++YYCURSOR;
	switch (yych) {
	case 0x00:
	case '\n':	goto yy9;
	case ':':
		yyt2 = YYCURSOR;
		goto yy13;
	default:
		yyt2 = YYCURSOR;
		goto yy11;
	}
yy11:
	yych = *++YYCURSOR;
	switch (yych) {
	case 0x00:
	case '\n':	goto yy9;
	case ':':	goto yy13;
	default:	goto yy11;
	}
yy13:
	yych = *++YYCURSOR;
	switch (yych) {
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':
		yyt3 = YYCURSOR;
		goto yy14;
	default:	goto yy9;
	}
yy14:
	yych = *++YYCURSOR;
	switch (yych) {
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':	goto yy14;
	case ':':	goto yy16;
	default:	goto yy9;
	}
yy16:
	yych = *++YYCURSOR;
	switch (yych) {
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':
		yyt4 = YYCURSOR;
		goto yy17;
	default:	goto yy9;
	}
yy17:
	yych = *++YYCURSOR;
	switch (yych) {
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':	goto yy17;
	case ':':	goto yy19;
	default:	goto yy9;
	}
yy19:
	yych = *++YYCURSOR;
	switch (yych) {
	case 0x00:
	case '\n':	goto yy9;
	case ':':
		yyt5 = YYCURSOR;
		goto yy22;
	default:
		yyt5 = YYCURSOR;
		goto yy20;
	}
yy20:
	yych = *++YYCURSOR;
	switch (yych) {
	case 0x00:
	case '\n':	goto yy9;
	case ':':	goto yy22;
	default:	goto yy20;
	}
yy22:
	yych = *++YYCURSOR;
	switch (yych) {
	case '/':
		yyt6 = YYCURSOR;
		goto yy23;
	default:	goto yy9;
	}
yy23:
	yych = *++YYCURSOR;
	switch (yych) {
	case 0x00:
	case '\n':	goto yy9;
	case ':':	goto yy25;
	default:	goto yy23;
	}
yy25:
	yych = *++YYCURSOR;
	switch (yych) {
	case '/':
		yyt7 = YYCURSOR;
		goto yy26;
	default:	goto yy9;
	}
yy26:
	yych = *++YYCURSOR;
	switch (yych) {
	case 0x00:
	case ':':	goto yy9;
	case '\n':	goto yy28;
	default:	goto yy26;
	}
yy28:
	++YYCURSOR;
	n = yyt1;
	p = yyt2;
	u = yyt3;
	g = yyt4;
	f = yyt5;
	h = yyt6;
	c = yyt7;
	{
            fprintf(stderr, "user:     %.*s\n", (int)(p - n) - 1, n);
            fprintf(stderr, "password: %.*s\n", (int)(u - p) - 1, p);
            fprintf(stderr, "UID:      %.*s\n", (int)(g - u) - 1, u);
            fprintf(stderr, "GID:      %.*s\n", (int)(f - g) - 1, g);
            fprintf(stderr, "info:     %.*s\n", (int)(h - f) - 1, f);
            fprintf(stderr, "home:     %.*s\n", (int)(c - h) - 1, h);
            fprintf(stderr, "command:  %.*s\n", (int)(YYCURSOR - c - 1), c);
            fprintf(stderr, "\n");
            goto loop;
        }
}

}

int main()
{
    const char *fname = "etc_passwd";
    FILE *f;

    // prepare input file
    f = fopen(fname, "w");
    fprintf(f,
        "root:x:0:0:root:/root:/bin/bash\n"
        "bin:x:1:1:bin:/bin:/bin/false\n"
        "portage:x:250:250:portage:/var/tmp/portage:/bin/false\n");
    fclose(f);

    // read input file into buffer
    f = fopen(fname, "r");
    fseek(f, 0, SEEK_END);
    const size_t fsize = (size_t) ftell(f);
    fseek(f, 0, SEEK_SET);
    char *buffer = (char*) malloc(fsize + 1);
    fread(buffer, 1, fsize, f);
    buffer[fsize] = 0;
    fclose(f);

    assert(lex(buffer) == 0);

    // cleanup
    remove(fname);
    free(buffer);
    return 0;
}