~ubuntu-branches/ubuntu/quantal/openmotif/quantal

« back to all changes in this revision

Viewing changes to tools/wml/wml.c

  • Committer: Bazaar Package Importer
  • Author(s): Stefan Bauer
  • Date: 2010-06-23 12:12:31 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20100623121231-u89gxdp51sg9wjj2
Tags: 2.3.0-1
* New Maintainer (Closes: #379258) 
* Acknowledge NMU changes
* New upstream release (Closes: #494375)
* Get rid of security patches as they are already part of new upstream
  release (00-xpmvuln.openmotif.patch, 342092-CVE-2005-3964.patch)
* Bump Standards to 3.8.4
* Added {misc:Depends} to make the package lintian cleaner
* Fix weak-library-dev-dependency by adding ${binary:Version}) for the
  -dev Package of openmotif
* Let package depend on autotools-dev to use newer autotools-helper-files
* Work around an autoconf-bug (Gentoo-Bug #1475)
* Added Client-side anti-aliased fonts support via XFT
* Added UTF-8 and UTF8_STRING atom support
* Ability to show text and pixmaps in Label, LabelGadget and all
  derived widgets
* Support of PNG/JPEG image formats in the same way as XPM is supported
* Increase FILE_OFFSET_BITS to 64 to show files >2GB in file-selector
  Idea taken from Magne Oestlyngen (Closes: #288537)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* 
 
2
 *  @OPENGROUP_COPYRIGHT@
 
3
 *  COPYRIGHT NOTICE
 
4
 *  Copyright (c) 1990, 1991, 1992, 1993 Open Software Foundation, Inc.
 
5
 *  Copyright (c) 1996, 1997, 1998, 1999, 2000 The Open Group
 
6
 *  ALL RIGHTS RESERVED (MOTIF). See the file named COPYRIGHT.MOTIF for
 
7
 *  the full copyright text.
 
8
 *  
 
9
 *  This software is subject to an open license. It may only be
 
10
 *  used on, with or for operating systems which are themselves open
 
11
 *  source systems. You must contact The Open Group for a license
 
12
 *  allowing distribution and sublicensing of this software on, with,
 
13
 *  or for operating systems which are not Open Source programs.
 
14
 *  
 
15
 *  See http://www.opengroup.org/openmotif/license for full
 
16
 *  details of the license agreement. Any use, reproduction, or
 
17
 *  distribution of the program constitutes recipient's acceptance of
 
18
 *  this agreement.
 
19
 *  
 
20
 *  EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS
 
21
 *  PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 
22
 *  KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY
 
23
 *  WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY
 
24
 *  OR FITNESS FOR A PARTICULAR PURPOSE
 
25
 *  
 
26
 *  EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT
 
27
 *  NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT,
 
28
 *  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 
29
 *  DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED
 
30
 *  AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 
31
 *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
 
32
 *  ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE
 
33
 *  EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE
 
34
 *  POSSIBILITY OF SUCH DAMAGES.
 
35
*/ 
 
36
/* 
 
37
 * HISTORY
 
38
*/ 
 
39
#ifdef REV_INFO
 
40
#ifndef lint
 
41
static char rcsid[] = "$TOG: wml.c /main/8 1999/04/16 09:41:47 mgreess $"
 
42
#endif
 
43
#endif
 
44
 
 
45
#ifdef HAVE_CONFIG_H
 
46
#include <config.h>
 
47
#endif
 
48
 
 
49
 
 
50
/*
 
51
*  (c) Copyright 1989, 1990, DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS. */
 
52
 
 
53
/*
 
54
 * This is the main program for WML. It declares all global data structures
 
55
 * used during a compilation, and during output.
 
56
 */
 
57
 
 
58
/*
 
59
 * WML is a semi-standard Unix application. It reads its input from
 
60
 * stdin, which is expected to be a stream containing a WML description
 
61
 * of a UIL language. If this stream is successfully parsed and semantically
 
62
 * validated, then WML writes a series of standard .h and .dat files into
 
63
 * the user directory. The .h files will be used directly to construct
 
64
 * the UIL compiler. The .dat files are used by other phases of UIL
 
65
 * table generation.
 
66
 *
 
67
 * The files created by WML are:
 
68
 *
 
69
 *      .h files:
 
70
 *              UilSymGen.h
 
71
 *              UilSymArTy.h
 
72
 *              UilSymRArg.h
 
73
 *              UilDrmClas.h
 
74
 *              UilConst.h
 
75
 *              UilSymReas.h
 
76
 *              UilSymArTa.h
 
77
 *              UilSymCtl.h
 
78
 *              UilSymNam.h
 
79
 *      .dat files
 
80
 *              argument.dat
 
81
 *              reason.dat
 
82
 *              grammar.dat
 
83
 *      .mm files
 
84
 *              wml-uil.mm
 
85
 */
 
86
 
 
87
#include "wml.h"
 
88
 
 
89
#ifdef HAVE_FCNTL_H
 
90
#include <fcntl.h>
 
91
#else
 
92
#include <sys/file.h>
 
93
#endif
 
94
#include <stdio.h>
 
95
#include <stdlib.h>
 
96
 
 
97
 
 
98
/*
 
99
 * Globals used during WML parsing.
 
100
 *
 
101
 * WML uses globals exclusively to communicate data during parsing. The
 
102
 * current object being constructed is held by these globals, and all
 
103
 * routines called from the parse assume correct setting of these globals.
 
104
 * This simplisitic approach is possible since the WML description language
 
105
 * has no recursive constructs requiring a frame stack.
 
106
 */
 
107
 
 
108
/*
 
109
 * Error and other counts
 
110
 */
 
111
int             wml_err_count = 0;      /* total errors */
 
112
int             wml_line_count = 0;     /* lines read from input */
 
113
 
 
114
/*
 
115
 * Dynamic ordered vector of all objects encountered during parse. This
 
116
 * is used to detect name collisions, and is the primary order vector
 
117
 * used for all other vectors constructed curing the semantic resolution
 
118
 * phase of processing.
 
119
 */
 
120
DynamicHandleListDef    wml_synobj;
 
121
DynamicHandleListDefPtr wml_synobj_ptr = &wml_synobj;
 
122
 
 
123
 
 
124
/*
 
125
 * Dynamic vectors of vectors partitioned and ordered
 
126
 * as required by the semantic processing and output routines. All
 
127
 * point to resolved objects rather than syntactic objects.
 
128
 */
 
129
DynamicHandleListDef    wml_obj_datatype;       /* datatype objects */
 
130
DynamicHandleListDefPtr wml_obj_datatype_ptr = &wml_obj_datatype;
 
131
 
 
132
DynamicHandleListDef    wml_obj_enumval;        /* enumeration value objects */
 
133
DynamicHandleListDefPtr wml_obj_enumval_ptr = &wml_obj_enumval;
 
134
 
 
135
DynamicHandleListDef    wml_obj_enumset;        /* enumeration set objects */
 
136
DynamicHandleListDefPtr wml_obj_enumset_ptr = &wml_obj_enumset;
 
137
 
 
138
DynamicHandleListDef    wml_obj_reason; /* reason resource objects */
 
139
DynamicHandleListDefPtr wml_obj_reason_ptr = &wml_obj_reason;
 
140
 
 
141
DynamicHandleListDef    wml_obj_arg;    /* argument resource objects */
 
142
DynamicHandleListDefPtr wml_obj_arg_ptr = &wml_obj_arg;
 
143
 
 
144
DynamicHandleListDef    wml_obj_child;  /* argument resource objects */
 
145
DynamicHandleListDefPtr wml_obj_child_ptr = &wml_obj_child;
 
146
 
 
147
DynamicHandleListDef    wml_obj_allclass;       /* metaclass, widget, gadget */
 
148
DynamicHandleListDefPtr wml_obj_allclass_ptr = &wml_obj_allclass;
 
149
 
 
150
DynamicHandleListDef    wml_obj_class;          /* widget & gadget objects */
 
151
DynamicHandleListDefPtr wml_obj_class_ptr = &wml_obj_class;
 
152
 
 
153
DynamicHandleListDef    wml_obj_ctrlist;        /* controls list objects */
 
154
DynamicHandleListDefPtr wml_obj_ctrlist_ptr = &wml_obj_ctrlist;
 
155
 
 
156
DynamicHandleListDef    wml_obj_charset;        /* charset objects */
 
157
DynamicHandleListDefPtr wml_obj_charset_ptr = &wml_obj_charset;
 
158
 
 
159
DynamicHandleListDef    wml_tok_sens;           /* case-sensitive tokens */
 
160
DynamicHandleListDefPtr wml_tok_sens_ptr = &wml_tok_sens;
 
161
 
 
162
DynamicHandleListDef    wml_tok_insens;         /* case-insensitive tokens */
 
163
DynamicHandleListDefPtr wml_tok_insens_ptr = &wml_tok_insens;
 
164
 
 
165
 
 
166
/*
 
167
 * Routines only accessible in this module
 
168
 */
 
169
void wmlInit ();
 
170
 
 
171
/*
 
172
 * External variables
 
173
 */
 
174
extern  int     yyleng;
 
175
 
 
176
 
 
177
 
 
178
 
 
179
/*
 
180
 * The WML main routine:
 
181
 *
 
182
 *      1. Initialize global storage
 
183
 *      2. Open the input file if there is one
 
184
 *      3. Parse the WML description in stdin. Exit on errors
 
185
 *      4. Perform semantic validation and resolution. Exit on errors.
 
186
 *      5. Output files
 
187
 */
 
188
 
 
189
int main (argc, argv)
 
190
    int         argc;
 
191
    char        **argv;
 
192
 
 
193
{
 
194
 
 
195
int             done;
 
196
int             fd;             /* input file descriptor */
 
197
 
 
198
/*
 
199
 * Initialize storage
 
200
 */
 
201
wmlInit ();
 
202
 
 
203
/*
 
204
 * Assume that anything in argv must be an input file. Open it, and
 
205
 * dup it to stdin
 
206
 */
 
207
if ( argc > 1 )
 
208
    {
 
209
    if ( (fd=open(argv[1],O_RDONLY)) == -1 )
 
210
        printf ("\nCouldn't open file %s", argv[1]);
 
211
    else
 
212
        dup2 (fd, 0);
 
213
    }
 
214
 
 
215
/*
 
216
 * Process the input
 
217
 */
 
218
done = 0;
 
219
while (!done)
 
220
    {
 
221
    
 
222
    /*
 
223
     * Parse the input stream
 
224
     */
 
225
    yyleng = 0;         /* initialization safety */
 
226
    yyparse ();
 
227
    if ( wml_err_count > 0 ) break;
 
228
    printf ("\nParse of WML input complete");
 
229
    
 
230
    /*
 
231
     * Perform semantic validation, and construct resolved data structures
 
232
     */
 
233
    wmlResolveDescriptors ();
 
234
    if ( wml_err_count > 0 ) break;
 
235
    printf ("\nSemantic validation and resolution complete");
 
236
    
 
237
    /*
 
238
     * Output 
 
239
     */
 
240
    wmlOutput ();
 
241
    if ( wml_err_count > 0 ) break;
 
242
    printf ("\nWML Uil*.h and wml-uil.mm file creation complete\n");
 
243
    
 
244
    done = 1;
 
245
    }
 
246
 
 
247
/*
 
248
 * Report inaction on errors
 
249
 */
 
250
if ( wml_err_count > 0 )
 
251
    {
 
252
    printf ("\nWML found %d errors, no or incomplete output produced\n",
 
253
            wml_err_count);
 
254
     /* Begin fixing the bug CR 4748 */
 
255
     exit(1);
 
256
     /* End fixing the bug CR 4748 */
 
257
    }
 
258
 
 
259
return (0);
 
260
 
 
261
}
 
262
 
 
263
 
 
264
/*
 
265
 * Routine to initialize WML.
 
266
 *
 
267
 * The main job is to dynamically allocate any dynamic lists to a reasonable
 
268
 * initial state.
 
269
 */
 
270
void wmlInit ()
 
271
 
 
272
{
 
273
 
 
274
/*
 
275
 * Initialize the list of all syntactic objects
 
276
 */
 
277
wmlInitHList (wml_synobj_ptr, 1000, TRUE);
 
278
 
 
279
}
 
280
 
 
281
int yywrap()
 
282
{
 
283
return(1);
 
284
}