/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1985-2010 AT&T Intellectual Property *
* and is licensed under the *
* Common Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* Glenn Fowler <gsf@research.att.com> *
* David Korn <dgk@research.att.com> *
* Phong Vo <kpv@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* regex collation symbol support
*/
#include "reglib.h"
#include <ccode.h>
#ifndef UCS_BYTE
#endif
#include "ucs_names.h"
typedef struct Ucs_map_s
{
const char* name;
} Ucs_map_t;
static struct Local_s
{
int fatal;
unsigned char* a2n;
#endif
} local;
/*
* initialize the writeable tables from the readonly data
* the tables are big enough to be concerned about text vs. data vs. bss
* UCS_BYTE==0 100K
* UCS_BYTE==1 20K
*/
static int
initialize(void)
{
register int i;
register Ucs_map_t* a;
register Ucs_map_t* w;
return -1;
{
return -1;
}
{
free(w);
return -1;
}
{
free(w);
return -1;
}
for (i = 0; i < elementsof(ucs_attrs); i++, w++)
{
w->next = 0;
}
for (i = 0; i < elementsof(ucs_names); i++, w++)
{
w->next = 0;
{
while (a->next)
a = a->next;
a->next = w;
}
else
}
#endif
return 0;
}
/*
* return the collating symbol delimited by [c c], where c is either '=' or '.'
* s points to the first char after the initial [
* if e!=0 it is set to point to the next char in s on return
*
* the collating symbol is converted to multibyte in <buf,size>
* the return value is:
* -1 syntax error or buf not large enough
* >=0 size with 0-terminated mb collation element
* or ligature value in buf
*/
int
{
register int c;
register char* u;
register char* b;
register char* x;
register Ucs_map_t* a;
Ucs_map_t* z;
const char* t;
const char* v;
int n;
int r;
int ul;
int term;
wchar_t w[2];
if (size < 2)
r = -1;
{
s--;
r = -1;
}
r = -1;
else
{
t = s;
mbchar(s);
if ((n = (s - t)) == 1)
{
{
s += 2;
r = -1;
}
else
{
return -1;
ul = 0;
b = buf;
r = 1;
s = t;
do
{
v = s;
u = b;
for (;;)
{
if (!(c = *s++))
return -1;
if (c == term)
{
if (!(c = *s++))
return -1;
if (c != term)
{
if (c != ']')
return -1;
r = -1;
break;
}
}
if (c == ' ' || c == '-' && u > b && *s != ' ' && *s != '-')
break;
if (isupper(c))
c = tolower(c);
if (u > x)
break;
*u++ = c;
}
*u = 0;
else
{
if (u < x)
*u++ = ' ';
if (b == buf)
{
if (isupper(*v))
else if (islower(*v))
}
b = u;
}
} while (r > 0);
b--;
*b = 0;
if (ul)
{
ul = 0;
else
}
for(;;)
{
for (a = z; a; a = a->next)
if ((attr[0] & a->attr[0]) == attr[0] && (attr[1] & a->attr[1]) == attr[1] && (attr[2] & a->attr[2]) == attr[2])
{
#if 0
if (a->code <= 0xff)
{
#else
#endif
buf[r = 1] = 0;
ul = 0;
break;
}
#endif
w[0] = a->code;
w[1] = 0;
ul = 0;
break;
}
if (!ul)
break;
ul = 0;
}
}
if (r < 0)
{
return -1;
buf[n] = 0;
if (n == 1)
r = n;
else
{
if (!*t)
r = n;
}
}
}
else if (*s++ != term || *s++ != ']')
{
s--;
r = -1;
}
else if (n > (size - 1))
r = -1;
else
{
buf[r = n] = 0;
}
}
if (e)
*e = (char*)s;
return r;
}