[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Collation patch.
From: |
Valeriy E. Ushakov |
Subject: |
Collation patch. |
Date: |
Tue, 15 Jul 1997 21:46:46 +0400 (MSD) |
Well, to break the silence.
English users - don't bother - you probably don't need this :-)
The following is a patch I've already sent to Jeff for inclusion in
the next version of lout. It adds locale abiding collation. It would
be a good idea though if as many people as possible will try it before
the code is merged into mainstream distribution.
Apply the patch, add -DCOLLATE to C compiler flags and recompile.
NOTE WELL: If you run lout several times with different collation in
effect -- you loose.
The patch also fixes a minor bug in z37.c that caused trouble with
zero width characters. I tripped over this while playing with
devanagari (or tibetan, my memory is hazy). You'll probably never see
this bug with fonts for latin/cyrillic alphabets.
Please send you comments, suggestions, bug reports and fixes related
to this patch to *me* (not to Jeff or to the list).
Happy louting.
--- externs~ Sat Nov 30 14:19:01 1996
+++ externs Fri Feb 7 21:20:04 1997
@@ -31,8 +31,11 @@
#include <string.h>
#include <stdarg.h>
-#if LOCALE_ON
+#if LOCALE_ON || COLLATE
#include <locale.h>
+#endif
+
+#if LOCALE_ON
#include <nl_types.h>
extern nl_catd MsgCat;
#define condcatgets(cat, set, msg, s) catgets(cat, set, msg, s)
--- z01.c~ Sun Nov 17 15:57:38 1996
+++ z01.c Fri Feb 7 21:20:29 1997
@@ -230,6 +230,11 @@
MsgCat = catopen(catname, 0);
#endif
+#if COLLATE
+ if (!setlocale (LC_COLLATE, ""))
+ Error(1, 6, "unable to initialize collation", WARN, no_fpos);
+#endif /* COLLATE */
+
/* initialise various modules, add current directory to search paths */
BackEnd = POSTSCRIPT;
BackEndWord = STR_POSTSCRIPT;
--- z37.c~ Thu Nov 14 13:18:50 1996
+++ z37.c Tue Jan 14 13:35:44 1997
@@ -516,7 +516,7 @@
fnt[ch].right = wx;
fnt[ch].up = ury - xheight2;
fnt[ch].last_adjust =
- (urx == 0 || fixed_pitch) ? 0 : urx - wx;
+ (urx == 0 || wx == 0 || fixed_pitch) ? 0 :
urx - wx;
break;
case PLAINTEXT: fnt[ch].left = 0;
--- z45.c~ Sun Nov 17 14:32:24 1996
+++ z45.c Fri Feb 7 21:20:43 1997
@@ -61,7 +61,7 @@
/* from system.h */
-#include <string.h>
+#include <string.h> /* uwe: it also gives us strcoll() */
/* already included in externs #include <stdlib.h> */
#include <ctype.h>
@@ -352,6 +352,27 @@
buf->left = lim - beg;
}
+
+#if COLLATE
+/* Compare two lines A and B, returning negative, zero, or positive
+ depending on whether A compares less than, equal to, or greater than B. */
+
+static int
+compare (a, b)
+ register struct line *a, *b;
+{
+ int diff, tmpa, tmpb, mini;
+
+ tmpa = a->length, tmpb = b->length;
+ mini = min (tmpa, tmpb);
+ if (mini == 0)
+ return tmpa - tmpb;
+
+ return strcoll (a->text, b->text);
+}
+
+#else /* !COLLATE -- good old ASCIIbetical order */
+
/* Compare two lines A and B, returning negative, zero, or positive
depending on whether A compares less than, equal to, or greater than B. */
@@ -380,6 +401,7 @@
return diff;
}
+#endif /* !COLLATE */
/* Sort the array LINES with NLINES members, using TEMP for temporary space. */
SY, Uwe
--
address@hidden | Zu Grunde kommen
http://www.ptc.spbu.ru/~uwe/ | Ist zu Grunde gehen
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Collation patch.,
Valeriy E. Ushakov <=