summaryrefslogtreecommitdiff
path: root/lib/libc/regex
Commit message (Collapse)AuthorAgeFilesLines
* libc/locale: Fix type breakage in __collate_range_cmp().Pedro F. Giffuni2016-06-051-3/+3
| | | | | | | | | | | | | | | | | | | When collation support was brought in, the second and third arguments in __collate_range_cmp() were changed from int to wchar_t, breaking the ABI. Change them to a "char" type which makes more sense and keeps the ABI compatible. Also introduce __wcollate_range_cmp() which does work with wide characters. This function is used only internally in libc so we don't export it. Use the new function in glob(3), fnmatch(3), and regexec(3). PR: 179721 Suggested by: ache. jilles MFC after: 3 weeks (perhaps partial only) Notes: svn path=/head/; revision=301461
* libc: regexec(3) adjustment.Pedro F. Giffuni2016-05-252-24/+50
| | | | | | | | | | | | | | | | | | | | | | | | | Change the behavior of when REG_STARTEND is combined with REG_NOTBOL. From the original posting[1]: "Enable the assumption that pmatch[0].rm_so is a continuation offset to a string and allows us to do a proper assessment of the character in regards to it's word position ('^' or '\<'), without risking going into unallocated memory." This change makes us similar to how glibc handles REG_STARTEND | REG_NOTBOL, and is closely related to a soon-to-land fix to sed. Special thanks to Martijn van Duren and Ingo Schwarze for working out some consistent behaviour. Differential Revision: https://reviews.freebsd.org/D6257 Taken from: openbsd-tech 2016-05-24 [1] (Martijn van Duren) Relnotes: yes MFC after: 1 month Notes: svn path=/head/; revision=300683
* libc/regex: fix two buffer underruns.Pedro F. Giffuni2016-05-211-9/+6
| | | | | | | | | | | | | | | Fix some rather complex regex issues found on OpenBSD as part of some ongoing work to fix a sed(1) bug. Curiously the OpenBSD tests don't trigger segfaults on FreeBSD but the bugs were confirmed by running a port of FreeBSD's regex under OpenBSD's malloc. Huge thanks to Ingo for confirming the behavior. Taken from: Ingo Schwarze (through openbsd-tech 2016-05-15) MFC after: 1 week Notes: svn path=/head/; revision=300378
* libc: spelling fixes.Pedro F. Giffuni2016-04-301-1/+1
| | | | | | | Mostly on comments. Notes: svn path=/head/; revision=298830
* regex: prevent two improbable signed integer overflows.Pedro F. Giffuni2016-04-231-2/+2
| | | | | | | | | | | | | | In matcher() we used an integer to index nsub of type size_t. In print() we used an integer to index nstates of type sopno, typedef'd long. In both cases the indexes never take negative values. Match the types to avoid any error. MFC after: 5 days Notes: svn path=/head/; revision=298521
* Add -static to CFLAGS to unbreak the tests by using a libc.a withEnji Cooper2015-12-131-1/+1
| | | | | | | | | | | | the xlocale private symbols exposed which aren't exposed publicly via the DSO PR: 191354 MFC after: 1 week Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=292153
* Fix -Wformat issues and minor whitespace issues in surrounding areasEnji Cooper2015-12-051-29/+25
| | | | | | | | MFC after: 1 week Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=291838
* split.ih:Enji Cooper2015-12-053-4/+6
| | | | | | | | | | | | - Create automatically generated include header for split.c main.c: - Use function definitions from debug.ih and split.ih instead of externs Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=291837
* Use `==` instead of `=` in the function comment above split(..) so mkh -pEnji Cooper2015-12-051-1/+1
| | | | | | | | | | exposes split(..). MFC after: 1 week Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=291836
* Use ANSI C function prototypes/definitions instead of K&R style onesEnji Cooper2015-12-051-16/+11
| | | | | | | | MFC after: 1 week Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=291835
* Add missing headers and sort #includes per style(9)Enji Cooper2015-12-051-3/+5
| | | | | | | | MFC after: 1 week Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=291834
* - Use ANSI C function prototypes/definitions instead of K&R style onesEnji Cooper2015-12-051-28/+12
| | | | | | | | | | - Add a missing return type for main(..) MFC after: 1 week Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=291833
* Fix -Wformat warnings by using the correct format qualifiersEnji Cooper2015-12-051-1/+1
| | | | | | | | MFC after: 1 week Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=291832
* mdoc: rendering fixesBaptiste Daroussin2015-04-262-4/+8
| | | | Notes: svn path=/head/; revision=282007
* computematchjumps(): fix allocator sizeof operand mismatch.Pedro F. Giffuni2015-04-221-2/+2
| | | | | | | | | Mostly cosmetical warning. Found by: Clang static analyzer Notes: svn path=/head/; revision=281858
* Prevent NULL pointer de-reference.Pedro F. Giffuni2015-02-211-1/+1
| | | | | | | | As a follow up to r279090, if dp hasn't been defined, we shouldn't attempt to do an optimization here. Notes: svn path=/head/; revision=279104
* regex(3): Fix uninitialized pointer values.Pedro F. Giffuni2015-02-202-3/+3
| | | | | | | | CID: 405582 (also clang static checker) CID: 1018724 Notes: svn path=/head/; revision=279090
* Disallow pattern spaces which would cause intermediate calculations toXin LI2015-02-141-0/+17
| | | | | | | | | | | overflow size_t. Obtained from: DragonFly (2841837793bd095a82f477e9c370cfe6cfb3862c dillon) Security: CERT VU#695940 MFC after: 3 days Notes: svn path=/head/; revision=278739
* mdoc: remove EOL whitespace.Joel Dahl2014-12-291-2/+2
| | | | Notes: svn path=/head/; revision=276360
* Plug a memory leak.Xin LI2014-12-191-1/+3
| | | | | | | | Obtained from: DragonFlyBSD (commit 5119ece) MFC after: 2 weeks Notes: svn path=/head/; revision=275930
* regex(3): Add support for \< and \> word delimitersPedro F. Giffuni2014-06-302-2/+25
| | | | | | | | | | | | | | | | | | | | | Solaris and other OSs have support for \< and \> as word delimiters in utilities like sed(1). These are useful to have for general compatiblity with Solaris but should be avoided for portability with other systems, including the traditional BSDs. Bump __FreeBSD_version as this is likely to affect some userland utilities. Reference: https://www.illumos.org/issues/516 PR: bin/153257 Obtained from: Illumos MFC after: 1 month Notes: svn path=/head/; revision=268066
* Revert r267675:Pedro F. Giffuni2014-06-211-6/+6
| | | | | | | | | | | The code doesn't really benefit of using reallocf() in this case. Also, the realloc() results being assigned temporary variable which makes blind replacement with reallocf() mostly useless. Pointed out by: stefanf, bde Notes: svn path=/head/; revision=267700
* regex: Make use of reallocf().Pedro F. Giffuni2014-06-201-6/+6
| | | | | | | | | | | | | | | Use of reallocf is useful in libraries as we are not certain the application will exit after NULL. This somewhat reduces portability but if since you are building this as part of libc it is likely you have our non-standard reallocf(3) already. Reviewed by: ache MFC after: 5 days Notes: svn path=/head/; revision=267675
* Revert r265367:Pedro F. Giffuni2014-05-051-1/+1
| | | | | | | | | | | Use of calloc instead of malloc in regex (from OpenBSD). In this case the change makes no sense since we are using realloc() later. Reported by: ache Notes: svn path=/head/; revision=265375
* regex: Use calloc instead of malloc.Pedro F. Giffuni2014-05-051-1/+1
| | | | | | | | | | Mostly to reduce differences with OpenBSD. Obtained from: OpenBSD (CVS rev. 1.17) MFC after: 3 days Notes: svn path=/head/; revision=265367
* regex: Remove some unreachable breaks.Pedro F. Giffuni2014-05-012-7/+1
| | | | | | | | | | | | This is based on a much bigger cleanup done in Illumos. Reference: https://www.illumos.org/issues/2077 MFC after: 1 week Notes: svn path=/head/; revision=265202
* Replace use of ${.CURDIR} by ${LIBC_SRCTOP} and define ${LIBC_SRCTOP}Marcel Moolenaar2014-03-041-2/+2
| | | | | | | | | | | | | | if not already defined. This allows building libc from outside of lib/libc using a reach-over makefile. A typical use-case is to build a standard ILP32 version and a COMPAT32 version in a single iteration by building the COMPAT32 version using a reach-over makefile. Obtained from: Juniper Networks, Inc. Notes: svn path=/head/; revision=262722
* Fix assignment of maximum bounadary.Xin LI2013-03-011-1/+1
| | | | | | | | | Submitted by: Sascha Wildner <saw online de> Obtained from: DragonFly rev fd39c81ba220f7ad6e4dc9b30d45e828cf58a1ad MFC after: 2 weeks Notes: svn path=/head/; revision=247596
* Remove some duplicated copyright notices.David Chisnall2012-03-061-5/+0
| | | | | | | Approved by: dim (mentor) Notes: svn path=/head/; revision=232601
* Implement xlocale APIs from Darwin, mainly for use by libc++. This adds aDavid Chisnall2011-11-201-4/+16
| | | | | | | | | | | | | | | load of _l suffixed versions of various standard library functions that use the global locale, making them take an explicit locale parameter. Also adds support for per-thread locales. This work was funded by the FreeBSD Foundation. Please test any code you have that uses the C standard locale functions! Reviewed by: das (gdtoa changes) Approved by: dim (mentor) Notes: svn path=/head/; revision=227753
* Converting int to wint_t leads to broekn comparison of raw charKevin Lo2011-11-111-8/+8
| | | | | | | | | and encoded wint_t. Spotted by: ache Notes: svn path=/head/; revision=227435
* - Don't handle out-of-memory conditionKevin Lo2011-11-101-20/+21
| | | | | | | | | | - Fix types of function arguments match their declaration Reviewed by: delphij Obtained from: NetBSD Notes: svn path=/head/; revision=227414
* mdoc: drop redundant .Pp and .LP callsUlrich Spörlein2010-10-081-1/+0
| | | | | | | They have no effect when coming in pairs, or before .Bl/.Bd Notes: svn path=/head/; revision=213573
* Fix an off-by-one error in the marking of the O_CH operatorDiomidis Spinellis2009-09-161-1/+1
| | | | | | | | | | following an OOR2 operator. PR: 130504 MFC after: 2 weeks Notes: svn path=/head/; revision=197246
* Add a couple of debugging statements.Diomidis Spinellis2009-09-161-0/+3
| | | | Notes: svn path=/head/; revision=197245
* Add two test cases from PR 130504.Diomidis Spinellis2009-09-151-0/+3
| | | | | | | | | | | | | An additional one coming from http://www.research.att.com/~gsf/testregex/ was not added; at some point the entire AT&T regression test harness should be imported here. But that would also mean commitment to fix the uncovered errors. PR: 130504 Submitted by: Chris Kuklewicz Notes: svn path=/head/; revision=197234
* Add two example regexps: (1) one for matching all the charactersGiorgos Keramidas2008-09-051-0/+8
| | | | | | | | | | | that belong in a character class, and (2) one for matching all the characters *not* in a character class. Submitted by: Mark B, mkbucc at gmail.com MFC after: 3 days Notes: svn path=/head/; revision=182795
* getopt(3) returns -1, not EOF.Kevin Lo2008-02-181-1/+1
| | | | Notes: svn path=/head/; revision=176380
* Diff reduction against other *BSDs: ANSIfy functionXin LI2007-06-114-141/+66
| | | | | | | prototypes. No function changes. Notes: svn path=/head/; revision=170528
* Const'ify and ANSIfy the internal interfaces of regex(3).Xin LI2007-05-251-109/+100
| | | | | | | | This is the final change that makes libc to compile with WERROR on my amd64 crashbox. Notes: svn path=/head/; revision=169982
* Use C comments since we now preprocess these files with CPP.Daniel Eischen2007-04-291-1/+3
| | | | Notes: svn path=/head/; revision=169092
* Test cases for back references.Xin LI2007-03-051-0/+24
| | | | | | | Obtained from: OpenBSD Notes: svn path=/head/; revision=167223
* Only stop evaluation of a back reference if the match length isXin LI2007-03-051-15/+17
| | | | | | | | | zero and the recursion level is too deep. Obtained from: OpenBSD Notes: svn path=/head/; revision=167222
* Avoid infinite recursion on:Xin LI2007-03-051-0/+2
| | | | | | | | | echo "foo foo bar bar bar baz" | sed 's/\([^ ]*\)\( *\1\)*/\1/g' Obtained from: OpenBSD via NetBSD (rev. 1.18) Notes: svn path=/head/; revision=167216
* Per Regents of the University of Calfornia letter, remove advertisingWarner Losh2007-01-099-36/+0
| | | | | | | | | clause. # If I've done so improperly on a file, please let me know. Notes: svn path=/head/; revision=165903
* Add each directory's symbol map file to SYM_MAPS.Daniel Eischen2006-03-131-0/+2
| | | | Notes: svn path=/head/; revision=156613
* Add symbol maps and initial symbol version definitions to libc.Daniel Eischen2006-03-131-0/+8
| | | | | | | Reviewed by: davidxu Notes: svn path=/head/; revision=156608
* Use prototypes for CHIN1() and CHIN().Stefan Farfeleder2005-09-121-6/+2
| | | | Notes: svn path=/head/; revision=150053
* Fix a boundary condition error in slow() and fast() in multibyte locales:Tim J. Robbins2005-08-171-6/+7
| | | | | | | | we must allow the character beginning at "p" to be converted to a wide character for the purposes of EOL processing and word-boundary matching. Notes: svn path=/head/; revision=149180
* Document the fact that word-boundary matching does not workTim J. Robbins2005-08-171-1/+3
| | | | | | | properly in multibyte locales. Notes: svn path=/head/; revision=149179