diff options
| author | Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> | 2008-02-12 11:07:18 +0000 |
|---|---|---|
| committer | Thomas Guyot-Sionnest <dermoth@users.sourceforge.net> | 2008-02-12 11:07:18 +0000 |
| commit | bd7029a99b0c2974265c6665638ef14a052f42ab (patch) | |
| tree | f5661ba73366d81ef6e91f889ea7fec5ebe07b6b /gl/regcomp.c | |
| parent | f99612320d6eda67644c07be04bb21aa4d7789db (diff) | |
| download | monitoring-plugins-bd7029a99b0c2974265c6665638ef14a052f42ab.tar.gz | |
Sync to latest Gnulib
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1925 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'gl/regcomp.c')
| -rw-r--r-- | gl/regcomp.c | 56 |
1 files changed, 15 insertions, 41 deletions
diff --git a/gl/regcomp.c b/gl/regcomp.c index 8df6bb80..8827e03c 100644 --- a/gl/regcomp.c +++ b/gl/regcomp.c | |||
| @@ -1,11 +1,11 @@ | |||
| 1 | /* Extended regular expression matching and search library. | 1 | /* Extended regular expression matching and search library. |
| 2 | Copyright (C) 2002,2003,2004,2005,2006 Free Software Foundation, Inc. | 2 | Copyright (C) 2002,2003,2004,2005,2006,2007 Free Software Foundation, Inc. |
| 3 | This file is part of the GNU C Library. | 3 | This file is part of the GNU C Library. |
| 4 | Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>. | 4 | Contributed by Isamu Hasegawa <isamu@yamato.ibm.com>. |
| 5 | 5 | ||
| 6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
| 7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
| 8 | the Free Software Foundation; either version 2, or (at your option) | 8 | the Free Software Foundation; either version 3, or (at your option) |
| 9 | any later version. | 9 | any later version. |
| 10 | 10 | ||
| 11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
| @@ -451,8 +451,8 @@ re_compile_fastmap_iter (regex_t *bufp, const re_dfastate_t *init_state, | |||
| 451 | 451 | ||
| 452 | int | 452 | int |
| 453 | regcomp (preg, pattern, cflags) | 453 | regcomp (preg, pattern, cflags) |
| 454 | regex_t *__restrict preg; | 454 | regex_t *_Restrict_ preg; |
| 455 | const char *__restrict pattern; | 455 | const char *_Restrict_ pattern; |
| 456 | int cflags; | 456 | int cflags; |
| 457 | { | 457 | { |
| 458 | reg_errcode_t ret; | 458 | reg_errcode_t ret; |
| @@ -515,13 +515,13 @@ weak_alias (__regcomp, regcomp) | |||
| 515 | size_t | 515 | size_t |
| 516 | regerror (errcode, preg, errbuf, errbuf_size) | 516 | regerror (errcode, preg, errbuf, errbuf_size) |
| 517 | int errcode; | 517 | int errcode; |
| 518 | const regex_t *__restrict preg; | 518 | const regex_t *_Restrict_ preg; |
| 519 | char *__restrict errbuf; | 519 | char *_Restrict_ errbuf; |
| 520 | size_t errbuf_size; | 520 | size_t errbuf_size; |
| 521 | #else /* size_t might promote */ | 521 | #else /* size_t might promote */ |
| 522 | size_t | 522 | size_t |
| 523 | regerror (int errcode, const regex_t *__restrict preg, | 523 | regerror (int errcode, const regex_t *_Restrict_ preg, |
| 524 | char *__restrict errbuf, size_t errbuf_size) | 524 | char *_Restrict_ errbuf, size_t errbuf_size) |
| 525 | #endif | 525 | #endif |
| 526 | { | 526 | { |
| 527 | const char *msg; | 527 | const char *msg; |
| @@ -542,17 +542,13 @@ regerror (int errcode, const regex_t *__restrict preg, | |||
| 542 | 542 | ||
| 543 | if (BE (errbuf_size != 0, 1)) | 543 | if (BE (errbuf_size != 0, 1)) |
| 544 | { | 544 | { |
| 545 | size_t cpy_size = msg_size; | ||
| 545 | if (BE (msg_size > errbuf_size, 0)) | 546 | if (BE (msg_size > errbuf_size, 0)) |
| 546 | { | 547 | { |
| 547 | #if defined HAVE_MEMPCPY || defined _LIBC | 548 | cpy_size = errbuf_size - 1; |
| 548 | *((char *) __mempcpy (errbuf, msg, errbuf_size - 1)) = '\0'; | 549 | errbuf[cpy_size] = '\0'; |
| 549 | #else | ||
| 550 | memcpy (errbuf, msg, errbuf_size - 1); | ||
| 551 | errbuf[errbuf_size - 1] = 0; | ||
| 552 | #endif | ||
| 553 | } | 550 | } |
| 554 | else | 551 | memcpy (errbuf, msg, cpy_size); |
| 555 | memcpy (errbuf, msg, msg_size); | ||
| 556 | } | 552 | } |
| 557 | 553 | ||
| 558 | return msg_size; | 554 | return msg_size; |
| @@ -833,9 +829,6 @@ static reg_errcode_t | |||
| 833 | init_dfa (re_dfa_t *dfa, size_t pat_len) | 829 | init_dfa (re_dfa_t *dfa, size_t pat_len) |
| 834 | { | 830 | { |
| 835 | __re_size_t table_size; | 831 | __re_size_t table_size; |
| 836 | #ifndef _LIBC | ||
| 837 | char *codeset_name; | ||
| 838 | #endif | ||
| 839 | #ifdef RE_ENABLE_I18N | 832 | #ifdef RE_ENABLE_I18N |
| 840 | size_t max_i18n_object_size = MAX (sizeof (wchar_t), sizeof (wctype_t)); | 833 | size_t max_i18n_object_size = MAX (sizeof (wchar_t), sizeof (wctype_t)); |
| 841 | #else | 834 | #else |
| @@ -879,22 +872,7 @@ init_dfa (re_dfa_t *dfa, size_t pat_len) | |||
| 879 | dfa->map_notascii = (_NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_MAP_TO_NONASCII) | 872 | dfa->map_notascii = (_NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_MAP_TO_NONASCII) |
| 880 | != 0); | 873 | != 0); |
| 881 | #else | 874 | #else |
| 882 | # ifdef HAVE_LANGINFO_CODESET | 875 | if (strcmp (locale_charset (), "UTF-8") == 0) |
| 883 | codeset_name = nl_langinfo (CODESET); | ||
| 884 | # else | ||
| 885 | codeset_name = getenv ("LC_ALL"); | ||
| 886 | if (codeset_name == NULL || codeset_name[0] == '\0') | ||
| 887 | codeset_name = getenv ("LC_CTYPE"); | ||
| 888 | if (codeset_name == NULL || codeset_name[0] == '\0') | ||
| 889 | codeset_name = getenv ("LANG"); | ||
| 890 | if (codeset_name == NULL) | ||
| 891 | codeset_name = ""; | ||
| 892 | else if (strchr (codeset_name, '.') != NULL) | ||
| 893 | codeset_name = strchr (codeset_name, '.') + 1; | ||
| 894 | # endif | ||
| 895 | |||
| 896 | if (strcasecmp (codeset_name, "UTF-8") == 0 | ||
| 897 | || strcasecmp (codeset_name, "UTF8") == 0) | ||
| 898 | dfa->is_utf8 = 1; | 876 | dfa->is_utf8 = 1; |
| 899 | 877 | ||
| 900 | /* We check exhaustively in the loop below if this charset is a | 878 | /* We check exhaustively in the loop below if this charset is a |
| @@ -1071,7 +1049,7 @@ optimize_utf8 (re_dfa_t *dfa) | |||
| 1071 | mb_chars = true; | 1049 | mb_chars = true; |
| 1072 | break; | 1050 | break; |
| 1073 | case ANCHOR: | 1051 | case ANCHOR: |
| 1074 | switch (dfa->nodes[node].opr.idx) | 1052 | switch (dfa->nodes[node].opr.ctx_type) |
| 1075 | { | 1053 | { |
| 1076 | case LINE_FIRST: | 1054 | case LINE_FIRST: |
| 1077 | case LINE_LAST: | 1055 | case LINE_LAST: |
| @@ -3074,7 +3052,7 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token, | |||
| 3074 | #endif /* not RE_ENABLE_I18N */ | 3052 | #endif /* not RE_ENABLE_I18N */ |
| 3075 | non_match = true; | 3053 | non_match = true; |
| 3076 | if (syntax & RE_HAT_LISTS_NOT_NEWLINE) | 3054 | if (syntax & RE_HAT_LISTS_NOT_NEWLINE) |
| 3077 | bitset_set (sbcset, '\0'); | 3055 | bitset_set (sbcset, '\n'); |
| 3078 | re_string_skip_bytes (regexp, token_len); /* Skip a token. */ | 3056 | re_string_skip_bytes (regexp, token_len); /* Skip a token. */ |
| 3079 | token_len = peek_token_bracket (token, regexp, syntax); | 3057 | token_len = peek_token_bracket (token, regexp, syntax); |
| 3080 | if (BE (token->type == END_OF_RE, 0)) | 3058 | if (BE (token->type == END_OF_RE, 0)) |
| @@ -3605,10 +3583,6 @@ build_charclass_op (re_dfa_t *dfa, RE_TRANSLATE_TYPE trans, | |||
| 3605 | if (non_match) | 3583 | if (non_match) |
| 3606 | { | 3584 | { |
| 3607 | #ifdef RE_ENABLE_I18N | 3585 | #ifdef RE_ENABLE_I18N |
| 3608 | /* | ||
| 3609 | if (syntax & RE_HAT_LISTS_NOT_NEWLINE) | ||
| 3610 | bitset_set(cset->sbcset, '\0'); | ||
| 3611 | */ | ||
| 3612 | mbcset->non_match = 1; | 3586 | mbcset->non_match = 1; |
| 3613 | #endif /* not RE_ENABLE_I18N */ | 3587 | #endif /* not RE_ENABLE_I18N */ |
| 3614 | } | 3588 | } |
