Skip to content

Update VA_COPY macro to use va_copy function#3

Open
programmer-1101 wants to merge 4 commits intooffscale:masterfrom
programmer-1101:master
Open

Update VA_COPY macro to use va_copy function#3
programmer-1101 wants to merge 4 commits intooffscale:masterfrom
programmer-1101:master

Conversation

@programmer-1101
Copy link
Copy Markdown

Edit c89stringutils_string_extras.c for C89 compliance.

Key Changes:

  • Variable Scoping: Moved all local variable declarations to the beginning of functional blocks to satisfy C89 requirements.
  • VA_COPY Portability: Implemented a memcpy-based fallback for VA_COPY.
    This resolves build failures on architectures (like x86_64 and PowerPC)
    where va_list is an array type and cannot be assigned using '='.
  • CI Infrastructure: Updated Cirrus CI FreeBSD image to 14

va_list isn't guarenteed to be a simple assignable type. In the case it's not #define VA_COPY(dest, src) (dest) = (src) produces undefined behaviour
const char *start;

/* Fix assignment of targetLength. C89 requires variables to be defined at beginning of a scope */
targetLength = strlen(target);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was defined at the top of scope? - And the way I had it enabled it to be const

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right change was unnecessory. sorry about that.

char *strcasestr(const char *h, const char *n) {
const size_t l = strlen(n);
size_t l;
l = strlen(n);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was defined at the top of scope? - And the way I had it enabled it to be const

#else
#define NUM_FORMAT "%lld"
/* Fix:- Change from C99 long long to long */
#define NUM_FORMAT "%ld"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might want to guard this behind an if c89 do lld else do ld

Comment thread .cirrus.yml Outdated
@@ -1,5 +1,5 @@
freebsd_instance:
image_family: freebsd-13-0
image_family: freebsd-14
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

15 is out now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants