summaryrefslogtreecommitdiff
path: root/pkg/squashfs-tools/patch/0003-Convert-TOK_TO_STR-to-an-inline-function.patch
blob: 1aa8f747911ed5d03b9e59895dba99ade6304901 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
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
Upstream: https://github.com/plougher/squashfs-tools/pull/86

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