3 ms·
"You" used like "one", or "in common practice it isn't really used". It's just not in C's spirit to use canned libraries. Such use cases have long been transfer
by jstimpfle 8y ago
"You" used like "one", or "in common practice it isn't really used". It's just not in C's spirit to use canned libraries. Such use cases have long been transferred to Python and other languages. Sure, there is a regex API in the C standard library. I'd bet not even grep uses it.
The one use-case I'm envisioning is quickly exposing POSIX conformant regexen to the command-line.
- dahart 8y ago> I’d bet not even grep uses it. I’ll take you up on that bet. I see #include <regex.h> in every source repo of grep I can find right now. http://git.savannah.gnu.org/cgit/grep.git/tree/src/search.h http://git.savannah.gnu.org/cgit/grep.git/tree/src/search.h https://opensource.apple.com/source/text_cmds/text_cmds-99/grep/grep.h.auto.html https://opensource.apple.com/source/text_cmds/text_cmds-99/g... https://android.googlesource.com/platform/system/core.git/+/android-4.2.2_r1/toolbox/grep/grep.h https://android.googlesource.com/platform/system/core.git/+/... https://github.com/c9/node-gnu-tools/blob/master/grep-src/src/search.h https://github.com/c9/node-gnu-tools/blob/master/grep-src/sr... You owe me a beer. :) BTW, I do super agree with your comment to just not use strtok, and also the idea that most people are better off parsing text in perl or python...
- jstimpfle 8y agoNot sure why that header is included there, though. I can't find any uses of the regex library. There are multiple custom matchers implemented. So maybe it's that the GNU regex library uses the grep sources. In any case, there don't seem to be any uses of regexec() or regcomp(), for example. Which would have surprised me anyway since that API is rather limiting (you cannot search incrementally). Let's get that beer sometime, anyway.
- kahirsch 8y agoGNU grep uses the regex library in Gnulib. It can also use the Perl-compatible pcre library. I am finding it hard to believe that you think it's "just not in C's spirit to use canned libraries."
- jstimpfle 8y agoI was saying "canned", not "boxed" or "containerized". It's a lot easier to write the little things yourself. (And there are good benefits to be had from writing specialized code yourself, instead of relying on big fat generalized tankers.)
- kahirsch 8y agoI don't know what distinction you're trying to make about "canned" vs. other things. There are advantages and disadvantages of using libraries in any language. There are some aspects of C —e.g. the lack of garbage collection— that make it harder to reuse code compared to some languages. But it is definitely not against "C's spirit".
- jstimpfle 8y agoThe distinction is one of size and number. An npm for C would make no sense.