2 * ========================================================================
3 * Copyright 2006-2007 University of Washington
4 * Copyright 2013-2021 Eduardo Chappa
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * ========================================================================
21 * Stub functions to fill in functions used in utf8 support routines
28 void *block
= malloc (size
? size
: (size_t) 1);
29 if (!block
) fatal ("Out of memory");
35 fs_resize(void **block
, size_t size
)
37 if (!(*block
= realloc (*block
,size
? size
: (size_t) 1)))
38 fatal ("Can't resize memory");
42 fs_give (void **block
)
56 compare_ulong(unsigned long l1
, unsigned long l2
)
58 if (l1
< l2
) return -1;
59 if (l1
> l2
) return 1;
65 compare_cstring(unsigned char *s1
, unsigned char *s2
)
68 if (!s1
) return s2
? -1 : 0; /* empty string cases */
69 else if (!s2
) return 1;
70 for (; *s1
&& *s2
; s1
++,s2
++)
71 if ((i
= (compare_ulong (islower (*s1
) ? toupper (*s1
) : *s1
,
72 islower (*s2
) ? toupper (*s2
) : *s2
))) != 0)
73 return i
; /* found a difference */
74 if (*s1
) return 1; /* first string is longer */
75 return *s2
? -1 : 0; /* second string longer : strings identical */