Post B5WQpAiHkU85GbvjV2 by thephd@pony.social
(DIR) More posts by thephd@pony.social
(DIR) Post #B5WOM6Wo1w9fyrZZ44 by thephd@pony.social
0 likes, 0 repeats
Over/iunder on how mad GCC would be if i introduced a dependency on <algorithm> so I don't have to write a reverse string character search....
(DIR) Post #B5WOT6vcwLsvFWWW0W by thephd@pony.social
0 likes, 0 repeats
There's probably a simple C standard / POSIX standard function to reverse-search a string for a set of forbidden characters but god forbid I know the precise strCRUNCHMUNCHGRIND teeth-grating Polish-adjacent spelling it is under. I'm probably looking for "string reverse c span" or something like that.
(DIR) Post #B5WOens9cEtBchTTkW by thephd@pony.social
0 likes, 0 repeats
strrchr is only for one character, I need basically strrcspn I think. Which doesn't exist yet.
(DIR) Post #B5WOjUq5oB9C2ZkRRA by thephd@pony.social
0 likes, 0 repeats
Eh, no reason I can't just do 2 calls to strrchar.
(DIR) Post #B5WOnzwo5fILgC2F8a by atax1a@infosec.exchange
0 likes, 0 repeats
@thephd there's no reverse char span, just forward
(DIR) Post #B5WOscAruETlOcoVlI by thephd@pony.social
0 likes, 0 repeats
@atax1a I figured! Just have to commit to 2 calls of strrchar.
(DIR) Post #B5WP9L6obkP7OLtPuq by bnlandor@mastodon.social
0 likes, 0 repeats
@thephd or strrpbrk(), which doesn't exist either. But multiple calls to strrchr() work.
(DIR) Post #B5WQS3MQv2BbnrgXzM by Doomed_Daniel@mastodon.gamedev.place
0 likes, 0 repeats
@thephd and neither does strrstr() - why is strrchr() the only function of that kind?
(DIR) Post #B5WQpAiHkU85GbvjV2 by thephd@pony.social
0 likes, 0 repeats
@Doomed_Daniel I figure the core problem is just the sheer number of string functions one would need to cover everything.The better way would be to have a forward and reverse search, with a predicate that returns bool for "keep going" or "stop now".Then I imagine there'd be special cases for hardware or SIMD that can do certain things faster if you're not calling it with an opaque callback to return true/false, so then you'd add functions in to basically allow access to those faster instructions or optimized implementations.At least, that's how I'd propose this stuff to C to kind of "cover all bases, generally, then specialize for speed".
(DIR) Post #B5WXGFea5Y1Y8HUePo by enhancedscurry@mastodon.social
0 likes, 0 repeats
@thephd strrstr(3)?
(DIR) Post #B5WbA3LTKwis2Rr52e by SeiriosB@mastodon.social
0 likes, 0 repeats
@thephdI think the issue is that reverse-searching, or reverse-X in general, actually means "do X on a string that is the reverse of the one I have".What is really needed is a fast string reverser, then you get all functionality in the "reverse" direction for free.strrchr() is just too easy not to implement, but others would become bloat.@Doomed_Daniel
(DIR) Post #B5WdnHesFtMxdClTI8 by thephd@pony.social
0 likes, 0 repeats
@enhancedscurry "each of these is a needle", not "this whole string is one needle".
(DIR) Post #B5WhlN5JVaxdhNTWCm by enhancedscurry@mastodon.social
0 likes, 0 repeats
@thephd Ooooooh got it. Then yeah I got nothing.