/[public]/psiconv/tags/rel-0-9-9/lib/psiconv/unicode.c
ViewVC logotype

Diff of /psiconv/tags/rel-0-9-9/lib/psiconv/unicode.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 217 Revision 268
24#include "unicode.h" 24#include "unicode.h"
25#include "parse_routines.h" 25#include "parse_routines.h"
26#include "generate_routines.h" 26#include "generate_routines.h"
27 27
28#include <string.h> 28#include <string.h>
29#include <stdlib.h>
29 30
30#ifdef DMALLOC 31#ifdef DMALLOC
31#include <dmalloc.h> 32#include <dmalloc.h>
32#endif 33#endif
33 34
142 143
143int psiconv_unicode_write_char(const psiconv_config config, 144int psiconv_unicode_write_char(const psiconv_config config,
144 psiconv_buffer buf, 145 psiconv_buffer buf,
145 int lev, psiconv_ucs2 value) 146 int lev, psiconv_ucs2 value)
146{ 147{
147 psiconv_u8 byte;
148 int i; 148 int i;
149 int res=0; 149 int res=0;
150 150
151 if (config->unicode) { 151 if (config->unicode) {
152 if (value < 0x80) { 152 if (value < 0x80) {
224 if (result) 224 if (result)
225 result[0] = 0; 225 result[0] = 0;
226 return result; 226 return result;
227} 227}
228 228
229
230psiconv_ucs2 *psiconv_unicode_from_list(psiconv_list input)
231{
232 psiconv_ucs2 *result;
233 int i;
234 psiconv_ucs2 *character;
235
236 if (!(result = malloc(sizeof(psiconv_ucs2) * (psiconv_list_length(input)+1))))
237 goto ERROR1;
238 for (i = 0; i < psiconv_list_length(input); i++) {
239 if (!(character = psiconv_list_get(input,i)))
240 goto ERROR2;
241 result[i] = *character;
242 }
243 result[i] = 0;
244 return result;
245
246ERROR2:
247 free(result);
248ERROR1:
249 return NULL;
250}
251
252
253psiconv_ucs2 *psiconv_unicode_strstr(const psiconv_ucs2 *haystack,
254 const psiconv_ucs2 *needle)
255{
256 int i,j,haystack_len,needle_len;
257 haystack_len = psiconv_unicode_strlen(haystack);
258 needle_len = psiconv_unicode_strlen(needle);
259
260
261
262 for (i = 0; i < haystack_len - needle_len + 1; i++) {
263 for (j = 0; j < needle_len; j++)
264 if (haystack[i+j] != needle[j])
265 break;
266 if (j == needle_len)
267 return (psiconv_ucs2 *) haystack+i;
268 }
269 return NULL;
270}

Legend:
Removed from v.217  
changed lines
  Added in v.268

frodo@frodo.looijaard.name
ViewVC Help
Powered by ViewVC 1.1.26