diff options
author | Taco Hoekwater <taco@elvenkind.com> | 2009-04-22 15:09:21 +0000 |
---|---|---|
committer | Taco Hoekwater <taco@elvenkind.com> | 2009-04-22 15:09:21 +0000 |
commit | 27c36765240572fc41d9ca8c69b99e0a41493674 (patch) | |
tree | ad358e69f64f06096c79896dc3c88e80e658a913 /Build/source/texk/web2c/luatexdir/utils | |
parent | 6619094417b7606acce5c62de157d426351d5775 (diff) |
import luatex 0.40.0
git-svn-id: svn://tug.org/texlive/trunk@12791 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/luatexdir/utils')
-rw-r--r-- | Build/source/texk/web2c/luatexdir/utils/avlstuff.c | 31 | ||||
-rw-r--r-- | Build/source/texk/web2c/luatexdir/utils/avlstuff.h | 45 | ||||
-rw-r--r-- | Build/source/texk/web2c/luatexdir/utils/synctex.c | 54 | ||||
-rw-r--r-- | Build/source/texk/web2c/luatexdir/utils/utils.c | 24 | ||||
-rw-r--r-- | Build/source/texk/web2c/luatexdir/utils/utils.h | 109 |
5 files changed, 181 insertions, 82 deletions
diff --git a/Build/source/texk/web2c/luatexdir/utils/avlstuff.c b/Build/source/texk/web2c/luatexdir/utils/avlstuff.c index 2afeed93d62..5fb02a667bf 100644 --- a/Build/source/texk/web2c/luatexdir/utils/avlstuff.c +++ b/Build/source/texk/web2c/luatexdir/utils/avlstuff.c @@ -1,7 +1,7 @@ /* avlstuff.c Copyright 1996-2006 Han The Thanh <thanh@pdftex.org> - Copyright 2006-2008 Taco Hoekwater <taco@luatex.org> + Copyright 2006-2009 Taco Hoekwater <taco@luatex.org> This file is part of LuaTeX. @@ -24,20 +24,21 @@ #include "avl.h" static const char __svn_version[] = - "$Id: avlstuff.c 2271 2009-04-12 23:42:21Z oneiros $ $URL: http://scm.foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/utils/avlstuff.c $"; + "$Id: avlstuff.c 2329 2009-04-18 14:25:30Z hhenkel $ " + "$URL: http://scm.foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/utils/avlstuff.c $"; static struct avl_table **PdfObjTree = NULL; /**********************************************************************/ /* memory management functions for AVL */ -void *avl_xmalloc(struct libavl_allocator *allocator, size_t size) +static void *avl_xmalloc(struct libavl_allocator *allocator, size_t size) { assert(allocator != NULL && size > 0); return xmalloc(size); } -void avl_xfree(struct libavl_allocator *allocator, void *block) +static void avl_xfree(struct libavl_allocator *allocator, void *block) { assert(allocator != NULL && block != NULL); xfree(block); @@ -53,12 +54,14 @@ struct libavl_allocator avl_xallocator = { 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); } @@ -72,11 +75,11 @@ typedef struct oentry_ { /* AVL sort oentry into avl_table[] */ -int compare_info(const void *pa, const void *pb, void *param) +static int compare_info(const void *pa, const void *pb, void *param) { integer a, b; int as, ae, bs, be, al, bl; - + (void) param; a = ((const oentry *) pa)->int0; b = ((const oentry *) pb)->int0; if (a < 0 && b < 0) { /* string comparison */ @@ -129,8 +132,8 @@ void avl_put_obj(integer objptr, integer t) pdftex_fail("avlstuff.c: avl_create() PdfObjTree failed"); } oe = xtalloc(1, oentry); - oe->int0 = obj_tab[objptr].int0; - oe->objptr = objptr; /* allows to relocate objtab */ + oe->int0 = obj_info(objptr); + oe->objptr = objptr; /* allows to relocate obj_tab */ pp = avl_probe(PdfObjTree[t], oe); if (pp == NULL) pdftex_fail("avlstuff.c: avl_probe() out of memory in insertion"); @@ -156,19 +159,11 @@ integer avl_find_obj(integer t, integer i, integer byname) } /**********************************************************************/ - -struct avl_table *mf_tree = NULL; - -typedef struct { - char *tfm_name; - internalfontnumber fontnum; -} mf_entry; - -/**********************************************************************/ /* cleaning up... */ static void destroy_oentry(void *pa, void *pb) { + (void) pb; oentry *p = (oentry *) pa; xfree(p); } @@ -186,5 +181,3 @@ void PdfObjTree_free() xfree(PdfObjTree); PdfObjTree = NULL; } - -/**********************************************************************/ diff --git a/Build/source/texk/web2c/luatexdir/utils/avlstuff.h b/Build/source/texk/web2c/luatexdir/utils/avlstuff.h index 5dd90bb5df2..d920aace82b 100644 --- a/Build/source/texk/web2c/luatexdir/utils/avlstuff.h +++ b/Build/source/texk/web2c/luatexdir/utils/avlstuff.h @@ -1,27 +1,36 @@ -/* -Copyright (c) 2004-2007 Han The Thanh, <thanh@pdftex.org> +/* avlstuff.h -This file is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by Free -Software Foundation; either version 2 of the License, or (at your option) -any later version. + Copyright (c) 2004-2007 Han The Thanh, <thanh@pdftex.org> + Copyright 2006-2009 Taco Hoekwater <taco@luatex.org> -This file 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 General Public License -for more details. + This file is part of LuaTeX. -You should have received a copy of the GNU General Public License along -with pdfTeX; if not, write to the Free Software Foundation, Inc., 51 -Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + 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. -$Id: avlstuff.h 2271 2009-04-12 23:42:21Z oneiros $ -*/ + 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. -#include "avl.h" + You should have received a copy of the GNU General Public License along + with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */ -/* memory management functions for avl */ +/* $Id: avlstuff.h 2328 2009-04-18 12:50:26Z hhenkel $ */ + +#ifndef AVLSTUFF_H +# define AVLSTUFF_H + +# include "avl.h" extern struct libavl_allocator avl_xallocator; -/* end of file avlstuff.h */ +int comp_int_entry(const void *, const void *, void *); +int comp_string_entry(const void *, const void *, void *); +integer avl_find_obj(integer, integer, integer); +void avl_put_obj(integer, integer); +void PdfObjTree_free(); + +#endif /* AVLSTUFF_H */ diff --git a/Build/source/texk/web2c/luatexdir/utils/synctex.c b/Build/source/texk/web2c/luatexdir/utils/synctex.c index 459ef746d85..d4471b4bed7 100644 --- a/Build/source/texk/web2c/luatexdir/utils/synctex.c +++ b/Build/source/texk/web2c/luatexdir/utils/synctex.c @@ -106,7 +106,6 @@ Tue Jul 1 15:23:00 UTC 2008 #define ruleht rule_ht #define ruledp rule_dp #define rulewd rule_wd -#define zmem varmem #define jobname job_name #define totalpages total_pages #define curinput cur_input @@ -124,7 +123,6 @@ Tue Jul 1 15:23:00 UTC 2008 * and *tex.web for details, the synctex_ prefix prevents name conflicts, it * is some kind of namespace */ -# warning These structures MUST be kept in synchronization with the main program /* synctexoption is a global integer variable defined in *tex.web * it is set to 1 by texmfmp.c if the command line has the '-synctex=1' * option. */ @@ -132,13 +130,8 @@ Tue Jul 1 15:23:00 UTC 2008 # define SYNCTEX_NO_OPTION INT_MAX /* if synctex_options is set to SYNCTEX_NO_OPTION, no command line option was provided. */ -/* glue code: really define the main memory, - * this is exactly the same "mem" as in *tex.web. */ -# define mem zmem -/* glue code: synctexoffset is a global integer variable defined in *tex.web - * it is set to the offset where the primitive \synctex reads and writes its - * value. */ -# define SYNCTEX_VALUE zeqtb[synctexoffset].cint +# define SYNCTEX_VALUE int_par(param_synctex_code) + /* if there were a mean to share the value of synctex_code between *tex.web * and this file, it would be great. */ @@ -186,28 +179,14 @@ Tue Jul 1 15:23:00 UTC 2008 /* SYNCTEX_TAG_MODEL and SYNCTEX_LINE_MODEL are used to define * SYNCTEX_TAG and SYNCTEX_LINE in a model independant way * Both are tag and line accessors */ -/*# define box_node_size (7+synchronization_field_size)*/ -/* see: @d box_node_size=... - * There should be an automatic process here because these definitions - * are redundant. However, this process would certainly be overcomplicated - * (building then parsing the *tex.web file would be a pain) */ -# define width_offset 2 -/* see: @d width_offset=... */ -# define depth_offset 3 -/* see: @d depth_offset=... */ -# define height_offset 4 -/* see: @d height_offset=... */ /* Now define the local version of width(##), height(##) and depth(##) macros These only depend on the 3 macros above. */ # define SYNCTEX_TYPE(NODE) type(NODE) -/*# define rule_node 2*/ -/*# define glue_node 10*/ -/*# define kern_node 11*/ # define SYNCTEX_SUBTYPE(NODE) subtype(NODE) -# define SYNCTEX_WIDTH(NODE) mem[NODE+width_offset].cint -# define SYNCTEX_DEPTH(NODE) mem[NODE+depth_offset].cint -# define SYNCTEX_HEIGHT(NODE) mem[NODE+height_offset].cint +# define SYNCTEX_WIDTH(NODE) width(NODE) +# define SYNCTEX_DEPTH(NODE) depth(NODE) +# define SYNCTEX_HEIGHT(NODE) height(NODE) /* When an hlist ships out, it can contain many different kern/glue nodes with * exactly the same sync tag and line. To reduce the size of the .synctex @@ -235,6 +214,8 @@ Tue Jul 1 15:23:00 UTC 2008 # define SYNCTEX_NO_ERROR (0) # include "luatexd.h" +# include "nodes.h" +# include "commands.h" # undef SYNCTEX_OFFSET_IS_PDF # define SYNCTEX_OFFSET_IS_PDF (pdf_output_value>0) # undef SYNCTEX_OUTPUT @@ -518,7 +499,7 @@ void synctex_start_input(void) } /* All the synctex... functions below have the smallest set of parameters. It - * appears to be either the address of a node, or nothing at all. Using zmem, + * appears to be either the address of a node, or nothing at all. Using varmem, * which is the place where all the nodes are stored, one can retrieve every * information about a node. The other information is obtained through the * global context variable. @@ -731,6 +712,7 @@ static inline void synctex_record_void_vlist(halfword p); void synctex_void_vlist(halfword p, halfword this_box) { scaledpos pos; + (void)this_box; SYNCTEX_RETURN_IF_DISABLED; #if SYNCTEX_DEBUG printf("\nSynchronize DEBUG: synctexvoidvlist\n"); @@ -808,6 +790,7 @@ static inline void synctex_record_void_hlist(halfword p); void synctex_void_hlist(halfword p, halfword this_box) { scaledpos pos; + (void)this_box; SYNCTEX_RETURN_IF_DISABLED; #if SYNCTEX_DEBUG printf("\nSynchronize DEBUG: synctexvoidhlist\n"); @@ -858,6 +841,7 @@ void synctex_math_recorder(halfword p); void synctex_math(halfword p, halfword this_box) { scaledpos pos; + (void)this_box; SYNCTEX_RETURN_IF_DISABLED; #if SYNCTEX_DEBUG printf("\nSynchronize DEBUG: synctexmath\n"); @@ -891,6 +875,7 @@ static inline void synctex_record_rule(halfword p); void synctex_horizontal_rule_or_glue(halfword p, halfword this_box) { scaledpos pos; + (void)this_box; SYNCTEX_RETURN_IF_DISABLED; #if SYNCTEX_DEBUG printf("\nSynchronize DEBUG: synctexglue\n"); @@ -985,6 +970,7 @@ void synctex_char_recorder(halfword p); /* this message is sent whenever a char node ships out */ void synctexchar(halfword p, halfword this_box) { + (void)this_box; SYNCTEX_RETURN_IF_DISABLED; #if SYNCTEX_DEBUG printf("\nSynchronize DEBUG: synctexchar\n"); @@ -1013,6 +999,7 @@ void synctex_node_recorder(halfword p); for a node of an unknown type */ void synctexnode(halfword p, halfword this_box) { + (void)this_box; SYNCTEX_RETURN_IF_DISABLED; #if SYNCTEX_DEBUG printf("\nSynchronize DEBUG: synctexnode\n"); @@ -1049,9 +1036,6 @@ void synctex_current(void) return; } -#pragma mark - -#pragma mark Glue code Recorders - /* Recording the settings */ static inline int synctex_record_settings(void) { @@ -1227,6 +1211,7 @@ static inline void synctex_record_vlist(halfword p) static inline void synctex_record_tsilv(halfword p) { size_t len = 0; + (void)p; #if SYNCTEX_DEBUG > 999 printf("\nSynchronize DEBUG: synctex_record_tsilv\n"); #endif @@ -1243,6 +1228,7 @@ static inline void synctex_record_tsilv(halfword p) static inline void synctex_record_void_hlist(halfword p) { size_t len = 0; + (void)p; #if SYNCTEX_DEBUG > 999 printf("\nSynchronize DEBUG: synctex_record_void_hlist\n"); #endif @@ -1290,6 +1276,7 @@ static inline void synctex_record_hlist(halfword p) static inline void synctex_record_tsilh(halfword p) { size_t len = 0; + (void)p; #if SYNCTEX_DEBUG > 999 printf("\nSynchronize DEBUG: synctex_record_tsilh\n"); #endif @@ -1407,9 +1394,6 @@ static inline void synctex_record_rule(halfword p) } -#pragma mark - -#pragma mark Recorders - /* Recording a "$..." line */ void synctex_math_recorder(halfword p) { @@ -1455,6 +1439,7 @@ void synctex_kern_recorder(halfword p) void synctex_char_recorder(halfword p) { size_t len = 0; + (void)p; #if SYNCTEX_DEBUG > 999 printf("\nSynchronize DEBUG: synctex_char_recorder\n"); #endif @@ -1473,12 +1458,13 @@ void synctex_char_recorder(halfword p) void synctex_node_recorder(halfword p) { size_t len = 0; + (void)p; #if SYNCTEX_DEBUG > 999 printf("\nSynchronize DEBUG: synctex_node_recorder(0x%x)\n",p); #endif len = SYNCTEX_fprintf(SYNCTEX_FILE,"?%i,%i:%i,%i\n", synctex_ctxt.curh UNIT, synctex_ctxt.curv UNIT, - mem[p].hh.b0,mem[p].hh.b1); + type(p),subtype(p)); if(len>0) { synctex_ctxt.total_length += len; ++synctex_ctxt.count; diff --git a/Build/source/texk/web2c/luatexdir/utils/utils.c b/Build/source/texk/web2c/luatexdir/utils/utils.c index d743bb240ae..926fef3d34a 100644 --- a/Build/source/texk/web2c/luatexdir/utils/utils.c +++ b/Build/source/texk/web2c/luatexdir/utils/utils.c @@ -43,14 +43,15 @@ #include "xpdf/config.h" /* just to get the xpdf version */ static const char __svn_version[] = - "$Id: utils.c 2195 2009-03-31 14:09:50Z oneiros $ $URL: http://scm.foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/utils/utils.c $"; + "$Id: utils.c 2329 2009-04-18 14:25:30Z hhenkel $ " + "$URL: http://scm.foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/utils/utils.c $"; #define check_nprintf(size_get, size_want) \ if ((unsigned)(size_get) >= (unsigned)(size_want)) \ pdftex_fail ("snprintf failed: file %s, line %d", __FILE__, __LINE__); char *cur_file_name = NULL; -strnumber last_tex_string; +str_number last_tex_string; static char print_buf[PRINTF_BUF_SIZE]; static char *jobname_cstr = NULL; static char *job_id_string = NULL; @@ -176,14 +177,14 @@ void pdf_printf(const char *fmt, ...) va_end(args); } -strnumber maketexstring(const char *s) +str_number maketexstring(const char *s) { if (s == NULL || *s == 0) return get_nullstr(); return maketexlstring(s, strlen(s)); } -strnumber maketexlstring(const char *s, size_t l) +str_number maketexlstring(const char *s, size_t l) { if (s == NULL || l == 0) return get_nullstr(); @@ -297,7 +298,7 @@ void pdftex_warn(const char *fmt, ...) void tex_error(char *msg, char **hlp) { - strnumber aa = 0, bb = 0, cc = 0, dd = 0, ee = 0; + str_number aa = 0, bb = 0, cc = 0, dd = 0, ee = 0; int k = 0; if (hlp != NULL) { while (hlp[k] != NULL) @@ -471,7 +472,7 @@ void make_pdftex_banner(void) pdftexbanner_init = true; } -strnumber get_resname_prefix(void) +str_number get_resname_prefix(void) { /* static char name_str[] = */ /* "!\"$&'*+,-.0123456789:;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ\\" */ @@ -540,7 +541,7 @@ scaled ext_xn_over_d(scaled x, scaled n, scaled d) r += 0.5; else r -= 0.5; - if (r >= (double) maxinteger || r <= -(double) maxinteger) + if (r >= (double) max_integer || r <= -(double) max_integer) pdftex_warn("arithmetic: number too big"); return (scaled) r; } @@ -813,6 +814,7 @@ void unescapehex(poolpointer in) * hexadecimal encoded; * sizeof(out) should be at least lin*2+1. */ + static void convertStringToHexString(const char *in, char *out, int lin) { int i, j, k; @@ -859,7 +861,7 @@ static void convertStringToHexString(const char *in, char *out, int lin) scanning the info dict is also difficult, we start with a simpler implementation using just the first two items. */ -void print_ID(strnumber filename) +void print_ID(str_number filename) { time_t t; size_t size; @@ -1034,7 +1036,7 @@ void getcreationdate() That means, file names that are legal on some operation systems cannot any more be used since pdfTeX version 1.30.4. */ -char *makecfilename(strnumber s) +char *makecfilename(str_number s) { char *name = makecstring(s); char *p = name; @@ -1258,7 +1260,7 @@ int newcolorstack(integer s, integer literal_mode, boolean page_start) #define get_colstack(n) (&colstacks[n]) /* Puts a string on top of the string pool and updates pool_ptr. */ -void put_cstring_on_str_pool(poolpointer start, char *str) +static void put_cstring_on_str_pool(poolpointer start, char *str) { size_t len; @@ -1363,7 +1365,7 @@ integer colorstackpop(int colstack_no) return colstack->literal_mode; } -void colorstackpagestart() +static void colorstackpagestart() { int i, j; colstack_type *colstack; diff --git a/Build/source/texk/web2c/luatexdir/utils/utils.h b/Build/source/texk/web2c/luatexdir/utils/utils.h new file mode 100644 index 00000000000..0e55feb50aa --- /dev/null +++ b/Build/source/texk/web2c/luatexdir/utils/utils.h @@ -0,0 +1,109 @@ +/* utils.h + + 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/>. */ + +/* $Id: utils.h 2333 2009-04-18 17:45:46Z hhenkel $ */ + +#ifndef UTILS_H +# define UTILS_H + +# define overflow_string(a,b) { overflow(maketexstring(a),b); flush_str(last_tex_string); } + +integer fb_offset(void); +void fb_flush(void); +void fb_putchar(eight_bits b); +void fb_seek(integer); +void make_subset_tag(fd_entry *); +void pdf_puts(const char *); +__attribute__ ((format(printf, 1, 2))) +void pdf_printf(const char *, ...); +str_number maketexstring(const char *); +str_number maketexlstring(const char *, size_t); +void print_string(char *j); +void append_string(char *s); +__attribute__ ((format(printf, 1, 2))) +void tex_printf(const char *, ...); +void remove_pdffile(void); +__attribute__ ((noreturn, format(printf, 1, 2))) +void pdftex_fail(const char *, ...); +__attribute__ ((format(printf, 1, 2))) +void pdftex_warn(const char *, ...); +void tex_error(char *msg, char **hlp); +void garbage_warning(void); +char *makecstring(integer); +char *makeclstring(integer, size_t *); +void set_job_id(int, int, int, int); +void make_pdftex_banner(void); +str_number get_resname_prefix(void); +size_t xfwrite(void *, size_t size, size_t nmemb, FILE *); +int xfflush(FILE *); +int xgetc(FILE *); +int xputc(int, FILE *); +void write_stream_length(integer, longinteger); +scaled ext_xn_over_d(scaled, scaled, scaled); +void libpdffinish(void); +char *convertStringToPDFString(const char *in, int len); +void escapestring(poolpointer in); +void escapename(poolpointer in); +void escapehex(poolpointer in); +void unescapehex(poolpointer in); +void print_ID(str_number); +void init_start_time(); +void print_creation_date(); +void print_mod_date(); +void getcreationdate(void); +char *makecfilename(str_number s); +char *stripzeros(char *); +void initversionstring(char **versions); +extern void check_buffer_overflow(int wsize); +extern void check_pool_overflow(int wsize); + +extern str_number last_tex_string; +extern char *cur_file_name; +extern size_t last_ptr_index; + +/**********************************************************************/ +/* color stack and matrix transformation support */ + +int newcolorstack(integer s, integer literal_mode, boolean pagestart); +int colorstackused(); +integer colorstackset(int colstack_no, integer s); +integer colorstackpush(int colstack_no, integer s); +integer colorstackpop(int colstack_no); +integer colorstackcurrent(int colstack_no); +integer colorstackskippagestart(int colstack_no); +void checkpdfsave(scaledpos pos); +void checkpdfrestore(scaledpos pos); +void pdfshipoutbegin(boolean shipping_page); +void pdfshipoutend(boolean shipping_page); +void pdfsetmatrix(poolpointer in, scaledpos pos); +scaled getllx(); +scaled getlly(); +scaled geturx(); +scaled getury(); +void tconfusion(char *s); +void tprint(char *s); +void tprint_nl(char *s); +void tprint_esc(char *s); +void matrixtransformpoint(scaled x, scaled y); +void matrixtransformrect(scaled llx, scaled lly, scaled urx, scaled ury); +boolean matrixused(); +void matrixrecalculate(scaled urx); + +#endif /* UTILS_H */ |