OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [tags/] [gnu-src/] [newlib-1.18.0/] [newlib-1.18.0-or32-1.0rc1/] [newlib/] [libc/] [ctype/] [iswpunct.c] - Diff between revs 207 and 345

Only display areas with differences | Details | Blame | View Log

Rev 207 Rev 345
/* Copyright (c) 2002 Red Hat Incorporated.
/* Copyright (c) 2002 Red Hat Incorporated.
   All rights reserved.
   All rights reserved.
 
 
   Redistribution and use in source and binary forms, with or without
   Redistribution and use in source and binary forms, with or without
   modification, are permitted provided that the following conditions are met:
   modification, are permitted provided that the following conditions are met:
 
 
     Redistributions of source code must retain the above copyright
     Redistributions of source code must retain the above copyright
     notice, this list of conditions and the following disclaimer.
     notice, this list of conditions and the following disclaimer.
 
 
     Redistributions in binary form must reproduce the above copyright
     Redistributions in binary form must reproduce the above copyright
     notice, this list of conditions and the following disclaimer in the
     notice, this list of conditions and the following disclaimer in the
     documentation and/or other materials provided with the distribution.
     documentation and/or other materials provided with the distribution.
 
 
     The name of Red Hat Incorporated may not be used to endorse
     The name of Red Hat Incorporated may not be used to endorse
     or promote products derived from this software without specific
     or promote products derived from this software without specific
     prior written permission.
     prior written permission.
 
 
   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   ARE DISCLAIMED.  IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
   ARE DISCLAIMED.  IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
   DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
   DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
*/
 
 
/*
/*
FUNCTION
FUNCTION
        <<iswpunct>>---punctuation wide character test
        <<iswpunct>>---punctuation wide character test
 
 
INDEX
INDEX
        iswpunct
        iswpunct
 
 
ANSI_SYNOPSIS
ANSI_SYNOPSIS
        #include <wctype.h>
        #include <wctype.h>
        int iswpunct(wint_t <[c]>);
        int iswpunct(wint_t <[c]>);
 
 
TRAD_SYNOPSIS
TRAD_SYNOPSIS
        #include <wctype.h>
        #include <wctype.h>
        int iswpunct(<[c]>)
        int iswpunct(<[c]>)
        wint_t <[c]>;
        wint_t <[c]>;
 
 
DESCRIPTION
DESCRIPTION
<<iswpunct>> is a function which classifies wide-character values that
<<iswpunct>> is a function which classifies wide-character values that
are punctuation.
are punctuation.
 
 
RETURNS
RETURNS
<<iswpunct>> returns non-zero if <[c]> is a punctuation wide character.
<<iswpunct>> returns non-zero if <[c]> is a punctuation wide character.
 
 
PORTABILITY
PORTABILITY
<<iswpunct>> is C99.
<<iswpunct>> is C99.
 
 
No supporting OS subroutines are required.
No supporting OS subroutines are required.
*/
*/
#include <_ansi.h>
#include <_ansi.h>
#include <newlib.h>
#include <newlib.h>
#include <wctype.h>
#include <wctype.h>
#include <string.h>
#include <string.h>
#include <ctype.h>
#include <ctype.h>
#include "local.h"
#include "local.h"
 
 
#ifdef _MB_CAPABLE
#ifdef _MB_CAPABLE
#include "utf8punct.h"
#include "utf8punct.h"
#endif /* _MB_CAPABLE */
#endif /* _MB_CAPABLE */
 
 
int
int
_DEFUN(iswpunct,(c), wint_t c)
_DEFUN(iswpunct,(c), wint_t c)
{
{
#ifdef _MB_CAPABLE
#ifdef _MB_CAPABLE
  unsigned const char *table;
  unsigned const char *table;
  unsigned char *ptr;
  unsigned char *ptr;
  unsigned char ctmp;
  unsigned char ctmp;
  int size;
  int size;
  wint_t x;
  wint_t x;
 
 
  c = _jp2uc (c);
  c = _jp2uc (c);
 
 
  x = (c >> 8);
  x = (c >> 8);
  /* for some large sections, all characters are punctuation so handle them here */
  /* for some large sections, all characters are punctuation so handle them here */
  if ((x >= 0xe0 && x <= 0xf8) ||
  if ((x >= 0xe0 && x <= 0xf8) ||
      (x >= 0xf00 && x <= 0xffe) ||
      (x >= 0xf00 && x <= 0xffe) ||
      (x >= 0x1000 && x <= 0x10fe))
      (x >= 0x1000 && x <= 0x10fe))
    return 1;
    return 1;
 
 
  switch (x)
  switch (x)
    {
    {
    case 0x22:
    case 0x22:
    case 0x25:
    case 0x25:
    case 0x28:
    case 0x28:
    case 0x29:
    case 0x29:
    case 0x2a:
    case 0x2a:
      return 1;
      return 1;
    case 0x00:
    case 0x00:
      table = u0;
      table = u0;
      size = sizeof(u0);
      size = sizeof(u0);
      break;
      break;
    case 0x02:
    case 0x02:
      table = u2;
      table = u2;
      size = sizeof(u2);
      size = sizeof(u2);
      break;
      break;
    case 0x03:
    case 0x03:
      table = u3;
      table = u3;
      size = sizeof(u3);
      size = sizeof(u3);
      break;
      break;
    case 0x04:
    case 0x04:
      table = u4;
      table = u4;
      size = sizeof(u4);
      size = sizeof(u4);
      break;
      break;
    case 0x05:
    case 0x05:
      table = u5;
      table = u5;
      size = sizeof(u5);
      size = sizeof(u5);
      break;
      break;
    case 0x06:
    case 0x06:
      table = u6;
      table = u6;
      size = sizeof(u6);
      size = sizeof(u6);
      break;
      break;
    case 0x07:
    case 0x07:
      table = u7;
      table = u7;
      size = sizeof(u7);
      size = sizeof(u7);
      break;
      break;
    case 0x09:
    case 0x09:
      table = u9;
      table = u9;
      size = sizeof(u9);
      size = sizeof(u9);
      break;
      break;
    case 0x0a:
    case 0x0a:
      table = ua;
      table = ua;
      size = sizeof(ua);
      size = sizeof(ua);
      break;
      break;
    case 0x0b:
    case 0x0b:
      table = ub;
      table = ub;
      size = sizeof(ub);
      size = sizeof(ub);
      break;
      break;
    case 0x0c:
    case 0x0c:
      table = uc;
      table = uc;
      size = sizeof(uc);
      size = sizeof(uc);
      break;
      break;
    case 0x0d:
    case 0x0d:
      table = ud;
      table = ud;
      size = sizeof(ud);
      size = sizeof(ud);
      break;
      break;
    case 0x0e:
    case 0x0e:
      table = ue;
      table = ue;
      size = sizeof(ue);
      size = sizeof(ue);
      break;
      break;
    case 0x0f:
    case 0x0f:
      table = uf;
      table = uf;
      size = sizeof(uf);
      size = sizeof(uf);
      break;
      break;
    case 0x10:
    case 0x10:
      table = u10;
      table = u10;
      size = sizeof(u10);
      size = sizeof(u10);
      break;
      break;
    case 0x13:
    case 0x13:
      table = u13;
      table = u13;
      size = sizeof(u13);
      size = sizeof(u13);
      break;
      break;
    case 0x16:
    case 0x16:
      table = u16;
      table = u16;
      size = sizeof(u16);
      size = sizeof(u16);
      break;
      break;
    case 0x17:
    case 0x17:
      table = u17;
      table = u17;
      size = sizeof(u17);
      size = sizeof(u17);
      break;
      break;
    case 0x18:
    case 0x18:
      table = u18;
      table = u18;
      size = sizeof(u18);
      size = sizeof(u18);
      break;
      break;
    case 0x1f:
    case 0x1f:
      table = u1f;
      table = u1f;
      size = sizeof(u1f);
      size = sizeof(u1f);
      break;
      break;
    case 0x20:
    case 0x20:
      table = u20;
      table = u20;
      size = sizeof(u20);
      size = sizeof(u20);
      break;
      break;
    case 0x21:
    case 0x21:
      table = u21;
      table = u21;
      size = sizeof(u21);
      size = sizeof(u21);
      break;
      break;
    case 0x23:
    case 0x23:
      table = u23;
      table = u23;
      size = sizeof(u23);
      size = sizeof(u23);
      break;
      break;
    case 0x24:
    case 0x24:
      table = u24;
      table = u24;
      size = sizeof(u24);
      size = sizeof(u24);
      break;
      break;
    case 0x26:
    case 0x26:
      table = u26;
      table = u26;
      size = sizeof(u26);
      size = sizeof(u26);
      break;
      break;
    case 0x27:
    case 0x27:
      table = u27;
      table = u27;
      size = sizeof(u27);
      size = sizeof(u27);
      break;
      break;
    case 0x2e:
    case 0x2e:
      table = u2e;
      table = u2e;
      size = sizeof(u2e);
      size = sizeof(u2e);
      break;
      break;
    case 0x2f:
    case 0x2f:
      table = u2f;
      table = u2f;
      size = sizeof(u2f);
      size = sizeof(u2f);
      break;
      break;
    case 0x30:
    case 0x30:
      table = u30;
      table = u30;
      size = sizeof(u30);
      size = sizeof(u30);
      break;
      break;
    case 0x31:
    case 0x31:
      table = u31;
      table = u31;
      size = sizeof(u31);
      size = sizeof(u31);
      break;
      break;
    case 0x32:
    case 0x32:
      table = u32;
      table = u32;
      size = sizeof(u32);
      size = sizeof(u32);
      break;
      break;
    case 0x33:
    case 0x33:
      table = u33;
      table = u33;
      size = sizeof(u33);
      size = sizeof(u33);
      break;
      break;
    case 0xa4:
    case 0xa4:
      table = ua4;
      table = ua4;
      size = sizeof(ua4);
      size = sizeof(ua4);
      break;
      break;
    case 0xfb:
    case 0xfb:
      table = ufb;
      table = ufb;
      size = sizeof(ufb);
      size = sizeof(ufb);
      break;
      break;
    case 0xfd:
    case 0xfd:
      table = ufd;
      table = ufd;
      size = sizeof(ufd);
      size = sizeof(ufd);
      break;
      break;
    case 0xfe:
    case 0xfe:
      table = ufe;
      table = ufe;
      size = sizeof(ufe);
      size = sizeof(ufe);
      break;
      break;
    case 0xff:
    case 0xff:
      table = uff;
      table = uff;
      size = sizeof(uff);
      size = sizeof(uff);
      break;
      break;
    case 0x103:
    case 0x103:
      table = u103;
      table = u103;
      size = sizeof(u103);
      size = sizeof(u103);
      break;
      break;
    case 0x1d0:
    case 0x1d0:
      table = u1d0;
      table = u1d0;
      size = sizeof(u1d0);
      size = sizeof(u1d0);
      break;
      break;
    case 0x1d1:
    case 0x1d1:
      table = u1d1;
      table = u1d1;
      size = sizeof(u1d1);
      size = sizeof(u1d1);
      break;
      break;
    case 0x1d6:
    case 0x1d6:
      table = u1d6;
      table = u1d6;
      size = sizeof(u1d6);
      size = sizeof(u1d6);
      break;
      break;
    case 0x1d7:
    case 0x1d7:
      table = u1d7;
      table = u1d7;
      size = sizeof(u1d7);
      size = sizeof(u1d7);
      break;
      break;
    case 0xe00:
    case 0xe00:
      table = ue00;
      table = ue00;
      size = sizeof(ue00);
      size = sizeof(ue00);
      break;
      break;
    case 0xfff:
    case 0xfff:
      table = ufff;
      table = ufff;
      size = sizeof(ufff);
      size = sizeof(ufff);
      break;
      break;
    case 0x10ff:
    case 0x10ff:
      table = u10ff;
      table = u10ff;
      size = sizeof(u10ff);
      size = sizeof(u10ff);
      break;
      break;
    default:
    default:
      return 0;
      return 0;
    }
    }
  /* we have narrowed down to a section of 256 characters to check */
  /* we have narrowed down to a section of 256 characters to check */
  /* now check if c matches the punctuation wide-chars within that section */
  /* now check if c matches the punctuation wide-chars within that section */
  ptr = (unsigned char *)table;
  ptr = (unsigned char *)table;
  ctmp = (unsigned char)c;
  ctmp = (unsigned char)c;
  while (ptr < table + size)
  while (ptr < table + size)
    {
    {
      if (ctmp == *ptr)
      if (ctmp == *ptr)
        return 1;
        return 1;
      if (ctmp < *ptr)
      if (ctmp < *ptr)
        return 0;
        return 0;
      /* otherwise c > *ptr */
      /* otherwise c > *ptr */
      /* look for 0x0 as next element which indicates a range */
      /* look for 0x0 as next element which indicates a range */
      ++ptr;
      ++ptr;
      if (*ptr == 0x0)
      if (*ptr == 0x0)
        {
        {
          /* we have a range..see if c falls within range */
          /* we have a range..see if c falls within range */
          ++ptr;
          ++ptr;
          if (ctmp <= *ptr)
          if (ctmp <= *ptr)
            return 1;
            return 1;
          ++ptr;
          ++ptr;
        }
        }
    }
    }
  /* not in table */
  /* not in table */
  return 0;
  return 0;
#else
#else
  return (c < (wint_t)0x100 ? ispunct (c) : 0);
  return (c < (wint_t)0x100 ? ispunct (c) : 0);
#endif /* _MB_CAPABLE */
#endif /* _MB_CAPABLE */
}
}
 
 
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.