Skip to content

apply, seq, libcommon: Improvements to the code internals#76

Open
takusuman wants to merge 63 commits into
masterfrom
apply-pick-impl
Open

apply, seq, libcommon: Improvements to the code internals#76
takusuman wants to merge 63 commits into
masterfrom
apply-pick-impl

Conversation

@takusuman
Copy link
Copy Markdown
Member

Closes #75.

@takusuman takusuman changed the title apply: Improvements to the code internals apply, seq: Improvements to the code internals Nov 25, 2025
Comment thread apply/apply.c Outdated
@takusuman takusuman marked this pull request as ready for review November 27, 2025 02:45
free(cmdl) for every return by buildcmd().
"char *argv[]" -> "char *const argv[]".
Use pfmt(3) instead of printf(3) because it treats the
non-literal string properly and doesn't create warnings.
When using MM_NOSTD, it comports just like printf(3).
PERHAPS it could be better to use vprintf(3) instead.
Now using "& MM_NOGET" so pfmt(3) comports just like printf(3).
Now using "^ MM_NOGET" so pfmt(3) comports just like printf(3).
@arthurbacci
Copy link
Copy Markdown
Member

By the way, regarding #34, I think we shall start compiling programs with -Wshadow, -Wunused, -Wpedantic, -Wall and -Wextra when testing. Perhaps -Wall with -Wextra are sufficient, but I hadn't checked the GCC docs yet.

I don't even compile what I code, the environment isn't working very well here.

@arthurbacci
Copy link
Copy Markdown
Member

For some reason f4fc181 removes void main() from seq.c and not 9dda692.

@takusuman
Copy link
Copy Markdown
Member Author

By the way, regarding #34, I think we shall start compiling programs with -Wshadow, -Wunused, -Wpedantic, -Wall and -Wextra when testing. Perhaps -Wall with -Wextra are sufficient, but I hadn't checked the GCC docs yet.

I don't even compile what I code, the environment isn't working very well here.

Check your build/mk.config later.

For some reason f4fc181 removes void main() from seq.c and not 9dda692.

Does it make a huge difference? This will be all squashed into a single commit later.

@arthurbacci
Copy link
Copy Markdown
Member

By the way, regarding #34, I think we shall start compiling programs with -Wshadow, -Wunused, -Wpedantic, -Wall and -Wextra when testing. Perhaps -Wall with -Wextra are sufficient, but I hadn't checked the GCC docs yet.

I don't even compile what I code, the environment isn't working very well here.

Check your build/mk.config later.

For some reason f4fc181 removes void main() from seq.c and not 9dda692.

Does it make a huge difference? This will be all squashed into a single commit later.

Why are you squashing PRs?

@takusuman
Copy link
Copy Markdown
Member Author

By the way, regarding #34, I think we shall start compiling programs with -Wshadow, -Wunused, -Wpedantic, -Wall and -Wextra when testing. Perhaps -Wall with -Wextra are sufficient, but I hadn't checked the GCC docs yet.

I don't even compile what I code, the environment isn't working very well here.

Check your build/mk.config later.

For some reason f4fc181 removes void main() from seq.c and not 9dda692.

Does it make a huge difference? This will be all squashed into a single commit later.

Why are you squashing PRs?

Often a ton of commits that do one thing.
This didn't happen at large PR for the 20240220-fix branch.

@takusuman
Copy link
Copy Markdown
Member Author

@arthurbacci Let's go, last release of the year.

Comment thread apply/apply.c
Comment thread apply/apply.c Outdated
Comment thread apply/apply.c Outdated
Comment thread apply/apply.c Outdated
Comment thread apply/apply.c Outdated
Comment thread apply/apply.c Outdated
Comment thread apply/apply.c Outdated
Comment thread apply/apply.c Outdated
Comment thread apply/apply.c Outdated
Comment thread seq/seq.c
Comment thread apply/apply.c Outdated
Comment thread apply/apply.c Outdated
Comment thread apply/apply.c Outdated
Comment thread seq/seq.c Outdated
Comment thread seq/seq.c Outdated
Also sneakly add parenthesis to a multiplication in a function call, so we can start creating consistent rules of style.
@arthurbacci Perhaps I could say sorry for the parenthesis at index + (number - 1).
@takusuman
Copy link
Copy Markdown
Member Author

@arthurbacci Also removed the ch = cmd[c] thing.

Comment thread apply/apply.c Outdated
@takusuman
Copy link
Copy Markdown
Member Author

I think we would also need to do some fixes at libcommon/strjoin.c, @arthurbacci.

This function has undefined behavior if elems[0] is a null pointer. It should just allocate and return an empty string in this case. Also UB if malloc fails.

  • chqrlie at StackOverflow

I think the first is not the case since the for loop having *elems as a condition would already make the function stop if a NULL is found. For the second, I will do mea culpa and admit that I should've tested if joinbufp != NULL before continuing. Simple fixes in any case.

@takusuman
Copy link
Copy Markdown
Member Author

Added a if (!elems[0]) because, if it weren't for it, we'd be returning an empty string instead of a NULL.

@takusuman takusuman changed the title apply, seq: Improvements to the code internals apply, seq, libcommon: Improvements to the code internals Jan 10, 2026
@takusuman takusuman requested a review from arthurbacci January 10, 2026 18:51
I hope my cellphone's digital keyboard hasn't garbled a thing.
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.

Fix dumb allocation at apply(1B) code (and perhaps more of the code)

3 participants