summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/luatexdir/lang
diff options
context:
space:
mode:
authorPeter Breitenlohner <peb@mppmu.mpg.de>2013-03-21 09:16:59 +0000
committerPeter Breitenlohner <peb@mppmu.mpg.de>2013-03-21 09:16:59 +0000
commit388463b9fa865c3b2311508c41647b0f3c532031 (patch)
tree1cdfbf5552d0783ecbcc52017e49567e5042af33 /Build/source/texk/web2c/luatexdir/lang
parentabd0b00a4e8c1ac6f5b20c7474d70ef579129991 (diff)
Import MetaPost 1.800 and LuaTeX beta-0.75.0 from LuaTeX repository r4604
git-svn-id: svn://tug.org/texlive/trunk@29453 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/luatexdir/lang')
-rw-r--r--Build/source/texk/web2c/luatexdir/lang/hnjalloc.w26
-rw-r--r--Build/source/texk/web2c/luatexdir/lang/hyphen.w142
-rw-r--r--Build/source/texk/web2c/luatexdir/lang/texlang.w125
3 files changed, 110 insertions, 183 deletions
diff --git a/Build/source/texk/web2c/luatexdir/lang/hnjalloc.w b/Build/source/texk/web2c/luatexdir/lang/hnjalloc.w
index da1f04a6b55..91fefec9e5d 100644
--- a/Build/source/texk/web2c/luatexdir/lang/hnjalloc.w
+++ b/Build/source/texk/web2c/luatexdir/lang/hnjalloc.w
@@ -1,38 +1,40 @@
+% hnjalloc.w
+%
% LibHnj is dual licensed under LGPL and MPL. Boilerplate for both
% licenses follows.
-%
-%
+%
+%
% LibHnj - a library for high quality hyphenation and justification
% Copyright (C) 1998 Raph Levien, (C) 2001 ALTLinux, Moscow
-%
+%
% This library is free software; you can redistribute it and/or
% modify it under the terms of the GNU Library General Public
% License as published by the Free Software Foundation; either
% version 2 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
% Library General Public License for more details.
-%
+%
% You should have received a copy of the GNU Library General Public
-% License along with this library; if not, write to the
-% Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+% License along with this library; if not, write to the
+% Free Software Foundation, Inc., 59 Temple Place - Suite 330,
% Boston, MA 02111-1307 USA.
-%
-%
-%
+%
+%
+%
% The contents of this file are subject to the Mozilla Public License
% Version 1.0 (the "MPL"); you may not use this file except in
% compliance with the MPL. You may obtain a copy of the MPL at
% http://www.mozilla.org/MPL/
-%
+%
% Software distributed under the MPL is distributed on an "AS IS" basis,
% WITHOUT WARRANTY OF ANY KIND, either express or implied. See the MPL
% for the specific language governing rights and limitations under the
% MPL.
-@ wrappers for malloc
+@ wrappers for malloc
@c
#include <stdlib.h>
diff --git a/Build/source/texk/web2c/luatexdir/lang/hyphen.w b/Build/source/texk/web2c/luatexdir/lang/hyphen.w
index a5ad227d740..3188473c446 100644
--- a/Build/source/texk/web2c/luatexdir/lang/hyphen.w
+++ b/Build/source/texk/web2c/luatexdir/lang/hyphen.w
@@ -1,34 +1,36 @@
+% hyphen.w
+%
% Libhnj is dual licensed under LGPL and MPL. Boilerplate for both
% licenses follows.
-%
-%
+%
+%
% LibHnj - a library for high quality hyphenation and justification
-% Copyright (C) 1998 Raph Levien,
-% (C) 2001 ALTLinux, Moscow (http://www.alt-linux.org),
+% Copyright (C) 1998 Raph Levien,
+% (C) 2001 ALTLinux, Moscow (http://www.alt-linux.org),
% (C) 2001 Peter Novodvorsky (nidd@@cs.msu.su)
-%
+%
% This library is free software; you can redistribute it and/or
% modify it under the terms of the GNU Library General Public
% License as published by the Free Software Foundation; either
% version 2 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
% Library General Public License for more details.
-%
+%
% You should have received a copy of the GNU Library General Public
-% License along with this library; if not, write to the
-% Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+% License along with this library; if not, write to the
+% Free Software Foundation, Inc., 59 Temple Place - Suite 330,
% Boston, MA 02111-1307 USA.
-%
-%
-%
+%
+%
+%
% The contents of this file are subject to the Mozilla Public License
% Version 1.0 (the "MPL"); you may not use this file except in
% compliance with the MPL. You may obtain a copy of the MPL at
% http://www.mozilla.org/MPL/
-%
+%
% Software distributed under the MPL is distributed on an "AS IS" basis,
% WITHOUT WARRANTY OF ANY KIND, either express or implied. See the MPL
% for the specific language governing rights and limitations under the
@@ -36,6 +38,10 @@
@ @c
+static const char _svn_version[] =
+ "$Id: hyphen.w 4599 2013-03-19 15:41:07Z taco $ "
+ "$URL: https://foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/lang/hyphen.w $";
+
#include <stdlib.h> /* for NULL, malloc */
#include <stdio.h> /* for fprintf */
#include <string.h> /* for strdup */
@@ -54,11 +60,6 @@
#include "lang/hnjalloc.h"
#include "lang/hyphen.h"
-@ @c
-static const char _svn_version[] =
- "$Id: hyphen.w 3831 2010-08-25 04:35:34Z taco $ "
-"$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.66.0/source/texk/web2c/luatexdir/lang/hyphen.w $";
-
@ TODO: should be moved to separate library
@c
@@ -74,13 +75,6 @@ static unsigned char *hnj_strdup(const unsigned char *s)
return new;
}
-static int is_utf8_follow(unsigned char c)
-{
- if (c >= 0x80 && c < 0xC0)
- return 1;
- return 0;
-}
-
@* Type definitions.
@ a little bit of a hash table implementation. This simply maps strings
@@ -589,7 +583,6 @@ for a hyphenation point between characters
void hnj_hyphen_load(HyphenDict * dict, const unsigned char *f)
{
int state_num, last_state;
- int i, j = 0;
int ch;
int found;
HashEntry *e;
@@ -603,7 +596,7 @@ void hnj_hyphen_load(HyphenDict * dict, const unsigned char *f)
unsigned char *pat;
char *org;
while ((format = next_pattern(&l, &f)) != NULL) {
- int i, j, e;
+ int i, j, e1;
if (l>=255) {
help1("Individual patterns should not be longer than 254 bytes total.");
print_err("Pattern of enormous length ignored");
@@ -633,31 +626,31 @@ void hnj_hyphen_load(HyphenDict * dict, const unsigned char *f)
repl = hnj_strdup(repl + 1);
}
#endif
- for (i = 0, j = 0, e = 0; (unsigned) i < l; i++) {
+ for (i = 0, j = 0, e1 = 0; (unsigned) i < l; i++) {
if (format[i] >= '0' && format[i] <= '9')
j++;
if (is_utf8_follow(format[i]))
- e++;
+ e1++;
}
- /* |l-e| => number of {\it characters} not {\it bytes} */
+ /* |l-e1| => number of {\it characters} not {\it bytes} */
/* |l-j| => number of pattern bytes */
- /* |l-e-j| => number of pattern characters */
+ /* |l-e1-j| => number of pattern characters */
pat = (unsigned char *) malloc((1 + l - (size_t) j));
- org = (char *) malloc((size_t) (2 + l - (size_t) e - (size_t) j));
+ org = (char *) malloc((size_t) (2 + l - (size_t) e1 - (size_t) j));
/* remove hyphenation encoders (digits) from pat */
org[0] = '0';
- for (i = 0, j = 0, e = 0; (unsigned) i < l; i++) {
+ for (i = 0, j = 0, e1 = 0; (unsigned) i < l; i++) {
unsigned char c = format[i];
if (is_utf8_follow(c)) {
- pat[j + e++] = c;
+ pat[j + e1++] = c;
} else if (c < '0' || c > '9') {
- pat[e + j++] = c;
+ pat[e1 + j++] = c;
org[j] = '0';
} else {
org[j] = (char) c;
}
}
- pat[e + j] = 0;
+ pat[e1 + j] = 0;
org[j + 1] = 0;
hyppat_insert(dict->patterns, pat, org);
}
@@ -666,31 +659,31 @@ void hnj_hyphen_load(HyphenDict * dict, const unsigned char *f)
v = new_HashIter(dict->patterns);
while (nextHash(v, &word)) {
int wordsize = (int) strlen((char *) word);
- int j, l;
- for (l = 1; l <= wordsize; l++) {
- if (is_utf8_follow(word[l]))
+ int j1, l1;
+ for (l1 = 1; l1 <= wordsize; l1++) {
+ if (is_utf8_follow(word[l1]))
continue; /* Do not clip an utf8 sequence */
- for (j = 1; j <= l; j++) {
+ for (j1 = 1; j1 <= l1; j1++) {
char *subpat_pat;
- int i = l - j;
- if (is_utf8_follow(word[i]))
+ int i1 = l1 - j1;
+ if (is_utf8_follow(word[i1]))
continue; /* Do not start halfway an utf8 sequence */
if ((subpat_pat =
- hyppat_lookup(dict->patterns, word + i, j)) != NULL) {
+ hyppat_lookup(dict->patterns, word + i1, j1)) != NULL) {
char *newpat_pat;
if ((newpat_pat =
- hyppat_lookup(dict->merged, word, l)) == NULL) {
+ hyppat_lookup(dict->merged, word, l1)) == NULL) {
char *neworg;
unsigned char *newword =
- (unsigned char *) malloc((size_t) (l + 1));
- int e = 0;
- strncpy((char *) newword, (char *) word, (size_t) l);
- newword[l] = 0;
- for (i = 0; i < l; i++)
- if (is_utf8_follow(newword[i]))
- e++;
- neworg = malloc((size_t) (l + 2 - e));
- sprintf(neworg, "%0*d", l + 1 - e, 0); /* fill with right amount of '0' */
+ (unsigned char *) malloc((size_t) (l1 + 1));
+ int e1 = 0;
+ strncpy((char *) newword, (char *) word, (size_t) l1);
+ newword[l1] = 0;
+ for (i1 = 0; i1 < l1; i1++)
+ if (is_utf8_follow(newword[i1]))
+ e1++;
+ neworg = malloc((size_t) (l1 + 2 - e1));
+ sprintf(neworg, "%0*d", l1 + 1 - e1, 0); /* fill with right amount of '0' */
hyppat_insert(dict->merged, newword,
combine(neworg, subpat_pat));
} else {
@@ -707,31 +700,31 @@ void hnj_hyphen_load(HyphenDict * dict, const unsigned char *f)
v = new_HashIter(dict->merged);
while (nextHashStealPattern(v, &word, &pattern)) {
static unsigned char mask[] = { 0x3F, 0x1F, 0xF, 0x7 };
- int j = (int) strlen((char *) word);
+ int j1 = (int) strlen((char *) word);
#ifdef VERBOSE
- printf("word %s pattern %s, j = %d\n", word, pattern, j);
+ printf("word %s pattern %s, j = %d\n", word, pattern, j1);
#endif
state_num = hnj_get_state(dict, word, &found);
dict->states[state_num].match = pattern;
/* now, put in the prefix transitions */
while (found < 0) {
- j--;
+ j1--;
last_state = state_num;
- ch = word[j];
+ ch = word[j1];
if (ch >= 0x80) {
int m;
- int i = 1;
- while (is_utf8_follow(word[j - i]))
- i++;
- ch = word[j - i] & mask[i];
- m = j - i;
- while (i--) {
- ch = (ch << 6) + (0x3F & word[j - i]);
+ int i1 = 1;
+ while (is_utf8_follow(word[j1 - i1]))
+ i1++;
+ ch = word[j1 - i1] & mask[i1];
+ m = j1 - i1;
+ while (i1--) {
+ ch = (ch << 6) + (0x3F & word[j1 - i1]);
}
- j = m;
+ j1 = m;
}
- word[j] = '\0';
+ word[j1] = '\0';
state_num = hnj_get_state(dict, word, &found);
hnj_add_trans(dict, state_num, last_state, ch);
}
@@ -740,6 +733,8 @@ void hnj_hyphen_load(HyphenDict * dict, const unsigned char *f)
clear_hyppat_hash(&dict->merged);
/* put in the fallback states */
+ {
+ int i, j = 0;
for (i = 0; i < HASH_SIZE; i++) {
for (e = dict->state_num->entries[i]; e; e = e->next) {
/* do not do state==0 otherwise things get confused */
@@ -766,13 +761,14 @@ void hnj_hyphen_load(HyphenDict * dict, const unsigned char *f)
}
}
#endif
+ }
clear_state_hash(&dict->state_num);
}
@ @c
void hnj_hyphen_hyphenate(HyphenDict * dict,
- halfword first,
- halfword last,
+ halfword first1,
+ halfword last1,
int length,
halfword left, halfword right, lang_variables * lan)
{
@@ -785,9 +781,9 @@ void hnj_hyphen_hyphenate(HyphenDict * dict,
char *hyphens = hnj_malloc(hyphen_len + 1);
/* Add a '.' to beginning and end to facilitate matching */
- set_vlink(begin_point, first);
- set_vlink(end_point, get_vlink(last));
- set_vlink(last, end_point);
+ set_vlink(begin_point, first1);
+ set_vlink(end_point, get_vlink(last1));
+ set_vlink(last1, end_point);
for (char_num = 0; char_num < hyphen_len; char_num++) {
hyphens[char_num] = '0';
@@ -847,12 +843,12 @@ void hnj_hyphen_hyphenate(HyphenDict * dict,
}
/* restore the correct pointers */
- set_vlink(last, get_vlink(end_point));
+ set_vlink(last1, get_vlink(end_point));
/* pattern is \.{\^.\^w\^o\^r\^d\^.\^} |word_len|=4, |ext_word_len|=6, |hyphens|=7
* check \.{ \^ \^ \^ } so drop first two and stop after |word_len-1|
*/
- for (here = first, char_num = 2; here != left; here = get_vlink(here))
+ for (here = first1, char_num = 2; here != left; here = get_vlink(here))
char_num++;
for (; here != right; here = get_vlink(here)) {
if (hyphens[char_num] & 1)
diff --git a/Build/source/texk/web2c/luatexdir/lang/texlang.w b/Build/source/texk/web2c/luatexdir/lang/texlang.w
index 01081c02326..d5c06819df1 100644
--- a/Build/source/texk/web2c/luatexdir/lang/texlang.w
+++ b/Build/source/texk/web2c/luatexdir/lang/texlang.w
@@ -1,110 +1,39 @@
% texlang.w
-%
-% Copyright 2006-2010 Taco Hoekwater <taco@@luatex.org>
-
+%
+% Copyright 2006-2012 Taco Hoekwater <taco@@luatex.org>
+%
% This file is part of LuaTeX.
-
+%
% LuaTeX is free software; you can redistribute it and/or modify it under
% the terms of the GNU General Public License as published by the Free
% Software Foundation; either version 2 of the License, or (at your
% option) any later version.
-
+%
% LuaTeX 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 General Public License along
% with LuaTeX; if not, see <http://www.gnu.org/licenses/>.
@ @c
-#include "ptexlib.h"
+static const char _svn_version[] =
+ "$Id: texlang.w 4599 2013-03-19 15:41:07Z taco $"
+ "$URL: https://foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/lang/texlang.w $";
+#include "ptexlib.h"
#include <string.h>
-
#include "lua/luatex-api.h"
-
-static const char _svn_version[] =
- "$Id: texlang.w 3907 2010-10-04 09:02:29Z taco $ "
-"$URL: http://foundry.supelec.fr/svn/luatex/tags/beta-0.66.0/source/texk/web2c/luatexdir/lang/texlang.w $";
-
-
@ Low-level helpers
-@c
-#define ex_hyphen_char int_par(ex_hyphen_char_code)
-static char *uni2string(char *utf8_text, unsigned ch)
-{
- /* Increment and deposit character */
- if (ch >= 17 * 65536)
- return (utf8_text);
-
- if (ch <= 127)
- *utf8_text++ = (char) ch;
- else if (ch <= 0x7ff) {
- *utf8_text++ = (char) (0xc0 | (ch >> 6));
- *utf8_text++ = (char) (0x80 | (ch & 0x3f));
- } else if (ch <= 0xffff) {
- *utf8_text++ = (char) (0xe0 | (ch >> 12));
- *utf8_text++ = (char) (0x80 | ((ch >> 6) & 0x3f));
- *utf8_text++ = (char) (0x80 | (ch & 0x3f));
- } else {
- unsigned val = ch - 0x10000;
- unsigned u = ((val & 0xf0000) >> 16) + 1, z = (val & 0x0f000) >> 12, y =
- (val & 0x00fc0) >> 6, x = val & 0x0003f;
- *utf8_text++ = (char) (0xf0 | (u >> 2));
- *utf8_text++ = (char) (0x80 | ((u & 3) << 4) | z);
- *utf8_text++ = (char) (0x80 | y);
- *utf8_text++ = (char) (0x80 | x);
- }
- return (utf8_text);
-}
-
-static unsigned u_length(register unsigned int *str)
-{
- register unsigned len = 0;
- while (*str++ != '\0')
- ++len;
- return (len);
-}
-
-
-static void utf82u_strcpy(unsigned int *ubuf, const char *utf8buf)
-{
- int len = (int) strlen(utf8buf) + 1;
- unsigned int *upt = ubuf, *uend = ubuf + len - 1;
- const unsigned char *pt = (const unsigned char *) utf8buf, *end =
- pt + strlen(utf8buf);
- int w, w2;
-
- while (pt < end && *pt != '\0' && upt < uend) {
- if (*pt <= 127)
- *upt = *pt++;
- else if (*pt <= 0xdf) {
- *upt = (unsigned int) (((*pt & 0x1f) << 6) | (pt[1] & 0x3f));
- pt += 2;
- } else if (*pt <= 0xef) {
- *upt =
- (unsigned int) (((*pt & 0xf) << 12) | ((pt[1] & 0x3f) << 6) |
- (pt[2] & 0x3f));
- pt += 3;
- } else {
- w = (((*pt & 0x7) << 2) | ((pt[1] & 0x30) >> 4)) - 1;
- w = (w << 6) | ((pt[1] & 0xf) << 2) | ((pt[2] & 0x30) >> 4);
- w2 = ((pt[2] & 0xf) << 6) | (pt[3] & 0x3f);
- *upt = (unsigned int) (w * 0x400 + w2 + 0x10000);
- pt += 4;
- }
- ++upt;
- }
- *upt = '\0';
-}
-
@ @c
#define noVERBOSE
-#define MAX_TEX_LANGUAGES 32768
+#define MAX_TEX_LANGUAGES 16384
+
+#define ex_hyphen_char int_par(ex_hyphen_char_code)
static struct tex_language *tex_languages[MAX_TEX_LANGUAGES] = { NULL };
@@ -218,14 +147,14 @@ int get_post_exhyphen_char(int n)
}
@ @c
-void load_patterns(struct tex_language *lang, const unsigned char *buffer)
+void load_patterns(struct tex_language *lang, const unsigned char *buff)
{
- if (lang == NULL || buffer == NULL || strlen((const char *) buffer) == 0)
+ if (lang == NULL || buff == NULL || strlen((const char *) buff) == 0)
return;
if (lang->patterns == NULL) {
lang->patterns = hnj_hyphen_new();
}
- hnj_hyphen_load(lang->patterns, buffer);
+ hnj_hyphen_load(lang->patterns, buff);
}
void clear_patterns(struct tex_language *lang)
@@ -254,7 +183,7 @@ void load_tex_patterns(int curlang, halfword head)
/* Cleans one word which is returned in |cleaned|,
returns the new offset into |buffer| */
-const char *clean_hyphenation(const char *buffer, char **cleaned)
+const char *clean_hyphenation(const char *buff, char **cleaned)
{
int items = 0;
unsigned char word[MAX_WORD_LEN + 1]; /* work buffer for bytes */
@@ -262,12 +191,12 @@ const char *clean_hyphenation(const char *buffer, char **cleaned)
int u = 0; /* unicode buffer value */
int i = 0; /* index into buffer */
char *uindex = (char *)word;
- const char *s = buffer;
+ const char *s = buff;
while (*s && !isspace(*s)) {
word[i++] = (unsigned)*s;
s++;
- if ((s-buffer)>MAX_WORD_LEN) {
+ if ((s-buff)>MAX_WORD_LEN) {
/* todo: this is too strict, should count unicode, not bytes */
*cleaned = NULL;
tex_error("exception too long", NULL);
@@ -276,7 +205,7 @@ const char *clean_hyphenation(const char *buffer, char **cleaned)
}
/* now convert the input to unicode */
word[i] = '\0';
- utf82u_strcpy(uword, (const char *)word);
+ utf2uni_strcpy(uword, (const char *)word);
/* build the new word string */
i = 0;
@@ -327,7 +256,7 @@ const char *clean_hyphenation(const char *buffer, char **cleaned)
}
@ @c
-void load_hyphenation(struct tex_language *lang, const unsigned char *buffer)
+void load_hyphenation(struct tex_language *lang, const unsigned char *buff)
{
const char *s;
const char *value;
@@ -340,7 +269,7 @@ void load_hyphenation(struct tex_language *lang, const unsigned char *buffer)
lang->exceptions = luaL_ref(L, LUA_REGISTRYINDEX);
}
lua_rawgeti(L, LUA_REGISTRYINDEX, lang->exceptions);
- s = (const char *) buffer;
+ s = (const char *) buff;
while (*s) {
while (isspace(*s))
s++;
@@ -640,7 +569,7 @@ static void do_exception(halfword wordstart, halfword r, char *replacement)
int clang;
lang_variables langdata;
unsigned uword[MAX_WORD_LEN + 1] = { 0 };
- utf82u_strcpy(uword, replacement);
+ utf2uni_strcpy(uword, replacement);
len = u_length(uword);
i = 0;
t = wordstart;
@@ -844,7 +773,7 @@ void hnj_hyphenation(halfword head, halfword tail)
char *hy = utf8word;
char *replacement = NULL;
boolean explicit_hyphen = false;
- halfword s, r = head, wordstart = null, save_tail = null, left =
+ halfword s, r = head, wordstart = null, save_tail1 = null, left =
null, right = null;
/* this first movement assures two things:
@@ -864,7 +793,7 @@ void hnj_hyphenation(halfword head, halfword tail)
return;
assert(tail != null);
- save_tail = vlink(tail);
+ save_tail1 = vlink(tail);
s = new_penalty(0);
couple_nodes(tail, s);
@@ -899,7 +828,7 @@ void hnj_hyphenation(halfword head, halfword tail)
r = vlink(r);
}
if (valid_wordend(r) && wordlen >= lhmin + rhmin
- && (hyf_font != 0) && (lang = tex_languages[clang]) != NULL) {
+ && (hyf_font != 0) && clang >=0 && (lang = tex_languages[clang]) != NULL) {
*hy = 0;
if (lang->exceptions != 0 &&
(replacement =
@@ -964,7 +893,7 @@ void hnj_hyphenation(halfword head, halfword tail)
r = find_next_wordstart(r);
}
flush_node(vlink(tail));
- vlink(tail) = save_tail;
+ vlink(tail) = save_tail1;
}