diff options
author | Robert Yang <liezhi.yang@windriver.com> | 2015-07-06 03:00:35 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-07-08 00:01:23 +0100 |
commit | eb068cc954b4dadda7d12724ae5edb8e12484460 (patch) | |
tree | eaeaf6b16237fb6ad168b5a3667262fd38b3b15a /meta/recipes-devtools | |
parent | 21bdccb23e5dec65db7f5c09aee6772f4b79a6cd (diff) | |
download | poky-eb068cc954b4dadda7d12724ae5edb8e12484460.tar.gz |
file: fix long-options
Backport two patches to fix bug with long options:
* 0001-Fix-bug-with-long-options-and-explicitly-number-them.patch
* 0002-fix-bug-with-5.23-long-options.patch
(From OE-Core rev: df6ddc4bf9795212fda87f9d401893eb254074da)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools')
3 files changed, 144 insertions, 0 deletions
diff --git a/meta/recipes-devtools/file/file/0001-Fix-bug-with-long-options-and-explicitly-number-them.patch b/meta/recipes-devtools/file/file/0001-Fix-bug-with-long-options-and-explicitly-number-them.patch new file mode 100644 index 0000000000..0a3e27aa3a --- /dev/null +++ b/meta/recipes-devtools/file/file/0001-Fix-bug-with-long-options-and-explicitly-number-them.patch | |||
@@ -0,0 +1,116 @@ | |||
1 | From 21f9d5f0e0340ada998f7f9d316368c7167a4afa Mon Sep 17 00:00:00 2001 | ||
2 | From: Christos Zoulas <christos@zoulas.com> | ||
3 | Date: Thu, 11 Jun 2015 12:52:32 +0000 | ||
4 | Subject: [PATCH 1/2] Fix bug with long options and explicitly number them to | ||
5 | avoid this in the future. | ||
6 | |||
7 | Upstream-Status: Backport | ||
8 | |||
9 | Signed-off-by: Robert Yang <liezhi.yang@windriver.com> | ||
10 | |||
11 | --- | ||
12 | src/file.c | 44 +++++++++++++++++++++++---------------------- | ||
13 | src/file_opts.h | 10 +++++----- | ||
14 | 2 files changed, 27 insertions(+), 26 deletions(-) | ||
15 | |||
16 | diff --git a/src/file.c b/src/file.c | ||
17 | index f60dde0..c700f66 100644 | ||
18 | --- a/src/file.c | ||
19 | +++ b/src/file.c | ||
20 | @@ -89,10 +89,15 @@ private int /* Global command-line options */ | ||
21 | |||
22 | private const char *separator = ":"; /* Default field separator */ | ||
23 | private const struct option long_options[] = { | ||
24 | +#define OPT_HELP 1 | ||
25 | +#define OPT_APPLE 2 | ||
26 | +#define OPT_EXTENSIONS 3 | ||
27 | +#define OPT_MIME_TYPE 4 | ||
28 | +#define OPT_MIME_ENCODING 5 | ||
29 | #define OPT(shortname, longname, opt, doc) \ | ||
30 | {longname, opt, NULL, shortname}, | ||
31 | -#define OPT_LONGONLY(longname, opt, doc) \ | ||
32 | - {longname, opt, NULL, 0}, | ||
33 | +#define OPT_LONGONLY(longname, opt, doc, id) \ | ||
34 | + {longname, opt, NULL, id}, | ||
35 | #include "file_opts.h" | ||
36 | #undef OPT | ||
37 | #undef OPT_LONGONLY | ||
38 | @@ -182,24 +187,20 @@ main(int argc, char *argv[]) | ||
39 | while ((c = getopt_long(argc, argv, OPTSTRING, long_options, | ||
40 | &longindex)) != -1) | ||
41 | switch (c) { | ||
42 | - case 0 : | ||
43 | - switch (longindex) { | ||
44 | - case 0: | ||
45 | - help(); | ||
46 | - break; | ||
47 | - case 10: | ||
48 | - flags |= MAGIC_APPLE; | ||
49 | - break; | ||
50 | - case 11: | ||
51 | - flags |= MAGIC_EXTENSION; | ||
52 | - break; | ||
53 | - case 12: | ||
54 | - flags |= MAGIC_MIME_TYPE; | ||
55 | - break; | ||
56 | - case 13: | ||
57 | - flags |= MAGIC_MIME_ENCODING; | ||
58 | - break; | ||
59 | - } | ||
60 | + case OPT_HELP: | ||
61 | + help(); | ||
62 | + break; | ||
63 | + case OPT_APPLE: | ||
64 | + flags |= MAGIC_APPLE; | ||
65 | + break; | ||
66 | + case OPT_EXTENSIONS: | ||
67 | + flags |= MAGIC_EXTENSION; | ||
68 | + break; | ||
69 | + case OPT_MIME_TYPE: | ||
70 | + flags |= MAGIC_MIME_TYPE; | ||
71 | + break; | ||
72 | + case OPT_MIME_ENCODING: | ||
73 | + flags |= MAGIC_MIME_ENCODING; | ||
74 | break; | ||
75 | case '0': | ||
76 | nulsep = 1; | ||
77 | @@ -595,7 +596,7 @@ help(void) | ||
78 | #define OPT(shortname, longname, opt, doc) \ | ||
79 | fprintf(stdout, " -%c, --" longname, shortname), \ | ||
80 | docprint(doc); | ||
81 | -#define OPT_LONGONLY(longname, opt, doc) \ | ||
82 | +#define OPT_LONGONLY(longname, opt, doc, id) \ | ||
83 | fprintf(stdout, " --" longname), \ | ||
84 | docprint(doc); | ||
85 | #include "file_opts.h" | ||
86 | diff --git a/src/file_opts.h b/src/file_opts.h | ||
87 | index 036505f..2e30d06 100644 | ||
88 | --- a/src/file_opts.h | ||
89 | +++ b/src/file_opts.h | ||
90 | @@ -12,7 +12,7 @@ | ||
91 | * switch statement! | ||
92 | */ | ||
93 | |||
94 | -OPT_LONGONLY("help", 0, " display this help and exit\n") | ||
95 | +OPT_LONGONLY("help", 0, " display this help and exit\n", OPT_HELP) | ||
96 | OPT('v', "version", 0, " output version information and exit\n") | ||
97 | OPT('m', "magic-file", 1, " LIST use LIST as a colon-separated list of magic\n" | ||
98 | " number files\n") | ||
99 | @@ -29,10 +29,10 @@ OPT('f', "files-from", 1, " FILE read the filenames to be examined from FIL | ||
100 | OPT('F', "separator", 1, " STRING use string as separator instead of `:'\n") | ||
101 | OPT('i', "mime", 0, " output MIME type strings (--mime-type and\n" | ||
102 | " --mime-encoding)\n") | ||
103 | -OPT_LONGONLY("apple", 0, " output the Apple CREATOR/TYPE\n") | ||
104 | -OPT_LONGONLY("extension", 0, " output a slash-separated list of extnsions\n") | ||
105 | -OPT_LONGONLY("mime-type", 0, " output the MIME type\n") | ||
106 | -OPT_LONGONLY("mime-encoding", 0, " output the MIME encoding\n") | ||
107 | +OPT_LONGONLY("apple", 0, " output the Apple CREATOR/TYPE\n", OPT_APPLE) | ||
108 | +OPT_LONGONLY("extension", 0, " output a slash-separated list of extensions\n", OPT_EXTENSIONS) | ||
109 | +OPT_LONGONLY("mime-type", 0, " output the MIME type\n", OPT_MIME_TYPE) | ||
110 | +OPT_LONGONLY("mime-encoding", 0, " output the MIME encoding\n", OPT_MIME_ENCODING) | ||
111 | OPT('k', "keep-going", 0, " don't stop at the first match\n") | ||
112 | OPT('l', "list", 0, " list magic strength\n") | ||
113 | #ifdef S_IFLNK | ||
114 | -- | ||
115 | 1.7.9.5 | ||
116 | |||
diff --git a/meta/recipes-devtools/file/file/0002-fix-bug-with-5.23-long-options.patch b/meta/recipes-devtools/file/file/0002-fix-bug-with-5.23-long-options.patch new file mode 100644 index 0000000000..a9f2eda6c8 --- /dev/null +++ b/meta/recipes-devtools/file/file/0002-fix-bug-with-5.23-long-options.patch | |||
@@ -0,0 +1,26 @@ | |||
1 | From 5c40ae1728f08bb7e1229d3aa90e38d2c342fc53 Mon Sep 17 00:00:00 2001 | ||
2 | From: Christos Zoulas <christos@zoulas.com> | ||
3 | Date: Thu, 11 Jun 2015 12:53:26 +0000 | ||
4 | Subject: [PATCH 2/2] fix bug with 5.23 long options | ||
5 | |||
6 | Upstream-Status: Backport | ||
7 | |||
8 | Signed-off-by: Robert Yang <liezhi.yang@windriver.com> | ||
9 | --- | ||
10 | ChangeLog | 3 +++ | ||
11 | 1 file changed, 3 insertions(+) | ||
12 | |||
13 | diff --git a/ChangeLog b/ChangeLog | ||
14 | index 1ac5ad2..0922fc7 100644 | ||
15 | --- a/ChangeLog | ||
16 | +++ b/ChangeLog | ||
17 | @@ -1,3 +1,6 @@ | ||
18 | +2015-06-11 8:52 Christos Zoulas <christos@zoulas.com> | ||
19 | + | ||
20 | + * redo long option encoding to fix off-by-one in 5.23 | ||
21 | |||
22 | 2015-06-10 13:50 Christos Zoulas <christos@zoulas.com> | ||
23 | |||
24 | -- | ||
25 | 1.7.9.5 | ||
26 | |||
diff --git a/meta/recipes-devtools/file/file_5.23.bb b/meta/recipes-devtools/file/file_5.23.bb index d71f29056c..04a1d7bfcf 100644 --- a/meta/recipes-devtools/file/file_5.23.bb +++ b/meta/recipes-devtools/file/file_5.23.bb | |||
@@ -14,6 +14,8 @@ DEPENDS_class-native = "zlib-native" | |||
14 | SRC_URI = "ftp://ftp.astron.com/pub/file/${BP}.tar.gz \ | 14 | SRC_URI = "ftp://ftp.astron.com/pub/file/${BP}.tar.gz \ |
15 | file://debian-742262.patch \ | 15 | file://debian-742262.patch \ |
16 | file://0001-Add-P-prompt-into-Usage-info.patch \ | 16 | file://0001-Add-P-prompt-into-Usage-info.patch \ |
17 | file://0001-Fix-bug-with-long-options-and-explicitly-number-them.patch \ | ||
18 | file://0002-fix-bug-with-5.23-long-options.patch \ | ||
17 | " | 19 | " |
18 | 20 | ||
19 | SRC_URI[md5sum] = "61db35209ce71a6d576392ce6e1d2f80" | 21 | SRC_URI[md5sum] = "61db35209ce71a6d576392ce6e1d2f80" |