Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

does w64devkit include a regex header/lib ? With C. #127

Closed
ggbbrr opened this issue May 9, 2024 · 6 comments
Closed

does w64devkit include a regex header/lib ? With C. #127

ggbbrr opened this issue May 9, 2024 · 6 comments

Comments

@ggbbrr
Copy link

ggbbrr commented May 9, 2024

I'm trying to compile a C program with regex. I get "fatal error: regex.h: No such file or directory".

@skeeto
Copy link
Owner

skeeto commented May 9, 2024 via email

@skeeto
Copy link
Owner

skeeto commented May 9, 2024 via email

@avih
Copy link

avih commented May 14, 2024

This is the second such that I've made, and I'm planning to collect more in contrib/ in the future.

Not sure if you mean more libraries in general, or more posix regex specifically, but if the latter, then there's a much smaller posix compliant (presumably) regex package, which is Henry Spencer's POSIX BSD implementation, originally in 4.4BSD.

This is the latest clean code I could find - https://github.com/garyhouston/regex which includes a single bugfix. to build it in w64devkit: make lib (compiles about 5 files) and then add to the generated regex.h: #include <stdlib.h> and #include <sys/types.h>.

libregex.a is about 50k stripped, and only supports ASCII locale (general UTF-8 works except for Unicode collating etc).

The same code, with some build convenience and few compiler warnings eliminated (and pre-generated regex.h) but without real code changes, is here: https://github.com/garyhouston/rxspencer . to build it without cmake:

cc -c -DPOSIX_MISTAKE reg*.c
ar rcs libregex.a reg*.o

This library is also part or NetBSD's pkgsrc as librxspencer, but I couldn't find its source in the pkgsrc files (the info link seem to point to the github rxspencer project owner webpage).

I think both could be great as a vendored regex implementation, though not sure which I prefer yet (the latter has a lot of small compiler warning fixes - mostly casts, and I didn't look at them closely).

A slightly older version of this code (and nearly identical) is in the sources of 4.4BSD.

An evolution of this code is at current FreeBSD (and I'm guessing other BSD's) lib/libc/regex, and I did manage to compile it from FreeBSD 13.3 after some effort, but it did not work correctly (and uses wint_t char types etc, not the simple ASCII which the original older code uses).

So FYI if you want this in addition, or maybe iunstead of, the PCRE thingy.

@skeeto
Copy link
Owner

skeeto commented May 14, 2024 via email

@avih
Copy link

avih commented May 14, 2024

That's why I'm uninterested in distributing libraries in w64devkit, aside from the essential toolchain runtime bits.

Yeah, I don't disagree.

Specifically about regex though, since you already have a PCRE based thingy, I thought you might be interested in something much smaller which provides possibly good enough functionality.

I think I'll use it (the spencer one) if I need regex, though TBH I don't need it often or really at all, but having a small windows-compatible POSIX regex lib is just too good to ignore IMHO.

FWIW, tcl used (uses?) an earlier version of the spencer V8 regex code as its regex engine, and so does less as fallback when system regex is unavailable - e.g. on Windows, though I've not yet seen projects which vendor the spencer BSD POSIX code, and I've always wanted to have POSIX regex API for windows...

@avih
Copy link

avih commented May 14, 2024

Off topic for this thread, but in general, autoconf (and I guess libtool) would be nice to have, especially to build from a git repo rather than a source tarball, but I don't know enough on autotools to begin with (other than using it to generate configure).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants