summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbehdad <behdad>2002-03-15 15:47:31 +0000
committerbehdad <behdad>2002-03-15 15:47:31 +0000
commit795dbd72617c0a57f7021ed30ce05e6a73effd08 (patch)
treec83b68b8cac0b034af5b3986170802e4da937790
parent11c4b13eade76a25df7cb86333c477c53c1d4807 (diff)
Rule L3 implemented.
-rw-r--r--AUTHORS2
-rw-r--r--ChangeLog13
-rw-r--r--NEWS16
-rw-r--r--TODO4
-rw-r--r--configure.in8
-rw-r--r--fribidi.c68
-rw-r--r--fribidi.h16
-rw-r--r--fribidi_main.c19
8 files changed, 123 insertions, 23 deletions
diff --git a/AUTHORS b/AUTHORS
index 3a55084..1bc52f5 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -34,3 +34,5 @@ Markus Kuhn <Markus.Kuhn@cl.cam.ac.uk>
Abel Cheung <maddog@linux.org.hk>
* Implemented pkgconfig support.
+Dominique Unruh <dominique@unruh.de>
+ * Contributed a patch for reordering NSMs (rule L3).
diff --git a/ChangeLog b/ChangeLog
index 13a5868..de6fa32 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2002-03-15 Behdad Esfahbod <behdad@bamdad.org>
+ * fribidi.c, fribidi.h: Applied the patch from
+ Dominique Unruh <dominique@unruh.de> to reorder the NSM character
+ to follow their base character (rule L3), fribidi_reorder_nsm_status(),
+ fribidi_set_reorder_nsm() added.
+ * fribidi_main.c: Option --reordernsm added, also --test sets
+ --reordernsm.
+ * TODO: Done task for rule L3 removed.
+ * AUTHORS: Dominique Unruh <dominique@unruh.de> added.
+ * tests/test_UTF-8_nsmreorder.input,
+ tests/test_UTF-8_nsmreorder.reference: Added.
+ * NEWS: Updated, will be used to reflect each release News.
+
2002-03-12 Behdad Esfahbod <behdad@bamdad.org>
* fribidi.spec.in: Small cleanup.
diff --git a/NEWS b/NEWS
index 14dbae8..f2514c7 100644
--- a/NEWS
+++ b/NEWS
@@ -1,11 +1,15 @@
-See ChangeLog.
+New in 0.10.2:
-fribidi.spec has bee added to CVS, please use this file if you are
-going to create an RPM package from fribidi.
+* Rule L3 of UAX#9 implemented. Now fribidi implements the whole Unicode
+ BiDi Algorithm.
-Fribidi tested on sourceforge.net's compile farm.
+New in 0.10.1:
-Currently tested and has no problem with:
+* fribidi.spec has been added to distribution, please use this file if you
+ are going to create an RPM package from fribidi.
+
+* Fribidi tested on sourceforge.net's compile farm.
+ Currently tested and has no problem with:
[x86] Linux 2.4 (RedHat 7.1)
[x86] Linux 2.2 (Debian 2.2)
@@ -15,3 +19,5 @@ Currently tested and has no problem with:
[Sparc - Ultra60] Linux 2.2 (Debian 2.2)
[Sparc - R220] Sun Solaris (8)
[x86] Windows 2000 (Cygwin)
+
+See ChangeLog for more descriptive list of changes.
diff --git a/TODO b/TODO
index b5c03fc..aed3d24 100644
--- a/TODO
+++ b/TODO
@@ -23,7 +23,7 @@ Implementation issues:
* Fix iconv problem: Check for old iconvs (without wchar_t, without
byteorder UTF-32 or UCS-4 types).
-* When there is no glibc, libiconvs should be linked when --without-charset
+* When there is no glibc, libiconv should be linked when --without-charset
is enabled.
* Design better apis to do reorder based on available levels, remove
@@ -37,7 +37,7 @@ Implementation issues:
BiDi algorithms issues:
-* Handle the L3 rule.
+*
General issues:
diff --git a/configure.in b/configure.in
index 0f6ee5f..d37c1f0 100644
--- a/configure.in
+++ b/configure.in
@@ -9,7 +9,7 @@ AC_INIT(fribidi.c)
# FRIBIDI_BINARY_AGE++;
# FRIBIDI_RPM_RELEASE = 0;
#
-# If any functions have been added:
+# If any major functions have been added:
# FRIBIDI_INTERFACE_AGE = 0;
# FRIBIDI_INTERFACE_VERSION++;
#
@@ -21,10 +21,10 @@ AC_INIT(fribidi.c)
#
FRIBIDI_MAJOR_VERSION=0
FRIBIDI_MINOR_VERSION=10
-FRIBIDI_MICRO_VERSION=1post
+FRIBIDI_MICRO_VERSION=2
FRIBIDI_INTERFACE_VERSION=2
-FRIBIDI_INTERFACE_AGE=1
-FRIBIDI_BINARY_AGE=1
+FRIBIDI_INTERFACE_AGE=2
+FRIBIDI_BINARY_AGE=2
FRIBIDI_RPM_RELEASE=0
FRIBIDI_VERSION=$FRIBIDI_MAJOR_VERSION.$FRIBIDI_MINOR_VERSION.$FRIBIDI_MICRO_VERSION
diff --git a/fribidi.c b/fribidi.c
index 74928c8..f28a5a5 100644
--- a/fribidi.c
+++ b/fribidi.c
@@ -1083,6 +1083,20 @@ fribidi_set_mirroring (boolean mirror)
mirroring = mirror;
}
+static boolean reorder_nsm = FALSE;
+
+boolean
+fribidi_reorder_nsm_status (void)
+{
+ return reorder_nsm;
+}
+
+void
+fribidi_set_reorder_nsm (boolean reorder)
+{
+ reorder_nsm = reorder;
+}
+
/*======================================================================
* Here starts the exposed front end functions.
*----------------------------------------------------------------------*/
@@ -1169,7 +1183,7 @@ fribidi_log2vis ( /* input */
return TRUE;
}
- /* If l2v is to be calculated we must have l2v as well. If it is not
+ /* If l2v is to be calculated we must have v2l as well. If it is not
given by the caller, we have to make a private instance of it. */
if (position_L_to_V_list && !position_V_to_L_list)
{
@@ -1182,7 +1196,7 @@ fribidi_log2vis ( /* input */
{
#ifdef DEBUG
fprintf (stderr, "%s: cannot handle strings > %ld characters\n",
- FRIBIDI_PACKAGE, FRIBIDI_MAX_STRING_LENGTH);
+ FRIBIDI_PACKAGE, (long) FRIBIDI_MAX_STRING_LENGTH);
#endif
return FALSE;
}
@@ -1196,8 +1210,6 @@ fribidi_log2vis ( /* input */
FriBidiLevel level_idx;
FriBidiStrIndex i;
- /* TBD: L3 */
-
/* Set up the ordering array to sorted order */
if (position_V_to_L_list)
{
@@ -1258,6 +1270,54 @@ fribidi_log2vis ( /* input */
DBG (" Mirroring, Done\n");
}
+ if (reorder_nsm)
+ {
+ /* L3. Reorder NSMs. */
+ DBG (" Reordering NSM sequences\n");
+ /* We apply this rule before L2, so go backward in odd levels. */
+ for (pp = type_rl_list->next; pp->next; pp = pp->next)
+ {
+ if (pp->level & 1)
+ {
+ FriBidiStrIndex i;
+ boolean is_nsm_seq, seq_end;
+
+ is_nsm_seq = 0;
+ for (i = RL_POS (pp) + RL_LEN (pp) - 1; i >= RL_POS (pp); i--)
+ {
+ FriBidiCharType this_type;
+
+ this_type = fribidi_get_type (visual_str[i]);
+ if (is_nsm_seq && this_type != FRIBIDI_TYPE_NSM)
+ {
+ if (visual_str)
+ {
+ bidi_string_reverse (visual_str + i,
+ seq_end - i + 1);
+ }
+ if (position_V_to_L_list)
+ {
+ index_array_reverse (position_V_to_L_list + i,
+ seq_end - i + 1);
+ }
+ is_nsm_seq = 0;
+ }
+ else if (!is_nsm_seq && this_type == FRIBIDI_TYPE_NSM)
+ {
+ seq_end = i;
+ is_nsm_seq = 1;
+ }
+ }
+ if (is_nsm_seq)
+ {
+ DBG
+ ("Warning: NSMs at the beggining of run level.\n");
+ }
+ }
+ }
+ DBG (" Reordering NSM sequences, Done\n");
+ }
+
/* L2. Reorder. */
DBG (" Reordering\n");
for (level_idx = max_level; level_idx > 0; level_idx--)
diff --git a/fribidi.h b/fribidi.h
index fb84f13..85230f9 100644
--- a/fribidi.h
+++ b/fribidi.h
@@ -97,12 +97,24 @@ extern "C"
boolean fribidi_mirroring_status (void);
/*======================================================================
- * fribidi_set_mirroring() sets mirroring on or off,
+ * fribidi_set_mirroring() sets mirroring on or off.
*----------------------------------------------------------------------*/
void fribidi_set_mirroring (boolean mirror);
/*======================================================================
- * fribidi_set_debug() turn on or off debugging, default is off.
+ * fribidi_reorder_nsm_status() returns whether reordering of NSM
+ * sequences is on or off, default is off.
+ *----------------------------------------------------------------------*/
+ boolean fribidi_reorder_nsm_status (void);
+
+/*======================================================================
+ * fribidi_set_reorder_nsm() sets reordering of NSM characters on or off.
+ *----------------------------------------------------------------------*/
+ void fribidi_set_reorder_nsm (boolean);
+
+/*======================================================================
+ * fribidi_set_debug() turn on or off debugging, default is off, return
+ * false is fribidi is not compiled with debug enabled.
*----------------------------------------------------------------------*/
boolean fribidi_set_debug (boolean debug);
diff --git a/fribidi_main.c b/fribidi_main.c
index 6dffe92..430adf8 100644
--- a/fribidi_main.c
+++ b/fribidi_main.c
@@ -62,7 +62,8 @@ die (char *fmt, ...)
exit (-1);
}
-boolean do_break, do_pad, do_mirror, do_clean, show_input, show_changes;
+boolean do_break, do_pad, do_mirror, do_reorder_nsm, do_clean, show_input,
+ show_changes;
boolean show_visual, show_basedir, show_ltov, show_vtol, show_levels;
int text_width;
char *char_set;
@@ -87,7 +88,8 @@ help (void)
" -v, --verbose Verbose mode, same as --basedir --ltov --vtol \\\n"
" --levels --changes\n"
" -d, --debug Output debug information\n"
- " -t, --test Test %s, same as --clean --nobreak --showinput\n",
+ " -t, --test Test %s, same as --clean --nobreak --showinput \\\n"
+ " --reordernsm\n",
FRIBIDI_PACKAGE);
#ifdef FRIBIDI_NO_CHARSETS
printf (" -c, --charset CS Specify character set, default is %s \\\n"
@@ -116,12 +118,13 @@ help (void)
(" --wltr Set base direction to LTR if no strong character found \\\n"
" (default)\n"
" --nomirror Turn mirroring off, to do it later\n"
+ " --reordernsm Reorder NSM sequences to follow their base character\n"
" --clean Remove explicit format codes in visual string \\\n"
" output, currently does not affect other outputs\n"
- " --basedir Output Base Direction\n"
- " --ltov Output Logical to Visual position map\n"
- " --vtol Output Visual to Logical position map\n");
- printf (" --levels Output Embedding Levels\n"
+ " --basedir Output Base Direction\n");
+ printf (" --ltov Output Logical to Visual position map\n"
+ " --vtol Output Visual to Logical position map\n"
+ " --levels Output Embedding Levels\n"
" --changes Output information about changes between \\\n"
" logical and visual string (start, length)\n"
" --novisual Do not output the visual string, to be used with \\\n"
@@ -169,6 +172,7 @@ main (int argc, char *argv[])
do_pad = TRUE;
do_mirror = TRUE;
do_clean = FALSE;
+ do_reorder_nsm = FALSE;
show_input = FALSE;
show_visual = TRUE;
show_basedir = FALSE;
@@ -217,6 +221,7 @@ main (int argc, char *argv[])
{"bol", 1, 0, 'B'},
{"eol", 1, 0, 'E'},
{"nomirror", 0, &do_mirror, FALSE},
+ {"reordernsm", 0, &do_reorder_nsm, TRUE},
{"clean", 0, &do_clean, TRUE},
{"ltr", 0, (int *) &input_base_direction, FRIBIDI_TYPE_L},
{"rtl", 0, (int *) &input_base_direction, FRIBIDI_TYPE_R},
@@ -275,6 +280,7 @@ main (int argc, char *argv[])
do_clean = TRUE;
show_input = TRUE;
do_break = FALSE;
+ do_reorder_nsm = TRUE;
break;
case 'c':
char_set = strdup (optarg);
@@ -322,6 +328,7 @@ main (int argc, char *argv[])
die ("unrecognized character set `%s'\n", char_set);
fribidi_set_mirroring (do_mirror);
+ fribidi_set_reorder_nsm (do_reorder_nsm);
exit_val = 0;
file_found = FALSE;
while (optind < argc || !file_found)