~ubuntu-branches/ubuntu/saucy/luatex/saucy

« back to all changes in this revision

Viewing changes to source/texk/web2c/luatexdir/ptexmac.h

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Preining
  • Date: 2009-12-25 09:47:05 UTC
  • mfrom: (1.1.9 upstream) (4.2.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091225094705-y33rpflo8t4u9nag
Tags: 0.50.0-1
* new upstream release
* disable fix-hurd-ftbfs patch, included upstream
* disable upstram-fixes, included upstream
* disable ubuntu_libpoppler-0.11, not needed anymore

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* ptexmac.h
2
 
 
3
 
   Copyright 1996-2006 Han The Thanh <thanh@pdftex.org>
4
 
   Copyright 2006-2008 Taco Hoekwater <taco@luatex.org>
5
 
 
6
 
   This file is part of LuaTeX.
7
 
 
8
 
   LuaTeX is free software; you can redistribute it and/or modify it under
9
 
   the terms of the GNU General Public License as published by the Free
10
 
   Software Foundation; either version 2 of the License, or (at your
11
 
   option) any later version.
12
 
 
13
 
   LuaTeX is distributed in the hope that it will be useful, but WITHOUT
14
 
   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15
 
   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
16
 
   License for more details.
17
 
 
18
 
   You should have received a copy of the GNU General Public License along
19
 
   with LuaTeX; if not, see <http://www.gnu.org/licenses/>. */
20
 
 
21
 
/* $Id: ptexmac.h 2333 2009-04-18 17:45:46Z hhenkel $ */
22
 
 
23
 
#ifndef PTEXMAC_H
24
 
#  define PTEXMAC_H
25
 
 
26
 
/* Not all systems define it. */
27
 
#  ifndef M_PI
28
 
#    define M_PI           3.14159265358979323846
29
 
                                                /* pi */
30
 
#    define M_PI_2         1.5707963267948966192E0
31
 
                                                /* Hex 2^ 0 * 1.921FB54442D18 */
32
 
#    define M_PI_4         7.8539816339744830962E-1
33
 
                                                /* Hex 2^-1 * 1.921FB54442D18 */
34
 
#  endif
35
 
 
36
 
#  ifdef WIN32
37
 
/* Why relying on gmalloc() ???*/
38
 
#    define gmalloc(n) xmalloc(n)
39
 
#    define gfree(p) free(p)
40
 
#    define inline __inline
41
 
#    define srandom(n) srand(n)
42
 
#    define random() rand()
43
 
#  endif
44
 
 
45
 
/**********************************************************************/
46
 
/* Pascal WEB macros */
47
 
 
48
 
#  define max_integer      0x7FFFFFFF
49
 
#  define max_dimen        0x3FFFFFFF
50
 
 
51
 
#  define obj_info(a)      obj_tab[(a)].int0
52
 
#  define obj_link(a)      obj_tab[(a)].int1
53
 
#  define obj_offset(a)    obj_tab[(a)].int2
54
 
#  define obj_os_idx(a)    obj_tab[(a)].int3
55
 
#  define obj_aux(a)       obj_tab[(a)].int4
56
 
#  define obj_data_ptr     obj_aux
57
 
 
58
 
/* types of objects */
59
 
#  define obj_type_others  0    /* objects which are not linked in any list */
60
 
#  define obj_type_page    1    /* index of linked list of Page objects */
61
 
#  define obj_type_font    2    /* index of linked list of Fonts objects */
62
 
#  define obj_type_outline 3    /* index of linked list of outline objects */
63
 
#  define obj_type_dest    4    /* index of linked list of destination objects */
64
 
#  define obj_type_obj     5    /* index of linked list of raw objects */
65
 
#  define obj_type_xform   6    /* index of linked list of XObject forms */
66
 
#  define obj_type_ximage  7    /* index of linked list of XObject image */
67
 
#  define obj_type_thread  8    /* index of linked list of num article threads */
68
 
#  define head_tab_max     obj_type_thread      /* max index of |head_tab| */
69
 
 
70
 
#  define pdfroom(n) do {                                    \
71
 
    if ((unsigned)(n + pdf_ptr) > (unsigned)pdf_buf_size) {  \
72
 
        if (pdf_os_mode)                                     \
73
 
            zpdf_os_get_os_buf(n);                           \
74
 
        else {                                               \
75
 
            if ((unsigned)(n) > (unsigned)pdf_buf_size)      \
76
 
                pdftex_fail("PDF output buffer overflowed"); \
77
 
            else                                             \
78
 
                pdf_flush();                                 \
79
 
        }                                                    \
80
 
    }                                                        \
81
 
} while (0)
82
 
 
83
 
