1 | /* |
1 | /* |
2 | unicode.c - Part of psiconv, a PSION 5 file formats converter |
2 | unicode.c - Part of psiconv, a PSION 5 file formats converter |
3 | Copyright (c) 2003-2004 Frodo Looijaard <frodol@dds.nl> |
3 | Copyright (c) 2003-2014 Frodo Looijaard <frodo@frodo.looijaard.name> |
4 | |
4 | |
5 | This program is free software; you can redistribute it and/or modify |
5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by |
6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or |
7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. |
8 | (at your option) any later version. |
… | |
… | |
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 | |
143 | int psiconv_unicode_write_char(const psiconv_config config, |
144 | int 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) { |
… | |
… | |
262 | for (i = 0; i < haystack_len - needle_len + 1; i++) { |
262 | for (i = 0; i < haystack_len - needle_len + 1; i++) { |
263 | for (j = 0; j < needle_len; j++) |
263 | for (j = 0; j < needle_len; j++) |
264 | if (haystack[i+j] != needle[j]) |
264 | if (haystack[i+j] != needle[j]) |
265 | break; |
265 | break; |
266 | if (j == needle_len) |
266 | if (j == needle_len) |
267 | return haystack+i; |
267 | return (psiconv_ucs2 *) haystack+i; |
268 | } |
268 | } |
269 | return NULL; |
269 | return NULL; |
270 | } |
270 | } |