summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/luatexdir/utils
diff options
context:
space:
mode:
authorLuigi Scarso <luigi.scarso@gmail.com>2018-09-05 21:57:30 +0000
committerLuigi Scarso <luigi.scarso@gmail.com>2018-09-05 21:57:30 +0000
commitecd1605a23ef54d2a4a69e1a361172d350e03b3b (patch)
tree8ea1d9745c24dbc5e755f13d801fa01e88944650 /Build/source/texk/web2c/luatexdir/utils
parent04563248956e7059aad4fc4f6bf7da18562f7b8c (diff)
luatex: correct automake file for pplib; replaced cweb files with c files.
git-svn-id: svn://tug.org/texlive/trunk@48594 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/luatexdir/utils')
-rw-r--r--Build/source/texk/web2c/luatexdir/utils/avlstuff.c63
-rw-r--r--Build/source/texk/web2c/luatexdir/utils/avlstuff.w61
-rw-r--r--Build/source/texk/web2c/luatexdir/utils/managed-sa.c (renamed from Build/source/texk/web2c/luatexdir/utils/managed-sa.w)90
-rw-r--r--Build/source/texk/web2c/luatexdir/utils/unistring.c (renamed from Build/source/texk/web2c/luatexdir/utils/unistring.w)103
-rw-r--r--Build/source/texk/web2c/luatexdir/utils/utils.c (renamed from Build/source/texk/web2c/luatexdir/utils/utils.w)303
5 files changed, 310 insertions, 310 deletions
diff --git a/Build/source/texk/web2c/luatexdir/utils/avlstuff.c b/Build/source/texk/web2c/luatexdir/utils/avlstuff.c
new file mode 100644
index 00000000000..887ba4f46e8
--- /dev/null
+++ b/Build/source/texk/web2c/luatexdir/utils/avlstuff.c
@@ -0,0 +1,63 @@
+/*
+
+Copyright 1996-2006 Han The Thanh <thanh@pdftex.org>
+Copyright 2006-2009 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/>.
+
+*/
+
+#include "ptexlib.h"
+#include "utils/avl.h"
+
+/*tex
+
+ Some memory management functions for AVL.
+
+*/
+
+static void *avl_xmalloc(struct libavl_allocator *allocator, size_t size)
+{
+ assert(allocator != NULL && size > 0);
+ return xmalloc((unsigned) size);
+}
+
+static void avl_xfree(struct libavl_allocator *allocator, void *block)
+{
+ assert(allocator != NULL && block != NULL);
+ xfree(block);
+}
+
+struct libavl_allocator avl_xallocator = {
+ avl_xmalloc,
+ avl_xfree
+};
+
+/*tex
+
+ The general AVL comparison functions.
+
+*/
+int comp_int_entry(const void *pa, const void *pb, void *p)
+{
+ (void) p;
+ cmp_return(*(const int *) pa, *(const int *) pb);
+ return 0;
+}
+
+int comp_string_entry(const void *pa, const void *pb, void *p)
+{
+ (void) p;
+ return strcmp((const char *) pa, (const char *) pb);
+}
diff --git a/Build/source/texk/web2c/luatexdir/utils/avlstuff.w b/Build/source/texk/web2c/luatexdir/utils/avlstuff.w
deleted file mode 100644
index 1ea148b0917..00000000000
--- a/Build/source/texk/web2c/luatexdir/utils/avlstuff.w
+++ /dev/null
@@ -1,61 +0,0 @@
-% avlstuff.w
-%
-% Copyright 1996-2006 Han The Thanh <thanh@@pdftex.org>
-% Copyright 2006-2009 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/>.
-
-@* AVL helper functions.
-
-@ @c
-
-
-#include "ptexlib.h"
-#include "utils/avl.h"
-
-@ memory management functions for AVL
-@c
-static void *avl_xmalloc(struct libavl_allocator *allocator, size_t size)
-{
- assert(allocator != NULL && size > 0);
- return xmalloc((unsigned) size);
-}
-
-static void avl_xfree(struct libavl_allocator *allocator, void *block)
-{
- assert(allocator != NULL && block != NULL);
- xfree(block);
-}
-
-struct libavl_allocator avl_xallocator = {
- avl_xmalloc,
- avl_xfree
-};
-
-@ general AVL comparison functions
-@c
-int comp_int_entry(const void *pa, const void *pb, void *p)
-{
- (void) p;
- cmp_return(*(const int *) pa, *(const int *) pb);
- return 0;
-}
-
-int comp_string_entry(const void *pa, const void *pb, void *p)
-{
- (void) p;
- return strcmp((const char *) pa, (const char *) pb);
-}
diff --git a/Build/source/texk/web2c/luatexdir/utils/managed-sa.w b/Build/source/texk/web2c/luatexdir/utils/managed-sa.c
index 6ac4a68ac08..6cf10e301ce 100644
--- a/Build/source/texk/web2c/luatexdir/utils/managed-sa.w
+++ b/Build/source/texk/web2c/luatexdir/utils/managed-sa.c
@@ -1,36 +1,36 @@
-% managed-sa.w
-%
-% Copyright 2006-2010 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/>.
+/*
-@* Sparse arrays with an embedded save stack.
+Copyright 2006-2010 Taco Hoekwater <taco@luatex.org>
-These functions are called very often but a few days of experimenting proved that
-there is not much to gain (if at all) from using macros or optimizations like
-preallocating and fast access to the first 128 entries. In practice the overhead
-is mostly in accessing memory and not in (probably inlined) calls. So, we should
-accept fate and wait for faster memory. It's the price we pay for being unicode
-on the one hand and sparse on the other.
+This file is part of LuaTeX.
-@ @c
+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/>.
+
+*/
+
+/*tex
+
+ Here we implement sparse arrays with an embedded save stack. These functions
+ are called very often but a few days of experimenting proved that there is
+ not much to gain (if at all) from using macros or optimizations like
+ preallocating and fast access to the first 128 entries. In practice the
+ overhead is mostly in accessing memory and not in (probably inlined) calls.
+ So, we should accept fate and wait for faster memory. It's the price we pay
+ for being unicode on the one hand and sparse on the other.
+
+*/
#include "ptexlib.h"
-@ @c
static void store_sa_stack(sa_tree a, int n, sa_tree_item v, int gl)
{
sa_stack_item st;
@@ -47,7 +47,6 @@ static void store_sa_stack(sa_tree a, int n, sa_tree_item v, int gl)
a->stack[a->stack_ptr] = st;
}
-@ @c
static void skip_in_stack(sa_tree a, int n)
{
int p = a->stack_ptr;
@@ -61,7 +60,6 @@ static void skip_in_stack(sa_tree a, int n)
}
}
-@ @c
sa_tree_item get_sa_item(const sa_tree head, const int n)
{
if (head->tree != NULL) {
@@ -76,7 +74,6 @@ sa_tree_item get_sa_item(const sa_tree head, const int n)
return head->dflt;
}
-@ @c
void set_sa_item(sa_tree head, int n, sa_tree_item v, int gl)
{
int h = HIGHPART_PART(n);
@@ -103,13 +100,11 @@ void set_sa_item(sa_tree head, int n, sa_tree_item v, int gl)
head->tree[h][m][l] = v;
}
-@ @c
void rawset_sa_item(sa_tree head, int n, sa_tree_item v)
{
head->tree[HIGHPART_PART(n)][MIDPART_PART(n)][LOWPART_PART(n)] = v;
}
-@ @c
void clear_sa_stack(sa_tree a)
{
xfree(a->stack);
@@ -117,7 +112,6 @@ void clear_sa_stack(sa_tree a)
a->stack_size = a->stack_step;
}
-@ @c
void destroy_sa_tree(sa_tree a)
{
if (a == NULL)
@@ -138,7 +132,6 @@ void destroy_sa_tree(sa_tree a)
xfree(a);
}
-@ @c
sa_tree copy_sa_tree(sa_tree b)
{
sa_tree a = (sa_tree) Mxmalloc_array(sa_tree_head, 1);
@@ -168,15 +161,17 @@ sa_tree copy_sa_tree(sa_tree b)
return a;
}
-@ The main reason to fill in the lowest entry branches here immediately
-is that most of the sparse arrays have a bias toward ASCII values.
+/*tes
-Allocating those here immediately improves the chance of the structure
-|a->tree[0][0][x]| being close together in actual memory locations
+ The main reason to fill in the lowest entry branches here immediately is that
+ most of the sparse arrays have a bias toward \ASCII\ values.
-@c
+ Allocating those here immediately improves the chance of the structure
+ |a->tree[0][0][x]| being close together in actual memory locations
-/* we could save less for type 0 stacks */
+ We could save less for type 0 stacks.
+
+*/
sa_tree new_sa_tree(int size, int type, sa_tree_item dflt)
{
@@ -190,11 +185,9 @@ sa_tree new_sa_tree(int size, int type, sa_tree_item dflt)
a->stack_step = size;
a->stack_type = type;
a->stack_ptr = 0;
- /* printf("creating sa tree of type %d\n",type); */
return (sa_tree) a;
}
-@ @c
void restore_sa_stack(sa_tree head, int gl)
{
sa_stack_item st;
@@ -209,7 +202,6 @@ void restore_sa_stack(sa_tree head, int gl)
}
}
-@ @c
void dump_sa_tree(sa_tree a, const char * name)
{
boolean f;
@@ -219,10 +211,10 @@ void dump_sa_tree(sa_tree a, const char * name)
x = a->dflt.int_value;
dump_int(x);
if (a->tree != NULL) {
- dump_int(1); /* marker */
+ /*tex A marker: */
+ dump_int(1);
n = a->stack_type;
dump_int(n);
- /* printf("dumping sa tree %s with type %d\n",name,n); */
for (h = 0; h < HIGHPART; h++) {
if (a->tree[h] != NULL) {
f = 1;
@@ -253,11 +245,11 @@ void dump_sa_tree(sa_tree a, const char * name)
}
}
} else {
- dump_int(0); /* marker */
+ /*tex A marker: */
+ dump_int(0);
}
}
-@ @c
sa_tree undump_sa_tree(const char * name)
{
int x, n;
@@ -272,13 +264,13 @@ sa_tree undump_sa_tree(const char * name)
a->stack = Mxmalloc_array(sa_stack_item, a->stack_size);
a->stack_ptr = 0;
a->tree = NULL;
- undump_int(x); /* marker */
+ /*tex The marker: */
+ undump_int(x);
if (x == 0)
return a;
a->tree = (sa_tree_item ***) Mxcalloc_array(void *, HIGHPART);
undump_int(n);
a->stack_type = n;
- /* printf("undumping sa tree %s with type %d\n",name,n); */
for (h = 0; h < HIGHPART; h++) {
undump_qqqq(f);
if (f > 0) {
diff --git a/Build/source/texk/web2c/luatexdir/utils/unistring.w b/Build/source/texk/web2c/luatexdir/utils/unistring.c
index a5b365a5f2e..6c95ee31e67 100644
--- a/Build/source/texk/web2c/luatexdir/utils/unistring.w
+++ b/Build/source/texk/web2c/luatexdir/utils/unistring.c
@@ -1,34 +1,29 @@
-% unistring.w
-%
-% Copyright 2013 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
-
-
-@ @c
+/*
+
+Copyright 2013 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/>.
+
+*/
+
#include "ptexlib.h"
#include <string.h>
-@ @c
static void utf_error(void)
{
- const char *hlp[] =
- { "A funny symbol that I can't read has just been (re)read.",
+ const char *hlp[] = {
+ "A funny symbol that I can't read has just been (re)read.",
"Just continue, I'll change it to 0xFFFD.",
NULL
};
@@ -37,7 +32,6 @@ static void utf_error(void)
deletions_allowed = true;
}
-@ @c
unsigned str2uni(const unsigned char *k)
{
register int ch;
@@ -45,7 +39,8 @@ unsigned str2uni(const unsigned char *k)
const unsigned char *text = k;
if ((ch = *text++) < 0x80) {
val = (unsigned) ch;
- } else if (ch <= 0xbf) { /* error */
+ } else if (ch <= 0xbf) {
+ /*tex An error that we skip. */
} else if (ch <= 0xdf) {
if (*text >= 0x80 && *text < 0xc0)
val = (unsigned) (((ch & 0x1f) << 6) | (*text++ & 0x3f));
@@ -64,9 +59,11 @@ unsigned str2uni(const unsigned char *k)
*text >= 0xc0 || text[1] >= 0xc0 || text[2] >= 0xc0)
val = 0xFFFD;
} else {
- /* the 5- and 6-byte UTF-8 sequences generate integers
- that are outside of the valid UCS range, and therefore
- unsupported
+ /*tex
+
+ The 5- and 6-byte UTF-8 sequences generate integers that are outside
+ of the valid UCS range, and therefore unsupported.
+
*/
}
if (val == 0xFFFD)
@@ -74,8 +71,11 @@ unsigned str2uni(const unsigned char *k)
return (val);
}
-@ This is a very basic helper
-@c
+/*tex
+
+ A real basic helper.
+*/
+
unsigned char *uni2str(unsigned unic)
{
unsigned char *buf = xmalloc(5);
@@ -106,26 +106,30 @@ unsigned char *uni2str(unsigned unic)
return buf;
}
-@ |buffer_to_unichar| converts a sequence of bytes in the |buffer|
-into a unicode character value. It does not check for overflow
-of the |buffer|, but it is careful to check the validity of the
-UTF-8 encoding.
+/*tex
+
+ Function |buffer_to_unichar| converts a sequence of bytes in the |buffer|
+ into a unicode character value. It does not check for overflow of the
+ |buffer|, but it is careful to check the validity of the \UTF-8 encoding.
+
+*/
-@c
int buffer_to_unichar(int k)
{
return str2uni((const unsigned char *)(buffer+k));
}
+/*tex
+
+ These came from texlang.c:
+
+*/
-@ These came from texlang.w
-@c
char *uni2string(char *utf8_text, unsigned ch)
{
- /* Increment and deposit character */
+ /*tex Increment and deposit character: */
if (ch >= 17 * 65536)
return (utf8_text);
-
if (ch <= 127)
*utf8_text++ = (char) ch;
else if (ch <= 0x7ff) {
@@ -155,15 +159,12 @@ unsigned u_length(register unsigned int *str)
return (len);
}
-
void utf2uni_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);
+ 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++;
@@ -171,9 +172,7 @@ void utf2uni_strcpy(unsigned int *ubuf, const char *utf8buf)
*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));
+ *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;
@@ -187,15 +186,11 @@ void utf2uni_strcpy(unsigned int *ubuf, const char *utf8buf)
*upt = '\0';
}
-@ @c
char *utf16be_str(long code)
{
static char buf[SMALL_BUF_SIZE];
long v;
unsigned vh, vl;
-
- assert(code >= 0);
-
if (code <= 0xFFFF)
sprintf(buf, "%04lX", code);
else {
@@ -206,5 +201,3 @@ char *utf16be_str(long code)
}
return buf;
}
-
-
diff --git a/Build/source/texk/web2c/luatexdir/utils/utils.w b/Build/source/texk/web2c/luatexdir/utils/utils.c
index 420f5cfe4e4..55ff1cb3e29 100644
--- a/Build/source/texk/web2c/luatexdir/utils/utils.w
+++ b/Build/source/texk/web2c/luatexdir/utils/utils.c
@@ -1,51 +1,52 @@
-% utils.w
-%
-% Copyright 1996-2006 Han The Thanh <thanh@@pdftex.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
-
-
-@ @c
+/*
+
+Copyright 1996-2006 Han The Thanh <thanh@pdftex.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/>.
+
+*/
+
#include "ptexlib.h"
-#include <kpathsea/config.h> /* this is a trick to load mingw32's io.h early,
- using a macro redefinition of |eof()|. */
+/*tex
+
+ This is a trick to load mingw32's io.h early, using a macro redefinition of
+ |eof()|.
+
+*/
+
+#include <kpathsea/config.h>
#include "sys/types.h"
#include <kpathsea/c-stat.h>
#include <kpathsea/c-fopen.h>
#include <string.h>
#include <time.h>
-#include <float.h> /* for |DBL_EPSILON| */
+
+/*tex For |DBL_EPSILON|: */
+
+#include <float.h>
+
#include "zlib.h"
#include "md5.h"
-#include "lua/luatex-api.h" /* for luatex_banner */
+#include "lua/luatex-api.h"
#include "luatex_svnversion.h"
#include "png.h"
#include "mplib.h"
-/* POPPLER_VERSION is defined in poppler-config.h for poppler from
- * the TeX Live tree, or in the Makefile for an installed version. */
-#include "poppler-config.h"
-
-@ @c
#define check_nprintf(size_get, size_want) \
if ((unsigned)(size_get) >= (unsigned)(size_want)) \
formatted_error("internal","snprintf failed: file %s, line %d", __FILE__, __LINE__);
@@ -55,12 +56,11 @@ static char print_buf[PRINTF_BUF_SIZE];
int epochseconds;
int microseconds;
-/* define |char_ptr|, |char_array|, and |char_limit| */
typedef char char_entry;
define_array(char);
-@ @c
#define SUBSET_TAG_LENGTH 6
+
void make_subset_tag(fd_entry * fd)
{
int i, j = 0, a[SUBSET_TAG_LENGTH];
@@ -117,7 +117,6 @@ void make_subset_tag(fd_entry * fd)
formatted_warning("subsets","subset-tag collision, resolved in round %d",j);
}
-@ @c
__attribute__ ((format(printf, 1, 2)))
void tex_printf(const char *fmt, ...)
{
@@ -129,7 +128,6 @@ void tex_printf(const char *fmt, ...)
va_end(args);
}
-@ @c
size_t xfwrite(void *ptr, size_t size, size_t nmemb, FILE * stream)
{
if (fwrite(ptr, size, nmemb, stream) != nmemb)
@@ -137,7 +135,6 @@ size_t xfwrite(void *ptr, size_t size, size_t nmemb, FILE * stream)
return nmemb;
}
-@ @c
int xfflush(FILE * stream)
{
if (fflush(stream) != 0)
@@ -145,7 +142,6 @@ int xfflush(FILE * stream)
return 0;
}
-@ @c
int xgetc(FILE * stream)
{
int c = getc(stream);
@@ -154,7 +150,6 @@ int xgetc(FILE * stream)
return c;
}
-@ @c
int xputc(int c, FILE * stream)
{
int i = putc(c, stream);
@@ -163,7 +158,6 @@ int xputc(int c, FILE * stream)
return i;
}
-@ @c
scaled ext_xn_over_d(scaled x, scaled n, scaled d)
{
double r = (((double) x) * ((double) n)) / ((double) d);
@@ -176,9 +170,13 @@ scaled ext_xn_over_d(scaled x, scaled n, scaled d)
return (scaled) r;
}
-@ function strips trailing zeros in string with numbers;
-leading zeros are not stripped (as in real life)
-@c
+/*tex
+
+ This function strips trailing zeros in string with numbers; leading zeros are
+ not stripped (as in real life), It's not used.
+
+*/
+
#if 0
char *stripzeros(char *a)
{
@@ -248,9 +246,9 @@ char *stripzeros(char *a)
}
#endif
-@ @c
void initversionstring(char **versions)
{
+
#ifdef LuajitTeX
#define LUA_VER_STRING LUAJIT_VERSION
#else
@@ -258,35 +256,37 @@ void initversionstring(char **versions)
#endif
#define STR(tok) STR2(tok)
#define STR2(tok) #tok
+
const_string fmt =
- "Compiled with libpng %s; using %s\n"
- "Compiled with %s\n" /* Lua or LuaJIT */
- "Compiled with mplib version %s\n"
- "Compiled with poppler version %s\n"
- "Compiled with zlib %s; using %s\n"
- "\nDevelopment id: %s\n";
+ "Compiled with libpng %s; using %s\n"
+ "Compiled with %s\n" /* Lua or LuaJIT */
+ "Compiled with mplib version %s\n"
+ "Compiled with zlib %s; using %s\n"
+ "\nDevelopment id: %s\n";
size_t len = strlen(fmt)
- + strlen(PNG_LIBPNG_VER_STRING) + strlen(png_libpng_ver)
- + strlen(LUA_VER_STRING)
- + strlen(mp_metapost_version())
- + strlen(POPPLER_VERSION)
- + strlen(ZLIB_VERSION) + strlen(zlib_version)
- + strlen(STR(luatex_svn_revision))
- + 1;
-
- /* len will be more than enough, because of the placeholder chars in fmt
- that get replaced by the arguments. */
+ + strlen(PNG_LIBPNG_VER_STRING) + strlen(png_libpng_ver)
+ + strlen(LUA_VER_STRING)
+ + strlen(mp_metapost_version())
+ + strlen(ZLIB_VERSION) + strlen(zlib_version)
+ + strlen(STR(luatex_svn_revision))
+ + 1;
+
+ /*tex
+ The size of |len| will be more than enough, because of the placeholder
+ chars in fmt that get replaced by the arguments.
+ */
*versions = xmalloc(len);
sprintf(*versions, fmt,
PNG_LIBPNG_VER_STRING, png_libpng_ver, LUA_VER_STRING,
- mp_metapost_version(),POPPLER_VERSION,
+ mp_metapost_version(),
ZLIB_VERSION, zlib_version,STR(luatex_svn_revision));
+
#undef STR2
#undef STR
#undef LUA_VER_STRING
+
}
-@ @c
void check_buffer_overflow(int wsize)
{
if (wsize > buf_size) {
@@ -294,16 +294,18 @@ void check_buffer_overflow(int wsize)
if (nsize < wsize) {
nsize = wsize + 5;
}
- buffer =
- (unsigned char *) xreallocarray(buffer, char, (unsigned) nsize);
+ buffer = (unsigned char *) xreallocarray(buffer, char, (unsigned) nsize);
buf_size = nsize;
}
}
-@ the return value is a decimal number with the point |dd| places from the back,
- |scaled_out| is the number of scaled points corresponding to that.
+/*tex
+
+ The return value is a decimal number with the point |dd| places from the
+ back, |scaled_out| is the number of scaled points corresponding to that.
+
+*/
-@c
#define max_integer 0x7FFFFFFF
scaled divide_scaled(scaled s, scaled m, int dd)
@@ -331,7 +333,7 @@ scaled divide_scaled(scaled s, scaled m, int dd)
q = 10 * q + (10 * r) / m;
r = (10 * r) % m;
}
- /* rounding */
+ /*tex Rounding: */
if (2 * r >= m) {
q++;
}
@@ -343,8 +345,12 @@ scaled divide_scaled(scaled s, scaled m, int dd)
#define floor win32_floor
#endif
-@ Same function, but using doubles instead of integers (faster)
-@c
+/*tex
+
+ The same function, but using doubles instead of integers (faster).
+
+*/
+
scaled divide_scaled_n(double sd, double md, double n)
{
double dd, di = 0.0;
@@ -356,11 +362,9 @@ scaled divide_scaled_n(double sd, double md, double n)
return (scaled) di;
}
-@ @c
int do_zround(double r)
{
int i;
-
if (r > 2147483647.0)
i = 2147483647;
else if (r < -2147483647.0)
@@ -369,16 +373,20 @@ int do_zround(double r)
i = (int) (r + 0.5);
else
i = (int) (r - 0.5);
-
return i;
}
-@ Old MSVC doesn't have |rint|.
-@c
+/*tex
+
+ Old MSVC doesn't have |rint|.
+
+*/
+
#if defined(_MSC_VER) && _MSC_VER <= 1600
# include <math.h>
+
double rint(double x)
{
return floor(x+0.5);
@@ -386,57 +394,66 @@ double rint(double x)
#endif
-@ replace tmpfile() on Windows
-@c
+/*tex
+
+ We replace |tmpfile| on \MSWINDOWS:
+
+*/
+
#if defined(_WIN32)
-/* _cairo_win_tmpfile (void) - replace tmpfile() on Windows
- * extracted from cairo-misc.c in cairo - a vector graphics library
- * with display and print output
- * the functiion name is changed from
- * _cairo_win32_tmpfile (void) to
- * _cairo_win_tmpfile (void)
- *
- *
- * Copyright 2002 University of Southern California
- * Copyright 2005 Red Hat, Inc.
- * Copyright 2007 Adrian Johnson
- *
- * This library is free software; you can redistribute it and/or
- * modify it either under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- * The Original Code is the cairo graphics library.
- *
- * The Initial Developer of the Original Code is University of Southern
- * California.
- *
- * Contributor(s):
- * Carl D. Worth <cworth@cworth.org>
- * Adrian Johnson <ajohnson@redneon.com>
- */
+
+/*
+
+ _cairo_win_tmpfile (void) - replace tmpfile() on Windows
+ extracted from cairo-misc.c in cairo - a vector graphics library
+ with display and print output
+
+ the functiion name is changed from _cairo_win32_tmpfile (void) to
+ _cairo_win_tmpfile (void)
+
+ Copyright 2002 University of Southern California
+ Copyright 2005 Red Hat, Inc.
+ Copyright 2007 Adrian Johnson
+
+ This library is free software; you can redistribute it and/or modify it
+ either under the terms of the GNU Lesser General Public License version 2.1
+ as published by the Free Software Foundation (the "LGPL") or, at your option,
+ under the terms of the Mozilla Public License Version 1.1 (the "MPL"). If you
+ do not alter this notice, a recipient may use your version of this file under
+ either the MPL or the LGPL.
+
+ You should have received a copy of the LGPL along with this library in the
+ file COPYING-LGPL-2.1; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA You should have
+ received a copy of the MPL along with this library in the file
+ COPYING-MPL-1.1
+
+ The contents of this file are subject to the Mozilla Public License Version
+ 1.1 (the "License"); you may not use this file except in compliance with the
+ License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
+
+ This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ KIND, either express or implied. See the LGPL or the MPL for the specific
+ language governing rights and limitations.
+
+ The Original Code is the cairo graphics library. The Initial Developer of the
+ Original Code is University of Southern California. Contributor(s):
+
+ Carl D. Worth <cworth@cworth.org>
+ Adrian Johnson <ajohnson@redneon.com>
+
+*/
#include <stdio.h>
#define WIN32_LEAN_AND_MEAN
-/* We require Windows 2000 features such as ETO_PDY */
+
+/*tex
+
+ We require \MSWINDOWS\ 2000 features such as |ETO_PDY|. We probably can now
+ assume that all \MSWINDOWS\ versions are recent.
+
+*/
+
#if !defined(WINVER) || (WINVER < 0x0500)
# define WINVER 0x0500
#endif
@@ -447,14 +464,15 @@ double rint(double x)
#include <windows.h>
#include <io.h>
-/* tmpfile() replacement for Windows.
- *
- * On Windows tmpfile() creates the file in the root directory. This
- * may fail due to unsufficient privileges. However, this isn't a
- * problem on Windows CE so we don't use it there.
- */
-FILE *
-_cairo_win_tmpfile (void)
+/*tex
+
+ On \MSWINDOWS\ |tmpfile| creates the file in the root directory. This may
+ fail due to unsufficient privileges. However, this isn't a problem on
+ \MSWINDOWS\ CE so we don't use it there. Who is actually using CE anyway?
+
+*/
+
+FILE * _cairo_win_tmpfile (void)
{
DWORD path_len;
WCHAR path_name[MAX_PATH + 1];
@@ -462,14 +480,11 @@ _cairo_win_tmpfile (void)
HANDLE handle;
int fd;
FILE *fp;
-
path_len = GetTempPathW (MAX_PATH, path_name);
if (path_len <= 0 || path_len >= MAX_PATH)
- return NULL;
-
+ return NULL;
if (GetTempFileNameW (path_name, L"ps_", 0, file_name) == 0)
- return NULL;
-
+ return NULL;
handle = CreateFileW (file_name,
GENERIC_READ | GENERIC_WRITE,
0,
@@ -478,22 +493,20 @@ _cairo_win_tmpfile (void)
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_DELETE_ON_CLOSE,
NULL);
if (handle == INVALID_HANDLE_VALUE) {
- DeleteFileW (file_name);
- return NULL;
+ DeleteFileW (file_name);
+ return NULL;
}
-
fd = _open_osfhandle((intptr_t) handle, 0);
if (fd < 0) {
- CloseHandle (handle);
- return NULL;
+ CloseHandle (handle);
+ return NULL;
}
-
fp = _fdopen(fd, "w+b");
if (fp == NULL) {
- _close(fd);
- return NULL;
+ _close(fd);
+ return NULL;
}
-
return fp;
}
+
#endif