#  define pdfout(c)  do {   \
84
 
    pdfroom(1);             \
85
 
    pdf_buf[pdf_ptr++] = c; \
86
 
} while (0)
87
 
 
88
 
#  define pdfoffset()     (pdf_gone + pdf_ptr)
89
 
 
90
 
/**********************************************************************/
91
 
 
92
 
#  define PRINTF_BUF_SIZE     1024
93
 
#  define MAX_CSTRING_LEN     1024 * 1024
94
 
#  define MAX_PSTRING_LEN     1024
95
 
#  define SMALL_BUF_SIZE      256
96
 
#  define SMALL_ARRAY_SIZE    256
97
 
 
98
 
#  define check_buf(size, buf_size)                                 \
99
 
  if ((unsigned)(size) > (unsigned)(buf_size))                      \
100
 
    pdftex_fail("buffer overflow: %d > %d at file %s, line %d",     \
101
 
                (int)(size), (int)(buf_size), __FILE__,  __LINE__ )
102
 
 
103
 
#  define append_char_to_buf(c, p, buf, buf_size) do { \
104
 
    if (c == 9)                                        \
105
 
        c = 32;                                        \
106
 
    if (c == 13 || c == EOF)                           \
107
 
        c = 10;                                        \
108
 
    if (c != ' ' || (p > buf && p[-1] != 32)) {        \
109
 
        check_buf(p - buf + 1, (buf_size));            \
110
 
        *p++ = c;                                      \
111
 
    }                                                  \
112
 
} while (0)
113
 
 
114
 
#  define append_eol(p, buf, buf_size) do {            \
115
 
    check_buf(p - buf + 2, (buf_size));                \
116
 
    if (p - buf > 1 && p[-1] != 10)                    \
117
 
        *p++ = 10;                                     \
118
 
    if (p - buf > 2 && p[-2] == 32) {                  \
119
 
        p[-2] = 10;                                    \
120
 
        p--;                                           \
121
 
    }                                                  \
122
 
    *p = 0;                                            \
123
 
} while (0)
124
 
 
125
 
#  define remove_eol(p, buf) do {                      \
126
 
    p = strend(buf) - 1;                               \
127
 
    if (*p == 10)                                      \
128
 
        *p = 0;                                        \
129
 
} while (0)
130
 
 
131
 
#  define skip(p, c)   if (*p == c)  p++
132
 
 
133
 
#  define alloc_array(T, n, s) do {                    \
134
 
    if (T##_array == NULL) {                           \
135
 
        T##_limit = (s);                               \
136
 
        if ((unsigned)(n) > T##_limit)                 \
137
 
            T##_limit = (n);                           \
138
 
        T##_array = xtalloc(T##_limit, T##_entry);     \
139
 
        T##_ptr = T##_array;                           \
140
 
    }                                                  \
141
 
    else if ((unsigned)(T##_ptr - T##_array + (n)) > (unsigned)(T##_limit)) { \
142
 
        last_ptr_index = T##_ptr - T##_array;          \
143
 
        T##_limit *= 2;                                \
144
 
        if ((unsigned)(T##_ptr - T##_array + (n)) > (unsigned)(T##_limit)) \
145
 
            T##_limit = T##_ptr - T##_array + (n);     \
146
 
        xretalloc(T##_array, T##_limit, T##_entry);    \
147
 
        T##_ptr = T##_array + last_ptr_index;          \
148
 
    }                                                  \
149
 
} while (0)
150
 
 
151
 
#  define define_array(T)                   \
152
 
T##_entry      *T##_ptr, *T##_array = NULL; \
153
 
size_t          T##_limit
154
 
 
155
 
#  define xfree(p)            do { if (p != NULL) free(p); p = NULL; } while (0)
156
 
#  define strend(s)           strchr(s, 0)
157
 
#  define xtalloc             XTALLOC
158
 
#  define xretalloc           XRETALLOC
159
 
 
160
 
#  define set_cur_file_name(s) \
161
 
    cur_file_name = s;         \
162
 
    pack_file_name(maketexstring(cur_file_name), get_nullstr(), get_nullstr())
163
 
 
164
 
#  define cmp_return(a, b) \
165
 
    if ((a) > (b))         \
166
 
        return 1;          \
167
 
    if ((a) < (b))         \
168
 
        return -1
169
 
 
170
 
#  define str_prefix(s1, s2)  (strncmp((s1), (s2), strlen(s2)) == 0)
171
 
 
172
 
#endif                          /* PTEXMAC_H */