예제 #1
0
파일: crlf.c 프로젝트: 0CV0/libgit2
static int crlf_load_attributes(struct crlf_attrs *ca, git_repository *repo, const char *path)
{
#define NUM_CONV_ATTRS 3

	static const char *attr_names[NUM_CONV_ATTRS] = {
		"crlf", "eol", "text",
	};

	const char *attr_vals[NUM_CONV_ATTRS];
	int error;

	error = git_attr_get_many(attr_vals,
		repo, 0, path, NUM_CONV_ATTRS, attr_names);

	if (error == GIT_ENOTFOUND) {
		ca->crlf_action = GIT_CRLF_GUESS;
		ca->eol = GIT_EOL_UNSET;
		return 0;
	}

	if (error == 0) {
		ca->crlf_action = check_crlf(attr_vals[2]); /* text */
		if (ca->crlf_action == GIT_CRLF_GUESS)
			ca->crlf_action = check_crlf(attr_vals[0]); /* clrf */

		ca->eol = check_eol(attr_vals[1]); /* eol */
		return 0;
	}

	return -1;
}
예제 #2
0
/*
 *	GOTO statement
 */
void
parse_goto(TOKEN *first_token)
{
    TOKEN	token;

    out_white_space(first_token);
    out_str("goto");

    if (get_token(&token) != IDENTIFIER)
        parse_error("Illegal GOTO label");
    else {
        out_token(&token);
        check_eol();
    }
}
예제 #3
0
파일: code.c 프로젝트: BlockoS/pceas
void
class1(int *ip)
{
	check_eol(ip);

	/* update location counter */
	loccnt++;

	/* generate code */
	if (pass == LAST_PASS) {
		/* opcode */
		putbyte(data_loccnt, opval);

		/* output line */
		println();
	}
}
예제 #4
0
파일: proc.c 프로젝트: m6502/pceas
void
do_call(int *ip)
{
	struct t_proc *ptr;
	int value;

	/* define label */
	labldef(loccnt, 1);

	/* update location counter */
	data_loccnt = loccnt;
	loccnt += 3;

	/* generate code */
	if (pass == LAST_PASS) {
		/* skip spaces */
		while (isspace(prlnbuf[*ip]))
			(*ip)++;

		/* extract name */
		if (!colsym(ip)) {
			if (symbol[0] == 0)
				fatal_error("Syntax error!");
			return;
		}

		/* check end of line */
		check_eol(ip);

		/* lookup proc table */
		if((ptr = proc_look())) {
			/* check banks */
			if (bank == ptr->bank)
				value = ptr->org + 0xA000;
			else {
				/* different */
				if (ptr->call)
					value = ptr->call;
				else {
					/* new call */
					value = call_ptr + 0x8000;
					ptr->call = value;

					/* init */
					if (call_ptr == 0) {
						call_bank = ++max_bank;
					}

					/* install */
					poke(call_ptr++, 0xA8);			// tay
					poke(call_ptr++, 0x43);			// tma #5
					poke(call_ptr++, 0x20);
					poke(call_ptr++, 0x48);			// pha
					poke(call_ptr++, 0xA9);			// lda #...
					poke(call_ptr++, ptr->bank+bank_base);
					poke(call_ptr++, 0x53);			// tam #5
					poke(call_ptr++, 0x20);
					poke(call_ptr++, 0x98);			// tya
					poke(call_ptr++, 0x20);			// jsr ...
					poke(call_ptr++, (ptr->org & 0xFF));
					poke(call_ptr++, (ptr->org >> 8) + 0xA0);
					poke(call_ptr++, 0xA8);			// tay
					poke(call_ptr++, 0x68);			// pla
					poke(call_ptr++, 0x53);			// tam #5
					poke(call_ptr++, 0x20);
					poke(call_ptr++, 0x98);			// tya
					poke(call_ptr++, 0x60);			// rts
				}
			}
		}
		else {
			/* lookup symbol table */
			if ((lablptr = stlook(0)) == NULL) {
				fatal_error("Undefined destination!");
				return;
			}

			/* get symbol value */
			value = lablptr->value;
		}

		/* opcode */
		putbyte(data_loccnt, 0x20);
		putword(data_loccnt+1, value);

		/* output line */
		println();
	}
예제 #5
0
파일: crlf.c 프로젝트: Study-C/libgit2
static int crlf_check(
	git_filter        *self,
	void              **payload, /* points to NULL ptr on entry, may be set */
	const git_filter_source *src,
	const char **attr_values)
{
	int error;
	struct crlf_attrs ca;

	GIT_UNUSED(self);

	if (!attr_values) {
		ca.crlf_action = GIT_CRLF_GUESS;
		ca.eol = GIT_EOL_UNSET;
	} else {
		ca.crlf_action = check_crlf(attr_values[2]); /* text */
		if (ca.crlf_action == GIT_CRLF_GUESS)
			ca.crlf_action = check_crlf(attr_values[0]); /* clrf */
		ca.eol = check_eol(attr_values[1]); /* eol */
	}
	ca.auto_crlf = GIT_AUTO_CRLF_DEFAULT;

	/*
	 * Use the core Git logic to see if we should perform CRLF for this file
	 * based on its attributes & the value of `core.autocrlf`
	 */
	ca.crlf_action = crlf_input_action(&ca);

	if (ca.crlf_action == GIT_CRLF_BINARY)
		return GIT_PASSTHROUGH;

	if (ca.crlf_action == GIT_CRLF_GUESS ||
		(ca.crlf_action == GIT_CRLF_AUTO &&
		git_filter_source_mode(src) == GIT_FILTER_SMUDGE)) {

		error = git_repository__cvar(
			&ca.auto_crlf, git_filter_source_repo(src), GIT_CVAR_AUTO_CRLF);
		if (error < 0)
			return error;

		if (ca.auto_crlf == GIT_AUTO_CRLF_FALSE)
			return GIT_PASSTHROUGH;

		if (ca.auto_crlf == GIT_AUTO_CRLF_INPUT &&
			git_filter_source_mode(src) == GIT_FILTER_SMUDGE)
			return GIT_PASSTHROUGH;
	}

	if (git_filter_source_mode(src) == GIT_FILTER_CLEAN) {
		error = git_repository__cvar(
			&ca.safe_crlf, git_filter_source_repo(src), GIT_CVAR_SAFE_CRLF);
		if (error < 0)
			return error;

		/* downgrade FAIL to WARN if ALLOW_UNSAFE option is used */
		if ((git_filter_source_options(src) & GIT_FILTER_OPT_ALLOW_UNSAFE) &&
			ca.safe_crlf == GIT_SAFE_CRLF_FAIL)
			ca.safe_crlf = GIT_SAFE_CRLF_WARN;
	}

	*payload = git__malloc(sizeof(ca));
	GITERR_CHECK_ALLOC(*payload);
	memcpy(*payload, &ca, sizeof(ca));

	return 0;
}
예제 #6
0
/*
 *	CALL statement
 *	Handles CALL <procedure name> [ ( <parameter list> ) ] ;
 */
void
parse_call(TOKEN *first_token)
{
    TOKEN		token;
    int		token_class;
    DECL_MEMBER	*id_type;
    DECL_ID		*id_id;
    char		*new_func, *tmp_out_string;
    char		func_name[MAX_TOKEN_LENGTH];

    /* Get procedure name */
    token_class = get_token(&token);
    if (token_class != IDENTIFIER) {
        parse_error("Illegal procedure name");
        return;
    }

    out_white_space(first_token);

    /* Check for function conversion */
    if (check_cvt_id(&token, &cvt_functions[0], &new_func)) {
        out_str(new_func);
        token_class = get_token(&token);
    } else

        if (find_symbol(&token, &id_type, &id_id) &&
                (id_type->type->token_type != PROCEDURE)) {

            /* Skip white space */
            token.white_space_start = token.white_space_end;

            /* Check for call to pointer */
            func_name[0] = '\0';
            tmp_out_string = out_string;
            out_string = func_name;
            token_class = parse_variable(&token, &id_type, &id_id);
            out_string = tmp_out_string;

            if ((id_type->type->token_type == POINTER) ||
#ifdef OFFSET
                    (id_type->type->token_type == OFFSET) ||
#endif
                    (id_type->type->token_type == WORD)) {
                /* Yes - use pointer reference */
                out_str("(*");
                out_str(func_name);
                out_char(')');
            } else {
                parse_error("Illegal procedure reference");
                return;
            }
        } else {
            out_token_name(&token);
            token_class = get_token(&token);
        }

    /* Get parameter list (if any) */
    if (token_class == LEFT_PAREN) {
        out_token(&token);

        do {
            token_class = parse_expression(&token);
            out_token(&token);
        } while (token_class == COMMA);

        if (token_class == RIGHT_PAREN)
            /* Get end of line */
            check_eol();
        else
            parse_error("Illegal parameter list seperator");
    } else

        if (token_class == END_OF_LINE) {
            /* No parameter list */
            out_str("()");
            out_token(&token);
        } else
            parse_error("';' expected");
}