Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-5]: src/sbin/rcorder pull up rcorder.c 1.5 and rcorder.8 1.3, a...



details:   https://anonhg.NetBSD.org/src/rev/13d24cafd60c
branches:  netbsd-1-5
changeset: 488570:13d24cafd60c
user:      mrg <mrg%NetBSD.org@localhost>
date:      Tue Jul 18 16:29:58 2000 +0000

description:
pull up rcorder.c 1.5 and rcorder.8 1.3, approved by thorpej:
>implement `# KEYWORD:' support, with two new arguments to rcorder, to kill
>and skip keywords from the output list:
>
>        -k keyword      only files with `# KEYWORD: keyword' will be printed.
>        -s keyword      files with `# KEYWORD: keyword' will not be printed.
>
>(multiple keywords can exist on a single line, and multiple lines may exist,
>as with other special rcorder lines).
>
>requested by lukem.

diffstat:

 sbin/rcorder/rcorder.8 |   40 ++++++++++----
 sbin/rcorder/rcorder.c |  134 +++++++++++++++++++++++++++++++++++++++++++-----
 2 files changed, 148 insertions(+), 26 deletions(-)

diffs (truncated from 382 to 300 lines):

diff -r d5ce87554bf5 -r 13d24cafd60c sbin/rcorder/rcorder.8
--- a/sbin/rcorder/rcorder.8    Tue Jul 18 16:23:16 2000 +0000
+++ b/sbin/rcorder/rcorder.8    Tue Jul 18 16:29:58 2000 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: rcorder.8,v 1.1 1999/11/23 05:50:08 mrg Exp $
+.\"    $NetBSD: rcorder.8,v 1.1.6.1 2000/07/18 16:29:58 mrg Exp $
 .\"
 .\" Copyright (c) 1998
 .\"    Perry E. Metzger.  All rights reserved.
@@ -30,7 +30,7 @@
 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
 .\"
-.Dd September 22, 1998
+.Dd July 17, 2000
 .Dt RCORDER 8
 .Os
 .Sh NAME
@@ -38,6 +38,8 @@
 .Nd print a dependency ordering of interdependent files
 .Sh SYNOPSIS
 .Nm
+.Op Fl k Ar keep
+.Op Fl s Ar skip
 .Ar
 .Sh DESCRIPTION
 .Nm
@@ -58,28 +60,47 @@
 .Pp
 Within each file, a block containing a series of
 .Dq REQUIRE ,
-.Dq PROVIDE
+.Dq PROVIDE ,
+.Dq BEFORE
 and
-.Dq BEFORE
+.Dq KEYWORD
 lines must appear.
 The format of the lines is rigid. Each line must begin with a single
 .Dq # ,
 followed by a single space, followed by
 .Dq PROVIDE: ,
-.Dq REQUIRE: 
+.Dq REQUIRE: ,
+.Dq BEFORE: ,
 or
-.Dq BEFORE: .
+.Dq KEYWORD: .
 No deviation is permitted.
 Each dependency line is then followed by a series of conditions,
 separated by whitespace. Multiple
 .Dq PROVIDE ,
-.Dq REQUIRE
+.Dq REQUIRE ,
+.Dq BEFORE
 and
-.Dq BEFORE
+.Dq KEYWORD
 lines may appear, but all such lines must appear in a sequence without 
 any intervening lines, as once a line that does not follow the format
 is reached, parsing stops.
 .Pp
+The options are as follows:
+.Bl -tag -width Ds
+.It Fl k
+Add the specified keyword to the
+.Dq keep list .
+If any
+.Fl k
+option is given, only those files containing the matching keyword are listed.
+.It Fl s
+Add the specified keyword to the
+.Dq skip list .
+If any
+.Fl s
+option is given, files containing the matching keyword are not listed.
+.El
+.Pp
  An example block follows:
 .Bd -literal -offset indent
 # REQUIRE: networking syslog
@@ -107,8 +128,6 @@
 arguments passed to
 .Nm
 in order for it to find a starting place in the dependency ordering.
-.\" .Sh FILES
-.\" .Sh EXAMPLES
 .Sh DIAGNOSTICS
 .Nm
 may print one of the following error messages and exit with a non-zero
@@ -137,4 +156,3 @@
 .Sh AUTHORS
 Written by Perry E. Metzger (perry%piermont.com@localhost) and Matthew R.
 Green (mrg%eterna.com.au@localhost).
-.\" .Sh BUGS
diff -r d5ce87554bf5 -r 13d24cafd60c sbin/rcorder/rcorder.c
--- a/sbin/rcorder/rcorder.c    Tue Jul 18 16:23:16 2000 +0000
+++ b/sbin/rcorder/rcorder.c    Tue Jul 18 16:29:58 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rcorder.c,v 1.4 2000/05/10 02:04:27 enami Exp $        */
+/*     $NetBSD: rcorder.c,v 1.4.4.1 2000/07/18 16:29:58 mrg Exp $      */
 
 /*
  * Copyright (c) 1998, 1999 Matthew R. Green
@@ -64,6 +64,10 @@
 #define PROVIDES_LEN   (sizeof(PROVIDES_STR) - 1)
 #define BEFORE_STR     "# BEFORE:"
 #define BEFORE_LEN     (sizeof(BEFORE_STR) - 1)
+#define KEYWORD_STR    "# KEYWORD:"
+#define KEYWORD_LEN    (sizeof(KEYWORD_STR) - 1)
+#define KEYWORDS_STR   "# KEYWORDS:"
+#define KEYWORDS_LEN   (sizeof(KEYWORDS_STR) - 1)
 
 int exit_code;
 int file_count;
@@ -82,7 +86,7 @@
 typedef struct filenode filenode;
 typedef struct f_provnode f_provnode;
 typedef struct f_reqnode f_reqnode;
-typedef struct beforelist beforelist;
+typedef struct strnodelist strnodelist;
 
 struct provnode {
        flag            head;
@@ -101,32 +105,42 @@
        f_reqnode       *next;
 };
 
+struct strnodelist {
+       filenode        *node;
+       char            *s;
+       strnodelist     *next;
+};
+
 struct filenode {
        char            *filename;
        flag            in_progress;
        filenode        *next, *last;
        f_reqnode       *req_list;
        f_provnode      *prov_list;
+       strnodelist     *keyword_list;
 };
 
-struct beforelist {
-       filenode        *node;
-       char            *s;
-       beforelist      *next;
-} *bl_list = NULL;
-
 filenode fn_head_s, *fn_head;
 
+strnodelist *bl_list;
+strnodelist *keep_list;
+strnodelist *skip_list;
+
 void do_file __P((filenode *fnode));
+void strnode_add __P((strnodelist **, char *, filenode *));
+int skip_ok __P((filenode *fnode));
+int keep_ok __P((filenode *fnode));
 void satisfy_req __P((f_reqnode *rnode, char *filename));
 void crunch_file __P((char *));
 void parse_require __P((filenode *, char *));
 void parse_provide __P((filenode *, char *));
 void parse_before __P((filenode *, char *));
+void parse_keywords __P((filenode *, char *));
 filenode *filenode_new __P((char *));
 void add_require __P((filenode *, char *));
 void add_provide __P((filenode *, char *));
 void add_before __P((filenode *, char *));
+void add_keyword __P((filenode *, char *));
 void insert_before __P((void));
 Hash_Entry *make_fake_provision __P((filenode *));
 void crunch_all_files __P((void));
@@ -141,7 +155,7 @@
 {
        int ch;
 
-       while ((ch = getopt(argc, argv, "d")) != -1)
+       while ((ch = getopt(argc, argv, "dk:s:")) != -1)
                switch (ch) {
                case 'd':
 #ifdef DEBUG
@@ -150,6 +164,12 @@
                        warnx("debugging not compiled in, -d ignored");
 #endif
                        break;
+               case 'k':
+                       strnode_add(&keep_list, optarg, 0);
+                       break;
+               case 's':
+                       strnode_add(&skip_list, optarg, 0);
+                       break;
                default:
                        /* XXX should crunch it? */
                        break;
@@ -184,6 +204,22 @@
        Hash_InitTable(provide_hash, file_count);
 }
 
+/* generic function to insert a new strnodelist element */
+void
+strnode_add(listp, s, fnode)
+       strnodelist **listp;
+       char *s;
+       filenode *fnode;
+{
+       strnodelist *ent;
+
+       ent = emalloc(sizeof *ent);
+       ent->node = fnode;
+       ent->s = s;
+       ent->next = *listp;
+       *listp = ent;
+}
+
 /*
  * below are the functions that deal with creating the lists
  * from the filename's given and the dependancies and provisions
@@ -205,6 +241,7 @@
        temp->filename = estrdup(filename);
        temp->req_list = NULL;
        temp->prov_list = NULL;
+       temp->keyword_list = NULL;
        temp->in_progress = RESET;
        /*
         * link the filenode into the list of filenodes.
@@ -220,7 +257,7 @@
 }
 
 /*
- * add a requirement a filenode.
+ * add a requirement to a filenode.
  */
 void
 add_require(fnode, s)
@@ -330,7 +367,7 @@
        filenode *fnode;
        char *s;
 {
-       beforelist *bf_ent;
+       strnodelist *bf_ent;
 
        bf_ent = emalloc(sizeof *bf_ent);
        bf_ent->node = fnode;
@@ -340,6 +377,18 @@
 }
 
 /*
+ * add a key to a filenode.
+ */
+void
+add_keyword(fnode, s)
+       filenode *fnode;
+       char *s;
+{
+
+       strnode_add(&fnode->keyword_list, s, fnode);
+}
+
+/*
  * loop over the rest of a REQUIRE line, giving each word to
  * add_require() to do the real work.
  */
@@ -388,6 +437,22 @@
 }
 
 /*
+ * loop over the rest of a KEYWORD line, giving each word to
+ * add_keyword() to do the real work.
+ */
+void
+parse_keywords(node, buffer)
+       filenode *node;
+       char *buffer;
+{
+       char *s;
+       
+       while ((s = strsep(&buffer, " \t\n")) != NULL)
+               if (*s != '\0')
+                       add_keyword(node, s);
+}
+
+/*
  * given a file name, create a filenode for it, read in lines looking
  * for provision and requirement lines, building the graphs as needed.
  */
@@ -397,7 +462,8 @@
 {
        FILE *fp;
        char *buf;
-       int require_flag, provide_flag, before_flag, directive_flag;
+       int require_flag, provide_flag, before_flag, keywords_flag,
+           directive_flag;
        filenode *node;
        char delims[3] = { '\\', '\\', '\0' };
        struct stat st;
@@ -428,7 +494,7 @@
         * and have no flags.
         */
        while ((buf = fparseln(fp, NULL, NULL, delims, 0))) {



Home | Main Index | Thread Index | Old Index