Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 5594aa6

Browse files
committed
Fix broken definition of :print: character class, per Bruno Wolff.
Also, make :alnum: character class directly dependent on isalnum() rather than guessing.
1 parent 3b97d9f commit 5594aa6

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

src/backend/regex/regc_locale.c

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
* permission to use and distribute the software in accordance with the
4848
* terms specified in this license.
4949
*
50-
* $Header: /cvsroot/pgsql/src/backend/regex/regc_locale.c,v 1.3 2003/08/08 21:41:56 momjian Exp $
50+
* $Header: /cvsroot/pgsql/src/backend/regex/regc_locale.c,v 1.4 2003/09/29 00:21:58 tgl Exp $
5151
*/
5252

5353
/* ASCII character-name table */
@@ -388,6 +388,12 @@ pg_isgraph(pg_wchar c)
388388
return (c >= 0 && c <= UCHAR_MAX && isgraph((unsigned char) c));
389389
}
390390

391+
static int
392+
pg_isprint(pg_wchar c)
393+
{
394+
return (c >= 0 && c <= UCHAR_MAX && isprint((unsigned char) c));
395+
}
396+
391397
static int
392398
pg_ispunct(pg_wchar c)
393399
{
@@ -657,16 +663,25 @@ cclass(struct vars * v, /* context */
657663
switch ((enum classes) index)
658664
{
659665
case CC_PRINT:
666+
cv = getcvec(v, UCHAR_MAX, 0, 0);
667+
if (cv)
668+
{
669+
for (i = 0; i <= UCHAR_MAX; i++)
670+
{
671+
if (pg_isprint((chr) i))
672+
addchr(cv, (chr) i);
673+
}
674+
}
675+
break;
660676
case CC_ALNUM:
661-
cv = getcvec(v, UCHAR_MAX, 1, 0);
677+
cv = getcvec(v, UCHAR_MAX, 0, 0);
662678
if (cv)
663679
{
664680
for (i = 0; i <= UCHAR_MAX; i++)
665681
{
666-
if (pg_isalpha((chr) i))
682+
if (pg_isalnum((chr) i))
667683
addchr(cv, (chr) i);
668684
}
669-
addrange(cv, (chr) '0', (chr) '9');
670685
}
671686
break;
672687
case CC_ALPHA:

src/backend/regex/regcomp.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
2929
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030
*
31-
* $Header: /cvsroot/pgsql/src/backend/regex/regcomp.c,v 1.38 2003/08/08 21:41:56 momjian Exp $
31+
* $Header: /cvsroot/pgsql/src/backend/regex/regcomp.c,v 1.39 2003/09/29 00:21:58 tgl Exp $
3232
*
3333
*/
3434

@@ -184,6 +184,7 @@ static int pg_isalnum(pg_wchar c);
184184
static int pg_isupper(pg_wchar c);
185185
static int pg_islower(pg_wchar c);
186186
static int pg_isgraph(pg_wchar c);
187+
static int pg_isprint(pg_wchar c);
187188
static int pg_ispunct(pg_wchar c);
188189
static int pg_isspace(pg_wchar c);
189190
static pg_wchar pg_toupper(pg_wchar c);

0 commit comments

Comments
 (0)