summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2007-09-23 09:47:57 +0000
committerMarc Espie <espie@cvs.openbsd.org>2007-09-23 09:47:57 +0000
commit2f05a54a973b82f3957901d408b37a9a5fc386e0 (patch)
treed3e10bb64586933ab48af3d6545ada2e897b7b7c
parent86e89f1941245d96a167ed39e0f8557dd4d25953 (diff)
put parsing of operator (:, ::, !) into its own function
-rw-r--r--usr.bin/make/gnode.h3
-rw-r--r--usr.bin/make/parse.c55
2 files changed, 35 insertions, 23 deletions
diff --git a/usr.bin/make/gnode.h b/usr.bin/make/gnode.h
index 7d5f1770495..795a87842db 100644
--- a/usr.bin/make/gnode.h
+++ b/usr.bin/make/gnode.h
@@ -1,7 +1,7 @@
#ifndef GNODE_H
#define GNODE_H
/* $OpenPackages$ */
-/* $OpenBSD: gnode.h,v 1.5 2007/09/17 12:42:09 espie Exp $ */
+/* $OpenBSD: gnode.h,v 1.6 2007/09/23 09:47:56 espie Exp $ */
/*
* Copyright (c) 2001 Marc Espie.
@@ -155,6 +155,7 @@ struct GNode_ {
#define OP_FORCE 0x00000002 /* Always execute commands (!) */
#define OP_DOUBLEDEP 0x00000004 /* Execution of commands depends on kids
* per line (::) */
+#define OP_ERROR 0x00000000
#define OP_OPMASK (OP_DEPENDS|OP_FORCE|OP_DOUBLEDEP)
#define OP_OPTIONAL 0x00000008 /* Don't care if the target doesn't
diff --git a/usr.bin/make/parse.c b/usr.bin/make/parse.c
index 2f932f1feb4..bf04d4b95d6 100644
--- a/usr.bin/make/parse.c
+++ b/usr.bin/make/parse.c
@@ -1,5 +1,5 @@
/* $OpenPackages$ */
-/* $OpenBSD: parse.c,v 1.94 2007/09/18 08:46:10 espie Exp $ */
+/* $OpenBSD: parse.c,v 1.95 2007/09/23 09:47:56 espie Exp $ */
/* $NetBSD: parse.c,v 1.29 1997/03/10 21:20:04 christos Exp $ */
/*
@@ -157,6 +157,7 @@ static void lookup_sysv_style_include(const char *, const char *, bool);
static void lookup_sysv_include(const char *, const char *);
static void lookup_conditional_include(const char *, const char *);
static bool parse_as_special_line(Buffer, Buffer, const char *);
+static int parse_operator(const char **);
static const char *parse_do_targets(Lst, int *, const char *);
static void parse_target_line(struct growableArray *, const char *,
@@ -738,6 +739,35 @@ handle_special_targets(Lst paths)
}
}
+static int
+parse_operator(const char **pos)
+{
+ const char *cp = *pos;
+ int op = OP_ERROR;
+
+ if (*cp == '!') {
+ op = OP_FORCE;
+ } else if (*cp == ':') {
+ if (cp[1] == ':') {
+ op = OP_DOUBLEDEP;
+ cp++;
+ } else {
+ op = OP_DEPENDS;
+ }
+ } else {
+ Parse_Error(PARSE_FATAL, "Missing dependency operator");
+ return OP_ERROR;
+ }
+
+ cp++; /* Advance beyond operator */
+
+ /* Get to the first source */
+ while (isspace(*cp))
+ cp++;
+ *pos = cp;
+ return op;
+}
+
/*-
*---------------------------------------------------------------------
* ParseDoDependency --
@@ -788,31 +818,12 @@ ParseDoDependency(const char *line) /* the line to parse */
if (cp == NULL || specType == SPECIAL_ERROR)
return;
- /* Have now parsed all the target names. Must parse the operator next.
- * The result is left in op . */
- if (*cp == '!') {
- op = OP_FORCE;
- } else if (*cp == ':') {
- if (cp[1] == ':') {
- op = OP_DOUBLEDEP;
- cp++;
- } else {
- op = OP_DEPENDS;
- }
- } else {
- Parse_Error(PARSE_FATAL, "Missing dependency operator");
+ op = parse_operator(&cp);
+ if (op == OP_ERROR)
return;
- }
-
- cp++; /* Advance beyond operator */
Array_FindP(&gtargets, ParseDoOp, op);
- /*
- * Get to the first source
- */
- while (isspace(*cp))
- cp++;
line = cp;
/*