Hi Paul, On Thu, Sep 18, 2025 at 04:40:32PM -0700, Paul Eggert wrote: > On 2025-09-18 15:40, Alejandro Colomar wrote: > > I know you already have str_startswith() and str_endswith(). The issue > > with those is that they're limited to returning a bool. The pointers > > are quite useful, IME. And the reason we chose those names in the > > committee --originally, the proposal was for stpprefix() and > > strsuffix()-- is that those compacted names are usually avoided by users > > as they know libc is more likely to take those. Thus, there's less > > existing code that would conflict with those names. Plus, they're > > consistent with the rest of libc. > > I can certainly see the C standard preferring names that are already > reserved by the standard. > > Not sure I like having bool variants that are trivial wrappers for the > pointer variants, though. Life is already complicated enough. > > As Bruno wrote str_startswith and str_endswith I'd value his opinion.
How about adding the stp* variants that return a pointer, which is certainly useful, and leaving the less useful bool-returning variants unimplemented for now? Would that make sense? TBH, I'm not fully convinced about the bool-returning variants, and at times I wonder if we should only standardize the stp* variants, at least for a first round. > > tty = stppfx(tty, "/dev/") ?: tty; > > Is "?:" in the C standard now? I missed that. No, it's not (yet). In shadow utils we don't care too much about what the standard says, TBH. We do use a lot of GNU extensions, when they're valuable. However, I'm working on convincing the committee to add "?:". In the last meeting, it was blocked, due to conflicting with another proposal from someone else. Since that proposal got rejected in the last meeting, I guess the next meeting is the time for my proposal. I'll let you know if it gets accepted. Have a lovely night! Alex -- <https://www.alejandro-colomar.es> Use port 80 (that is, <...:80/>).
signature.asc
Description: PGP signature
