Ejemplo n.º 1
0
static void
read_logical_line(Buffer linebuf, int c)
{
	for (;;) {
		if (c == '\n') {
			current->lineno++;
			break;
		}
		if (c == EOF)
			break;
		Buf_AddChar(linebuf, c);
		c = read_char();
		while (c == '\\') {
			c = read_char();
			if (c == '\n') {
				Buf_AddSpace(linebuf);
				current->lineno++;
				do {
					c = read_char();
				} while (c == ' ' || c == '\t');
			} else {
				Buf_AddChar(linebuf, '\\');
				if (c == '\\') {
					Buf_AddChar(linebuf, '\\');
					c = read_char();
				}
				break;
			}
		}
	}
}
Ejemplo n.º 2
0
Archivo: var.c Proyecto: aharri/base
/* POSIX says that variable assignments passed on the command line should be
 * propagated to sub makes through MAKEFLAGS.
 */
void
Var_AddCmdline(const char *name)
{
	Var *v;
	unsigned int i;
	BUFFER buf;
	char *s;

	Buf_Init(&buf, MAKE_BSIZE);

	for (v = ohash_first(&global_variables, &i); v != NULL;
	    v = ohash_next(&global_variables, &i)) {
		/* This is not as expensive as it looks: this function is
		 * called before parsing Makefiles, so there are just a
		 * few non cmdling variables in there.
		 */
		if (!(v->flags & VAR_FROM_CMD)) {
			continue;
		}
		/* We assume variable names don't need quoting */
		Buf_AddString(&buf, v->name);
		Buf_AddChar(&buf, '=');
		for (s = var_get_value(v); *s != '\0'; s++) {
			if (strchr(quotable, *s))
				Buf_AddChar(&buf, '\\');
			Buf_AddChar(&buf, *s);
		}
		Buf_AddSpace(&buf);
	}
	Var_Append(name, Buf_Retrieve(&buf));
	Buf_Destroy(&buf);
}
Ejemplo n.º 3
0
Archivo: var.c Proyecto: aharri/base
/* Add to a variable, insert a separating space if the variable was already
 * defined.
 */
static void
var_append_value(Var *v, const char *val)
{
	if ((v->flags & VAR_DUMMY) == 0) {
		Buf_AddSpace(&(v->val));
		Buf_AddString(&(v->val), val);
	} else {
		var_set_initial_value(v, val);
		v->flags &= ~VAR_DUMMY;
	}
}
Ejemplo n.º 4
0
void
Make_DoAllVar(GNode *gn)
{
    GNode *child;
    LstNode ln;
    BUFFER allsrc, oodate;
    char *target;
    bool do_oodate;
    int oodate_count, allsrc_count = 0;

    oodate_count = 0;
    allsrc_count = 0;

    for (ln = Lst_First(&gn->children); ln != NULL; ln = Lst_Adv(ln)) {
        child = (GNode *)Lst_Datum(ln);
        if ((child->type & (OP_EXEC|OP_USE|OP_INVISIBLE)) != 0)
            continue;
        if (OP_NOP(child->type) ||
                (target = Var(TARGET_INDEX, child)) == NULL) {
            /*
             * this node is only source; use the specific pathname
             * for it
             */
            target = child->path != NULL ? child->path :
                     child->name;
        }

        /*
         * It goes in the OODATE variable if the parent is younger than
         * the child or if the child has been modified more recently
         * than the start of the make.  This is to keep make from
         * getting confused if something else updates the parent after
         * the make starts (shouldn't happen, I know, but sometimes it
         * does). In such a case, if we've updated the kid, the parent
         * is likely to have a modification time later than that of the
         * kid and anything that relies on the OODATE variable will be
         * hosed.
         */
        do_oodate = false;
        if (gn->type & OP_JOIN) {
            if (child->built_status == MADE)
                do_oodate = true;
        } else if (is_strictly_before(gn->mtime, child->mtime) ||
                   (!is_strictly_before(child->mtime, now) &&
                    child->built_status == MADE))
            do_oodate = true;
        if (do_oodate) {
            oodate_count++;
            if (oodate_count == 1)
                Var(OODATE_INDEX, gn) = target;
            else {
                if (oodate_count == 2) {
                    Buf_Init(&oodate, 0);
                    Buf_AddString(&oodate,
                                  Var(OODATE_INDEX, gn));
                }
                Buf_AddSpace(&oodate);
                Buf_AddString(&oodate, target);
            }
        }
        allsrc_count++;
        if (allsrc_count == 1)
            Var(ALLSRC_INDEX, gn) = target;
        else {
            if (allsrc_count == 2) {
                Buf_Init(&allsrc, 0);
                Buf_AddString(&allsrc,
                              Var(ALLSRC_INDEX, gn));
            }
            Buf_AddSpace(&allsrc);
            Buf_AddString(&allsrc, target);
        }
    }

    if (allsrc_count > 1)
        Var(ALLSRC_INDEX, gn) = Buf_Retrieve(&allsrc);
    if (oodate_count > 1)
        Var(OODATE_INDEX, gn) = Buf_Retrieve(&oodate);

    if (gn->impliedsrc)
        Var(IMPSRC_INDEX, gn) = Var(TARGET_INDEX, gn->impliedsrc);

    if (gn->type & OP_JOIN)
        Var(TARGET_INDEX, gn) = Var(ALLSRC_INDEX, gn);
}