Skip to content

Compiler: use safer string functions#540

Merged
bvdberg merged 1 commit into
c2lang:masterfrom
chqrlie:string-safety
Jul 21, 2026
Merged

Compiler: use safer string functions#540
bvdberg merged 1 commit into
c2lang:masterfrom
chqrlie:string-safety

Conversation

@chqrlie

@chqrlie chqrlie commented Jul 16, 2026

Copy link
Copy Markdown
Contributor
  • add pstrcpy and pstrcat to string.c2i as safer alternatives for strcpy and strcat.
  • use snprintf instead of sprintf
  • use pstrcpy and pstrcat instead of strcpy and strcat
  • fix strlcpy and strlcat for conformity with BSD semantics. pstrcpy and pstrcat argument order and semantics are more convenient for readability and efficiency.

* add `pstrcpy` and `pstrcat` to string.c2i as safer alternatives
  for `strcpy` and `strcat`.
* use `snprintf` instead of `sprintf`
* use `pstrcpy` and `pstrcat` instead of `strcpy` and `strcat`
* use `elemsof` instead of `sizeof` for array lengths
* fix `strlcpy` and `strlcat` for conformity with BSD semantics.
  `pstrcpy` and `pstrcat` argument order and semantics are more
  convenient for readability and efficiency.
@bvdberg
bvdberg merged commit c106ebe into c2lang:master Jul 21, 2026
6 checks passed
@chqrlie
chqrlie deleted the string-safety branch July 21, 2026 09:34
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