]>
git.wh0rd.org - fontconfig.git/blob - src/fcstr.c
4 * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
6 * Permission to use, copy, modify, distribute, and sell this software and its
7 * documentation for any purpose is hereby granted without fee, provided that
8 * the above copyright notice appear in all copies and that both that
9 * copyright notice and this permission notice appear in supporting
10 * documentation, and that the name of Keith Packard not be used in
11 * advertising or publicity pertaining to distribution of the software without
12 * specific, written prior permission. Keith Packard makes no
13 * representations about the suitability of this software for any purpose. It
14 * is provided "as is" without express or implied warranty.
16 * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
17 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
18 * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
19 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
20 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
21 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
22 * PERFORMANCE OF THIS SOFTWARE.
31 FcStrCopy (const FcChar8
*s
)
37 r
= (FcChar8
*) malloc (strlen ((char *) s
) + 1);
40 FcMemAlloc (FC_MEM_STRING
, strlen ((char *) s
) + 1);
41 strcpy ((char *) r
, (char *) s
);
46 FcStrPlus (const FcChar8
*s1
, const FcChar8
*s2
)
48 int l
= strlen ((char *)s1
) + strlen ((char *) s2
) + 1;
49 FcChar8
*s
= malloc (l
);
53 FcMemAlloc (FC_MEM_STRING
, l
);
54 strcpy ((char *) s
, (char *) s1
);
55 strcat ((char *) s
, (char *) s2
);
60 FcStrFree (FcChar8
*s
)
62 FcMemFree (FC_MEM_STRING
, strlen ((char *) s
) + 1);
67 FcStrCmpIgnoreCase (const FcChar8
*s1
, const FcChar8
*s2
)
82 return (int) c2
- (int) c1
;
86 FcUtf8ToUcs4 (FcChar8
*src_orig
,
90 FcChar8
*src
= src_orig
;
106 else if (!(s
& 0x40))
110 else if (!(s
& 0x20))
115 else if (!(s
& 0x10))
120 else if (!(s
& 0x08))
125 else if (!(s
& 0x04))
130 else if ( ! (s
& 0x02))
147 if ((s
& 0xc0) != 0x80)
153 return src
- src_orig
;
157 FcUtf8Len (FcChar8
*string
,
171 clen
= FcUtf8ToUcs4 (string
, &c
, len
);
172 if (clen
<= 0) /* malformed UTF8 string */
183 else if (max
> 0x100)