summaryrefslogtreecommitdiff
path: root/pkg/squashfs-tools/patch/0003-Convert-TOK_TO_STR-to-an-inline-function.patch
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2020-01-31 23:49:33 -0800
committerMichael Forney <mforney@mforney.org>2020-02-01 01:37:46 -0800
commit3d9401137c5034e53f9bd31b1e5dbf9365c6c260 (patch)
tree6a484a8f3d94112127f9d04a7f72f8bd9642194e /pkg/squashfs-tools/patch/0003-Convert-TOK_TO_STR-to-an-inline-function.patch
parent413335f482a5d6d79e33ffa321c71d8fe883d200 (diff)
squashfs-tools: Fix a few portability issues
Diffstat (limited to 'pkg/squashfs-tools/patch/0003-Convert-TOK_TO_STR-to-an-inline-function.patch')
-rw-r--r--pkg/squashfs-tools/patch/0003-Convert-TOK_TO_STR-to-an-inline-function.patch149
1 files changed, 149 insertions, 0 deletions
diff --git a/pkg/squashfs-tools/patch/0003-Convert-TOK_TO_STR-to-an-inline-function.patch b/pkg/squashfs-tools/patch/0003-Convert-TOK_TO_STR-to-an-inline-function.patch
new file mode 100644
index 00000000..83f8a231
--- /dev/null
+++ b/pkg/squashfs-tools/patch/0003-Convert-TOK_TO_STR-to-an-inline-function.patch
@@ -0,0 +1,149 @@
+From 5bab68afaeaab209cde2ddb8767f0aa3f5b30e9f Mon Sep 17 00:00:00 2001
+From: Michael Forney <mforney@mforney.org>
+Date: Fri, 31 Jan 2020 17:59:06 -0800
+Subject: [PATCH] Convert TOK_TO_STR to an inline function
+
+This avoids the use of statement expressions, which are a GNU C
+extension.
+---
+ squashfs-tools/action.c | 33 ++++++++++++++++++++++++---------
+ squashfs-tools/action.h | 16 ----------------
+ 2 files changed, 24 insertions(+), 25 deletions(-)
+
+diff --git a/squashfs-tools/action.c b/squashfs-tools/action.c
+index 38438dc..18505dc 100644
+--- a/squashfs-tools/action.c
++++ b/squashfs-tools/action.c
+@@ -91,6 +91,21 @@ extern char *subpathname(struct dir_ent *);
+
+ extern int read_file(char *filename, char *type, int (parse_line)(char *));
+
++static inline char *tok_to_str(int op, char *s)
++{
++ switch(op) {
++ case TOK_EOF:
++ s = "EOF";
++ break;
++ case TOK_STRING:
++ break;
++ default:
++ s = token_table[op].string;
++ break;
++ }
++ return s;
++}
++
+ /*
+ * Lexical analyser
+ */
+@@ -321,7 +336,7 @@ static struct expr *parse_test(char *name)
+ while(1) {
+ if (token != TOK_STRING) {
+ SYNTAX_ERROR("Unexpected token \"%s\", expected "
+- "argument\n", TOK_TO_STR(token, string));
++ "argument\n", tok_to_str(token, string));
+ goto failed;
+ }
+
+@@ -338,7 +353,7 @@ static struct expr *parse_test(char *name)
+
+ if (token != TOK_COMMA) {
+ SYNTAX_ERROR("Unexpected token \"%s\", expected "
+- "\",\" or \")\"\n", TOK_TO_STR(token, string));
++ "\",\" or \")\"\n", tok_to_str(token, string));
+ goto failed;
+ }
+ token = get_token(&string);
+@@ -388,7 +403,7 @@ static struct expr *get_atom()
+ default:
+ SYNTAX_ERROR("Unexpected token \"%s\", expected test "
+ "operation, \"!\", or \"(\"\n",
+- TOK_TO_STR(token, string));
++ tok_to_str(token, string));
+ return NULL;
+ }
+ }
+@@ -425,7 +440,7 @@ static struct expr *parse_expr(int subexp)
+ if (op != TOK_AND && op != TOK_OR) {
+ free_parse_tree(expr);
+ SYNTAX_ERROR("Unexpected token \"%s\", expected "
+- "\"&&\" or \"||\"\n", TOK_TO_STR(op, string));
++ "\"&&\" or \"||\"\n", tok_to_str(op, string));
+ return NULL;
+ }
+
+@@ -454,7 +469,7 @@ int parse_action(char *s, int verbose)
+
+ if (token != TOK_STRING) {
+ SYNTAX_ERROR("Unexpected token \"%s\", expected name\n",
+- TOK_TO_STR(token, string));
++ tok_to_str(token, string));
+ return 0;
+ }
+
+@@ -476,7 +491,7 @@ int parse_action(char *s, int verbose)
+
+ if (token != TOK_OPEN_BRACKET) {
+ SYNTAX_ERROR("Unexpected token \"%s\", expected \"(\"\n",
+- TOK_TO_STR(token, string));
++ tok_to_str(token, string));
+ goto failed;
+ }
+
+@@ -492,7 +507,7 @@ int parse_action(char *s, int verbose)
+ while (1) {
+ if (token != TOK_STRING) {
+ SYNTAX_ERROR("Unexpected token \"%s\", expected "
+- "argument\n", TOK_TO_STR(token, string));
++ "argument\n", tok_to_str(token, string));
+ goto failed;
+ }
+
+@@ -509,7 +524,7 @@ int parse_action(char *s, int verbose)
+
+ if (token != TOK_COMMA) {
+ SYNTAX_ERROR("Unexpected token \"%s\", expected "
+- "\",\" or \")\"\n", TOK_TO_STR(token, string));
++ "\",\" or \")\"\n", tok_to_str(token, string));
+ goto failed;
+ }
+ token = get_token(&string);
+@@ -537,7 +552,7 @@ skip_args:
+
+ if (token != TOK_AT) {
+ SYNTAX_ERROR("Unexpected token \"%s\", expected \"@\"\n",
+- TOK_TO_STR(token, string));
++ tok_to_str(token, string));
+ goto failed;
+ }
+
+diff --git a/squashfs-tools/action.h b/squashfs-tools/action.h
+index 0a8de7c..156162d 100644
+--- a/squashfs-tools/action.h
++++ b/squashfs-tools/action.h
+@@ -38,22 +38,6 @@
+ #define TOK_STRING 8
+ #define TOK_EOF 9
+
+-#define TOK_TO_STR(OP, S) ({ \
+- char *s; \
+- switch(OP) { \
+- case TOK_EOF: \
+- s = "EOF"; \
+- break; \
+- case TOK_STRING: \
+- s = S; \
+- break; \
+- default: \
+- s = token_table[OP].string; \
+- break; \
+- } \
+- s; \
+-})
+-
+
+ struct token_entry {
+ char *string;
+--
+2.25.0
+