change type of UTF8 char code (unsigned long > unsigned int)

This commit is contained in:
Vlasta Vesely 2018-04-29 08:21:46 +02:00
parent 9571ee9871
commit b187c13cbc
6 changed files with 14 additions and 14 deletions

View file

@ -33,7 +33,7 @@ struct syllable *syllable_append(struct syllable *tail, const char *data)
return ptr; return ptr;
} }
unsigned long syllable_chain_length(struct syllable *head) unsigned int syllable_chain_length(struct syllable *head)
{ {
struct syllable *walk = head; struct syllable *walk = head;
unsigned int length = 0; unsigned int length = 0;

View file

@ -13,7 +13,7 @@ void syllable_drop(struct syllable *syllable);
struct syllable *syllable_append(struct syllable *tail, const char *data); struct syllable *syllable_append(struct syllable *tail, const char *data);
unsigned long syllable_chain_length(struct syllable *head); unsigned int syllable_chain_length(struct syllable *head);
char *syllable_chain_to_string(struct syllable *head); char *syllable_chain_to_string(struct syllable *head);
#endif /* __SYLLABE_H */ #endif /* __SYLLABE_H */

View file

@ -7,7 +7,7 @@
#include "syllable.h" #include "syllable.h"
#include "utf8.h" #include "utf8.h"
static const struct transliteration_letter *find_letter_by_code(unsigned long c, static const struct transliteration_letter *find_letter_by_code(unsigned int c,
const struct transliteration_letter *table) const struct transliteration_letter *table)
{ {
const struct transliteration_letter *walk = table; const struct transliteration_letter *walk = table;
@ -43,7 +43,7 @@ char *transliterate_devanagari_to_latin(const char *text,
const char *ptr = text; const char *ptr = text;
const char *end = ptr + length; const char *end = ptr + length;
char *tmp; char *tmp;
unsigned long c; unsigned int c;
struct syllable *head, *tail; struct syllable *head, *tail;
const struct transliteration_letter *letter; const struct transliteration_letter *letter;

View file

@ -10,7 +10,7 @@
#define FLAG_MODIFIER 1 << 1 #define FLAG_MODIFIER 1 << 1
struct transliteration_letter { struct transliteration_letter {
unsigned long code; unsigned int code;
unsigned int flags; unsigned int flags;
const char *data; const char *data;
}; };

10
utf8.c
View file

@ -3,9 +3,9 @@
#include <stdlib.h> #include <stdlib.h>
#include "utf8.h" #include "utf8.h"
unsigned long utf8_unpack_char(const char *src) unsigned int utf8_unpack_char(const char *src)
{ {
unsigned long c = 0; unsigned int c = 0;
if ((src[0] & 0x80) == 0x00) { if ((src[0] & 0x80) == 0x00) {
c = ((src[0] & 0x7f) << 0); c = ((src[0] & 0x7f) << 0);
@ -26,7 +26,7 @@ unsigned long utf8_unpack_char(const char *src)
return c; return c;
} }
void utf8_pack_char(char *dest, unsigned long c) void utf8_pack_char(char *dest, unsigned int c)
{ {
if (c <= 0x00007f) { if (c <= 0x00007f) {
dest[0] = c; dest[0] = c;
@ -47,7 +47,7 @@ void utf8_pack_char(char *dest, unsigned long c)
} }
} }
unsigned int utf8_char_length(unsigned long c) unsigned int utf8_char_length(unsigned int c)
{ {
if (c <= 0x00007f) { if (c <= 0x00007f) {
return 1; return 1;
@ -62,7 +62,7 @@ unsigned int utf8_char_length(unsigned long c)
return 0; // should not happen return 0; // should not happen
} }
char *utf8_code_to_string(unsigned long c) char *utf8_code_to_string(unsigned int c)
{ {
unsigned int length = utf8_char_length(c) + 1; unsigned int length = utf8_char_length(c) + 1;
char *buffer; char *buffer;

8
utf8.h
View file

@ -3,10 +3,10 @@
#ifndef __UTF8_H #ifndef __UTF8_H
#define __UTF8_H #define __UTF8_H
unsigned long utf8_unpack_char(const char *src); unsigned int utf8_unpack_char(const char *src);
void utf8_pack_char(char *dest, unsigned long c); void utf8_pack_char(char *dest, unsigned int c);
unsigned int utf8_char_length(unsigned long c); unsigned int utf8_char_length(unsigned int c);
char *utf8_code_to_string(unsigned long c); char *utf8_code_to_string(unsigned int c);
#endif /* __UTF8_H */ #endif /* __UTF8_H */