Permalink
Browse files

Misc warning fixes

  • Loading branch information...
behdad committed Nov 23, 2017
1 parent f394882 commit 84ea058eb1f8211613006993e64bcc06c3e6dae7
Showing with 53 additions and 50 deletions.
  1. +12 −10 fribidi-vs-unicode/test-character.c
  2. +3 −3 fribidi-vs-unicode/test.c
  3. +37 −35 lib/fribidi-bidi.c
  4. +1 −2 lib/fribidi-brackets.c
@@ -29,17 +29,19 @@
static void die(const char *fmt, ...)
{
va_list ap;
va_start(ap,fmt);
va_start(ap,fmt);
vfprintf(stderr, fmt, ap);
exit(-1);
}
static
FriBidiChar parse_uni_char(const char *start, int len)
{
return strtoul(start, NULL, 16);
}
static
void parse_test_line (char *line,
int line_no,
FriBidiChar **code_points, /* Field 0 */
@@ -55,7 +57,7 @@ void parse_test_line (char *line,
char *end;
int level;
code_points_array = g_array_new (FALSE, FALSE, sizeof (FriBidiChar));
levels_array = g_array_new (FALSE, FALSE, sizeof (FriBidiLevel));
@@ -76,7 +78,7 @@ void parse_test_line (char *line,
line = end;
}
*code_points_len = code_points_array->len;
*code_points = (FriBidiChar *) g_array_free (code_points_array, FALSE);
@@ -96,7 +98,7 @@ void parse_test_line (char *line,
line++;
else
die("Oops! Didn't find expected ;\n");
/* Field 2. resolved paragraph_dir */
end = line;
while (isdigit (*end))
@@ -155,7 +157,7 @@ void parse_test_line (char *line,
for(; errno = 0, level = strtol (line, &end, 10), line != end && errno != EINVAL; line = end) {
g_array_append_val (visual_ordering_array, level);
}
*visual_ordering_len = visual_ordering_array->len;
*visual_ordering = (int*)g_array_free (visual_ordering_array, FALSE);
}
@@ -203,7 +205,7 @@ main (int argc, char **argv)
}
die("Unknown option %s!\n", arg);
}
filename = argv[next_arg++];
error = NULL;
@@ -303,7 +305,7 @@ main (int argc, char **argv)
types_len,
&base_dir,
levels))
;
{}
for (i = 0; i < types_len; i++)
ltor[i] = i;
@@ -314,7 +316,7 @@ main (int argc, char **argv)
levels,
NULL,
ltor))
;
{}
j = 0;
for (i = 0; i < types_len; i++)
@@ -389,7 +391,7 @@ main (int argc, char **argv)
types_len,
&base_dir,
levels))
;
{}
fribidi_set_debug (0);
}
@@ -279,7 +279,7 @@ main (int argc, char **argv)
types_len,
&base_dir,
levels))
;
{}
for (i = 0; i < types_len; i++)
ltor[i] = i;
@@ -290,7 +290,7 @@ main (int argc, char **argv)
levels,
NULL,
ltor))
;
{}
j = 0;
for (i = 0; i < types_len; i++)
@@ -366,7 +366,7 @@ main (int argc, char **argv)
types_len,
&base_dir,
levels))
;
{}
fribidi_set_debug (0);
}
View
@@ -8,22 +8,22 @@
* Copyright (C) 2004 Sharif FarsiWeb, Inc
* Copyright (C) 2001,2002 Behdad Esfahbod
* Copyright (C) 1999,2000,2017 Dov Grobgeld
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public License
* along with this library, in a file named COPYING; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA
*
*
* For licensing issues, contact <fribidi.license@gmail.com>.
*/
@@ -48,7 +48,6 @@
/* Some convenience macros */
#define RL_TYPE(list) ((list)->type)
#define RL_LEN(list) ((list)->len)
#define RL_POS(list) ((list)->pos)
#define RL_LEVEL(list) ((list)->level)
/* "Within this scope, bidirectional types EN and AN are treated as R" */
@@ -138,7 +137,7 @@ static FriBidiRun *get_adjacent_run(FriBidiRun *list, fribidi_boolean forward, f
while (ppp)
{
FriBidiCharType ppp_type = RL_TYPE (ppp);
if (ppp_type == _FRIBIDI_TYPE_SENTINEL)
break;
@@ -471,11 +470,12 @@ pairing_nodes_sorted_merge(FriBidiPairingNode *nodes1,
static void sort_pairing_nodes(FriBidiPairingNode **nodes)
{
FriBidiPairingNode *front, *back;
/* 0 or 1 node case */
if (!*nodes || !(*nodes)->next)
return;
FriBidiPairingNode *front, *back;
pairing_nodes_front_back_split(*nodes, &front, &back);
sort_pairing_nodes(&front);
sort_pairing_nodes(&back);
@@ -508,6 +508,7 @@ fribidi_get_par_embedding_levels_ex (
FriBidiParType base_dir;
FriBidiRun *main_run_list = NULL, *explicits_list = NULL, *pp;
fribidi_boolean status = false;
int max_iso_level = 0;
if UNLIKELY
(!len)
@@ -684,7 +685,7 @@ fribidi_get_par_embedding_levels_ex (
isolate_overflow--;
RL_LEVEL (pp) = level;
}
else if (valid_isolate_count > 0)
{
/* Pop away all LRE,RLE,LRO, RLO levels
@@ -747,7 +748,7 @@ fribidi_get_par_embedding_levels_ex (
else
new_level = level + 2 - (level%2);
}
RL_LEVEL (pp) = level;
RL_ISOLATE_LEVEL (pp) = isolate_level++;
base_level_per_iso_level[isolate_level] = new_level;
@@ -830,7 +831,7 @@ fribidi_get_par_embedding_levels_ex (
# endif /* DEBUG */
/* 4. Resolving weak types. Also calculate the maximum isolate level */
int max_iso_level = 0;
max_iso_level = 0;
DBG ("resolving weak types");
{
int *last_strong_stack;
@@ -889,7 +890,7 @@ fribidi_get_par_embedding_levels_ex (
pp = merge_with_prev (pp);
}
else
RL_TYPE (pp) = prev_type;
RL_TYPE (pp) = prev_type;
if (prev_type == next_type && RL_LEVEL (pp) == RL_LEVEL (pp->next))
{
@@ -950,7 +951,7 @@ fribidi_get_par_embedding_levels_ex (
last_strong_stack[iso_level] = prev_type;
/* W2 ??? */
/* W3: Change ALs to R. */
if (this_type == FRIBIDI_TYPE_AL)
{
@@ -1024,38 +1025,37 @@ fribidi_get_par_embedding_levels_ex (
FriBidiPairingNode *pairing_nodes = NULL;
FriBidiRun ***bracket_stack = fribidi_malloc(sizeof(bracket_stack[0])
* num_iso_levels);
memset(bracket_stack, 0, sizeof(bracket_stack[0])*num_iso_levels);
int *bracket_stack_size = fribidi_malloc(sizeof(bracket_stack_size[0])
* num_iso_levels);
int last_level = RL_LEVEL(main_run_list);
int last_iso_level = 0;
memset(bracket_stack, 0, sizeof(bracket_stack[0])*num_iso_levels);
memset(bracket_stack_size, 0, sizeof(bracket_stack_size[0])*num_iso_levels);
/* Build the bd16 pair stack. */
int last_level = RL_LEVEL(main_run_list);
int last_iso_level = 0;
for_run_list (pp, main_run_list)
{
int level = RL_LEVEL(pp);
int iso_level = RL_ISOLATE_LEVEL(pp);
FriBidiBracketType brack_prop = RL_BRACKET_TYPE(pp);
/* Interpret the isolating run sequence as such that they
end at a change in the level, unless the iso_level has been
raised. */
if (level != last_level && last_iso_level == iso_level)
bracket_stack_size[last_iso_level] = 0;
if (!bracket_stack[iso_level])
bracket_stack[iso_level] = fribidi_malloc (sizeof (bracket_stack[0])
* FRIBIDI_BIDI_MAX_NESTED_BRACKET_PAIRS);
FriBidiBracketType brack_prop = RL_BRACKET_TYPE(pp);
if (brack_prop!= FRIBIDI_NO_BRACKET)
{
if (FRIBIDI_IS_BRACKET_OPEN(brack_prop))
{
if (bracket_stack_size[iso_level]==FRIBIDI_BIDI_MAX_NESTED_BRACKET_PAIRS)
break;
/* push onto the pair stack */
bracket_stack[iso_level][bracket_stack_size[iso_level]++] = pp;
}
@@ -1068,7 +1068,7 @@ fribidi_get_par_embedding_levels_ex (
if (FRIBIDI_BRACKET_ID(se_brack_prop) == FRIBIDI_BRACKET_ID(brack_prop))
{
bracket_stack_size[iso_level] = stack_idx;
pairing_nodes = pairing_nodes_push(pairing_nodes,
bracket_stack[iso_level][stack_idx],
pp);
@@ -1099,20 +1099,20 @@ fribidi_get_par_embedding_levels_ex (
while (ppairs)
{
int iso_level = ppairs->open->isolate_level;
int embedding_level = base_level_per_iso_level[iso_level];
int embedding_level = base_level_per_iso_level[iso_level];
/* Find matching strong. */
fribidi_boolean found = false;
FriBidiRun *ppn;
for (ppn = ppairs->open; ppn!= ppairs->close; ppn = ppn->next)
{
FriBidiCharType this_type = RL_TYPE_AN_EN_AS_RTL(ppn);
/* Calculate level like in resolve implicit levels below to prevent
embedded levels not to match the base_level */
int this_level = RL_LEVEL (ppn) +
(FRIBIDI_LEVEL_IS_RTL (RL_LEVEL(ppn)) ^ FRIBIDI_DIR_TO_LEVEL (this_type));
/* N0b */
if (FRIBIDI_IS_STRONG (this_type) && this_level == embedding_level)
{
@@ -1121,7 +1121,7 @@ fribidi_get_par_embedding_levels_ex (
break;
}
}
/* N0c */
/* Search for any strong type preceding and within the bracket pair */
if (!found)
@@ -1136,11 +1136,11 @@ fribidi_get_par_embedding_levels_ex (
{
prec_strong_level = RL_LEVEL (ppn) +
(FRIBIDI_LEVEL_IS_RTL (RL_LEVEL(ppn)) ^ FRIBIDI_DIR_TO_LEVEL (this_type));
break;
}
}
for (ppn = ppairs->open; ppn!= ppairs->close; ppn = ppn->next)
{
FriBidiCharType this_type = RL_TYPE_AN_EN_AS_RTL(ppn);
@@ -1157,10 +1157,10 @@ fribidi_get_par_embedding_levels_ex (
}
}
}
ppairs = ppairs->next;
}
free_pairing_nodes(pairing_nodes);
{
int i;
@@ -1169,12 +1169,14 @@ fribidi_get_par_embedding_levels_ex (
}
fribidi_free(bracket_stack);
fribidi_free(bracket_stack_size);
/* Remove the bracket property and re-compact */
const FriBidiBracketType NoBracket = FRIBIDI_NO_BRACKET;
for_run_list (pp, main_run_list)
pp->bracket_type = NoBracket;
compact_list (main_run_list);
{
const FriBidiBracketType NoBracket = FRIBIDI_NO_BRACKET;
for_run_list (pp, main_run_list)
pp->bracket_type = NoBracket;
compact_list (main_run_list);
}
}
# if DEBUG
View
@@ -46,7 +46,7 @@ fribidi_get_bracket (
)
{
FriBidiBracketType bracket_type;
register uint8_t char_type;
register uint8_t char_type = FRIBIDI_GET_BRACKET_TYPE (ch);
/* The bracket type from the table may be:
0 - Not a bracket
@@ -56,7 +56,6 @@ fribidi_get_bracket (
This will be recodeded into the FriBidiBracketType as having a
bracket_id = 0 if the character is not a bracket.
*/
char_type = FRIBIDI_GET_BRACKET_TYPE (ch);
fribidi_boolean is_open = false;
if (char_type == 0)

0 comments on commit 84ea058

Please sign in to comment.