Merge branch 'ical'
[alpine.git] / pico / utf8stub.c
blob5c25ce8535d77cf5f045dbec17773632a837a0aa
1 #if !defined(lint) && !defined(DOS)
2 static char rcsid[] = "$Id: utf8stub.c 769 2007-10-24 00:15:40Z hubert@u.washington.edu $";
3 #endif
5 /*
6 * ========================================================================
7 * Copyright 2006-2007 University of Washington
8 * Copyright 2013-2017 Eduardo Chappa
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * ========================================================================
20 #include <system.h>
21 #include "utf8stub.h"
25 * Stub functions to fill in functions used in utf8 support routines
29 void *
30 fs_get (size_t size)
32 void *block = malloc (size ? size : (size_t) 1);
33 if (!block) fatal ("Out of memory");
34 return (block);
38 void
39 fs_resize(void **block, size_t size)
41 if (!(*block = realloc (*block,size ? size : (size_t) 1)))
42 fatal ("Can't resize memory");
45 void
46 fs_give (void **block)
48 free (*block);
49 *block = NULL;
52 void
53 fatal(char *s)
59 int
60 compare_ulong(unsigned long l1, unsigned long l2)
62 if (l1 < l2) return -1;
63 if (l1 > l2) return 1;
64 return 0;
68 int
69 compare_cstring(unsigned char *s1, unsigned char *s2)
71 int i;
72 if (!s1) return s2 ? -1 : 0; /* empty string cases */
73 else if (!s2) return 1;
74 for (; *s1 && *s2; s1++,s2++)
75 if ((i = (compare_ulong (islower (*s1) ? toupper (*s1) : *s1,
76 islower (*s2) ? toupper (*s2) : *s2))) != 0)
77 return i; /* found a difference */
78 if (*s1) return 1; /* first string is longer */
79 return *s2 ? -1 : 0; /* second string longer : strings identical */
82 int
83 panicking(void)
85 return(0);