[File] [PATCH] Fix build with gcc 4.8
Christos Zoulas
christos at zoulas.com
Sat Mar 4 18:10:20 UTC 2023
Committed, thanks!
christos
> On Mar 1, 2023, at 11:12 PM, Xi Ruoyao <xry111 at xry111.site> wrote:
>
> Fix the following build failure with gcc 4.8:
>
> ../../src/funcs.c: In function 'check_regex':
> ../../src/funcs.c:665:2: error: 'for' loop initial declarations are only allowed in C99 mode
> for (const char *p = pat; *p; p++) {
> ^
> ../../src/funcs.c:665:2: note: use option -std=c99 or -std=gnu99 to compile your code
>
> Fixes: https://bugs.astron.com/view.php?id=429
> Signed-off-by: Xi Ruoyao <xry111 at xry111.site>
> ---
> src/funcs.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/src/funcs.c b/src/funcs.c
> index e265de8c..792310bb 100644
> --- a/src/funcs.c
> +++ b/src/funcs.c
> @@ -661,8 +661,9 @@ check_regex(struct magic_set *ms, const char *pat)
> {
> char sbuf[512];
> unsigned char oc = '\0';
> + const char *p;
>
> - for (const char *p = pat; *p; p++) {
> + for (p = pat; *p; p++) {
> unsigned char c = *p;
> // Avoid repetition
> if (c == oc && strchr("?*+{", c) != NULL) {
> --
> 2.39.2
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 235 bytes
Desc: Message signed with OpenPGP
URL: <https://mailman.astron.com/pipermail/file/attachments/20230304/f71294e8/attachment.asc>
More information about the File
mailing list