summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbehdad <behdad>2002-01-03 15:31:24 +0000
committerbehdad <behdad>2002-01-03 15:31:24 +0000
commit707dd98f6e1fb3cb28b61e9547d878ec989b6f8d (patch)
tree25a5298f2b3d68e15fdb789c6c1cf7fb1cb02dbb
parent52ac73796959aae40315b0958622b94d6cddab62 (diff)
Final (hopefuly) revision for 0.10.0 release
-rw-r--r--.indent.pro5
-rw-r--r--AUTHORS29
-rw-r--r--ChangeLog23
-rw-r--r--Makefile.am21
-rw-r--r--TODO2
-rwxr-xr-xbootstrap2
-rw-r--r--configure.in4
-rw-r--r--fribidi.c291
-rw-r--r--fribidi.h72
-rw-r--r--fribidi.pc.in10
-rw-r--r--fribidi_char_sets.c44
-rw-r--r--fribidi_char_sets.h51
-rw-r--r--fribidi_char_sets_cap_rtl.c4
-rw-r--r--fribidi_char_sets_cap_rtl.h22
-rw-r--r--fribidi_char_sets_cp1255.c4
-rw-r--r--fribidi_char_sets_cp1255.h22
-rw-r--r--fribidi_char_sets_cp1256.c4
-rw-r--r--fribidi_char_sets_cp1256.h22
-rw-r--r--fribidi_char_sets_isiri_3342.c4
-rw-r--r--fribidi_char_sets_isiri_3342.h22
-rw-r--r--fribidi_char_sets_iso8859_6.c4
-rw-r--r--fribidi_char_sets_iso8859_6.h22
-rw-r--r--fribidi_char_sets_iso8859_8.c4
-rw-r--r--fribidi_char_sets_iso8859_8.h22
-rw-r--r--fribidi_char_sets_utf8.c4
-rw-r--r--fribidi_char_sets_utf8.h24
-rw-r--r--fribidi_char_type.c21
-rw-r--r--fribidi_create_char_types.c7
-rw-r--r--fribidi_main.c66
-rw-r--r--fribidi_types.h7
-rw-r--r--fribidi_unicode.h7
-rw-r--r--fribidi_utils.c54
-rw-r--r--fribidi_wcwidth.c (renamed from wcwidth.c)21
-rw-r--r--getopt.c4
34 files changed, 510 insertions, 415 deletions
diff --git a/.indent.pro b/.indent.pro
index 4f9e4a3..c94e224 100644
--- a/.indent.pro
+++ b/.indent.pro
@@ -1,12 +1,13 @@
-T TypeLink
-T LevelInfo
-T FriBidiChar
+-T FriBidiStrIndex
+-T FriBidiMaskType
-T FriBidiCharType
-T FriBidiPropCharType
+-T FriBidiLevel
-T FriBidiCharSet
-T FriBidiCharSetHandler
--T FriBidiStrIndex
--T FriBidiMaskType
-T FriBidiRunType
-T FriBidiList
-T FriBidiMemChunk
diff --git a/AUTHORS b/AUTHORS
index 5e90338..3a55084 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,31 +1,36 @@
Dov Grobgeld <dov@imagic.weizmann.ac.il>
- * Initial author.
+ * Initial author.
Behdad Esfahbod <behdad@bamdad.org>
- * Current maintainer, Added explicit bidi support, fixed all conformance
- bugs, changed the library to use bitmasks, rewrote many things.
+ * Current maintainer, Added explicit bidi support, fixed all
+ conformance bugs, changed the library to use bitmasks, rewrote
+ many things, removed glib dependency.
Owen Tayler <otaylor@redhat.com>
- * Contributed very important memory leak and speed patches.
+ * Contributed very important memory leak and speed patches.
Raphael Finkel <raphael@cs.uky.edu>
- * Contributed UTF-8 converters.
+ * Contributed UTF-8 converters.
Pablo Saratxaga <pablo@mandrakesoft.com>
- * Contributed several arabic charset converters.
+ * Contributed several arabic charset converters.
Manish Singh <yosh@gimp.org>
- * Contributed patch to make fribidi use libtool.
+ * Contributed patch to make fribidi use libtool.
Omer Zak <omerz@actcom.co.il>
- * Contributed several bug fixes, improved interface UTF-8 converters, and
- several considerations for embedded systems.
+ * Contributed several bug fixes, improved interface UTF-8 converters,
+ and several considerations for embedded systems.
Roozbeh Pournader <roozbeh@sharif.edu>
- * Fixed small things here and there.
+ * Fixed small things here and there.
Dan Kenigsberg <danken@cs.technion.ac.il>
- * Contributed a patch to make Fribidi work without Glib.
+ * Contributed a patch to make Fribidi work without Glib.
Markus Kuhn <Markus.Kuhn@cl.cam.ac.uk>
- * Free wcwidth() implementation.
+ * Free wcwidth() implementation.
+
+Abel Cheung <maddog@linux.org.hk>
+ * Implemented pkgconfig support.
+
diff --git a/ChangeLog b/ChangeLog
index 2c1cc80..a2a1bc9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,23 @@
-2002-01-01 Behdad Esfahbod <behdad@bamdad.org>
- * fribidi_char_set_*.[ch]: Old interface is back, new interface
- starts with fribidix instead of fribidi.
+2002-01-02 Behdad Esfahbod <behdad@bamdad.org>
+ * bootstrap: automake option -a added
+ * fribidi_types.h: FriBidiStrIndex type changed from uint16 to int.
+ FriBidiLevel introduced, as uint8 to hold the type for bidi levels.
+ * fribidi.c, fribidi.h, fribidi_utils.c, fribidi_main.c: Updated to
+ use FriBidiLeveli and FriBidiStrIndex.
+ * fribidi.h, fribidi.c: fribidi_remove_explicits() replaced by
+ fribidi_remove_bidi_marks() which also updates l2v, v2l and levels.
+ * fribidi.h, fribidi_char_type.c: fribidi_get_types() added.
+ * wcwidth.c: Replaced by fribidi_wcwidth.c.
+ * fribidi_wcwidth.c: Markus Kuhn's implementation of wcwidth(),
+ updated to use fribidi's types.
+ * fribidi.pc.in: Added, input file for pkgconfig support.
+ * configure.in, Makefile.am: Updated to make fribidi.pc, which
+ pkgconfig needs.
+ * AUTHORS: Abel Cheung <maddog@linux.org.hk> added, has implemented
+ pkgconfig support.
+ * fribidi_char_sets.h, fribidi_char_sets.c: Check for macro
+ FRIBIDI_0_9_INTERFACE to define fribidi_*_to_unicode functions with
+ 0.9.x interface.
2001-12-31 Behdad Esfahbod <behdad@bamdad.org>
* configure.in: Check for sed added.
diff --git a/Makefile.am b/Makefile.am
index 5576107..c9e6b03 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -34,6 +34,7 @@ libfribidi_la_SOURCES = \
fribidi_mem.c \
fribidi_mirroring.c \
fribidi_char_type.c \
+ fribidi_wcwidth.c \
fribidi_utils.c \
$(libfribidi_charsets) \
$(libfribidi_charsets_extra)
@@ -83,6 +84,7 @@ EXTRA_DIST = \
run.tests \
ANNOUNCE \
acinclude.m4 \
+ fribidi.pc.in \
$(TEST_FILES) \
$(TABLE_FILES) \
$(EXTRA_HEADERS)
@@ -95,16 +97,14 @@ fribidi_create_char_types_SOURCES = fribidi_create_char_types.c packtab.c
fribidi_create_mirroring_SOURCES = fribidi_create_mirroring.c
bin_PROGRAMS = fribidi
-fribidi_SOURCES = fribidi_main.c wcwidth.c $(GETOPT_SRC)
+fribidi_SOURCES = fribidi_main.c $(GETOPT_SRC)
fribidi_LDADD = libfribidi.la
-unidata/BidiMirroring.txt:
+unidata/%:
+ file="$@" && file="`echo "$$file" | $(SED) 's|^unidata/||'`" && \
(test -d unidata || mkdir unidata) && cd unidata && \
- wget http://www.unicode.org/Public/UNIDATA/BidiMirroring.txt
-
-unidata/UnicodeData.txt:
- (test -d unidata || mkdir unidata) && cd unidata && \
- wget http://www.unicode.org/Public/UNIDATA/UnicodeData.txt
+ $(DOWNLOAD) "http://www.unicode.org/Public/UNIDATA/$$file" || \
+ ($(RM) -f "$$file"; false)
build_fribidi_tab_mirroring.i: fribidi_create_mirroring \
unidata/BidiMirroring.txt
@@ -113,7 +113,7 @@ build_fribidi_tab_mirroring.i: fribidi_create_mirroring \
./fribidi_create_mirroring "$$UNIDATA"
fribidi_tab_mirroring.i:
- $(MAKE) build_fribidi_tab_mirroring.i || ($(RM) -f "$@" && false)
+ $(MAKE) build_fribidi_tab_mirroring.i || ($(RM) -f $@; false)
$(srcdir)/fribidi_mirroring.c: fribidi_tab_mirroring.i
touch $@
@@ -130,7 +130,7 @@ fribidi_tab_char_type_%.i: fribidi_create_char_types \
else UNIDATA="$(srcdir)/unidata"; fi && \
./fribidi_create_char_types "`echo "$@" \
| $(SED) 's/[^0-9]*//g'`" "$$UNIDATA" || \
- ($(RM) -f "$@"; false)
+ ($(RM) -f $@; false)
$(RM) -f fribidi_tab_char_type_stamp
$(MAKE) fribidi_tab_char_type_stamp
@@ -167,6 +167,9 @@ TESTS = run.tests
bin_SCRIPTS = fribidi-config
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = fribidi.pc
+
CLEANFILES =
DISTCLEANFILES = fribidi_tab_char_type_stamp fribidi_config.h
diff --git a/TODO b/TODO
index 67847d5..a57025d 100644
--- a/TODO
+++ b/TODO
@@ -1,5 +1,7 @@
Implementation issues:
+* configure.in, Makefile.am: better check for downloader.
+
* Revise Reorder api, in fribidi_main.c reorder after link break.
* Add an option to fribidi_main.c to assume two consecutive returns as
diff --git a/bootstrap b/bootstrap
index f26507e..9fd144e 100755
--- a/bootstrap
+++ b/bootstrap
@@ -2,5 +2,5 @@
aclocal \
&& autoheader \
-&& automake --gnu --include-deps \
+&& automake --add-missing --gnu --include-deps \
&& autoconf
diff --git a/configure.in b/configure.in
index ceee469..1e64ba1 100644
--- a/configure.in
+++ b/configure.in
@@ -1,6 +1,6 @@
AC_INIT(fribidi.c)
-PACKAGE=fribidi
+PACKAGE=FriBidi
VERSION=0.10.0pre
INTERFACE_VERSION=2
AM_CONFIG_HEADER(config.h)
@@ -15,6 +15,7 @@ AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_RANLIB
AC_PATH_PROG(SED, sed, $PATH)
+AC_PATH_PROG(DOWNLOAD, wget, $PATH)
dnl Checks for libraries
@@ -167,6 +168,7 @@ fi
AC_OUTPUT([
Makefile
fribidi-config
+fribidi.pc
],[case "$CONFIG_FILES" in
*fribidi-config*)chmod +x fribidi-config;;
esac])
diff --git a/fribidi.c b/fribidi.c
index 609c5a0..cf6c8b0 100644
--- a/fribidi.c
+++ b/fribidi.c
@@ -68,7 +68,8 @@ struct _TypeLink
TypeLink *next;
FriBidiCharType type;
- int pos, len, level;
+ FriBidiStrIndex pos, len;
+ FriBidiLevel level;
};
#define FRIBIDI_LEVEL_START -1
@@ -78,7 +79,7 @@ struct _TypeLink
typedef struct
{
FriBidiCharType override; /* only L, R and N are valid */
- unsigned int level;
+ FriBidiLevel level;
}
LevelInfo;
@@ -97,9 +98,9 @@ fribidi_set_debug (boolean debug)
}
static void
-bidi_string_reverse (FriBidiChar *str, int len)
+bidi_string_reverse (FriBidiChar *str, FriBidiStrIndex len)
{
- int i;
+ FriBidiStrIndex i;
for (i = 0; i < len / 2; i++)
{
FriBidiChar tmp = str[i];
@@ -109,9 +110,9 @@ bidi_string_reverse (FriBidiChar *str, int len)
}
static void
-index_array_reverse (FriBidiStrIndex *arr, int len)
+index_array_reverse (FriBidiStrIndex *arr, FriBidiStrIndex len)
{
- int i;
+ FriBidiStrIndex i;
for (i = 0; i < len / 2; i++)
{
FriBidiStrIndex tmp = arr[i];
@@ -170,12 +171,12 @@ free_type_link (TypeLink *link)
}
static TypeLink *
-run_length_encode_types (FriBidiCharType *char_type, int type_len)
+run_length_encode_types (FriBidiCharType *char_type, FriBidiStrIndex type_len)
{
TypeLink *list, *last, *link;
TypeLink current;
- int i;
+ FriBidiStrIndex i;
/* Add the starting link */
list = new_type_link ();
@@ -291,95 +292,92 @@ static void
override_list (TypeLink *base, TypeLink *over)
{
TypeLink *p = base, *q, *r, *s, *t;
- int pos = 0, pos2;
+ FriBidiStrIndex pos = 0, pos2;
- if (!base)
- base = over;
- else if (over)
+ if (!over)
+ return;
+ q = over;
+ while (q)
{
- q = over;
- while (q)
+ if (!q->len || q->pos < pos)
{
- if (!q->len || q->pos < pos)
- {
- t = q;
- q = q->next;
- free_type_link (t);
- continue;
- }
- pos = q->pos;
- while (p->next && p->next->pos <= pos)
- p = p->next;
- /* now p is the element that q must be inserted 'in'. */
- pos2 = pos + q->len;
- r = p;
- while (r->next && r->next->pos < pos2)
+ t = q;
+ q = q->next;
+ free_type_link (t);
+ continue;
+ }
+ pos = q->pos;
+ while (p->next && p->next->pos <= pos)
+ p = p->next;
+ /* now p is the element that q must be inserted 'in'. */
+ pos2 = pos + q->len;
+ r = p;
+ while (r->next && r->next->pos < pos2)
+ r = r->next;
+ /* now r is the last element that q affects. */
+ if (p == r)
+ {
+ /* split p into at most 3 interval, and insert q in the place of
+ the second interval, set r to be the third part. */
+ /* third part needed? */
+ if (p->next && p->next->pos == pos2)
r = r->next;
- /* now r is the last element that q affects. */
- if (p == r)
+ else
{
- /* split p into at most 3 interval, and insert q in the place of
- the second interval, set r to be the third part. */
- /* third part needed? */
- if (p->next && p->next->pos == pos2)
- r = r->next;
- else
- {
- r = new_type_link ();
- *r = *p;
- if (r->next)
- {
- r->next->prev = r;
- r->len = r->next->pos - pos2;
- }
- else
- r->len -= pos - p->pos;
- r->pos = pos2;
- }
- /* first part needed? */
- if (p->prev && p->pos == pos)
+ r = new_type_link ();
+ *r = *p;
+ if (r->next)
{
- t = p;
- p = p->prev;
- free_type_link (t);
+ r->next->prev = r;
+ r->len = r->next->pos - pos2;
}
else
- p->len = pos - p->pos;
+ r->len -= pos - p->pos;
+ r->pos = pos2;
}
- else
+ /* first part needed? */
+ if (p->prev && p->pos == pos)
{
- /* cut the end of p. */
- p->len = pos - p->pos;
- /* if all of p is cut, remove it. */
- if (!p->len && p->prev)
- p = p->prev;
-
- /* cut the begining of r. */
- r->pos = pos2;
- if (r->next)
- r->len = r->next->pos - pos2;
- /* if all of r is cut, remove it. */
- if (!r->len && r->next)
- r = r->next;
+ t = p;
+ p = p->prev;
+ free_type_link (t);
+ }
+ else
+ p->len = pos - p->pos;
+ }
+ else
+ {
+ /* cut the end of p. */
+ p->len = pos - p->pos;
+ /* if all of p is cut, remove it. */
+ if (!p->len && p->prev)
+ p = p->prev;
+
+ /* cut the begining of r. */
+ r->pos = pos2;
+ if (r->next)
+ r->len = r->next->pos - pos2;
+ /* if all of r is cut, remove it. */
+ if (!r->len && r->next)
+ r = r->next;
- /* remove the elements between p and r. */
- for (s = p->next; s != r;)
- {
- t = s;
- s = s->next;
- free_type_link (t);
- }
+ /* remove the elements between p and r. */
+ for (s = p->next; s != r;)
+ {
+ t = s;
+ s = s->next;
+ free_type_link (t);
}
- /* before updating the next and prev links to point to the inserted q,
- we must remember the next element of q in the 'over' list.
- */
- t = q;
- q = q->next;
- p->next = t;
- t->prev = p;
- t->next = r;
- r->prev = t;
}
+ /* before updating the next and prev links to point to the inserted q,
+ we must remember the next element of q in the 'over' list.
+ */
+ t = q;
+ q = q->next;
+ p->next = t;
+ t->prev = p;
+ t->next = r;
+ r->prev = t;
}
}
@@ -428,9 +426,9 @@ compact_neutrals (TypeLink *list)
}
}
-/*=======================================================
+/*=========================================================================
* define macros for push and pop the status in to / out of the stack
- *-------------------------------------------------------*/
+ *-------------------------------------------------------------------------*/
/* There's some little points in pushing and poping into the status stack:
1. when the embedding level is not valid (more than MAX_LEVEL=61),
@@ -558,7 +556,7 @@ print_resolved_levels (TypeLink *pp)
fprintf (stderr, " Res. levels: ");
while (pp)
{
- int i;
+ FriBidiStrIndex i;
for (i = 0; i < RL_LEN (pp); i++)
fprintf (stderr, "%c", fribidi_char_from_level (RL_LEVEL (pp)));
pp = pp->next;
@@ -572,7 +570,7 @@ print_resolved_types (TypeLink *pp)
fprintf (stderr, " Res. types : ");
while (pp)
{
- int i;
+ FriBidiStrIndex i;
for (i = 0; i < RL_LEN (pp); i++)
fprintf (stderr, "%c", fribidi_char_from_type (pp->type));
pp = pp->next;
@@ -585,7 +583,7 @@ print_resolved_types (TypeLink *pp)
static void
print_bidi_string (FriBidiChar *str)
{
- int i;
+ FriBidiStrIndex i;
fprintf (stderr, " Org. types : ");
for (i = 0; str[i]; i++)
fprintf (stderr, "%c",
@@ -599,14 +597,14 @@ print_bidi_string (FriBidiChar *str)
*----------------------------------------------------------------------*/
static void
fribidi_analyse_string ( /* input */
- FriBidiChar *str,
- int len, FriBidiCharType *pbase_dir,
+ FriBidiChar *str, FriBidiStrIndex len,
+ FriBidiCharType *pbase_dir,
/* output */
- TypeLink **ptype_rl_list, int *pmax_level)
+ TypeLink **ptype_rl_list, FriBidiLevel *pmax_level)
{
- int base_level, base_dir;
- int max_level;
- int i;
+ FriBidiLevel base_level, max_level;
+ FriBidiCharType base_dir;
+ FriBidiStrIndex i;
TypeLink *type_rl_list, *explicits_list, *explicits_list_end, *pp;
DBG ("Entering fribidi_analyse_string()\n");
@@ -666,7 +664,9 @@ fribidi_analyse_string ( /* input */
embedding level. Set the directional override status to neutral.
Process each character iteratively, applying rules X2 through X9.
Only embedding levels from 0 to 61 are valid in this phase. */
- int level, override, new_level, new_override, i;
+ FriBidiLevel level, new_level;
+ FriBidiCharType override, new_override;
+ FriBidiStrIndex i;
int stack_size, over_pushed, first_interval;
LevelInfo *status_stack;
TypeLink temp_link;
@@ -1103,40 +1103,77 @@ fribidi_set_mirroring (boolean mirror)
*----------------------------------------------------------------------*/
/*======================================================================
- * fribidi_remove_explicits() removes explicit marks, and returns the
- * new length.
+ * fribidi_remove_bidi_marks() removes bidirectional marks, and returns
+ * the new length, updates each of other inputs if not NULL.
*----------------------------------------------------------------------*/
-int
-fribidi_remove_explicits (FriBidiChar *str, int length)
+FriBidiStrIndex
+fribidi_remove_bidi_marks (FriBidiChar *str, FriBidiStrIndex length,
+ FriBidiStrIndex *position_to_this_list,
+ FriBidiStrIndex *position_from_this_list,
+ FriBidiLevel *embedding_level_list)
{
- int i, j;
+ FriBidiStrIndex i, j;
+ boolean private_from_this = FALSE;
+
+ DBG ("Entering fribidi_remove_bidi_marks()\n");
+
+ /* If to_this is to not null, we must have from_this as well. If it is
+ not given by the caller, we have to make a private instance of it. */
+ if (position_to_this_list && !position_from_this_list)
+ {
+ private_from_this = TRUE;
+ position_from_this_list =
+ (FriBidiStrIndex *) malloc (sizeof (FriBidiStrIndex) * length);
+ }
- DBG ("Entering fribidi_remove_explicits()\n");
j = 0;
for (i = 0; i < length; i++)
if (!FRIBIDI_IS_EXPLICIT (fribidi_get_type (str[i]))
&& str[i] != UNI_LRM && str[i] != UNI_RLM)
- str[j++] = str[i];
+ {
+ str[j] = str[i];
+ if (embedding_level_list)
+ embedding_level_list[j] = embedding_level_list[i];
+ if (position_from_this_list)
+ position_from_this_list[j] = position_from_this_list[i];
+ j++;
+ }
+
+ /* Convert the from_this list to to_this */
+ if (position_to_this_list)
+ {
+ DBG (" Converting from_this list to to_this\n");
+ for (i = 0; i < length; i++)
+ position_to_this_list[i] = -1;
+ for (i = 0; i < length; i++)
+ position_to_this_list[position_from_this_list[i]] = i;
+ DBG (" Converting from_this list to to_this, Done\n");
+ }
+
+ if (private_from_this)
+ free (position_from_this_list);
- DBG ("Leaving fribidi_remove_explicits()\n");
+ DBG ("Leaving fribidi_remove_bidi_marks()\n");
return j;
}
+
/*======================================================================
* fribidi_log2vis() calls the function_analyse_string() and then
* does reordering and fills in the output strings.
*----------------------------------------------------------------------*/
boolean
fribidi_log2vis ( /* input */
- FriBidiChar *str, int len, FriBidiCharType *pbase_dir,
+ FriBidiChar *str, FriBidiStrIndex len,
+ FriBidiCharType *pbase_dir,
/* output */
FriBidiChar *visual_str,
FriBidiStrIndex *position_L_to_V_list,
FriBidiStrIndex *position_V_to_L_list,
- uint8 *embedding_level_list)
+ FriBidiLevel *embedding_level_list)
{
TypeLink *type_rl_list, *pp = NULL;
- int max_level;
+ FriBidiLevel max_level;
boolean private_V_to_L = FALSE;
DBG ("Entering fribidi_log2vis()\n");
@@ -1153,7 +1190,7 @@ fribidi_log2vis ( /* input */
{
private_V_to_L = TRUE;
position_V_to_L_list =
- (FriBidiStrIndex *) malloc (sizeof (FriBidiStrIndex) * (len + 1));
+ (FriBidiStrIndex *) malloc (sizeof (FriBidiStrIndex) * len);
}
if (len > FRIBIDI_MAX_STRING_LENGTH && position_V_to_L_list)
@@ -1171,8 +1208,8 @@ fribidi_log2vis ( /* input */
/* 7. Reordering resolved levels */
DBG ("Reordering resolved levels\n");
{
- int level_idx;
- int i;
+ FriBidiLevel level_idx;
+ FriBidiStrIndex i;
/* TBD: L3 */
@@ -1188,7 +1225,7 @@ fribidi_log2vis ( /* input */
if (visual_str)
{
DBG (" Initialize visual_str\n");
- for (i = 0; i <= len; i++)
+ for (i = 0; i < len; i++)
visual_str[i] = str[i];
visual_str[len] = 0;
DBG (" Initialize visual_str, Done\n");
@@ -1200,7 +1237,8 @@ fribidi_log2vis ( /* input */
DBG (" Fill the embedding levels array\n");
for (pp = type_rl_list->next; pp->next; pp = pp->next)
{
- int i, pos, len, level;
+ FriBidiStrIndex i, pos, len;
+ FriBidiLevel level;
pos = pp->pos;
len = pp->len;
@@ -1222,7 +1260,7 @@ fribidi_log2vis ( /* input */
{
if (pp->level & 1)
{
- int i;
+ FriBidiStrIndex i;
for (i = RL_POS (pp); i < RL_POS (pp) + RL_LEN (pp); i++)
{
FriBidiChar mirrored_ch;
@@ -1244,8 +1282,7 @@ fribidi_log2vis ( /* input */
if (RL_LEVEL (pp) >= level_idx)
{
/* Find all stretches that are >= level_idx */
- int len = RL_LEN (pp);
- int pos = RL_POS (pp);
+ FriBidiStrIndex len = RL_LEN (pp), pos = RL_POS (pp);
TypeLink *pp1 = pp->next;
while (pp1->next && RL_LEVEL (pp1) >= level_idx)
{
@@ -1267,7 +1304,7 @@ fribidi_log2vis ( /* input */
if (position_L_to_V_list)
{
DBG (" Converting v2l list to l2v\n");
- for (i = 0; i <= len; i++)
+ for (i = 0; i < len; i++)
position_L_to_V_list[position_V_to_L_list[i]] = i;
DBG (" Converting v2l list to l2v, Done\n");
}
@@ -1291,12 +1328,13 @@ fribidi_log2vis ( /* input */
boolean
fribidi_log2vis_get_embedding_levels ( /* input */
FriBidiChar *str,
- int len, FriBidiCharType *pbase_dir,
+ FriBidiStrIndex len,
+ FriBidiCharType *pbase_dir,
/* output */
- uint8 *embedding_level_list)
+ FriBidiLevel *embedding_level_list)
{
TypeLink *type_rl_list, *pp;
- int max_level;
+ FriBidiLevel max_level;
DBG ("Entering fribidi_log2vis_get_embedding_levels()\n");
@@ -1312,10 +1350,8 @@ fribidi_log2vis_get_embedding_levels ( /* input */
for (pp = type_rl_list->next; pp->next; pp = pp->next)
{
- int i;
- int pos = RL_POS (pp);
- int len = RL_LEN (pp);
- int level = RL_LEVEL (pp);
+ FriBidiStrIndex i, pos = RL_POS (pp), len = RL_LEN (pp);
+ FriBidiLevel level = RL_LEVEL (pp);
for (i = 0; i < len; i++)
embedding_level_list[pos + i] = level;
}
@@ -1326,8 +1362,15 @@ fribidi_log2vis_get_embedding_levels ( /* input */
return TRUE;
}
+
+
+
+
+
+
+
char *fribidi_version_info =
- FRIBIDI_PACKAGE " " FRIBIDI_VERSION " (interface version"
+ FRIBIDI_PACKAGE " " FRIBIDI_VERSION " (interface version "
FRIBIDI_INTERFACE_VERSION_STR ")\n"
"Copyright (C) 2001 FriBidi Project (http://fribidi.sf.net/).\n" "\n"
FRIBIDI_PACKAGE " comes with NO WARRANTY, to the extent permitted by law.\n"
diff --git a/fribidi.h b/fribidi.h
index 9abb0e8..d7db643 100644
--- a/fribidi.h
+++ b/fribidi.h
@@ -38,20 +38,34 @@ extern "C"
#endif
boolean fribidi_log2vis ( /* input */
- FriBidiChar *str,
- int len, FriBidiCharType *pbase_dir,
+ FriBidiChar *str, FriBidiStrIndex len,
+ FriBidiCharType *pbase_dirs,
/* output */
FriBidiChar *visual_str,
FriBidiStrIndex *position_L_to_V_list,
FriBidiStrIndex *position_V_to_L_list,
- uint8 *embedding_level_list);
+ FriBidiLevel *embedding_level_list);
boolean fribidi_log2vis_get_embedding_levels ( /* input */
FriBidiChar *str,
- int len,
+ FriBidiStrIndex len,
FriBidiCharType *pbase_dir,
/* output */
- uint8 *embedding_level_list);
+ FriBidiLevel
+ *embedding_level_list);
+
+/*======================================================================
+ * fribidi_remove_bidi_marks() removes bidirectional marks, and returns
+ * the new length, also updates each of other inputs if not NULL.
+ *----------------------------------------------------------------------*/
+ FriBidiStrIndex fribidi_remove_bidi_marks (FriBidiChar *str,
+ FriBidiStrIndex length,
+ FriBidiStrIndex
+ *position_to_this_list,
+ FriBidiStrIndex
+ *position_from_this_list,
+ FriBidiLevel
+ *embedding_level_list);
/*======================================================================
* fribidi_get_type() returns bidi type of a character.
@@ -59,6 +73,14 @@ extern "C"
FriBidiCharType fribidi_get_type (FriBidiChar uch);
/*======================================================================
+ * fribidi_get_types() returns bidi type of a string.
+ *----------------------------------------------------------------------*/
+ void fribidi_get_types ( /* input */
+ FriBidiChar *str, FriBidiStrIndex len,
+ /* output */
+ FriBidiCharType *type);
+
+/*======================================================================
* fribidi_get_mirror_char() returns the mirrored character, if input
* character has a mirror, or the input itself.
* if mirrored_ch is NULL, just returns if character has a mirror or not.
@@ -69,12 +91,6 @@ extern "C"
FriBidiChar *mirrored_ch);
/*======================================================================
- * fribidi_remove_explicits() removes explicit marks, and returns the
- * new length.
- *----------------------------------------------------------------------*/
- int fribidi_remove_explicits (FriBidiChar *str, int length);
-
-/*======================================================================
* fribidi_mirroring_status() returns whether mirroring is on or off,
* default is on.
*----------------------------------------------------------------------*/
@@ -99,10 +115,12 @@ extern "C"
*----------------------------------------------------------------------*/
void fribidi_find_string_changes ( /* input */
FriBidiChar *old_str,
- int old_len,
- FriBidiChar *new_str, int new_len,
+ FriBidiStrIndex old_len,
+ FriBidiChar *new_str,
+ FriBidiStrIndex new_len,
/* output */
- int *change_start, int *change_len);
+ FriBidiStrIndex *change_start,
+ FriBidiStrIndex *change_len);
/*======================================================================
@@ -124,7 +142,7 @@ extern "C"
* The selection is between logical characters 10 to 45. Calculate
* the corresponding visual selection(s):
*
- * int sel_span[2] = {10,45};
+ * FriBidiStrIndex sel_span[2] = {10,45};
*
* fribidi_map_range(sel_span,
* TRUE,
@@ -134,21 +152,20 @@ extern "C"
* // output
* &num_vis_ranges, *vis_ranges);
**----------------------------------------------------------------------*/
- void fribidi_map_range (int span[2],
- int len,
+ void fribidi_map_range (FriBidiStrIndex span[2], FriBidiStrIndex len,
boolean is_v2l_map,
FriBidiStrIndex *position_map,
- uint8 *embedding_level_list,
+ FriBidiLevel *embedding_level_list,
/* output */
- int *num_mapped_spans, int spans[3][2]);
+ int *num_mapped_spans, FriBidiStrIndex spans[3][2]);
/*======================================================================
* fribidi_is_char_rtl() answers the question whether a character
* was resolved in the rtl direction. This simply involves asking
* if the embedding level for the character is odd.
*----------------------------------------------------------------------*/
- boolean fribidi_is_char_rtl (uint8 *embedding_level_list,
- FriBidiCharType base_dir, int idx);
+ boolean fribidi_is_char_rtl (FriBidiLevel *embedding_level_list,
+ FriBidiCharType base_dir, FriBidiStrIndex idx);
/*======================================================================
* fribidi_xpos_resolve() does the complicated translation of
@@ -198,15 +215,14 @@ extern "C"
* beyond the end of the line, res_attach_before is true.
*
*----------------------------------------------------------------------*/
- void fribidi_xpos_resolve (int x_pos,
- int x_offset,
- int len,
- uint8 *embedding_level_list,
+ void fribidi_xpos_resolve (int x_pos, int x_offset,
+ FriBidiStrIndex len,
+ FriBidiLevel *embedding_level_list,
FriBidiCharType base_dir,
FriBidiStrIndex *vis2log, int *char_widths,
/* output */
- int *res_log_pos,
- int *res_vis_pos,
+ FriBidiStrIndex *res_log_pos,
+ FriBidiStrIndex *res_vis_pos,
int *res_cursor_x_pos,
boolean *res_cursor_dir_is_rtl,
boolean *res_attach_before);
@@ -218,7 +234,7 @@ extern "C"
*----------------------------------------------------------------------*/
void fribidi_runs_log2vis ( /* input */
FriBidiList *logical_runs, /* List of FriBidiRunType */
- int len, FriBidiStrIndex *log2vis,
+ FriBidiStrIndex len, FriBidiStrIndex *log2vis,
FriBidiCharType base_dir,
/* output */
FriBidiList **visual_runs);
diff --git a/fribidi.pc.in b/fribidi.pc.in
new file mode 100644
index 0000000..64590f7
--- /dev/null
+++ b/fribidi.pc.in
@@ -0,0 +1,10 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: @PACKAGE@
+Description: Unicode BiDirectional algorithm library
+Version: @VERSION@
+Libs: -L${libdir} -lfribidi
+Cflags: -I${includedir}/fribidi
diff --git a/fribidi_char_sets.c b/fribidi_char_sets.c
index 04cfbb4..dd5f9d1 100644
--- a/fribidi_char_sets.c
+++ b/fribidi_char_sets.c
@@ -60,8 +60,8 @@ FriBidiCharSetHandler;
#define _FRIBIDI_ADD_CHAR_SET(char_set) \
{ \
- fribidix_##char_set##_to_unicode, \
- fribidix_unicode_to_##char_set, \
+ fribidi_##char_set##_to_unicode, \
+ fribidi_unicode_to_##char_set, \
fribidi_char_set_name_##char_set, \
fribidi_char_set_title_##char_set, \
fribidi_char_set_desc_##char_set, \
@@ -87,6 +87,7 @@ FriBidiCharSet
fribidi_parse_charset (char *s)
{
int i;
+
for (i = FRIBIDI_CHAR_SETS_NUM; i; i--)
if (fribidi_strcasecmp (s, fribidi_char_sets[i].name) == 0)
return i;
@@ -98,9 +99,9 @@ fribidi_parse_charset (char *s)
/* Convert the character string "s" in charset "char_set" to unicode
string "us" and return it's length. */
int
-fribidix_charset_to_unicode (FriBidiCharSet char_set, char *s, int length,
- /* output */
- FriBidiChar *us)
+fribidi_charset_to_unicode (FriBidiCharSet char_set, char *s, int length,
+ /* output */
+ FriBidiChar *us)
{
fribidi_char_set_enter (char_set);
return fribidi_char_sets[char_set].charset_to_unicode == NULL ? 0 :
@@ -110,10 +111,10 @@ fribidix_charset_to_unicode (FriBidiCharSet char_set, char *s, int length,
/* Convert the unicode string "us" with length "length" to character
string "s" in charset "char_set" and return it's length. */
int
-fribidix_unicode_to_charset (FriBidiCharSet char_set, FriBidiChar *us,
- int length,
- /* output */
- char *s)
+fribidi_unicode_to_charset (FriBidiCharSet char_set, FriBidiChar *us,
+ int length,
+ /* output */
+ char *s)
{
fribidi_char_set_enter (char_set);
return fribidi_char_sets[char_set].unicode_to_charset == NULL ? 0 :
@@ -173,4 +174,29 @@ fribidi_char_set_leave (FriBidiCharSet char_set)
return TRUE;
}
+
+/* 0.9.x interface, deprecated, just for compatibility. */
+int
+fribidi_charset_to_unicode_0_9 (FriBidiCharSet char_set, char *s,
+ /* output */
+ FriBidiChar *us)
+{
+ return fribidi_charset_to_unicode (char_set, s, strlen (s), us);
+}
+
+/* Also old character sets. */
+
+#define FRIBIDI_0_9_TO_UNICODE_DEFINE(cs) \
+ int fribidi_##cs##_to_unicode_0_9 (char *s, FriBidiChar *us) \
+ { \
+ return fribidi_##cs##_to_unicode (s, strlen(s), us); \
+ }
+FRIBIDI_0_9_TO_UNICODE_DEFINE (utf8)
+FRIBIDI_0_9_TO_UNICODE_DEFINE (cap_rtl)
+FRIBIDI_0_9_TO_UNICODE_DEFINE (iso8859_6)
+FRIBIDI_0_9_TO_UNICODE_DEFINE (iso8859_8)
+FRIBIDI_0_9_TO_UNICODE_DEFINE (cp1255)
+FRIBIDI_0_9_TO_UNICODE_DEFINE (cp1256)
+FRIBIDI_0_9_TO_UNICODE_DEFINE (isiri_3342)
+#undef FRIBIDI_0_9_TO_UNICODE_DEFINE
#endif
diff --git a/fribidi_char_sets.h b/fribidi_char_sets.h
index a4a9096..136882a 100644
--- a/fribidi_char_sets.h
+++ b/fribidi_char_sets.h
@@ -63,16 +63,16 @@ FriBidiCharSet;
/* Convert the character string "s" in charset "char_set" to unicode
string "us" and return it's length. */
-int fribidix_charset_to_unicode (FriBidiCharSet char_set, char *s, int length,
- /* output */
- FriBidiChar *us);
+int fribidi_charset_to_unicode (FriBidiCharSet char_set, char *s, int length,
+ /* output */
+ FriBidiChar *us);
/* Convert the unicode string "us" with length "length" to character
string "s" in charset "char_set" and return it's length. */
-int fribidix_unicode_to_charset (FriBidiCharSet char_set, FriBidiChar *us,
- int length,
- /* output */
- char *s);
+int fribidi_unicode_to_charset (FriBidiCharSet char_set, FriBidiChar *us,
+ int length,
+ /* output */
+ char *s);
/* Return the string containing the name of the charset. */
char *fribidi_char_set_name (FriBidiCharSet char_set);
@@ -97,14 +97,33 @@ boolean fribidi_char_set_leave (FriBidiCharSet char_set);
FriBidiCharSet fribidi_parse_charset (char *s);
-/* Old style, just for compatibility. do not use these. */
-
-#define fribidi_charset_to_unicode(char_set, s, us) \
- fribidix_charset_to_unicode(char_set, s, strlen(s), us)
-
-#define fribidi_unicode_to_charset(char_set, us, length, s) \
- fribidix_unicode_to_charset(char_set, us, length, s)
-
+#ifdef FRIBIDI_0_9_INTERFACE
+/* 0.9.x interface, deprecated, just for compatibility. */
+
+int fribidi_charset_to_unicode_0_9 (FriBidiCharSet char_set, char *s,
+ /* output */
+ FriBidiChar *us);
+#define fribidi_charset_to_unicode fribidi_charset_to_unicode_0_9
+
+/* Also old character sets. */
+#define fribidi_utf8_to_unicode fribidi_utf8_to_unicode_0_9
+#define fribidi_cap_rtl_to_unicode fribidi_cap_rtl_to_unicode_0_9
+#define fribidi_iso8859_6_to_unicode fribidi_iso8859_6_to_unicode_0_9
+#define fribidi_iso8859_8_to_unicode fribidi_iso8859_8_to_unicode_0_9
+#define fribidi_cp1255_to_unicode fribidi_cp1255_to_unicode_0_9
+#define fribidi_cp1256_to_unicode fribidi_cp1256_to_unicode_0_9
+#define fribidi_isiri_3342_to_unicode fribidi_isiri_3342_to_unicode_0_9
+
+#define FRIBIDI_0_9_TO_UNICODE_EXPORT(cs) \
+ int fribidi_##cs##_to_unicode_0_9 (char *s, FriBidiChar *us);
+FRIBIDI_0_9_TO_UNICODE_EXPORT (utf8)
+FRIBIDI_0_9_TO_UNICODE_EXPORT (cap_rtl)
+FRIBIDI_0_9_TO_UNICODE_EXPORT (iso8859_6)
+FRIBIDI_0_9_TO_UNICODE_EXPORT (iso8859_8)
+FRIBIDI_0_9_TO_UNICODE_EXPORT (cp1255)
+FRIBIDI_0_9_TO_UNICODE_EXPORT (cp1256)
+FRIBIDI_0_9_TO_UNICODE_EXPORT (isiri_3342)
+#undef FRIBIDI_0_9_TO_UNICODE_EXPORT
+#endif /* FRIBIDI_0_9_INTERFACE */
#endif /* FRIBIDI_CHAR_SETS_H */
-
#endif
diff --git a/fribidi_char_sets_cap_rtl.c b/fribidi_char_sets_cap_rtl.c
index 978de91..3e58e30 100644
--- a/fribidi_char_sets_cap_rtl.c
+++ b/fribidi_char_sets_cap_rtl.c
@@ -101,7 +101,7 @@ fribidi_unicode_to_cap_rtl_c (FriBidiChar uch)
}
int
-fribidix_cap_rtl_to_unicode (char *s, int len, FriBidiChar *us)
+fribidi_cap_rtl_to_unicode (char *s, int len, FriBidiChar *us)
{
int i, j;
@@ -153,7 +153,7 @@ fribidix_cap_rtl_to_unicode (char *s, int len, FriBidiChar *us)
}
int
-fribidix_unicode_to_cap_rtl (FriBidiChar *us, int length, char *s)
+fribidi_unicode_to_cap_rtl (FriBidiChar *us, int length, char *s)
{
int i, j;
diff --git a/fribidi_char_sets_cap_rtl.h b/fribidi_char_sets_cap_rtl.h
index 942bec3..67d603c 100644
--- a/fribidi_char_sets_cap_rtl.h
+++ b/fribidi_char_sets_cap_rtl.h
@@ -27,7 +27,7 @@
#ifndef FRIBIDI_CHAR_SETS_CAP_RTL_H
#define FRIBIDI_CHAR_SETS_CAP_RTL_H
-#include "fribidi.h"
+#include "fribidi_types.h"
#define fribidi_char_set_name_cap_rtl "CapRTL"
#define fribidi_char_set_title_cap_rtl "CapRTL (Test)"
@@ -35,20 +35,12 @@ char *fribidi_char_set_desc_cap_rtl (void);
boolean fribidi_char_set_enter_cap_rtl (void);
boolean fribidi_char_set_leave_cap_rtl (void);
-int fribidix_cap_rtl_to_unicode (char *s, int length,
- /* Output */
- FriBidiChar *us);
-int fribidix_unicode_to_cap_rtl (FriBidiChar *us, int length,
- /* Output */
- char *s);
-
-/* Old style, just for compatibility. do not use these. */
-
-#define fribidi_cap_rtl_to_unicode(s, us) \
- fribidix_cap_rtl_to_unicode(s, strlen(s), us)
-
-#define fribidi_unicode_to_cap_rtl(us, length, s) \
- fribidix_unicode_to_cap_rtl(us, length, s)
+int fribidi_cap_rtl_to_unicode (char *s, int length,
+ /* Output */
+ FriBidiChar *us);
+int fribidi_unicode_to_cap_rtl (FriBidiChar *us, int length,
+ /* Output */
+ char *s);
#endif /* FRIBIDI_CHAR_SETS_CAP_RTL_H */
diff --git a/fribidi_char_sets_cp1255.c b/fribidi_char_sets_cp1255.c
index d565d22..b9e0b8a 100644
--- a/fribidi_char_sets_cp1255.c
+++ b/fribidi_char_sets_cp1255.c
@@ -70,7 +70,7 @@ fribidi_cp1255_to_unicode_c (char sch)
}
int
-fribidix_cp1255_to_unicode (char *s, int len, FriBidiChar *us)
+fribidi_cp1255_to_unicode (char *s, int len, FriBidiChar *us)
{
int i;
@@ -97,7 +97,7 @@ fribidi_unicode_to_cp1255_c (FriBidiChar uch)
}
int
-fribidix_unicode_to_cp1255 (FriBidiChar *us, int length, char *s)
+fribidi_unicode_to_cp1255 (FriBidiChar *us, int length, char *s)
{
int i;
diff --git a/fribidi_char_sets_cp1255.h b/fribidi_char_sets_cp1255.h
index 9b7467f..662a343 100644
--- a/fribidi_char_sets_cp1255.h
+++ b/fribidi_char_sets_cp1255.h
@@ -27,7 +27,7 @@
#ifndef FRIBIDI_CHAR_SETS_CP1255_H
#define FRIBIDI_CHAR_SETS_CP1255_H
-#include "fribidi.h"
+#include "fribidi_types.h"
#define fribidi_char_set_name_cp1255 "CP1255"
#define fribidi_char_set_title_cp1255 "CP1255 (Hebrew/Yiddish)"
@@ -36,21 +36,13 @@
#define fribidi_char_set_leave_cp1255 NULL
FriBidiChar fribidi_cp1255_to_unicode_c (char ch);
-int fribidix_cp1255_to_unicode (char *s, int length,
- /* Output */
- FriBidiChar *us);
+int fribidi_cp1255_to_unicode (char *s, int length,
+ /* Output */
+ FriBidiChar *us);
char fribidi_unicode_to_cp1255_c (FriBidiChar uch);
-int fribidix_unicode_to_cp1255 (FriBidiChar *us, int length,
- /* Output */
- char *s);
-
-/* Old style, just for compatibility. do not use these. */
-
-#define fribidi_cp1255_to_unicode(s, us) \
- fribidix_cp1255_to_unicode(s, strlen(s), us)
-
-#define fribidi_unicode_to_cp1255(us, length, s) \
- fribidix_unicode_to_cp1255(us, length, s)
+int fribidi_unicode_to_cp1255 (FriBidiChar *us, int length,
+ /* Output */
+ char *s);
#endif /* FRIBIDI_CHAR_SETS_CP1255_H */
diff --git a/fribidi_char_sets_cp1256.c b/fribidi_char_sets_cp1256.c
index 967e13e..7b1af49 100644
--- a/fribidi_char_sets_cp1256.c
+++ b/fribidi_char_sets_cp1256.c
@@ -65,7 +65,7 @@ fribidi_cp1256_to_unicode_c (char sch)
}
int
-fribidix_cp1256_to_unicode (char *s, int len, FriBidiChar *us)
+fribidi_cp1256_to_unicode (char *s, int len, FriBidiChar *us)
{
int i;
@@ -216,7 +216,7 @@ fribidi_unicode_to_cp1256_c (FriBidiChar uch)
}
int
-fribidix_unicode_to_cp1256 (FriBidiChar *us, int length, char *s)
+fribidi_unicode_to_cp1256 (FriBidiChar *us, int length, char *s)
{
int i;
diff --git a/fribidi_char_sets_cp1256.h b/fribidi_char_sets_cp1256.h
index f06bc89..0f0b420 100644
--- a/fribidi_char_sets_cp1256.h
+++ b/fribidi_char_sets_cp1256.h
@@ -27,7 +27,7 @@
#ifndef FRIBIDI_CHAR_SETS_CP1256_H
#define FRIBIDI_CHAR_SETS_CP1256_H
-#include "fribidi.h"
+#include "fribidi_types.h"
#define fribidi_char_set_name_cp1256 "CP1256"
#define fribidi_char_set_title_cp1256 "CP1256 (MS-Arabic)"
@@ -36,21 +36,13 @@
#define fribidi_char_set_leave_cp1256 NULL
FriBidiChar fribidi_cp1256_to_unicode_c (char ch);
-int fribidix_cp1256_to_unicode (char *s, int length,
- /* Output */
- FriBidiChar *us);
+int fribidi_cp1256_to_unicode (char *s, int length,
+ /* Output */
+ FriBidiChar *us);
char fribidi_unicode_to_cp1256_c (FriBidiChar uch);
-int fribidix_unicode_to_cp1256 (FriBidiChar *us, int length,
- /* Output */
- char *s);
-
-/* Old style, just for compatibility. do not use these. */
-
-#define fribidi_cp1256_to_unicode(s, us) \
- fribidix_cp1256_to_unicode(s, strlen(s), us)
-
-#define fribidi_unicode_to_cp1256(us, length, s) \
- fribidix_unicode_to_cp1256(us, length, s)
+int fribidi_unicode_to_cp1256 (FriBidiChar *us, int length,
+ /* Output */
+ char *s);
#endif /* FRIBIDI_CHAR_SETS_CP1256_H */
diff --git a/fribidi_char_sets_isiri_3342.c b/fribidi_char_sets_isiri_3342.c
index 6477874..d380cbc 100644
--- a/fribidi_char_sets_isiri_3342.c
+++ b/fribidi_char_sets_isiri_3342.c
@@ -57,7 +57,7 @@ fribidi_isiri_3342_to_unicode_c (char sch)
}
int
-fribidix_isiri_3342_to_unicode (char *s, int len, FriBidiChar *us)
+fribidi_isiri_3342_to_unicode (char *s, int len, FriBidiChar *us)
{
int i;
@@ -218,7 +218,7 @@ fribidi_unicode_to_isiri_3342_c (FriBidiChar uch)
}
int
-fribidix_unicode_to_isiri_3342 (FriBidiChar *us, int length, char *s)
+fribidi_unicode_to_isiri_3342 (FriBidiChar *us, int length, char *s)
{
int i;
diff --git a/fribidi_char_sets_isiri_3342.h b/fribidi_char_sets_isiri_3342.h
index e2b6daa..25d250b 100644
--- a/fribidi_char_sets_isiri_3342.h
+++ b/fribidi_char_sets_isiri_3342.h
@@ -27,7 +27,7 @@
#ifndef FRIBIDI_CHAR_SETS_ISIRI_3342_H
#define FRIBIDI_CHAR_SETS_ISIRI_3342_H
-#include "fribidi.h"
+#include "fribidi_types.h"
#define fribidi_char_set_name_isiri_3342 "ISIRI-3342"
#define fribidi_char_set_title_isiri_3342 "ISIRI 3342 (Persian)"
@@ -36,21 +36,13 @@
#define fribidi_char_set_leave_isiri_3342 NULL
FriBidiChar fribidi_isiri_3342_to_unicode_c (char ch);
-int fribidix_isiri_3342_to_unicode (char *s, int length,
- /* Output */
- FriBidiChar *us);
+int fribidi_isiri_3342_to_unicode (char *s, int length,
+ /* Output */
+ FriBidiChar *us);
char fribidi_unicode_to_isiri_3342_c (FriBidiChar uch);
-int fribidix_unicode_to_isiri_3342 (FriBidiChar *us, int length,
- /* Output */
- char *s);
-
-/* Old style, just for compatibility. do not use these. */
-
-#define fribidi_isiri_3342_to_unicode(s, us) \
- fribidix_isiri_3342_to_unicode(s, strlen(s), us)
-
-#define fribidi_unicode_to_isiri_3342(us, length, s) \
- fribidix_unicode_to_isiri_3342(us, length, s)
+int fribidi_unicode_to_isiri_3342 (FriBidiChar *us, int length,
+ /* Output */
+ char *s);
#endif /* FRIBIDI_CHAR_SETS_ISIRI_3342_H */
diff --git a/fribidi_char_sets_iso8859_6.c b/fribidi_char_sets_iso8859_6.c
index 1d80df0..6a0d584 100644
--- a/fribidi_char_sets_iso8859_6.c
+++ b/fribidi_char_sets_iso8859_6.c
@@ -44,7 +44,7 @@ fribidi_iso8859_6_to_unicode_c (char sch)
}
int
-fribidix_iso8859_6_to_unicode (char *s, int len, FriBidiChar *us)
+fribidi_iso8859_6_to_unicode (char *s, int len, FriBidiChar *us)
{
int i;
@@ -73,7 +73,7 @@ fribidi_unicode_to_iso8859_6_c (FriBidiChar uch)
}
int
-fribidix_unicode_to_iso8859_6 (FriBidiChar *us, int length, char *s)
+fribidi_unicode_to_iso8859_6 (FriBidiChar *us, int length, char *s)
{
int i;
diff --git a/fribidi_char_sets_iso8859_6.h b/fribidi_char_sets_iso8859_6.h
index 105a6e2..9a64df6 100644
--- a/fribidi_char_sets_iso8859_6.h
+++ b/fribidi_char_sets_iso8859_6.h
@@ -27,7 +27,7 @@
#ifndef FRIBIDI_CHAR_SETS_ISO8859_6_H
#define FRIBIDI_CHAR_SETS_ISO8859_6_H
-#include "fribidi.h"
+#include "fribidi_types.h"
#define fribidi_char_set_name_iso8859_6 "ISO8859-6"
#define fribidi_char_set_title_iso8859_6 "ISO 8859-6 (Arabic)"
@@ -36,21 +36,13 @@
#define fribidi_char_set_leave_iso8859_6 NULL
FriBidiChar fribidi_iso8859_6_to_unicode_c (char ch);
-int fribidix_iso8859_6_to_unicode (char *s, int length,
- /* Output */
- FriBidiChar *us);
+int fribidi_iso8859_6_to_unicode (char *s, int length,
+ /* Output */
+ FriBidiChar *us);
char fribidi_unicode_to_iso8859_6_c (FriBidiChar uch);
-int fribidix_unicode_to_iso8859_6 (FriBidiChar *us, int length,
- /* Output */
- char *s);
-
-/* Old style, just for compatibility. do not use these. */
-
-#define fribidi_iso8859_6_to_unicode(s, us) \
- fribidix_iso8859_6_to_unicode(s, strlen(s), us)
-
-#define fribidi_unicode_to_iso8859_6(us, length, s) \
- fribidix_unicode_to_iso8859_6(us, length, s)
+int fribidi_unicode_to_iso8859_6 (FriBidiChar *us, int length,
+ /* Output */
+ char *s);
#endif /* FRIBIDI_CHAR_SETS_ISO8859_6_H */
diff --git a/fribidi_char_sets_iso8859_8.c b/fribidi_char_sets_iso8859_8.c
index 1312119..b826fe9 100644
--- a/fribidi_char_sets_iso8859_8.c
+++ b/fribidi_char_sets_iso8859_8.c
@@ -72,7 +72,7 @@ fribidi_iso8859_8_to_unicode_c (char sch)
}
int
-fribidix_iso8859_8_to_unicode (char *s, int len, FriBidiChar *us)
+fribidi_iso8859_8_to_unicode (char *s, int len, FriBidiChar *us)
{
int i;
@@ -110,7 +110,7 @@ fribidi_unicode_to_iso8859_8_c (FriBidiChar uch)
}
int
-fribidix_unicode_to_iso8859_8 (FriBidiChar *us, int length, char *s)
+fribidi_unicode_to_iso8859_8 (FriBidiChar *us, int length, char *s)
{
int i;
diff --git a/fribidi_char_sets_iso8859_8.h b/fribidi_char_sets_iso8859_8.h
index 1fda617..300e360 100644
--- a/fribidi_char_sets_iso8859_8.h
+++ b/fribidi_char_sets_iso8859_8.h
@@ -27,7 +27,7 @@
#ifndef FRIBIDI_CHAR_SETS_ISO8859_8_H
#define FRIBIDI_CHAR_SETS_ISO8859_8_H
-#include "fribidi.h"
+#include "fribidi_types.h"
#define fribidi_char_set_name_iso8859_8 "ISO8859-8"
#define fribidi_char_set_title_iso8859_8 "ISO 8859-8 (Hebrew)"
@@ -36,21 +36,13 @@
#define fribidi_char_set_leave_iso8859_8 NULL
FriBidiChar fribidi_iso8859_8_to_unicode_c (char ch);
-int fribidix_iso8859_8_to_unicode (char *s, int length,
- /* Output */
- FriBidiChar *us);
+int fribidi_iso8859_8_to_unicode (char *s, int length,
+ /* Output */
+ FriBidiChar *us);
char fribidi_unicode_to_iso8859_8_c (FriBidiChar uch);
-int fribidix_unicode_to_iso8859_8 (FriBidiChar *us, int length,
- /* Output */
- char *s);
-
-/* Old style, just for compatibility. do not use these. */
-
-#define fribidi_iso8859_8_to_unicode(s, us) \
- fribidix_iso8859_8_to_unicode(s, strlen(s), us)
-
-#define fribidi_unicode_to_iso8859_8(us, length, s) \
- fribidix_unicode_to_iso8859_8(us, length, s)
+int fribidi_unicode_to_iso8859_8 (FriBidiChar *us, int length,
+ /* Output */
+ char *s);
#endif /* FRIBIDI_CHAR_SETS_ISO8859_8_H */
diff --git a/fribidi_char_sets_utf8.c b/fribidi_char_sets_utf8.c
index 9acd6f0..c8c3bfb 100644
--- a/fribidi_char_sets_utf8.c
+++ b/fribidi_char_sets_utf8.c
@@ -29,7 +29,7 @@
/* the following added by Raphael Finkel <raphael@cs.uky.edu> 12/1999 */
int
-fribidix_utf8_to_unicode (char *s, int len, FriBidiChar *us)
+fribidi_utf8_to_unicode (char *s, int len, FriBidiChar *us)
/* warning: the length of input string may exceed the length of the output */
{
int length;
@@ -64,7 +64,7 @@ fribidix_utf8_to_unicode (char *s, int len, FriBidiChar *us)
}
int
-fribidix_unicode_to_utf8 (FriBidiChar *us, int length, char *s)
+fribidi_unicode_to_utf8 (FriBidiChar *us, int length, char *s)
/* warning: the length of output string may exceed the length of the input */
{
int i;
diff --git a/fribidi_char_sets_utf8.h b/fribidi_char_sets_utf8.h
index 26b777b..250e577 100644
--- a/fribidi_char_sets_utf8.h
+++ b/fribidi_char_sets_utf8.h
@@ -27,7 +27,7 @@
#ifndef FRIBIDI_CHAR_SETS_UTF8_H
#define FRIBIDI_CHAR_SETS_UTF8_H
-#include "fribidi.h"
+#include "fribidi_types.h"
#define fribidi_char_set_name_utf8 "UTF-8"
#define fribidi_char_set_title_utf8 "UTF-8 (Unicode)"
@@ -35,24 +35,16 @@
#define fribidi_char_set_enter_utf8 NULL
#define fribidi_char_set_leave_utf8 NULL
-int fribidix_unicode_to_utf8 (FriBidiChar *us, int length,
- /* Output */
- char *s);
+int fribidi_unicode_to_utf8 (FriBidiChar *us, int length,
+ /* Output */
+ char *s);
/* warning: the length of output string may exceed the length of the input */
/* the length of the string is returned */
-int fribidix_utf8_to_unicode (char *s, int length,
- /* Output */
- FriBidiChar *us);
+int fribidi_utf8_to_unicode (char *s, int length,
+ /* Output */
+ FriBidiChar *us);
-/* Old style, just for compatibility. do not use these. */
-
-#define fribidi_utf8_to_unicode(s, us) \
- fribidix_utf8_to_unicode(s, strlen(s), us)
-
-#define fribidi_unicode_to_utf8(us, length, s) \
- fribidix_unicode_to_utf8(us, length, s)
-
-#endif /* FRIBIDI_CHAR_SETS_UTF8_H */
+#endif
#endif
diff --git a/fribidi_char_type.c b/fribidi_char_type.c
index e667526..0424897 100644
--- a/fribidi_char_type.c
+++ b/fribidi_char_type.c
@@ -29,16 +29,17 @@
*----------------------------------------------------------------------*/
FriBidiCharType fribidi_get_type (FriBidiChar uch);
-/*
- Files fribidi_tab_char_type_small.i and fribidi_tab_char_type_large.i
- should be created by make, they should be symbolic linked to other files
- named fribidi_tab_char_type_n.i, which n is a digit, between 2 and 9,
- if you do not these files (you didn't run make), link, or copy file
- fribidi_tab_char_type_2.i to fribidi_tab_char_type_large.i and
- fribidi_tab_char_type_9.i to fribidi_tab_char_type_small.i
- infact, smaller n causes to larger file, and vice versa, then you should
- choose least n for larger, and largest n for small.
-*/
+void
+fribidi_get_types ( /* input */
+ FriBidiChar *str, FriBidiStrIndex len,
+ /* output */
+ FriBidiCharType *type)
+{
+ FriBidiStrIndex i;
+
+ for (i = 0; i < len; i++)
+ type[i] = fribidi_get_type (str[i]);
+}
#ifdef MEM_OPTIMIZED
diff --git a/fribidi_create_char_types.c b/fribidi_create_char_types.c
index 7bc9a00..b427197 100644
--- a/fribidi_create_char_types.c
+++ b/fribidi_create_char_types.c
@@ -220,10 +220,9 @@ main (int argc, char **argv)
max_depth = atoi (argv[1]);
if (!max_depth)
err ("invalid depth");
- if (max_depth < 2)
- max_depth = 2;
- if (max_depth > 9)
- max_depth = 9;
+ if (max_depth < 2 || max_depth > 9)
+ err2 ("invalid max_depth `%s', max_depth should be between 2 and 9",
+ argv[1]);
sprintf (file, "fribidi_tab_char_type_%d.i", max_depth);
init_table ();
read_unicode_data ();
diff --git a/fribidi_main.c b/fribidi_main.c
index 87a49da..140246a 100644
--- a/fribidi_main.c
+++ b/fribidi_main.c
@@ -31,7 +31,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
-#include <wchar.h>
#include <string.h>
#ifdef FRIBIDI_NO_CHARSETS
#include <iconv.h>
@@ -42,8 +41,6 @@
#define appname "fribidi"
#define appversion VERSION
-int wcwidth (wchar_t ucs);
-
extern char *fribidi_version_info;
#define MAX_STR_LEN 65000
@@ -362,10 +359,10 @@ main (int argc, char *argv[])
while (fgets (S_, sizeof (S_) - 1, IN))
{
char *new_line, *nl_found;
- FriBidiChar logical[FRIBIDI_MAX_STRING_LENGTH];
+ FriBidiChar logical[MAX_STR_LEN];
char outstring[MAX_STR_LEN];
FriBidiCharType base;
- int len;
+ FriBidiStrIndex len;
nl_found = "";
S_[sizeof (S_) - 1] = 0;
@@ -383,27 +380,26 @@ main (int argc, char *argv[])
#ifdef FRIBIDI_NO_CHARSETS
{
char *st = S_, *ust = (char *) logical;
- int in_len = len;
+ int in_len = (int) len;
len = sizeof logical;
- iconv (to_ucs4, &st, &in_len, &ust, &len);
+ iconv (to_ucs4, &st, &in_len, &ust, (int *) &len);
len = (FriBidiChar *) ust - logical;
}
#else
- len =
- fribidix_charset_to_unicode (char_set_num, S_, len, logical);
+ len = fribidi_charset_to_unicode (char_set_num, S_, len, logical);
#endif
{
FriBidiChar *visual;
FriBidiStrIndex *ltov, *vtol;
- uint8 *levels;
- int new_len;
+ FriBidiLevel *levels;
+ FriBidiStrIndex new_len;
boolean log2vis;
visual = show_visual ? ALLOCATE (FriBidiChar, len + 1) : NULL;
ltov = show_ltov ? ALLOCATE (FriBidiStrIndex, len + 1) : NULL;
vtol = show_vtol ? ALLOCATE (FriBidiStrIndex, len + 1) : NULL;
- levels = show_levels ? ALLOCATE (uint8, len + 1) : NULL;
+ levels = show_levels ? ALLOCATE (FriBidiLevel, len + 1) : NULL;
/* Create a bidi string. */
base = input_base_direction;
@@ -418,6 +414,12 @@ main (int argc, char *argv[])
new_len = len;
+ /* Remove explicit marks, if asked for. */
+ if (do_clean)
+ len =
+ fribidi_remove_bidi_marks (visual, len, ltov, vtol,
+ levels);
+
if (show_visual)
{
printf (nl_found);
@@ -425,16 +427,12 @@ main (int argc, char *argv[])
if (bol_text)
printf ("%s", bol_text);
- /* Remove explicit marks, if asked for. */
- if (do_clean)
- len = fribidi_remove_explicits (visual, len);
-
/* Convert it to input charset and print. */
{
- int idx, st;
+ FriBidiStrIndex idx, st;
for (idx = 0; idx < len;)
{
- int wid, inlen;
+ FriBidiStrIndex wid, inlen;
wid = break_width;
st = idx;
@@ -442,7 +440,7 @@ main (int argc, char *argv[])
if (char_set_num != FRIBIDI_CHARSET_CAP_RTL)
#endif
while (wid > 0 && idx < len)
- wid -= wcwidth (visual[idx++]);
+ wid -= fribidi_wcwidth (visual[idx++]);
#ifndef FRIBIDI_NO_CHARSETS
else
while (wid > 0 && idx < len)
@@ -462,21 +460,23 @@ main (int argc, char *argv[])
int in_len = inlen * sizeof visual[0];
new_len = sizeof outstring;
iconv (from_ucs4, &ust, &in_len, &str,
- &new_len);
+ (int *) &new_len);
*str = '\0';
new_len = str - outstring;
}
#else
new_len =
- fribidix_unicode_to_charset (char_set_num,
- visual + st, inlen,
- outstring);
+ fribidi_unicode_to_charset (char_set_num,
+ visual + st, inlen,
+ outstring);
#endif
if (FRIBIDI_IS_RTL (base))
printf ("%*s",
- (int) (padding_width +
- strlen (outstring) -
- (break_width - wid)), outstring);
+ (int) (do_pad ? (padding_width +
+ strlen (outstring) -
+ (break_width -
+ wid)) : 0),
+ outstring);
else
printf ("%s", outstring);
if (idx < len)
@@ -497,34 +497,34 @@ main (int argc, char *argv[])
}
if (show_ltov)
{
- int i;
+ FriBidiStrIndex i;
printf (nl_found);
for (i = 0; i < len; i++)
- printf ("%d ", ltov[i]);
+ printf ("%ld ", (long) ltov[i]);
nl_found = "\n";
}
if (show_vtol)
{
- int i;
+ FriBidiStrIndex i;
printf (nl_found);
for (i = 0; i < len; i++)
- printf ("%d ", vtol[i]);
+ printf ("%ld ", (long) vtol[i]);
nl_found = "\n";
}
if (show_levels)
{
- int i;
+ FriBidiStrIndex i;
printf (nl_found);
for (i = 0; i < len; i++)
- printf ("%d ", levels[i]);
+ printf ("%d ", (int) levels[i]);
nl_found = "\n";
}
if (show_changes)
{
- int change_start, change_len;
+ FriBidiStrIndex change_start, change_len;
fribidi_find_string_changes (logical, len,
visual, new_len,
&change_start,
diff --git a/fribidi_types.h b/fribidi_types.h
index 8280f5a..0b72d11 100644
--- a/fribidi_types.h
+++ b/fribidi_types.h
@@ -25,8 +25,9 @@
#include "fribidi_mem.h"
+typedef int8 FriBidiLevel;
typedef uint32 FriBidiChar;
-typedef uint16 FriBidiStrIndex;
+typedef int FriBidiStrIndex;
typedef int32 FriBidiMaskType;
typedef FriBidiMaskType FriBidiCharType;
@@ -41,7 +42,9 @@ typedef struct
FriBidiRunType;
#ifndef FRIBIDI_MAX_STRING_LENGTH
-#define FRIBIDI_MAX_STRING_LENGTH (sizeof (FriBidiStrIndex) == 2 ? 0xFFF0L : 0xFFFFFFF0L)
+#define FRIBIDI_MAX_STRING_LENGTH (sizeof (FriBidiStrIndex) == 2 ? \
+ 0x7FFE : (sizeof (FriBidiStrIndex) == 1 ? \
+ 0x7E : 0x8FFFFFFEL))
#endif
diff --git a/fribidi_unicode.h b/fribidi_unicode.h
index ca8b6b7..aba927d 100644
--- a/fribidi_unicode.h
+++ b/fribidi_unicode.h
@@ -19,6 +19,8 @@
* For licensing issues, contact <fwpg@sharif.edu>.
*/
+#include "fribidi_types.h"
+
#ifndef FRIBIDI_UNICODE_H
#define FRIBIDI_UNICODE_H
@@ -49,4 +51,9 @@
#define UNI_ARABIC_ZERO 0x0660
#define UNI_FARSI_ZERO 0x06F0
+/* wcwidth functions */
+int fribidi_wcwidth (FriBidiChar ch);
+int fribidi_wcswidth (const FriBidiChar *str, FriBidiStrIndex len);
+int fribidi_wcswidth_cjk (const FriBidiChar *str, FriBidiStrIndex len);
+
#endif /* FRIBIDI_UNICODE_H */
diff --git a/fribidi_utils.c b/fribidi_utils.c
index 3bef5a4..f781cbe 100644
--- a/fribidi_utils.c
+++ b/fribidi_utils.c
@@ -50,7 +50,7 @@
* The selection is between logical characters 10 to 45. Calculate
* the corresponding visual selection(s):
*
- * int sel_span[2] = {10,45};
+ * FriBidiStrIndex sel_span[2] = {10,45};
*
* fribidi_map_range(sel_span,
* TRUE,
@@ -61,16 +61,17 @@
* &num_vis_ranges, *vis_ranges);
**----------------------------------------------------------------------*/
void
-fribidi_map_range (int in_span[2], /* Start and end span */
- int len, boolean is_v2l_map, /* Needed for embedding_level */
- FriBidiStrIndex *position_map, uint8 *embedding_level_list,
+fribidi_map_range (FriBidiStrIndex in_span[2], /* Start and end span */
+ FriBidiStrIndex len, boolean is_v2l_map, /* Needed for embedding_level */
+ FriBidiStrIndex *position_map,
+ FriBidiLevel *embedding_level_list,
/* output */
- int *num_mapped_spans, int mapped_spans[63][2])
+ int *num_mapped_spans, FriBidiStrIndex mapped_spans[63][2])
{
- int ch_idx;
+ FriBidiStrIndex ch_idx;
boolean in_range = FALSE;
- int start_idx = in_span[0];
- int end_idx = in_span[1];
+ FriBidiStrIndex start_idx = in_span[0];
+ FriBidiStrIndex end_idx = in_span[1];
if (start_idx == -1)
start_idx = 0;
@@ -83,7 +84,7 @@ fribidi_map_range (int in_span[2], /* Start and end span */
/* This is a loop in the source space of the map... */
for (ch_idx = 0; ch_idx <= len; ch_idx++)
{
- int mapped_pos;
+ FriBidiStrIndex mapped_pos;
if (ch_idx < len)
mapped_pos = position_map[ch_idx];
@@ -112,12 +113,13 @@ fribidi_map_range (int in_span[2], /* Start and end span */
void
fribidi_find_string_changes ( /* input */
FriBidiChar *old_str,
- int old_len, FriBidiChar *new_str, int new_len,
+ FriBidiStrIndex old_len, FriBidiChar *new_str,
+ FriBidiStrIndex new_len,
/* output */
- int *change_start, int *change_len)
+ FriBidiStrIndex *change_start,
+ FriBidiStrIndex *change_len)
{
- int i;
- int num_bol, num_eol;
+ FriBidiStrIndex i, num_bol, num_eol;
/* Search forwards */
i = 0;
@@ -187,21 +189,19 @@ fribidi_find_string_changes ( /* input */
*
*----------------------------------------------------------------------*/
void
-fribidi_xpos_resolve (int x_pos,
- int x_offset,
- int len,
- uint8 *embedding_level_list,
+fribidi_xpos_resolve (int x_pos, int x_offset, FriBidiStrIndex len,
+ FriBidiLevel *embedding_level_list,
FriBidiCharType base_dir,
FriBidiStrIndex *vis2log, int *char_widths,
/* output */
- int *res_log_pos,
- int *res_vis_pos,
+ FriBidiStrIndex *res_log_pos,
+ FriBidiStrIndex *res_vis_pos,
int *res_cursor_x_pos,
boolean *res_cursor_dir_is_rtl,
boolean *res_attach_before)
{
int char_width_sum = 0;
- int char_idx;
+ FriBidiStrIndex char_idx;
char_width_sum = 0;
*res_vis_pos = 0;
@@ -224,7 +224,7 @@ fribidi_xpos_resolve (int x_pos,
/* Find the cursor pos by a linear search on the row */
for (char_idx = 0; char_idx < len; char_idx++)
{
- int log_pos = vis2log[char_idx];
+ FriBidiStrIndex log_pos = vis2log[char_idx];
int char_width = char_widths[log_pos];
if (x_offset + char_width_sum + char_width > x_pos)
@@ -295,8 +295,8 @@ fribidi_xpos_resolve (int x_pos,
* if the embedding level for the character is odd.
*----------------------------------------------------------------------*/
boolean
-fribidi_is_char_rtl (uint8 *embedding_level_list,
- FriBidiCharType base_dir, int idx)
+fribidi_is_char_rtl (FriBidiLevel *embedding_level_list,
+ FriBidiCharType base_dir, FriBidiStrIndex idx)
{
if (!embedding_level_list || idx < 0)
return FRIBIDI_IS_RTL (base_dir);
@@ -313,15 +313,15 @@ fribidi_is_char_rtl (uint8 *embedding_level_list,
void
fribidi_runs_log2vis ( /* input */
FriBidiList *logical_runs, /* List of FriBidiRunType */
- int len, FriBidiStrIndex *log2vis, FriBidiCharType base_dir, /* TBD: remove it, not needed */
+ FriBidiStrIndex len, FriBidiStrIndex *log2vis, FriBidiCharType base_dir, /* TBD: remove it, not needed */
/* output */
FriBidiList **visual_runs)
{
void **visual_attribs = (void **) malloc (sizeof (void *) * len);
void *current_attrib;
- int pos, i;
+ FriBidiStrIndex pos, i;
FriBidiList *list, *last;
- int current_idx;
+ FriBidiStrIndex current_idx;
/* 1. Open up the runlength encoded list and at the same time apply
@@ -332,7 +332,7 @@ fribidi_runs_log2vis ( /* input */
while (list)
{
FriBidiRunType *run = (FriBidiRunType *) (list->data);
- int length = run->length;
+ FriBidiStrIndex length = run->length;
void *attrib = run->attribute;
for (i = pos; i < pos + length; i++)
diff --git a/wcwidth.c b/fribidi_wcwidth.c
index fcd31a4..b03f767 100644
--- a/wcwidth.c
+++ b/fribidi_wcwidth.c
@@ -6,10 +6,9 @@
* Markus Kuhn -- 2001-09-08 -- public domain
*/
-/* Added by Behdad Esfahbod <behdad@bamdad.org> */
-#include <stdlib.h>
+/* Modified by Behdad Esfahbod <behdad@bamdad.org> to use fribidi types*/
-#include <wchar.h>
+#include "fribidi.h"
struct interval
{
@@ -19,7 +18,7 @@ struct interval
/* auxiliary function for binary search in interval table */
static int
-bisearch (wchar_t ucs, const struct interval *table, int max)
+bisearch (FriBidiChar ucs, const struct interval *table, int max)
{
int min = 0;
int mid;
@@ -67,12 +66,10 @@ bisearch (wchar_t ucs, const struct interval *table, int max)
* ISO 8859-1 and WGL4 characters, Unicode control characters,
* etc.) have a column width of 1.
*
- * This implementation assumes that wchar_t characters are encoded
- * in ISO 10646.
*/
int
-wcwidth (wchar_t ucs)
+fribidi_wcwidth (FriBidiChar ucs)
{
/* sorted list of non-overlapping intervals of non-spacing characters */
static const struct interval combining[] = {
@@ -137,12 +134,12 @@ wcwidth (wchar_t ucs)
int
-wcswidth (const wchar_t * pwcs, size_t n)
+fribidi_wcswidth (const FriBidiChar *pwcs, FriBidiStrIndex n)
{
int w, width = 0;
for (; *pwcs && n-- > 0; pwcs++)
- if ((w = wcwidth (*pwcs)) < 0)
+ if ((w = fribidi_wcwidth (*pwcs)) < 0)
return -1;
else
width += w;
@@ -160,7 +157,7 @@ wcswidth (const wchar_t * pwcs, size_t n)
* recommended for general use.
*/
static int
-wcwidth_cjk (wchar_t ucs)
+wcwidth_cjk (FriBidiChar ucs)
{
/* sorted list of non-overlapping intervals of East Asian Ambiguous
* characters */
@@ -225,12 +222,12 @@ wcwidth_cjk (wchar_t ucs)
sizeof (ambiguous) / sizeof (struct interval) - 1))
return 2;
- return wcwidth (ucs);
+ return fribidi_wcwidth (ucs);
}
int
-wcswidth_cjk (const wchar_t * pwcs, size_t n)
+fribidi_wcswidth_cjk (const FriBidiChar *pwcs, FriBidiStrIndex n)
{
int w, width = 0;
diff --git a/getopt.c b/getopt.c
index a619e96..db334c2 100644
--- a/getopt.c
+++ b/getopt.c
@@ -422,8 +422,8 @@ _getopt_initialize (argc, argv, optstring)
ordering = PERMUTE;
#ifdef _LIBC
- if (posixly_correct == NULL
- && argc == original_argc && argv == original_argv)
+ if (posixly_correct == NULL && argc == original_argc
+ && argv == original_argv)
{
if (nonoption_flags_max_len == 0)
{