regex
Having looked for quite a while and not found an answer, I have this question:
Is regex supported in C on the SDK? (regcomp etc..).
The regex.h file seems to compile fine, is there a library I need to add to get it to work?
Is regex supported in C on the SDK? (regcomp etc..).
The regex.h file seems to compile fine, is there a library I need to add to get it to work?
Re: regex
Answered by Google Search AI, also here:
https://answers.launchpad.net/gcc-arm-e ... ion/208555
So it appears to be a POSIX thing, not part of C. If you _really_ need regexes, maybe a standalone implementation would be a good solution, since it is unlikely to ever appear in the arm-none-eabi toolchain.
https://answers.launchpad.net/gcc-arm-e ... ion/208555
So it appears to be a POSIX thing, not part of C. If you _really_ need regexes, maybe a standalone implementation would be a good solution, since it is unlikely to ever appear in the arm-none-eabi toolchain.
Re: regex
Yes, this is the POSIX version of the regex stuff. What is odd is that the regex.h file seems to be in the SDK.
Re: regex
But isn't that because it's part of the C library the Pico SDK uses and links to ?
For me it seems to be at '/usr/include/newlib/regex.h'
And it seems similar for 'picolibc' which is an alternative to 'newlib'.
I would have thought 'regex' would be pure C code so available for anything, not just for POSIX, but I don't know much about these things.
It seems it's available via C++ for RP2040 - viewtopic.php?t=330066
Re: regex
One can call it a dark and dusty corner of the toolchain. The user is not expected to pull away the cobwebs and peer around. :D
If you use nm to look in the libc.a of the Arm toolchain, you won't find the regex object files in there. I tried the top level libc.a in the Arm toolchain directory that I have, the object files are not in there. But there is an rpmatch.o that references them, so it really is a very dusty corner... :P To compare, I took the Cygwin libc.a and the regex object files are present.
The C regex header looks like the classic Henry Spencer thingy, see this directory on the newlib mirror:
https://github.com/bminor/newlib/tree/m ... libc/posix
The bulk of the regex implementation is in regcomp.c, and available to compiled programs since it is in libc.a. It just isn't compiled into arm-none-eabi. Presumably adding a standalone Henry Spencer regex source file set (well, everybody uses it as a baseline) into your program, tweak the makefiles, make it non-POSIX usable etc, and the regex stuff that you coded should work the same.
If you use nm to look in the libc.a of the Arm toolchain, you won't find the regex object files in there. I tried the top level libc.a in the Arm toolchain directory that I have, the object files are not in there. But there is an rpmatch.o that references them, so it really is a very dusty corner... :P To compare, I took the Cygwin libc.a and the regex object files are present.
The C regex header looks like the classic Henry Spencer thingy, see this directory on the newlib mirror:
https://github.com/bminor/newlib/tree/m ... libc/posix
The bulk of the regex implementation is in regcomp.c, and available to compiled programs since it is in libc.a. It just isn't compiled into arm-none-eabi. Presumably adding a standalone Henry Spencer regex source file set (well, everybody uses it as a baseline) into your program, tweak the makefiles, make it non-POSIX usable etc, and the regex stuff that you coded should work the same.
Re: regex
Thanks for the replies. I think it might be possible to add the regex code, but it's a bit more work that I'd hoped, and also it uses more memory than I want to allocate to the feature at the moment. I have implemented a more appropriate wildcard system which works for my application, so am OK with no regex for now.
Re: regex
KISS - regex is a wonderful thing in the right place, but can be a nightmare to get right. It usually leaves me with a headache.
Re: regex
KISS - I'd agree with that. It may be worth deciding exactly what 'regex' functionality you actually need. It may be fairly simple to code your own functions to do what is needed.
Re: regex
I've rewritten a Psion Organiser 2 OPL compiler and runtime, and some of the later LZ commands have wildcards, but they are simple * and + wildcards. I thought I'd add regex as well for files name matching but it's just too resource hungry. Also the standard keyboard is a bit limited in characters. No ? for instance...
Jump to
- Community
- General discussion
- Announcements
- Other languages
- Deutsch
- Español
- Français
- Italiano
- Nederlands
- 日本語
- Polski
- Português
- Русский
- Türkçe
- User groups and events
- Raspberry Pi Official Magazine
- Using the Raspberry Pi
- Beginners
- Troubleshooting
- Advanced users
- Assistive technology and accessibility
- Education
- Picademy
- Teaching and learning resources
- Staffroom, classroom and projects
- Astro Pi
- Mathematica
- High Altitude Balloon
- Weather station
- Programming
- C/C++
- Java
- Python
- Scratch
- Other programming languages
- Windows 10 for IoT
- Wolfram Language
- Bare metal, Assembly language
- Graphics programming
- OpenGLES
- OpenVG
- OpenMAX
- General programming discussion
- Projects
- Networking and servers
- Automation, sensing and robotics
- Graphics, sound and multimedia
- Other projects
- Media centres
- Gaming
- AIY Projects
- Hardware and peripherals
- Camera board
- Compute Module
- Official Display
- HATs and other add-ons
- Device Tree
- Interfacing (DSI, CSI, I2C, etc.)
- Keyboard computers (400, 500, 500+)
- Raspberry Pi Pico
- General
- SDK
- MicroPython
- Other RP2040 boards
- Zephyr
- Rust
- AI Accelerator
- AI Camera - IMX500
- Hailo
- Software
- Raspberry Pi OS
- Raspberry Pi Connect
- Raspberry Pi Desktop for PC and Mac
- Beta testing
- Other
- Android
- Debian
- FreeBSD
- Gentoo
- Linux Kernel
- NetBSD
- openSUSE
- Plan 9
- Puppy
- Arch
- Pidora / Fedora
- RISCOS
- Ubuntu
- Ye Olde Pi Shoppe
- For sale
- Wanted
- Off topic
- Off topic discussion