I'm developing a little tool to grep from a process address space
with a regex-delimiter for the start and end (both included in the
result). Therefore I needed to enumerate the process-IDs whose exe-
cutable paths matches a certain regex. This is the code:
Everything is done without Posix-APIs but with pure C++ !
Am 18.01.2025 um 11:02 schrieb [email protected]:
On Fri, 17 Jan 2025 07:46:25 +0100
Bonita Montero <[email protected]> gabbled:
I'm developing a little tool to grep from a process address space
with a regex-delimiter for the start and end (both included in the
result). Therefore I needed to enumerate the process-IDs whose exe-
cutable paths matches a certain regex. This is the code:
Everything is done without Posix-APIs but with pure C++ !
Given its simply iterating a directory I'm not sure whats so amazing
about it.
However, thank you for reminding me about from_chars(), I'd forgotten
all about that function. Could have used it recently instead of strtol().
from_chars is more flexible because it returns where it has ended
parsing. That's necessary to detect syntax-errors because there
might be superfluous chars beyond the end.
On Fri, 17 Jan 2025 07:46:25 +0100
Bonita Montero <[email protected]> gabbled:
I'm developing a little tool to grep from a process address space
with a regex-delimiter for the start and end (both included in the
result). Therefore I needed to enumerate the process-IDs whose exe-
cutable paths matches a certain regex. This is the code:
Everything is done without Posix-APIs but with pure C++ !
Given its simply iterating a directory I'm not sure whats so amazing about it. >However, thank you for reminding me about from_chars(), I'd forgotten all >about that function. Could have used it recently instead of strtol().
Am 18.01.2025 um 11:02 schrieb [email protected]:
On Fri, 17 Jan 2025 07:46:25 +0100
Bonita Montero <[email protected]> gabbled:
I'm developing a little tool to grep from a process address space
with a regex-delimiter for the start and end (both included in the
result). Therefore I needed to enumerate the process-IDs whose exe-
cutable paths matches a certain regex. This is the code:
Everything is done without Posix-APIs but with pure C++ !
Given its simply iterating a directory I'm not sure whats so amazing
about it.
However, thank you for reminding me about from_chars(), I'd forgotten
all about that function. Could have used it recently instead of strtol().
from_chars is more flexible because it returns where it has ended
parsing. That's necessary to detect syntax-errors because there
might be superfluous chars beyond the end.
[email protected] writes:
On Fri, 17 Jan 2025 07:46:25 +0100
Bonita Montero <[email protected]> gabbled:
I'm developing a little tool to grep from a process address space
with a regex-delimiter for the start and end (both included in the
result). Therefore I needed to enumerate the process-IDs whose exe-
cutable paths matches a certain regex. This is the code:
Everything is done without Posix-APIs but with pure C++ !
Given its simply iterating a directory I'm not sure whats so amazing about it.
However, thank you for reminding me about from_chars(), I'd forgotten all
about that function. Could have used it recently instead of strtol().
It doesn't seem to handle unsigned conversions. It is far more common
(9 of 10 occurances) for me to use strtoul.
On 18.01.2025 18:38, Scott Lurndal wrote:
[email protected] writes:
On Fri, 17 Jan 2025 07:46:25 +0100
Bonita Montero <[email protected]> gabbled:
I'm developing a little tool to grep from a process address space
with a regex-delimiter for the start and end (both included in the
result). Therefore I needed to enumerate the process-IDs whose exe-
cutable paths matches a certain regex. This is the code:
Everything is done without Posix-APIs but with pure C++ !
Given its simply iterating a directory I'm not sure whats so amazing about it.
However, thank you for reminding me about from_chars(), I'd forgotten all >>> about that function. Could have used it recently instead of strtol().
It doesn't seem to handle unsigned conversions. It is far more common
(9 of 10 occurances) for me to use strtoul.
What do you mean? This compiles and runs fine for me (VS2022):
#include <iostream>
#include <cstdint>
#include <charconv>
int main() {
const char buff[] = "4294967295";
std::uint32_t k;
std::from_chars(std::begin(buff), std::end(buff), k);
std::cout << k << std::endl;
}
Output:
4294967295
| Sysop: | Keyop |
|---|---|
| Location: | Huddersfield, West Yorkshire, UK |
| Users: | 715 |
| Nodes: | 16 (2 / 14) |
| Uptime: | 22:56:47 |
| Calls: | 12,105 |
| Calls today: | 5 |
| Files: | 15,006 |
| Messages: | 6,518,139 |