hbase

heirloom base
git clone git://git.2f30.org/hbase
Log | Files | Refs | README

_collmult.c (1634B)


      1 /*
      2  * Changes by Gunnar Ritter, Freiburg i. Br., Germany, November 2002.
      3  *
      4  * Sccsid @(#)_collmult.c	1.4 (gritter) 9/22/03
      5  */
      6 /*  UNIX(R) Regular Expresssion Library
      7  *
      8  *  Note: Code is released under the GNU LGPL
      9  *
     10  *  Copyright (C) 2001 Caldera International, Inc.
     11  *
     12  *  This library is free software; you can redistribute it and/or
     13  *  modify it under the terms of the GNU Lesser General Public
     14  *  License as published by the Free Software Foundation; either
     15  *  version 2 of the License, or (at your option) any later version.
     16  *
     17  *  This library is distributed in the hope that it will be useful,
     18  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
     19  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     20  *  Lesser General Public License for more details.
     21  *
     22  *  You should have received a copy of the GNU Lesser General Public
     23  *  License along with this library; if not, write to:
     24  *        Free Software Foundation, Inc.
     25  *        59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     26  */
     27 
     28 /*	#include "synonyms.h"	*/
     29 #include "colldata.h"
     30 #include <stddef.h>
     31 
     32 #define CCM(p)	((const CollMult *)(p))
     33 
     34 LIBUXRE_STATIC const CollElem *
     35 libuxre_collmult(struct lc_collate *col, const CollElem *cep, wchar_t wc)
     36 {
     37 	const char *tbl;
     38 	size_t sz;
     39 	w_type ch;
     40 
     41 	if (col == 0 || cep->multbeg == 0
     42 		|| (tbl = (const char *)col->multtbl) == 0)
     43 	{
     44 		return ELEM_BADCHAR;
     45 	}
     46 	sz = col->elemsize + (sizeof(CollMult) - sizeof(CollElem));
     47 	tbl += sz * cep->multbeg;
     48 	while ((ch = CCM(tbl)->ch) != wc)
     49 	{
     50 		if (ch == 0)
     51 			return ELEM_BADCHAR;	/* end of list */
     52 		tbl += sz;
     53 	}
     54 	return &CCM(tbl)->elem;
     55 }