diff options
author | Kristian Schuster <116557017+KriSchu@users.noreply.github.com> | 2023-02-19 22:49:18 (GMT) |
---|---|---|
committer | Kristian Schuster <116557017+KriSchu@users.noreply.github.com> | 2023-02-19 22:49:18 (GMT) |
commit | a0d42777217296c0a7bdb1e1be8d8f6de1b24dd7 (patch) | |
tree | 8effe94c57b2f9796ba36090b07551baa8f1e1cb /gl/regex.h | |
parent | ca3d59cd6918c9e2739e783b721d4c1122640fd3 (diff) | |
parent | c07206f2ccc2356aa74bc6813a94c2190017d44e (diff) | |
download | monitoring-plugins-a0d42777217296c0a7bdb1e1be8d8f6de1b24dd7.tar.gz |
Merge remote-tracking branch 'origin/master' into feature_check_disk_add_ignore_missing_option
Diffstat (limited to 'gl/regex.h')
-rw-r--r-- | gl/regex.h | 142 |
1 files changed, 87 insertions, 55 deletions
@@ -1,22 +1,21 @@ | |||
1 | /* Definitions for data structures and routines for the regular | 1 | /* Definitions for data structures and routines for the regular |
2 | expression library. | 2 | expression library. |
3 | Copyright (C) 1985, 1989-1993, 1995-1998, 2000-2003, 2005-2013 Free Software | 3 | Copyright (C) 1985, 1989-2023 Free Software Foundation, Inc. |
4 | Foundation, Inc. | ||
5 | This file is part of the GNU C Library. | 4 | This file is part of the GNU C Library. |
6 | 5 | ||
7 | The GNU C Library is free software; you can redistribute it and/or | 6 | The GNU C Library is free software; you can redistribute it and/or |
8 | modify it under the terms of the GNU General Public | 7 | modify it under the terms of the GNU Lesser General Public |
9 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
10 | version 3 of the License, or (at your option) any later version. | 9 | version 2.1 of the License, or (at your option) any later version. |
11 | 10 | ||
12 | The GNU C Library is distributed in the hope that it will be useful, | 11 | The GNU C Library is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | General Public License for more details. | 14 | Lesser General Public License for more details. |
16 | 15 | ||
17 | You should have received a copy of the GNU General Public | 16 | You should have received a copy of the GNU Lesser General Public |
18 | License along with the GNU C Library; if not, see | 17 | License along with the GNU C Library; if not, see |
19 | <http://www.gnu.org/licenses/>. */ | 18 | <https://www.gnu.org/licenses/>. */ |
20 | 19 | ||
21 | #ifndef _REGEX_H | 20 | #ifndef _REGEX_H |
22 | #define _REGEX_H 1 | 21 | #define _REGEX_H 1 |
@@ -42,11 +41,6 @@ extern "C" { | |||
42 | supported within glibc itself, and glibc users should not define | 41 | supported within glibc itself, and glibc users should not define |
43 | _REGEX_LARGE_OFFSETS. */ | 42 | _REGEX_LARGE_OFFSETS. */ |
44 | 43 | ||
45 | /* The type of nonnegative object indexes. Traditionally, GNU regex | ||
46 | uses 'int' for these. Code that uses __re_idx_t should work | ||
47 | regardless of whether the type is signed. */ | ||
48 | typedef size_t __re_idx_t; | ||
49 | |||
50 | /* The type of object sizes. */ | 44 | /* The type of object sizes. */ |
51 | typedef size_t __re_size_t; | 45 | typedef size_t __re_size_t; |
52 | 46 | ||
@@ -58,7 +52,6 @@ typedef size_t __re_long_size_t; | |||
58 | 52 | ||
59 | /* The traditional GNU regex implementation mishandles strings longer | 53 | /* The traditional GNU regex implementation mishandles strings longer |
60 | than INT_MAX. */ | 54 | than INT_MAX. */ |
61 | typedef int __re_idx_t; | ||
62 | typedef unsigned int __re_size_t; | 55 | typedef unsigned int __re_size_t; |
63 | typedef unsigned long int __re_long_size_t; | 56 | typedef unsigned long int __re_long_size_t; |
64 | 57 | ||
@@ -244,19 +237,16 @@ extern reg_syntax_t re_syntax_options; | |||
244 | | RE_INVALID_INTERVAL_ORD) | 237 | | RE_INVALID_INTERVAL_ORD) |
245 | 238 | ||
246 | # define RE_SYNTAX_GREP \ | 239 | # define RE_SYNTAX_GREP \ |
247 | (RE_BK_PLUS_QM | RE_CHAR_CLASSES \ | 240 | ((RE_SYNTAX_POSIX_BASIC | RE_NEWLINE_ALT) \ |
248 | | RE_HAT_LISTS_NOT_NEWLINE | RE_INTERVALS \ | 241 | & ~(RE_CONTEXT_INVALID_DUP | RE_DOT_NOT_NULL)) |
249 | | RE_NEWLINE_ALT) | ||
250 | 242 | ||
251 | # define RE_SYNTAX_EGREP \ | 243 | # define RE_SYNTAX_EGREP \ |
252 | (RE_CHAR_CLASSES | RE_CONTEXT_INDEP_ANCHORS \ | 244 | ((RE_SYNTAX_POSIX_EXTENDED | RE_INVALID_INTERVAL_ORD | RE_NEWLINE_ALT) \ |
253 | | RE_CONTEXT_INDEP_OPS | RE_HAT_LISTS_NOT_NEWLINE \ | 245 | & ~(RE_CONTEXT_INVALID_OPS | RE_DOT_NOT_NULL)) |
254 | | RE_NEWLINE_ALT | RE_NO_BK_PARENS \ | ||
255 | | RE_NO_BK_VBAR) | ||
256 | 246 | ||
247 | /* POSIX grep -E behavior is no longer incompatible with GNU. */ | ||
257 | # define RE_SYNTAX_POSIX_EGREP \ | 248 | # define RE_SYNTAX_POSIX_EGREP \ |
258 | (RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES \ | 249 | RE_SYNTAX_EGREP |
259 | | RE_INVALID_INTERVAL_ORD) | ||
260 | 250 | ||
261 | /* P1003.2/D11.2, section 4.20.7.1, lines 5078ff. */ | 251 | /* P1003.2/D11.2, section 4.20.7.1, lines 5078ff. */ |
262 | # define RE_SYNTAX_ED RE_SYNTAX_POSIX_BASIC | 252 | # define RE_SYNTAX_ED RE_SYNTAX_POSIX_BASIC |
@@ -491,7 +481,8 @@ typedef struct re_pattern_buffer regex_t; | |||
491 | #ifdef _REGEX_LARGE_OFFSETS | 481 | #ifdef _REGEX_LARGE_OFFSETS |
492 | /* POSIX 1003.1-2008 requires that regoff_t be at least as wide as | 482 | /* POSIX 1003.1-2008 requires that regoff_t be at least as wide as |
493 | ptrdiff_t and ssize_t. We don't know of any hosts where ptrdiff_t | 483 | ptrdiff_t and ssize_t. We don't know of any hosts where ptrdiff_t |
494 | is wider than ssize_t, so ssize_t is safe. */ | 484 | is wider than ssize_t, so ssize_t is safe. ptrdiff_t is not |
485 | visible here, so use ssize_t. */ | ||
495 | typedef ssize_t regoff_t; | 486 | typedef ssize_t regoff_t; |
496 | #else | 487 | #else |
497 | /* The traditional GNU regex implementation mishandles strings longer | 488 | /* The traditional GNU regex implementation mishandles strings longer |
@@ -531,6 +522,30 @@ typedef struct | |||
531 | 522 | ||
532 | /* Declarations for routines. */ | 523 | /* Declarations for routines. */ |
533 | 524 | ||
525 | #ifndef _REGEX_NELTS | ||
526 | # if (defined __STDC_VERSION__ && 199901L <= __STDC_VERSION__ \ | ||
527 | && !defined __STDC_NO_VLA__) | ||
528 | # define _REGEX_NELTS(n) n | ||
529 | # else | ||
530 | # define _REGEX_NELTS(n) | ||
531 | # endif | ||
532 | #endif | ||
533 | |||
534 | #if defined __GNUC__ && 4 < __GNUC__ + (6 <= __GNUC_MINOR__) | ||
535 | # pragma GCC diagnostic push | ||
536 | # pragma GCC diagnostic ignored "-Wvla" | ||
537 | #endif | ||
538 | |||
539 | #ifndef _Attr_access_ | ||
540 | # ifdef __attr_access | ||
541 | # define _Attr_access_(arg) __attr_access (arg) | ||
542 | # elif defined __GNUC__ && 10 <= __GNUC__ | ||
543 | # define _Attr_access_(x) __attribute__ ((__access__ x)) | ||
544 | # else | ||
545 | # define _Attr_access_(x) | ||
546 | # endif | ||
547 | #endif | ||
548 | |||
534 | #ifdef __USE_GNU | 549 | #ifdef __USE_GNU |
535 | /* Sets the current default syntax to SYNTAX, and return the old syntax. | 550 | /* Sets the current default syntax to SYNTAX, and return the old syntax. |
536 | You can also simply assign to the 're_syntax_options' variable. */ | 551 | You can also simply assign to the 're_syntax_options' variable. */ |
@@ -541,11 +556,12 @@ extern reg_syntax_t re_set_syntax (reg_syntax_t __syntax); | |||
541 | BUFFER. Return NULL if successful, and an error string if not. | 556 | BUFFER. Return NULL if successful, and an error string if not. |
542 | 557 | ||
543 | To free the allocated storage, you must call 'regfree' on BUFFER. | 558 | To free the allocated storage, you must call 'regfree' on BUFFER. |
544 | Note that the translate table must either have been initialised by | 559 | Note that the translate table must either have been initialized by |
545 | 'regcomp', with a malloc'ed value, or set to NULL before calling | 560 | 'regcomp', with a malloc'ed value, or set to NULL before calling |
546 | 'regfree'. */ | 561 | 'regfree'. */ |
547 | extern const char *re_compile_pattern (const char *__pattern, size_t __length, | 562 | extern const char *re_compile_pattern (const char *__pattern, size_t __length, |
548 | struct re_pattern_buffer *__buffer); | 563 | struct re_pattern_buffer *__buffer) |
564 | _Attr_access_ ((__read_only__, 1, 2)); | ||
549 | 565 | ||
550 | 566 | ||
551 | /* Compile a fastmap for the compiled pattern in BUFFER; used to | 567 | /* Compile a fastmap for the compiled pattern in BUFFER; used to |
@@ -560,34 +576,40 @@ extern int re_compile_fastmap (struct re_pattern_buffer *__buffer); | |||
560 | match, or -2 for an internal error. Also return register | 576 | match, or -2 for an internal error. Also return register |
561 | information in REGS (if REGS and BUFFER->no_sub are nonzero). */ | 577 | information in REGS (if REGS and BUFFER->no_sub are nonzero). */ |
562 | extern regoff_t re_search (struct re_pattern_buffer *__buffer, | 578 | extern regoff_t re_search (struct re_pattern_buffer *__buffer, |
563 | const char *__string, __re_idx_t __length, | 579 | const char *__String, regoff_t __length, |
564 | __re_idx_t __start, regoff_t __range, | 580 | regoff_t __start, regoff_t __range, |
565 | struct re_registers *__regs); | 581 | struct re_registers *__regs) |
582 | _Attr_access_ ((__read_only__, 2, 3)); | ||
566 | 583 | ||
567 | 584 | ||
568 | /* Like 're_search', but search in the concatenation of STRING1 and | 585 | /* Like 're_search', but search in the concatenation of STRING1 and |
569 | STRING2. Also, stop searching at index START + STOP. */ | 586 | STRING2. Also, stop searching at index START + STOP. */ |
570 | extern regoff_t re_search_2 (struct re_pattern_buffer *__buffer, | 587 | extern regoff_t re_search_2 (struct re_pattern_buffer *__buffer, |
571 | const char *__string1, __re_idx_t __length1, | 588 | const char *__string1, regoff_t __length1, |
572 | const char *__string2, __re_idx_t __length2, | 589 | const char *__string2, regoff_t __length2, |
573 | __re_idx_t __start, regoff_t __range, | 590 | regoff_t __start, regoff_t __range, |
574 | struct re_registers *__regs, | 591 | struct re_registers *__regs, |
575 | __re_idx_t __stop); | 592 | regoff_t __stop) |
593 | _Attr_access_ ((__read_only__, 2, 3)) | ||
594 | _Attr_access_ ((__read_only__, 4, 5)); | ||
576 | 595 | ||
577 | 596 | ||
578 | /* Like 're_search', but return how many characters in STRING the regexp | 597 | /* Like 're_search', but return how many characters in STRING the regexp |
579 | in BUFFER matched, starting at position START. */ | 598 | in BUFFER matched, starting at position START. */ |
580 | extern regoff_t re_match (struct re_pattern_buffer *__buffer, | 599 | extern regoff_t re_match (struct re_pattern_buffer *__buffer, |
581 | const char *__string, __re_idx_t __length, | 600 | const char *__String, regoff_t __length, |
582 | __re_idx_t __start, struct re_registers *__regs); | 601 | regoff_t __start, struct re_registers *__regs) |
602 | _Attr_access_ ((__read_only__, 2, 3)); | ||
583 | 603 | ||
584 | 604 | ||
585 | /* Relates to 're_match' as 're_search_2' relates to 're_search'. */ | 605 | /* Relates to 're_match' as 're_search_2' relates to 're_search'. */ |
586 | extern regoff_t re_match_2 (struct re_pattern_buffer *__buffer, | 606 | extern regoff_t re_match_2 (struct re_pattern_buffer *__buffer, |
587 | const char *__string1, __re_idx_t __length1, | 607 | const char *__string1, regoff_t __length1, |
588 | const char *__string2, __re_idx_t __length2, | 608 | const char *__string2, regoff_t __length2, |
589 | __re_idx_t __start, struct re_registers *__regs, | 609 | regoff_t __start, struct re_registers *__regs, |
590 | __re_idx_t __stop); | 610 | regoff_t __stop) |
611 | _Attr_access_ ((__read_only__, 2, 3)) | ||
612 | _Attr_access_ ((__read_only__, 4, 5)); | ||
591 | 613 | ||
592 | 614 | ||
593 | /* Set REGS to hold NUM_REGS registers, storing them in STARTS and | 615 | /* Set REGS to hold NUM_REGS registers, storing them in STARTS and |
@@ -608,36 +630,41 @@ extern void re_set_registers (struct re_pattern_buffer *__buffer, | |||
608 | regoff_t *__starts, regoff_t *__ends); | 630 | regoff_t *__starts, regoff_t *__ends); |
609 | #endif /* Use GNU */ | 631 | #endif /* Use GNU */ |
610 | 632 | ||
611 | #if defined _REGEX_RE_COMP || (defined _LIBC && defined __USE_BSD) | 633 | #if defined _REGEX_RE_COMP || (defined _LIBC && defined __USE_MISC) |
612 | # ifndef _CRAY | ||
613 | /* 4.2 bsd compatibility. */ | 634 | /* 4.2 bsd compatibility. */ |
614 | extern char *re_comp (const char *); | 635 | extern char *re_comp (const char *); |
615 | extern int re_exec (const char *); | 636 | extern int re_exec (const char *); |
616 | # endif | ||
617 | #endif | 637 | #endif |
618 | 638 | ||
619 | /* GCC 2.95 and later have "__restrict"; C99 compilers have | 639 | /* For plain 'restrict', use glibc's __restrict if defined. |
640 | Otherwise, GCC 2.95 and later have "__restrict"; C99 compilers have | ||
620 | "restrict", and "configure" may have defined "restrict". | 641 | "restrict", and "configure" may have defined "restrict". |
621 | Other compilers use __restrict, __restrict__, and _Restrict, and | 642 | Other compilers use __restrict, __restrict__, and _Restrict, and |
622 | 'configure' might #define 'restrict' to those words, so pick a | 643 | 'configure' might #define 'restrict' to those words, so pick a |
623 | different name. */ | 644 | different name. */ |
624 | #ifndef _Restrict_ | 645 | #ifndef _Restrict_ |
625 | # if 199901L <= __STDC_VERSION__ | 646 | # if defined __restrict \ |
626 | # define _Restrict_ restrict | 647 | || 2 < __GNUC__ + (95 <= __GNUC_MINOR__) \ |
627 | # elif 2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__) | 648 | || __clang_major__ >= 3 |
628 | # define _Restrict_ __restrict | 649 | # define _Restrict_ __restrict |
650 | # elif 199901L <= __STDC_VERSION__ || defined restrict | ||
651 | # define _Restrict_ restrict | ||
629 | # else | 652 | # else |
630 | # define _Restrict_ | 653 | # define _Restrict_ |
631 | # endif | 654 | # endif |
632 | #endif | 655 | #endif |
633 | /* gcc 3.1 and up support the [restrict] syntax. Don't trust | 656 | /* For the ISO C99 syntax |
634 | sys/cdefs.h's definition of __restrict_arr, though, as it | 657 | array_name[restrict] |
635 | mishandles gcc -ansi -pedantic. */ | 658 | use glibc's __restrict_arr if available. |
659 | Otherwise, GCC 3.1 and clang support this syntax (but not in C++ mode). | ||
660 | Other ISO C99 compilers support it as well. */ | ||
636 | #ifndef _Restrict_arr_ | 661 | #ifndef _Restrict_arr_ |
637 | # if ((199901L <= __STDC_VERSION__ \ | 662 | # ifdef __restrict_arr |
638 | || ((3 < __GNUC__ || (3 == __GNUC__ && 1 <= __GNUC_MINOR__)) \ | 663 | # define _Restrict_arr_ __restrict_arr |
639 | && !defined __STRICT_ANSI__)) \ | 664 | # elif ((199901L <= __STDC_VERSION__ \ |
640 | && !defined __GNUG__) | 665 | || 3 < __GNUC__ + (1 <= __GNUC_MINOR__) \ |
666 | || __clang_major__ >= 3) \ | ||
667 | && !defined __cplusplus) | ||
641 | # define _Restrict_arr_ _Restrict_ | 668 | # define _Restrict_arr_ _Restrict_ |
642 | # else | 669 | # else |
643 | # define _Restrict_arr_ | 670 | # define _Restrict_arr_ |
@@ -650,15 +677,20 @@ extern int regcomp (regex_t *_Restrict_ __preg, | |||
650 | int __cflags); | 677 | int __cflags); |
651 | 678 | ||
652 | extern int regexec (const regex_t *_Restrict_ __preg, | 679 | extern int regexec (const regex_t *_Restrict_ __preg, |
653 | const char *_Restrict_ __string, size_t __nmatch, | 680 | const char *_Restrict_ __String, size_t __nmatch, |
654 | regmatch_t __pmatch[_Restrict_arr_], | 681 | regmatch_t __pmatch[_Restrict_arr_ |
682 | _REGEX_NELTS (__nmatch)], | ||
655 | int __eflags); | 683 | int __eflags); |
656 | 684 | ||
657 | extern size_t regerror (int __errcode, const regex_t *_Restrict_ __preg, | 685 | extern size_t regerror (int __errcode, const regex_t *_Restrict_ __preg, |
658 | char *_Restrict_ __errbuf, size_t __errbuf_size); | 686 | char *_Restrict_ __errbuf, size_t __errbuf_size) |
687 | _Attr_access_ ((__write_only__, 3, 4)); | ||
659 | 688 | ||
660 | extern void regfree (regex_t *__preg); | 689 | extern void regfree (regex_t *__preg); |
661 | 690 | ||
691 | #if defined __GNUC__ && 4 < __GNUC__ + (6 <= __GNUC_MINOR__) | ||
692 | # pragma GCC diagnostic pop | ||
693 | #endif | ||
662 | 694 | ||
663 | #ifdef __cplusplus | 695 | #ifdef __cplusplus |
664 | } | 696 | } |