Skip to content

Conversation

@BenBE
Copy link
Member

@BenBE BenBE commented Aug 14, 2025

This PR is a continuation of #1755, due to an accidentally fumbled push operation.

@melrovieira: Sorry, the git push to edit your PR (to clean up the commits), accidentally pushed the wrong commit to Github and thus unintentionally closed the PR.

This PR restores the actually intended push.

@BenBE BenBE added the new feature Completely new feature label Aug 14, 2025
@BenBE BenBE linked an issue Aug 14, 2025 that may be closed by this pull request
@melrovieira
Copy link

Este PR é uma continuação do #1755 , devido a uma operação de push malsucedida acidentalmente.

@melrovieira:Desculpe, o git push para editar seu PR (para limpar os commits) acidentalmente enviou o commit errado para o Github e, assim, fechou o PR sem querer.

Este PR restaura o push realmente pretendido.

No problem, do you want me to fix the indentation?

@BenBE BenBE force-pushed the process-state-filter branch from 2019e60 to 4cf9bd6 Compare August 14, 2025 19:15
@BenBE
Copy link
Member Author

BenBE commented Aug 14, 2025

@melrovieira: Não precisa; já corrigi o recuo e limpei tudo. Por favor, dê uma olhada nos commits atualizados neste PR. Tomei a liberdade de limpá-los para conter apenas alterações em locais do código onde a alteração era realmente necessária. Em PRs futuros, certifique-se de usar git add -p para limitar as modificações a locais no código que realmente pertencem às alterações necessárias para o recurso. O guia de estilo é um pouco flexível sobre isso, mas a intenção é, ao executar o comando astyle, selecionar as alterações realmente relevantes. Isso é um pouco complicado pelo fato de que a base de código original misturou o estilo de indentação para instruções switch/case em relação à indentação.


@melrovieira: No need; I already fixed the indentation and cleaned things up. Please take a look at the updated commits in this PR. I took the liberty to clean them up to only contain changes to code locations where a change was actually necessary. In future PRs be sure to use git add -p to limit modifications to locations in the code that actually belong to the changes necessary for the feature. The style guide is somewhat loose on this, but the intention is to, when running the astyle command, pick the actually relevant changes. This is somewhat complicated by the fact, that the original codebase mixed the indentation style for switch/case statements regarding indentation.

@melrovieira
Copy link

@melrovieira: Não precisa; já corrigi o recuo e limpei tudo. Por favor, dê uma olhada nos commits atualizados neste PR. Tomei a liberdade de limpá-los para conter apenas alterações em locais do código onde a alteração era realmente necessária. Em PRs futuros, certifique-se de usar git add -p para limitar as modificações a locais no código que realmente pertencem às alterações necessárias para o recurso. O guia de estilo é um pouco flexível sobre isso, mas a intenção é, ao executar o comando astyle, selecionar as alterações realmente relevantes. Isso é um pouco complicado pelo fato de que a base de código original misturou o estilo de indentação para instruções switch/case em relação à indentação.

@melrovieira: No need; I already fixed the indentation and cleaned things up. Please take a look at the updated commits in this PR. I took the liberty to clean them up to only contain changes to code locations where a change was actually necessary. In future PRs be sure to use git add -p to limit modifications to locations in the code that actually belong to the changes necessary for the feature. The style guide is somewhat loose on this, but the intention is to, when running the astyle command, pick the actually relevant changes. This is somewhat complicated by the fact, that the original codebase mixed the indentation style for switch/case statements regarding indentation.

Okay, I'll remember that. Thank you very much. 🤝

@BenBE BenBE force-pushed the process-state-filter branch 3 times, most recently from a0794f3 to 2dfd1d1 Compare August 14, 2025 19:42
@BenBE BenBE requested a review from natoscott August 14, 2025 19:50
BenBE and others added 3 commits August 14, 2025 22:38
…esses by state.

This exposes the internal Process state character conversion function so it can be
reused for the filter string processing. Multiple characters are allowed for the filter
and a process is displayed if any of the provided state characters matches the
state of the process currently processed.

Co-authored-by: Allison <[email protected]>
Co-authored-by: BenBE <[email protected]>
This creates a small lookup table to speed up the check (O(n+m) instead of O(n*m)).
@BenBE BenBE force-pushed the process-state-filter branch from 2dfd1d1 to f0002ff Compare August 14, 2025 20:53
}
bool valid_arg = true;
for (char* c = optarg; *c != '\0' && valid_arg; c++) {
if (*c == ',' || isspace(*c))
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be just me, but I prefer isblank rather than isspace here.

fprintf(stderr, "Error: invalid state filter value \"%s\".\n", optarg);
return STATUS_ERROR_EXIT;
}
valid_arg &= valid_states[(int)*c];
Copy link
Contributor

Choose a reason for hiding this comment

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

Since valid_arg is a boolean, using a bitwise AND operator doesn't look like a good idea to me.

Suggested change
valid_arg &= valid_states[(int)*c];
if (!valid_states[(int)*c]) {
valid_arg = false;
break;
}

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

Labels

new feature Completely new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Filter on process state

4 participants