From 812aa90acbef4930ae356ab194f3f2a8f573f6e4 Mon Sep 17 00:00:00 2001 From: Martin Schröder Date: Tue, 26 Dec 2006 23:37:34 +0000 Subject: Import pdftex 1.40-rc4, which also changes the signature of print_version_and_exit, and adds a new library (libs/obsdcompat). git-svn-id: svn://tug.org/texlive/trunk@2959 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/web2c/pdftexdir/avlstuff.c | 119 ++++++++++++++++++--------- 1 file changed, 81 insertions(+), 38 deletions(-) (limited to 'Build/source/texk/web2c/pdftexdir/avlstuff.c') diff --git a/Build/source/texk/web2c/pdftexdir/avlstuff.c b/Build/source/texk/web2c/pdftexdir/avlstuff.c index 1fab93223f1..1a05c762eb1 100644 --- a/Build/source/texk/web2c/pdftexdir/avlstuff.c +++ b/Build/source/texk/web2c/pdftexdir/avlstuff.c @@ -1,5 +1,5 @@ /* -Copyright (c) 2004 Han The Thanh, +Copyright (c) 2004-2005 Han The Thanh, 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 @@ -15,9 +15,8 @@ You should have received a copy of the GNU General Public License along with this file; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -$Id: //depot/Build/source.development/TeX/texk/web2c/pdftexdir/avlstuff.c#5 $ +$Id: avlstuff.c,v 1.12 2005/07/11 20:27:39 hahe Exp hahe $ -formatted by indent -kr */ #include "ptexlib.h" @@ -25,16 +24,11 @@ formatted by indent -kr #include #include "avl.h" -static const char perforce_id[] = - "$Id: //depot/Build/source.development/TeX/texk/web2c/pdftexdir/avlstuff.c#5 $"; - -/* One AVL tree for each obj_type 0...pdfobjtypemax */ - static struct avl_table *PdfObjTree[pdfobjtypemax + 1] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; - -/* memory management functions for avl */ +/**********************************************************************/ +/* memory management functions for AVL */ void *avl_xmalloc(struct libavl_allocator *allocator, size_t size) { @@ -53,67 +47,89 @@ struct libavl_allocator avl_xallocator = { avl_xfree }; +/**********************************************************************/ +/* general AVL comparison functions */ -/* AVL sort objentry into avl_table[] */ +int comp_int_entry(const void *pa, const void *pb, void *p) +{ + cmp_return(*(const int *) pa, *(const int *) pb); + return 0; +} + +int comp_string_entry(const void *pa, const void *pb, void *p) +{ + return strcmp((const char *) pa, (const char *) pb); +} + +/**********************************************************************/ +/* One AVL tree for each obj_type 0...pdfobjtypemax */ + + +typedef struct oentry_ { + integer int0; + integer objptr; +} oentry; + +/* AVL sort oentry into avl_table[] */ int compare_info(const void *pa, const void *pb, void *param) { integer a, b; int as, ae, bs, be, al, bl; - a = ((const objentry *) pa)->int0; - b = ((const objentry *) pb)->int0; - if (a < 0 && b < 0) { /* string comparison */ + a = ((const oentry *) pa)->int0; + b = ((const oentry *) pb)->int0; + if (a < 0 && b < 0) { /* string comparison */ as = strstart[-a]; - ae = strstart[-a + 1]; /* start of next string in pool */ + ae = strstart[-a + 1]; /* start of next string in pool */ bs = strstart[-b]; be = strstart[-b + 1]; al = ae - as; bl = be - bs; - if (al < bl) /* compare first by string length */ + if (al < bl) /* compare first by string length */ return -1; - else if (al > bl) + if (al > bl) return 1; - else - for (; as < ae; as++, bs++) { - if (strpool[as] < strpool[bs]) - return -1; - if (strpool[as] > strpool[bs]) - return 1; - } - return 0; - } else { /* integer comparison */ + for (; as < ae; as++, bs++) { + if (strpool[as] < strpool[bs]) + return -1; + if (strpool[as] > strpool[bs]) + return 1; + } + } else { /* integer comparison */ if (a < b) return -1; - else if (a > b) + if (a > b) return 1; - else - return 0; } + return 0; } - void avlputobj(integer objptr, integer t) { static void **pp; + static oentry *oe; if (PdfObjTree[t] == NULL) { PdfObjTree[t] = avl_create(compare_info, NULL, &avl_xallocator); if (PdfObjTree[t] == NULL) pdftex_fail("avlstuff.c: avl_create() PdfObjTree failed"); } - pp = avl_probe(PdfObjTree[t], &(objtab[objptr])); + oe = xtalloc(1, oentry); + oe->int0 = objtab[objptr].int0; + oe->objptr = objptr; /* allows to relocate objtab */ + pp = avl_probe(PdfObjTree[t], oe); if (pp == NULL) pdftex_fail("avlstuff.c: avl_probe() out of memory in insertion"); } -/* replacement for linear search pascal function "find_obj" */ +/* replacement for linear search pascal function "find_obj()" */ integer avlfindobj(integer t, integer i, integer byname) { - static objentry *p; - static objentry tmp; + static oentry *p; + static oentry tmp; if (byname > 0) tmp.int0 = -i; @@ -121,11 +137,38 @@ integer avlfindobj(integer t, integer i, integer byname) tmp.int0 = i; if (PdfObjTree[t] == NULL) return 0; - p = (objentry *) avl_find(PdfObjTree[t], &tmp); + p = (oentry *) avl_find(PdfObjTree[t], &tmp); if (p == NULL) return 0; - else - return (int) (p - (objentry *) objtab); + return p->objptr; +} + +/**********************************************************************/ + +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) +{ + oentry *p = (oentry *) pa; + xfree(p); +} + +void PdfObjTree_free() +{ + int i; + + for (i = 0; i <= pdfobjtypemax; i++) { + if (PdfObjTree[i] != NULL) + avl_destroy(PdfObjTree[i], destroy_oentry); + } } -/* end of file avlstuff.c */ +/**********************************************************************/ -- cgit v1.2.3