From f14c041e51482adcc737ece27314b711df2d7495 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Sun, 21 Nov 2010 03:53:19 -0300 Subject: [PATCH] qpkg: record Architecture: tag - qpkg.h (struct pkg): added "arch" field for the architecture - gobble.c (gobble_buf): record the architecture - gobble.c (gobble_buf): fail if trying to set the file name twice - qpkg.c (main): initialize trees before doing anything else, so that the argument processing stays together --- qpkg/gobble.c | 13 +++++++++++-- qpkg/qpkg.c | 6 ++++-- qpkg/qpkg.h | 1 + 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/qpkg/gobble.c b/qpkg/gobble.c index dfcbb64..3c9dfa4 100644 --- a/qpkg/gobble.c +++ b/qpkg/gobble.c @@ -134,8 +134,7 @@ initial: switch (NEXT) { case 'r': EXPECT("chitecture:"); - /* @@@ use later */ - goto skip_data; + goto architecture; case 'u': EXPECT("to-Installed:"); goto skip_data; @@ -290,6 +289,7 @@ package: pkg->more = jrb->val; jrb->val = pkg; pkg->version = NULL; + pkg->arch = NULL; pkg->conflicts = pkg->depends = NULL; pkg->filename = NULL; pkg->flags = 0; @@ -303,6 +303,13 @@ version: pkg->version = ID(versions)->key; goto eol; +architecture: + WHITESPACE; + if (pkg->arch) + FAIL; + pkg->arch = buf; + goto skip_data; + provides: /* @@@ later */ goto skip_data; @@ -314,6 +321,8 @@ status: filename: WHITESPACE; + if (pkg->filename) + FAIL; pkg->filename = buf; goto skip_data; diff --git a/qpkg/qpkg.c b/qpkg/qpkg.c index f79dc51..ee9faca 100644 --- a/qpkg/qpkg.c +++ b/qpkg/qpkg.c @@ -126,10 +126,12 @@ int main(int argc, char **argv) { int arg; - if (argc == 1) - usage(*argv); packages = make_tree(comp_id); versions = make_tree(comp_id); + + if (argc == 1) + usage(*argv); + for (arg = 1; arg != argc; arg++) { if (*argv[arg] == '-') usage(*argv); diff --git a/qpkg/qpkg.h b/qpkg/qpkg.h index 97d3b5b..a554577 100644 --- a/qpkg/qpkg.h +++ b/qpkg/qpkg.h @@ -35,6 +35,7 @@ struct ref { struct pkg { struct id *id; struct id *version; + const char *arch; struct ref *conflicts; struct ref *depends; const char *filename;