From 674b28f150e718e6a378f948709873f0cbb1c432 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Wed, 19 Dec 2018 14:52:56 -0600 Subject: [PATCH] util: Use L_ARRAY_SIZE instead of TABLE_SIZE --- src/util.c | 86 ++++++++++++++++++++++++++---------------------------- 1 file changed, 42 insertions(+), 44 deletions(-) diff --git a/src/util.c b/src/util.c index 31bc5c9c..ffdd1ae8 100644 --- a/src/util.c +++ b/src/util.c @@ -30,6 +30,7 @@ #include #include +#include #include "util.h" @@ -65,9 +66,6 @@ #define UTF8_LENGTH(c) \ ((c) < 0x80 ? 1 : ((c) < 0x800 ? 2 : 3)) -#define TABLE_SIZE(t) \ - (sizeof((t)) / sizeof(struct codepoint)) - struct codepoint { unsigned short from; unsigned short to; @@ -2698,79 +2696,79 @@ static gboolean populate_locking_shift(struct conversion_table *t, case GSM_DIALECT_SPANISH: t->locking_g = def_gsm; t->locking_u = def_unicode; - t->locking_len_u = TABLE_SIZE(def_unicode); + t->locking_len_u = L_ARRAY_SIZE(def_unicode); return TRUE; case GSM_DIALECT_TURKISH: t->locking_g = tur_gsm; t->locking_u = tur_unicode; - t->locking_len_u = TABLE_SIZE(tur_unicode); + t->locking_len_u = L_ARRAY_SIZE(tur_unicode); return TRUE; case GSM_DIALECT_PORTUGUESE: t->locking_g = por_gsm; t->locking_u = por_unicode; - t->locking_len_u = TABLE_SIZE(por_unicode); + t->locking_len_u = L_ARRAY_SIZE(por_unicode); return TRUE; case GSM_DIALECT_BENGALI: t->locking_g = ben_gsm; t->locking_u = ben_unicode; - t->locking_len_u = TABLE_SIZE(ben_unicode); + t->locking_len_u = L_ARRAY_SIZE(ben_unicode); return TRUE; case GSM_DIALECT_GUJARATI: t->locking_g = guj_gsm; t->locking_u = guj_unicode; - t->locking_len_u = TABLE_SIZE(guj_unicode); + t->locking_len_u = L_ARRAY_SIZE(guj_unicode); return TRUE; case GSM_DIALECT_HINDI: t->locking_g = hin_gsm; t->locking_u = hin_unicode; - t->locking_len_u = TABLE_SIZE(hin_unicode); + t->locking_len_u = L_ARRAY_SIZE(hin_unicode); return TRUE; case GSM_DIALECT_KANNADA: t->locking_g = kan_gsm; t->locking_u = kan_unicode; - t->locking_len_u = TABLE_SIZE(kan_unicode); + t->locking_len_u = L_ARRAY_SIZE(kan_unicode); return TRUE; case GSM_DIALECT_MALAYALAM: t->locking_g = mal_gsm; t->locking_u = mal_unicode; - t->locking_len_u = TABLE_SIZE(mal_unicode); + t->locking_len_u = L_ARRAY_SIZE(mal_unicode); return TRUE; case GSM_DIALECT_ORIYA: t->locking_g = ori_gsm; t->locking_u = ori_unicode; - t->locking_len_u = TABLE_SIZE(ori_unicode); + t->locking_len_u = L_ARRAY_SIZE(ori_unicode); return TRUE; case GSM_DIALECT_PUNJABI: t->locking_g = pun_gsm; t->locking_u = pun_unicode; - t->locking_len_u = TABLE_SIZE(pun_unicode); + t->locking_len_u = L_ARRAY_SIZE(pun_unicode); return TRUE; case GSM_DIALECT_TAMIL: t->locking_g = tam_gsm; t->locking_u = tam_unicode; - t->locking_len_u = TABLE_SIZE(tam_unicode); + t->locking_len_u = L_ARRAY_SIZE(tam_unicode); return TRUE; case GSM_DIALECT_TELUGU: t->locking_g = tel_gsm; t->locking_u = tel_unicode; - t->locking_len_u = TABLE_SIZE(tel_unicode); + t->locking_len_u = L_ARRAY_SIZE(tel_unicode); return TRUE; case GSM_DIALECT_URDU: t->locking_g = urd_gsm; t->locking_u = urd_unicode; - t->locking_len_u = TABLE_SIZE(urd_unicode); + t->locking_len_u = L_ARRAY_SIZE(urd_unicode); return TRUE; } @@ -2783,100 +2781,100 @@ static gboolean populate_single_shift(struct conversion_table *t, switch (lang) { case GSM_DIALECT_DEFAULT: t->single_g = def_ext_gsm; - t->single_len_g = TABLE_SIZE(def_ext_gsm); + t->single_len_g = L_ARRAY_SIZE(def_ext_gsm); t->single_u = def_ext_unicode; - t->single_len_u = TABLE_SIZE(def_ext_unicode); + t->single_len_u = L_ARRAY_SIZE(def_ext_unicode); return TRUE; case GSM_DIALECT_TURKISH: t->single_g = tur_ext_gsm; - t->single_len_g = TABLE_SIZE(tur_ext_gsm); + t->single_len_g = L_ARRAY_SIZE(tur_ext_gsm); t->single_u = tur_ext_unicode; - t->single_len_u = TABLE_SIZE(tur_ext_unicode); + t->single_len_u = L_ARRAY_SIZE(tur_ext_unicode); return TRUE; case GSM_DIALECT_SPANISH: t->single_g = spa_ext_gsm; - t->single_len_g = TABLE_SIZE(spa_ext_gsm); + t->single_len_g = L_ARRAY_SIZE(spa_ext_gsm); t->single_u = spa_ext_unicode; - t->single_len_u = TABLE_SIZE(spa_ext_unicode); + t->single_len_u = L_ARRAY_SIZE(spa_ext_unicode); return TRUE; case GSM_DIALECT_PORTUGUESE: t->single_g = por_ext_gsm; - t->single_len_g = TABLE_SIZE(por_ext_gsm); + t->single_len_g = L_ARRAY_SIZE(por_ext_gsm); t->single_u = por_ext_unicode; - t->single_len_u = TABLE_SIZE(por_ext_unicode); + t->single_len_u = L_ARRAY_SIZE(por_ext_unicode); return TRUE; case GSM_DIALECT_BENGALI: t->single_g = ben_ext_gsm; - t->single_len_g = TABLE_SIZE(ben_ext_gsm); + t->single_len_g = L_ARRAY_SIZE(ben_ext_gsm); t->single_u = ben_ext_unicode; - t->single_len_u = TABLE_SIZE(ben_ext_unicode); + t->single_len_u = L_ARRAY_SIZE(ben_ext_unicode); return TRUE; case GSM_DIALECT_GUJARATI: t->single_g = guj_ext_gsm; - t->single_len_g = TABLE_SIZE(guj_ext_gsm); + t->single_len_g = L_ARRAY_SIZE(guj_ext_gsm); t->single_u = guj_ext_unicode; - t->single_len_u = TABLE_SIZE(guj_ext_unicode); + t->single_len_u = L_ARRAY_SIZE(guj_ext_unicode); return TRUE; case GSM_DIALECT_HINDI: t->single_g = hin_ext_gsm; - t->single_len_g = TABLE_SIZE(hin_ext_gsm); + t->single_len_g = L_ARRAY_SIZE(hin_ext_gsm); t->single_u = hin_ext_unicode; - t->single_len_u = TABLE_SIZE(hin_ext_unicode); + t->single_len_u = L_ARRAY_SIZE(hin_ext_unicode); return TRUE; case GSM_DIALECT_KANNADA: t->single_g = kan_ext_gsm; - t->single_len_g = TABLE_SIZE(kan_ext_gsm); + t->single_len_g = L_ARRAY_SIZE(kan_ext_gsm); t->single_u = kan_ext_unicode; - t->single_len_u = TABLE_SIZE(kan_ext_unicode); + t->single_len_u = L_ARRAY_SIZE(kan_ext_unicode); return TRUE; case GSM_DIALECT_MALAYALAM: t->single_g = mal_ext_gsm; - t->single_len_g = TABLE_SIZE(mal_ext_gsm); + t->single_len_g = L_ARRAY_SIZE(mal_ext_gsm); t->single_u = mal_ext_unicode; - t->single_len_u = TABLE_SIZE(mal_ext_unicode); + t->single_len_u = L_ARRAY_SIZE(mal_ext_unicode); return TRUE; case GSM_DIALECT_ORIYA: t->single_g = ori_ext_gsm; - t->single_len_g = TABLE_SIZE(ori_ext_gsm); + t->single_len_g = L_ARRAY_SIZE(ori_ext_gsm); t->single_u = ori_ext_unicode; - t->single_len_u = TABLE_SIZE(ori_ext_unicode); + t->single_len_u = L_ARRAY_SIZE(ori_ext_unicode); return TRUE; case GSM_DIALECT_PUNJABI: t->single_g = pun_ext_gsm; - t->single_len_g = TABLE_SIZE(pun_ext_gsm); + t->single_len_g = L_ARRAY_SIZE(pun_ext_gsm); t->single_u = pun_ext_unicode; - t->single_len_u = TABLE_SIZE(pun_ext_unicode); + t->single_len_u = L_ARRAY_SIZE(pun_ext_unicode); return TRUE; case GSM_DIALECT_TAMIL: t->single_g = tam_ext_gsm; - t->single_len_g = TABLE_SIZE(tam_ext_gsm); + t->single_len_g = L_ARRAY_SIZE(tam_ext_gsm); t->single_u = tam_ext_unicode; - t->single_len_u = TABLE_SIZE(tam_ext_unicode); + t->single_len_u = L_ARRAY_SIZE(tam_ext_unicode); return TRUE; case GSM_DIALECT_TELUGU: t->single_g = tel_ext_gsm; - t->single_len_g = TABLE_SIZE(tel_ext_gsm); + t->single_len_g = L_ARRAY_SIZE(tel_ext_gsm); t->single_u = tel_ext_unicode; - t->single_len_u = TABLE_SIZE(tel_ext_unicode); + t->single_len_u = L_ARRAY_SIZE(tel_ext_unicode); return TRUE; case GSM_DIALECT_URDU: t->single_g = urd_ext_gsm; - t->single_len_g = TABLE_SIZE(urd_ext_gsm); + t->single_len_g = L_ARRAY_SIZE(urd_ext_gsm); t->single_u = urd_ext_unicode; - t->single_len_u = TABLE_SIZE(urd_ext_unicode); + t->single_len_u = L_ARRAY_SIZE(urd_ext_unicode); return TRUE; }