+++ /dev/null
-/* include/config.h. Generated automatically by configure. */
-/* include/config.h.in. Generated automatically from configure.in by autoheader. */
-
-/* Define if using alloca.c. */
-/* #undef C_ALLOCA */
-
-/* Define to empty if the keyword does not work. */
-/* #undef const */
-
-/* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems.
- This function is required for alloca.c support on those systems. */
-/* #undef CRAY_STACKSEG_END */
-
-/* Define if you have alloca, as a function or macro. */
-#define HAVE_ALLOCA 1
-
-/* Define if you have <alloca.h> and it should be used (not on Ultrix). */
-#define HAVE_ALLOCA_H 1
-
-/* Define as __inline if that's what the C compiler calls it. */
-/* #undef inline */
-
-/* Define to `unsigned' if <sys/types.h> doesn't define. */
-/* #undef size_t */
-
-/* If using the C implementation of alloca, define if you know the
- direction of stack growth for your system; otherwise it will be
- automatically deduced at run-time.
- STACK_DIRECTION > 0 => grows toward higher addresses
- STACK_DIRECTION < 0 => grows toward lower addresses
- STACK_DIRECTION = 0 => direction of growth unknown
- */
-/* #undef STACK_DIRECTION */
-
-/* Define if the `S_IS*' macros in <sys/stat.h> do not work properly. */
-/* #undef STAT_MACROS_BROKEN */
-
-/* Define if you have the ANSI C header files. */
-#define STDC_HEADERS 1
-
-/* Define if your processor stores words with the most significant
- byte first (like Motorola and SPARC, unlike Intel and VAX). */
-/* #undef WORDS_BIGENDIAN */
-
-/* Define if the X Window System is missing or not being used. */
-/* #undef X_DISPLAY_MISSING */
-
-/* Define if lex declares yytext as a char * by default, not a char[]. */
-#define YYTEXT_POINTER 1
-
-/* Define if symbols declared in assembly code need an underscore prefix */
-/* #undef NEED_UNDERSCORE_PREFIX */
-
-/* Define to use .string instead of .ascii */
-#define HAVE_ASM_STRING 1
-
-/* Define if struct msghdr contains msg_accrights */
-/* #undef HAVE_MSGHDR_ACCRIGHTS */
-
-/* Define if struct sockaddr_un contains sun_len */
-/* #undef HAVE_SOCKADDR_SUN_LEN */
-
-/* Define if you have the Xxf86dga library (-lXxf86dga). */
-#define HAVE_LIBXXF86DGA 1
-
-/* Define if you have the Xxf86dga library version 2.0 (-lXxf86dga). */
-/* #undef HAVE_LIBXXF86DGA2 */
-
-/* Define if you have the X Shm extension */
-#define HAVE_LIBXXSHM 1
-
-/* Define if you have the X Shape extension */
-#define HAVE_LIBXSHAPE 1
-
-/* Define if you have the Xxf86vm library */
-#define HAVE_LIBXXF86VM 1
-
-/* Define if you have the Xpm library */
-#define HAVE_LIBXXPM 1
-
-/* Define if you have the Open Sound system. */
-#define HAVE_OSS 1
-
-/* Define if you have the Open Sound system (MIDI interface). */
-#define HAVE_OSS_MIDI 1
-
-/* Define if X libraries are not reentrant (compiled without -D_REENTRANT). */
-/* #undef NO_REENTRANT_X11 */
-
-/* Define if libc is not reentrant */
-/* #undef NO_REENTRANT_LIBC */
-
-/* Define if libc uses __errno_location for reentrant errno */
-#define HAVE__ERRNO_LOCATION 1
-
-/* Define if libc uses __error for reentrant errno */
-/* #undef HAVE__ERROR */
-
-/* Define if libc uses ___errno for reentrant errno */
-/* #undef HAVE___ERRNO */
-
-/* Define if libc uses __thr_errno for reentrant errno */
-/* #undef HAVE__THR_ERRNO */
-
-/* Define if all debug messages are to be compiled out */
-/* #undef NO_DEBUG_MSGS */
-
-/* Define if TRACE messages are to be compiled out */
-/* #undef NO_TRACE_MSGS */
-
-/* Define if the struct statfs has the member bavail */
-#define STATFS_HAS_BAVAIL 1
-
-/* Define if the struct statfs has the member bfree */
-#define STATFS_HAS_BFREE 1
-
-/* Define if the struct statfs is defined by <sys/vfs.h> */
-#define STATFS_DEFINED_BY_SYS_VFS 1
-
-/* Define if the struct statfs is defined by <sys/statfs.h> */
-#define STATFS_DEFINED_BY_SYS_STATFS 1
-
-/* Define if the struct statfs is defined by <sys/mount.h> */
-/* #undef STATFS_DEFINED_BY_SYS_MOUNT */
-
-/* Define if ncurses have the new resizeterm function */
-#define HAVE_RESIZETERM 1
-
-/* Define if ncurses have the new getbkgd function */
-#define HAVE_GETBKGD 1
-
-/* Define if IPX should use netipx/ipx.h from libc */
-#define HAVE_IPX_GNU 1
-
-/* Define if IPX includes are taken from Linux kernel */
-/* #undef HAVE_IPX_LINUX */
-
-/* Define if OpenGL is present on the system or not */
-#define HAVE_OPENGL 1
-
-/* Define if the system has dynamic link library support with the dl* API */
-#define HAVE_DL_API 1
-
-/* Define if <linux/joystick.h> defines the Linux 2.2 joystick API */
-#define HAVE_LINUX_22_JOYSTICK_API 1
-
-/* Define if the OpenGL library supports the glXGetProcAddressARB call */
-/* #undef HAVE_GLX_GETPROCADDRESS */
-
-/* Define if the OpenGL headers define extension typedefs */
-/* #undef HAVE_GLEXT_PROTOTYPES */
-
-/* The number of bytes in a long long. */
-#define SIZEOF_LONG_LONG 8
-
-/* Define if you have the __libc_fork function. */
-/* #undef HAVE___LIBC_FORK */
-
-/* Define if you have the _lwp_create function. */
-/* #undef HAVE__LWP_CREATE */
-
-/* Define if you have the clone function. */
-#define HAVE_CLONE 1
-
-/* Define if you have the connect function. */
-#define HAVE_CONNECT 1
-
-/* Define if you have the dlopen function. */
-/* #undef HAVE_DLOPEN */
-
-/* Define if you have the gethostbyname function. */
-#define HAVE_GETHOSTBYNAME 1
-
-/* Define if you have the getnetbyaddr function. */
-#define HAVE_GETNETBYADDR 1
-
-/* Define if you have the getnetbyname function. */
-#define HAVE_GETNETBYNAME 1
-
-/* Define if you have the getpagesize function. */
-#define HAVE_GETPAGESIZE 1
-
-/* Define if you have the getprotobyname function. */
-#define HAVE_GETPROTOBYNAME 1
-
-/* Define if you have the getprotobynumber function. */
-#define HAVE_GETPROTOBYNUMBER 1
-
-/* Define if you have the getservbyport function. */
-#define HAVE_GETSERVBYPORT 1
-
-/* Define if you have the getsockopt function. */
-#define HAVE_GETSOCKOPT 1
-
-/* Define if you have the inet_network function. */
-#define HAVE_INET_NETWORK 1
-
-/* Define if you have the memmove function. */
-#define HAVE_MEMMOVE 1
-
-/* Define if you have the openpty function. */
-#define HAVE_OPENPTY 1
-
-/* Define if you have the rfork function. */
-/* #undef HAVE_RFORK */
-
-/* Define if you have the select function. */
-#define HAVE_SELECT 1
-
-/* Define if you have the sendmsg function. */
-#define HAVE_SENDMSG 1
-
-/* Define if you have the settimeofday function. */
-#define HAVE_SETTIMEOFDAY 1
-
-/* Define if you have the sigaltstack function. */
-/* #undef HAVE_SIGALTSTACK */
-
-/* Define if you have the statfs function. */
-#define HAVE_STATFS 1
-
-/* Define if you have the strcasecmp function. */
-#define HAVE_STRCASECMP 1
-
-/* Define if you have the strerror function. */
-#define HAVE_STRERROR 1
-
-/* Define if you have the strncasecmp function. */
-#define HAVE_STRNCASECMP 1
-
-/* Define if you have the tcgetattr function. */
-#define HAVE_TCGETATTR 1
-
-/* Define if you have the timegm function. */
-#define HAVE_TIMEGM 1
-
-/* Define if you have the usleep function. */
-#define HAVE_USLEEP 1
-
-/* Define if you have the vfscanf function. */
-#define HAVE_VFSCANF 1
-
-/* Define if you have the wait4 function. */
-#define HAVE_WAIT4 1
-
-/* Define if you have the waitpid function. */
-#define HAVE_WAITPID 1
-
-/* Define if you have the <GL/gl.h> header file. */
-#define HAVE_GL_GL_H 1
-
-/* Define if you have the <GL/glext.h> header file. */
-/* #undef HAVE_GL_GLEXT_H */
-
-/* Define if you have the <GL/glx.h> header file. */
-#define HAVE_GL_GLX_H 1
-
-/* Define if you have the <X11/Xlib.h> header file. */
-#define HAVE_X11_XLIB_H 1
-
-/* Define if you have the <X11/extensions/XShm.h> header file. */
-#define HAVE_X11_EXTENSIONS_XSHM_H 1
-
-/* Define if you have the <X11/extensions/shape.h> header file. */
-#define HAVE_X11_EXTENSIONS_SHAPE_H 1
-
-/* Define if you have the <X11/extensions/xf86dga.h> header file. */
-#define HAVE_X11_EXTENSIONS_XF86DGA_H 1
-
-/* Define if you have the <X11/extensions/xf86vmode.h> header file. */
-#define HAVE_X11_EXTENSIONS_XF86VMODE_H 1
-
-/* Define if you have the <X11/xpm.h> header file. */
-#define HAVE_X11_XPM_H 1
-
-/* Define if you have the <a.out.h> header file. */
-#define HAVE_A_OUT_H 1
-
-/* Define if you have the <a_out.h> header file. */
-#define HAVE_A_OUT_H 1
-
-/* Define if you have the <arpa/inet.h> header file. */
-#define HAVE_ARPA_INET_H 1
-
-/* Define if you have the <arpa/nameser.h> header file. */
-#define HAVE_ARPA_NAMESER_H 1
-
-/* Define if you have the <curses.h> header file. */
-/* #undef HAVE_CURSES_H */
-
-/* Define if you have the <dlfcn.h> header file. */
-#define HAVE_DLFCN_H 1
-
-/* Define if you have the <elf.h> header file. */
-#define HAVE_ELF_H 1
-
-/* Define if you have the <float.h> header file. */
-#define HAVE_FLOAT_H 1
-
-/* Define if you have the <libio.h> header file. */
-#define HAVE_LIBIO_H 1
-
-/* Define if you have the <libutil.h> header file. */
-/* #undef HAVE_LIBUTIL_H */
-
-/* Define if you have the <link.h> header file. */
-#define HAVE_LINK_H 1
-
-/* Define if you have the <linux/cdrom.h> header file. */
-#define HAVE_LINUX_CDROM_H 1
-
-/* Define if you have the <linux/joystick.h> header file. */
-#define HAVE_LINUX_JOYSTICK_H 1
-
-/* Define if you have the <linux/ucdrom.h> header file. */
-/* #undef HAVE_LINUX_UCDROM_H */
-
-/* Define if you have the <machine/soundcard.h> header file. */
-/* #undef HAVE_MACHINE_SOUNDCARD_H */
-
-/* Define if you have the <ncurses.h> header file. */
-#define HAVE_NCURSES_H 1
-
-/* Define if you have the <net/if.h> header file. */
-#define HAVE_NET_IF_H 1
-
-/* Define if you have the <netinet/in.h> header file. */
-#define HAVE_NETINET_IN_H 1
-
-/* Define if you have the <netinet/tcp.h> header file. */
-#define HAVE_NETINET_TCP_H 1
-
-/* Define if you have the <pty.h> header file. */
-#define HAVE_PTY_H 1
-
-/* Define if you have the <resolv.h> header file. */
-#define HAVE_RESOLV_H 1
-
-/* Define if you have the <sched.h> header file. */
-#define HAVE_SCHED_H 1
-
-/* Define if you have the <socket.h> header file. */
-/* #undef HAVE_SOCKET_H */
-
-/* Define if you have the <soundcard.h> header file. */
-/* #undef HAVE_SOUNDCARD_H */
-
-/* Define if you have the <strings.h> header file. */
-#define HAVE_STRINGS_H 1
-
-/* Define if you have the <sys/cdio.h> header file. */
-/* #undef HAVE_SYS_CDIO_H */
-
-/* Define if you have the <sys/errno.h> header file. */
-#define HAVE_SYS_ERRNO_H 1
-
-/* Define if you have the <sys/file.h> header file. */
-#define HAVE_SYS_FILE_H 1
-
-/* Define if you have the <sys/filio.h> header file. */
-/* #undef HAVE_SYS_FILIO_H */
-
-/* Define if you have the <sys/ipc.h> header file. */
-#define HAVE_SYS_IPC_H 1
-
-/* Define if you have the <sys/lwp.h> header file. */
-/* #undef HAVE_SYS_LWP_H */
-
-/* Define if you have the <sys/mman.h> header file. */
-#define HAVE_SYS_MMAN_H 1
-
-/* Define if you have the <sys/modem.h> header file. */
-/* #undef HAVE_SYS_MODEM_H */
-
-/* Define if you have the <sys/mount.h> header file. */
-#define HAVE_SYS_MOUNT_H 1
-
-/* Define if you have the <sys/msg.h> header file. */
-#define HAVE_SYS_MSG_H 1
-
-/* Define if you have the <sys/param.h> header file. */
-#define HAVE_SYS_PARAM_H 1
-
-/* Define if you have the <sys/reg.h> header file. */
-#define HAVE_SYS_REG_H 1
-
-/* Define if you have the <sys/shm.h> header file. */
-#define HAVE_SYS_SHM_H 1
-
-/* Define if you have the <sys/signal.h> header file. */
-#define HAVE_SYS_SIGNAL_H 1
-
-/* Define if you have the <sys/socket.h> header file. */
-#define HAVE_SYS_SOCKET_H 1
-
-/* Define if you have the <sys/sockio.h> header file. */
-/* #undef HAVE_SYS_SOCKIO_H */
-
-/* Define if you have the <sys/soundcard.h> header file. */
-#define HAVE_SYS_SOUNDCARD_H 1
-
-/* Define if you have the <sys/statfs.h> header file. */
-#define HAVE_SYS_STATFS_H 1
-
-/* Define if you have the <sys/strtio.h> header file. */
-/* #undef HAVE_SYS_STRTIO_H */
-
-/* Define if you have the <sys/syscall.h> header file. */
-#define HAVE_SYS_SYSCALL_H 1
-
-/* Define if you have the <sys/v86.h> header file. */
-/* #undef HAVE_SYS_V86_H */
-
-/* Define if you have the <sys/v86intr.h> header file. */
-/* #undef HAVE_SYS_V86INTR_H */
-
-/* Define if you have the <sys/vfs.h> header file. */
-#define HAVE_SYS_VFS_H 1
-
-/* Define if you have the <sys/vm86.h> header file. */
-#define HAVE_SYS_VM86_H 1
-
-/* Define if you have the <sys/wait.h> header file. */
-#define HAVE_SYS_WAIT_H 1
-
-/* Define if you have the <syscall.h> header file. */
-#define HAVE_SYSCALL_H 1
-
-/* Define if you have the <ucontext.h> header file. */
-/* #undef HAVE_UCONTEXT_H */
-
-/* Define if you have the curses library (-lcurses). */
-/* #undef HAVE_LIBCURSES */
-
-/* Define if you have the i386 library (-li386). */
-/* #undef HAVE_LIBI386 */
-
-/* Define if you have the m library (-lm). */
-#define HAVE_LIBM 1
-
-/* Define if you have the mmap library (-lmmap). */
-/* #undef HAVE_LIBMMAP */
-
-/* Define if you have the ncurses library (-lncurses). */
-#define HAVE_LIBNCURSES 1
-
-/* Define if you have the ossaudio library (-lossaudio). */
-/* #undef HAVE_LIBOSSAUDIO */
-
-/* Define if you have the w library (-lw). */
-/* #undef HAVE_LIBW */
-
-/* Define if you have the xpg4 library (-lxpg4). */
-/* #undef HAVE_LIBXPG4 */
+++ /dev/null
-/* Getopt for GNU.
- NOTE: getopt is now part of the C library, so if you don't know what
- "Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu
- before changing it!
-
- Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97
- Free Software Foundation, Inc.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The GNU C Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the GNU C Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
-\f
-/* This tells Alpha OSF/1 not to define a getopt prototype in <stdio.h>.
- Ditto for AIX 3.2 and <stdlib.h>. */
-#ifndef _NO_PROTO
-#define _NO_PROTO
-#endif
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#if !defined (__STDC__) || !__STDC__
-/* This is a separate conditional since some stdc systems
- reject `defined (const)'. */
-#ifndef const
-#define const
-#endif
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-
-/* Comment out all this code if we are using the GNU C Library, and are not
- actually compiling the library itself. This code is part of the GNU C
- Library, but also included in many other GNU distributions. Compiling
- and linking in this code is a waste when using the GNU C library
- (especially if it is a shared library). Rather than having every GNU
- program understand `configure --with-gnu-libc' and omit the object files,
- it is simpler to just do this in the source for each such file. */
-
-#define GETOPT_INTERFACE_VERSION 2
-#if !defined (_LIBC) && defined (__GLIBC__) && __GLIBC__ >= 2
-#include <gnu-versions.h>
-#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
-#define ELIDE_CODE
-#endif
-#endif
-
-#ifndef ELIDE_CODE
-
-
-/* This needs to come after some library #include
- to get __GNU_LIBRARY__ defined. */
-#ifdef __GNU_LIBRARY__
-/* Don't include stdlib.h for non-GNU C libraries because some of them
- contain conflicting prototypes for getopt. */
-#include <stdlib.h>
-#include <unistd.h>
-#endif /* GNU C library. */
-
-#ifdef VMS
-#include <unixlib.h>
-#if HAVE_STRING_H - 0
-#include <string.h>
-#endif
-#endif
-
-#if defined (WIN32) && !defined (__CYGWIN32__)
-/* It's not Unix, really. See? Capital letters. */
-#include <windows.h>
-#define getpid() GetCurrentProcessId()
-#endif
-
-#ifndef _
-/* This is for other GNU distributions with internationalized messages.
- When compiling libc, the _ macro is predefined. */
-#ifdef HAVE_LIBINTL_H
-# include <libintl.h>
-# define _(msgid) gettext (msgid)
-#else
-# define _(msgid) (msgid)
-#endif
-#endif
-
-/* This version of `getopt' appears to the caller like standard Unix `getopt'
- but it behaves differently for the user, since it allows the user
- to intersperse the options with the other arguments.
-
- As `getopt' works, it permutes the elements of ARGV so that,
- when it is done, all the options precede everything else. Thus
- all application programs are extended to handle flexible argument order.
-
- Setting the environment variable POSIXLY_CORRECT disables permutation.
- Then the behavior is completely standard.
-
- GNU application programs can use a third alternative mode in which
- they can distinguish the relative order of options and other arguments. */
-
-#include "getopt.h"
-
-/* For communication from `getopt' to the caller.
- When `getopt' finds an option that takes an argument,
- the argument value is returned here.
- Also, when `ordering' is RETURN_IN_ORDER,
- each non-option ARGV-element is returned here. */
-
-char *optarg = NULL;
-
-/* Index in ARGV of the next element to be scanned.
- This is used for communication to and from the caller
- and for communication between successive calls to `getopt'.
-
- On entry to `getopt', zero means this is the first call; initialize.
-
- When `getopt' returns -1, this is the index of the first of the
- non-option elements that the caller should itself scan.
-
- Otherwise, `optind' communicates from one call to the next
- how much of ARGV has been scanned so far. */
-
-/* 1003.2 says this must be 1 before any call. */
-int optind = 1;
-
-/* Formerly, initialization of getopt depended on optind==0, which
- causes problems with re-calling getopt as programs generally don't
- know that. */
-
-int __getopt_initialized = 0;
-
-/* The next char to be scanned in the option-element
- in which the last option character we returned was found.
- This allows us to pick up the scan where we left off.
-
- If this is zero, or a null string, it means resume the scan
- by advancing to the next ARGV-element. */
-
-static char *nextchar;
-
-/* Callers store zero here to inhibit the error message
- for unrecognized options. */
-
-int opterr = 1;
-
-/* Set to an option character which was unrecognized.
- This must be initialized on some systems to avoid linking in the
- system's own getopt implementation. */
-
-int optopt = '?';
-
-/* Describe how to deal with options that follow non-option ARGV-elements.
-
- If the caller did not specify anything,
- the default is REQUIRE_ORDER if the environment variable
- POSIXLY_CORRECT is defined, PERMUTE otherwise.
-
- REQUIRE_ORDER means don't recognize them as options;
- stop option processing when the first non-option is seen.
- This is what Unix does.
- This mode of operation is selected by either setting the environment
- variable POSIXLY_CORRECT, or using `+' as the first character
- of the list of option characters.
-
- PERMUTE is the default. We permute the contents of ARGV as we scan,
- so that eventually all the non-options are at the end. This allows options
- to be given in any order, even with programs that were not written to
- expect this.
-
- RETURN_IN_ORDER is an option available to programs that were written
- to expect options and other ARGV-elements in any order and that care about
- the ordering of the two. We describe each non-option ARGV-element
- as if it were the argument of an option with character code 1.
- Using `-' as the first character of the list of option characters
- selects this mode of operation.
-
- The special argument `--' forces an end of option-scanning regardless
- of the value of `ordering'. In the case of RETURN_IN_ORDER, only
- `--' can cause `getopt' to return -1 with `optind' != ARGC. */
-
-static enum
-{
- REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER
-} ordering;
-
-/* Value of POSIXLY_CORRECT environment variable. */
-static char *posixly_correct;
-\f
-#ifdef __GNU_LIBRARY__
-/* We want to avoid inclusion of string.h with non-GNU libraries
- because there are many ways it can cause trouble.
- On some systems, it contains special magic macros that don't work
- in GCC. */
-#include <string.h>
-#define my_index strchr
-#else
-
-/* Avoid depending on library functions or files
- whose names are inconsistent. */
-
-//char *getenv ();
-
-static char *
-my_index (str, chr)
- const char *str;
- int chr;
-{
- while (*str)
- {
- if (*str == chr)
- return (char *) str;
- str++;
- }
- return 0;
-}
-
-/* If using GCC, we can safely declare strlen this way.
- If not using GCC, it is ok not to declare it. */
-#ifdef __GNUC__
-/* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h.
- That was relevant to code that was here before. */
-#if !defined (__STDC__) || !__STDC__
-/* gcc with -traditional declares the built-in strlen to return int,
- and has done so at least since version 2.4.5. -- rms. */
-extern int strlen (const char *);
-#endif /* not __STDC__ */
-#endif /* __GNUC__ */
-
-#endif /* not __GNU_LIBRARY__ */
-\f
-/* Handle permutation of arguments. */
-
-/* Describe the part of ARGV that contains non-options that have
- been skipped. `first_nonopt' is the index in ARGV of the first of them;
- `last_nonopt' is the index after the last of them. */
-
-static int first_nonopt;
-static int last_nonopt;
-
-#ifdef _LIBC
-/* Bash 2.0 gives us an environment variable containing flags
- indicating ARGV elements that should not be considered arguments. */
-
-/* Defined in getopt_init.c */
-extern char *__getopt_nonoption_flags;
-
-static int nonoption_flags_max_len;
-static int nonoption_flags_len;
-
-static int original_argc;
-static char *const *original_argv;
-
-extern pid_t __libc_pid;
-
-/* Make sure the environment variable bash 2.0 puts in the environment
- is valid for the getopt call we must make sure that the ARGV passed
- to getopt is that one passed to the process. */
-static void
-__attribute__ ((unused))
-store_args_and_env (int argc, char *const *argv)
-{
- /* XXX This is no good solution. We should rather copy the args so
- that we can compare them later. But we must not use malloc(3). */
- original_argc = argc;
- original_argv = argv;
-}
-text_set_element (__libc_subinit, store_args_and_env);
-
-# define SWAP_FLAGS(ch1, ch2) \
- if (nonoption_flags_len > 0) \
- { \
- char __tmp = __getopt_nonoption_flags[ch1]; \
- __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \
- __getopt_nonoption_flags[ch2] = __tmp; \
- }
-#else /* !_LIBC */
-# define SWAP_FLAGS(ch1, ch2)
-#endif /* _LIBC */
-
-/* Exchange two adjacent subsequences of ARGV.
- One subsequence is elements [first_nonopt,last_nonopt)
- which contains all the non-options that have been skipped so far.
- The other is elements [last_nonopt,optind), which contains all
- the options processed since those non-options were skipped.
-
- `first_nonopt' and `last_nonopt' are relocated so that they describe
- the new indices of the non-options in ARGV after they are moved. */
-
-#if defined (__STDC__) && __STDC__
-static void exchange (char **);
-#endif
-
-static void
-exchange (argv)
- char **argv;
-{
- int bottom = first_nonopt;
- int middle = last_nonopt;
- int top = optind;
- char *tem;
-
- /* Exchange the shorter segment with the far end of the longer segment.
- That puts the shorter segment into the right place.
- It leaves the longer segment in the right place overall,
- but it consists of two parts that need to be swapped next. */
-
-#ifdef _LIBC
- /* First make sure the handling of the `__getopt_nonoption_flags'
- string can work normally. Our top argument must be in the range
- of the string. */
- if (nonoption_flags_len > 0 && top >= nonoption_flags_max_len)
- {
- /* We must extend the array. The user plays games with us and
- presents new arguments. */
- char *new_str = malloc (top + 1);
- if (new_str == NULL)
- nonoption_flags_len = nonoption_flags_max_len = 0;
- else
- {
- memcpy (new_str, __getopt_nonoption_flags, nonoption_flags_max_len);
- memset (&new_str[nonoption_flags_max_len], '\0',
- top + 1 - nonoption_flags_max_len);
- nonoption_flags_max_len = top + 1;
- __getopt_nonoption_flags = new_str;
- }
- }
-#endif
-
- while (top > middle && middle > bottom)
- {
- if (top - middle > middle - bottom)
- {
- /* Bottom segment is the short one. */
- int len = middle - bottom;
- register int i;
-
- /* Swap it with the top part of the top segment. */
- for (i = 0; i < len; i++)
- {
- tem = argv[bottom + i];
- argv[bottom + i] = argv[top - (middle - bottom) + i];
- argv[top - (middle - bottom) + i] = tem;
- SWAP_FLAGS (bottom + i, top - (middle - bottom) + i);
- }
- /* Exclude the moved bottom segment from further swapping. */
- top -= len;
- }
- else
- {
- /* Top segment is the short one. */
- int len = top - middle;
- register int i;
-
- /* Swap it with the bottom part of the bottom segment. */
- for (i = 0; i < len; i++)
- {
- tem = argv[bottom + i];
- argv[bottom + i] = argv[middle + i];
- argv[middle + i] = tem;
- SWAP_FLAGS (bottom + i, middle + i);
- }
- /* Exclude the moved top segment from further swapping. */
- bottom += len;
- }
- }
-
- /* Update records for the slots the non-options now occupy. */
-
- first_nonopt += (optind - last_nonopt);
- last_nonopt = optind;
-}
-
-/* Initialize the internal data when the first call is made. */
-
-#if defined (__STDC__) && __STDC__
-static const char *_getopt_initialize (int, char *const *, const char *);
-#endif
-static const char *
-_getopt_initialize (argc, argv, optstring)
- int argc;
- char *const *argv;
- const char *optstring;
-{
- /* Start processing options with ARGV-element 1 (since ARGV-element 0
- is the program name); the sequence of previously skipped
- non-option ARGV-elements is empty. */
-
- first_nonopt = last_nonopt = optind;
-
- nextchar = NULL;
-
- posixly_correct = getenv ("POSIXLY_CORRECT");
-
- /* Determine how to handle the ordering of options and nonoptions. */
-
- if (optstring[0] == '-')
- {
- ordering = RETURN_IN_ORDER;
- ++optstring;
- }
- else if (optstring[0] == '+')
- {
- ordering = REQUIRE_ORDER;
- ++optstring;
- }
- else if (posixly_correct != NULL)
- ordering = REQUIRE_ORDER;
- else
- ordering = PERMUTE;
-
-#ifdef _LIBC
- if (posixly_correct == NULL
- && argc == original_argc && argv == original_argv)
- {
- if (nonoption_flags_max_len == 0)
- {
- if (__getopt_nonoption_flags == NULL
- || __getopt_nonoption_flags[0] == '\0')
- nonoption_flags_max_len = -1;
- else
- {
- const char *orig_str = __getopt_nonoption_flags;
- int len = nonoption_flags_max_len = strlen (orig_str);
- if (nonoption_flags_max_len < argc)
- nonoption_flags_max_len = argc;
- __getopt_nonoption_flags =
- (char *) malloc (nonoption_flags_max_len);
- if (__getopt_nonoption_flags == NULL)
- nonoption_flags_max_len = -1;
- else
- {
- memcpy (__getopt_nonoption_flags, orig_str, len);
- memset (&__getopt_nonoption_flags[len], '\0',
- nonoption_flags_max_len - len);
- }
- }
- }
- nonoption_flags_len = nonoption_flags_max_len;
- }
- else
- nonoption_flags_len = 0;
-#endif
-
- return optstring;
-}
-\f
-/* Scan elements of ARGV (whose length is ARGC) for option characters
- given in OPTSTRING.
-
- If an element of ARGV starts with '-', and is not exactly "-" or "--",
- then it is an option element. The characters of this element
- (aside from the initial '-') are option characters. If `getopt'
- is called repeatedly, it returns successively each of the option characters
- from each of the option elements.
-
- If `getopt' finds another option character, it returns that character,
- updating `optind' and `nextchar' so that the next call to `getopt' can
- resume the scan with the following option character or ARGV-element.
-
- If there are no more option characters, `getopt' returns -1.
- Then `optind' is the index in ARGV of the first ARGV-element
- that is not an option. (The ARGV-elements have been permuted
- so that those that are not options now come last.)
-
- OPTSTRING is a string containing the legitimate option characters.
- If an option character is seen that is not listed in OPTSTRING,
- return '?' after printing an error message. If you set `opterr' to
- zero, the error message is suppressed but we still return '?'.
-
- If a char in OPTSTRING is followed by a colon, that means it wants an arg,
- so the following text in the same ARGV-element, or the text of the following
- ARGV-element, is returned in `optarg'. Two colons mean an option that
- wants an optional arg; if there is text in the current ARGV-element,
- it is returned in `optarg', otherwise `optarg' is set to zero.
-
- If OPTSTRING starts with `-' or `+', it requests different methods of
- handling the non-option ARGV-elements.
- See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above.
-
- Long-named options begin with `--' instead of `-'.
- Their names may be abbreviated as long as the abbreviation is unique
- or is an exact match for some defined option. If they have an
- argument, it follows the option name in the same ARGV-element, separated
- from the option name by a `=', or else the in next ARGV-element.
- When `getopt' finds a long-named option, it returns 0 if that option's
- `flag' field is nonzero, the value of the option's `val' field
- if the `flag' field is zero.
-
- The elements of ARGV aren't really const, because we permute them.
- But we pretend they're const in the prototype to be compatible
- with other systems.
-
- LONGOPTS is a vector of `struct option' terminated by an
- element containing a name which is zero.
-
- LONGIND returns the index in LONGOPT of the long-named option found.
- It is only valid when a long-named option has been found by the most
- recent call.
-
- If LONG_ONLY is nonzero, '-' as well as '--' can introduce
- long-named options. */
-
-int
-_getopt_internal (argc, argv, optstring, longopts, longind, long_only)
- int argc;
- char *const *argv;
- const char *optstring;
- const struct option *longopts;
- int *longind;
- int long_only;
-{
- optarg = NULL;
-
- if (optind == 0 || !__getopt_initialized)
- {
- if (optind == 0)
- optind = 1; /* Don't scan ARGV[0], the program name. */
- optstring = _getopt_initialize (argc, argv, optstring);
- __getopt_initialized = 1;
- }
-
- /* Test whether ARGV[optind] points to a non-option argument.
- Either it does not have option syntax, or there is an environment flag
- from the shell indicating it is not an option. The later information
- is only used when the used in the GNU libc. */
-#ifdef _LIBC
-#define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0' \
- || (optind < nonoption_flags_len \
- && __getopt_nonoption_flags[optind] == '1'))
-#else
-#define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0')
-#endif
-
- if (nextchar == NULL || *nextchar == '\0')
- {
- /* Advance to the next ARGV-element. */
-
- /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been
- moved back by the user (who may also have changed the arguments). */
- if (last_nonopt > optind)
- last_nonopt = optind;
- if (first_nonopt > optind)
- first_nonopt = optind;
-
- if (ordering == PERMUTE)
- {
- /* If we have just processed some options following some non-options,
- exchange them so that the options come first. */
-
- if (first_nonopt != last_nonopt && last_nonopt != optind)
- exchange ((char **) argv);
- else if (last_nonopt != optind)
- first_nonopt = optind;
-
- /* Skip any additional non-options
- and extend the range of non-options previously skipped. */
-
- while (optind < argc && NONOPTION_P)
- optind++;
- last_nonopt = optind;
- }
-
- /* The special ARGV-element `--' means premature end of options.
- Skip it like a null option,
- then exchange with previous non-options as if it were an option,
- then skip everything else like a non-option. */
-
- if (optind != argc && !strcmp (argv[optind], "--"))
- {
- optind++;
-
- if (first_nonopt != last_nonopt && last_nonopt != optind)
- exchange ((char **) argv);
- else if (first_nonopt == last_nonopt)
- first_nonopt = optind;
- last_nonopt = argc;
-
- optind = argc;
- }
-
- /* If we have done all the ARGV-elements, stop the scan
- and back over any non-options that we skipped and permuted. */
-
- if (optind == argc)
- {
- /* Set the next-arg-index to point at the non-options
- that we previously skipped, so the caller will digest them. */
- if (first_nonopt != last_nonopt)
- optind = first_nonopt;
- return -1;
- }
-
- /* If we have come to a non-option and did not permute it,
- either stop the scan or describe it to the caller and pass it by. */
-
- if (NONOPTION_P)
- {
- if (ordering == REQUIRE_ORDER)
- return -1;
- optarg = argv[optind++];
- return 1;
- }
-
- /* We have found another option-ARGV-element.
- Skip the initial punctuation. */
-
- nextchar = (argv[optind] + 1
- + (longopts != NULL && argv[optind][1] == '-'));
- }
-
- /* Decode the current option-ARGV-element. */
-
- /* Check whether the ARGV-element is a long option.
-
- If long_only and the ARGV-element has the form "-f", where f is
- a valid short option, don't consider it an abbreviated form of
- a long option that starts with f. Otherwise there would be no
- way to give the -f short option.
-
- On the other hand, if there's a long option "fubar" and
- the ARGV-element is "-fu", do consider that an abbreviation of
- the long option, just like "--fu", and not "-f" with arg "u".
-
- This distinction seems to be the most useful approach. */
-
- if (longopts != NULL
- && (argv[optind][1] == '-'
- || (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1])))))
- {
- char *nameend;
- const struct option *p;
- const struct option *pfound = NULL;
- int exact = 0;
- int ambig = 0;
- int indfound = -1;
- int option_index;
-
- for (nameend = nextchar; *nameend && *nameend != '='; nameend++)
- /* Do nothing. */ ;
-
- /* Test all long options for either exact match
- or abbreviated matches. */
- for (p = longopts, option_index = 0; p->name; p++, option_index++)
- if (!strncmp (p->name, nextchar, nameend - nextchar))
- {
- if ((unsigned int) (nameend - nextchar)
- == (unsigned int) strlen (p->name))
- {
- /* Exact match found. */
- pfound = p;
- indfound = option_index;
- exact = 1;
- break;
- }
- else if (pfound == NULL)
- {
- /* First nonexact match found. */
- pfound = p;
- indfound = option_index;
- }
- else
- /* Second or later nonexact match found. */
- ambig = 1;
- }
-
- if (ambig && !exact)
- {
- if (opterr)
- fprintf (stderr, _("%s: option `%s' is ambiguous\n"),
- argv[0], argv[optind]);
- nextchar += strlen (nextchar);
- optind++;
- optopt = 0;
- return '?';
- }
-
- if (pfound != NULL)
- {
- option_index = indfound;
- optind++;
- if (*nameend)
- {
- /* Don't test has_arg with >, because some C compilers don't
- allow it to be used on enums. */
- if (pfound->has_arg)
- optarg = nameend + 1;
- else
- {
- if (opterr)
- {
- if (argv[optind - 1][1] == '-')
- /* --option */
- fprintf (stderr,
- _("%s: option `--%s' doesn't allow an argument\n"),
- argv[0], pfound->name);
- else
- /* +option or -option */
- fprintf (stderr,
- _("%s: option `%c%s' doesn't allow an argument\n"),
- argv[0], argv[optind - 1][0], pfound->name);
- }
- nextchar += strlen (nextchar);
-
- optopt = pfound->val;
- return '?';
- }
- }
- else if (pfound->has_arg == 1)
- {
- if (optind < argc)
- optarg = argv[optind++];
- else
- {
- if (opterr)
- fprintf (stderr,
- _("%s: option `%s' requires an argument\n"),
- argv[0], argv[optind - 1]);
- nextchar += strlen (nextchar);
- optopt = pfound->val;
- return optstring[0] == ':' ? ':' : '?';
- }
- }
- nextchar += strlen (nextchar);
- if (longind != NULL)
- *longind = option_index;
- if (pfound->flag)
- {
- *(pfound->flag) = pfound->val;
- return 0;
- }
- return pfound->val;
- }
-
- /* Can't find it as a long option. If this is not getopt_long_only,
- or the option starts with '--' or is not a valid short
- option, then it's an error.
- Otherwise interpret it as a short option. */
- if (!long_only || argv[optind][1] == '-'
- || my_index (optstring, *nextchar) == NULL)
- {
- if (opterr)
- {
- if (argv[optind][1] == '-')
- /* --option */
- fprintf (stderr, _("%s: unrecognized option `--%s'\n"),
- argv[0], nextchar);
- else
- /* +option or -option */
- fprintf (stderr, _("%s: unrecognized option `%c%s'\n"),
- argv[0], argv[optind][0], nextchar);
- }
- nextchar = (char *) "";
- optind++;
- optopt = 0;
- return '?';
- }
- }
-
- /* Look at and handle the next short option-character. */
-
- {
- char c = *nextchar++;
- char *temp = my_index (optstring, c);
-
- /* Increment `optind' when we start to process its last character. */
- if (*nextchar == '\0')
- ++optind;
-
- if (temp == NULL || c == ':')
- {
- if (opterr)
- {
- if (posixly_correct)
- /* 1003.2 specifies the format of this message. */
- fprintf (stderr, _("%s: illegal option -- %c\n"),
- argv[0], c);
- else
- fprintf (stderr, _("%s: invalid option -- %c\n"),
- argv[0], c);
- }
- optopt = c;
- return '?';
- }
- /* Convenience. Treat POSIX -W foo same as long option --foo */
- if (temp[0] == 'W' && temp[1] == ';')
- {
- char *nameend;
- const struct option *p;
- const struct option *pfound = NULL;
- int exact = 0;
- int ambig = 0;
- int indfound = 0;
- int option_index;
-
- /* This is an option that requires an argument. */
- if (*nextchar != '\0')
- {
- optarg = nextchar;
- /* If we end this ARGV-element by taking the rest as an arg,
- we must advance to the next element now. */
- optind++;
- }
- else if (optind == argc)
- {
- if (opterr)
- {
- /* 1003.2 specifies the format of this message. */
- fprintf (stderr, _("%s: option requires an argument -- %c\n"),
- argv[0], c);
- }
- optopt = c;
- if (optstring[0] == ':')
- c = ':';
- else
- c = '?';
- return c;
- }
- else
- /* We already incremented `optind' once;
- increment it again when taking next ARGV-elt as argument. */
- optarg = argv[optind++];
-
- /* optarg is now the argument, see if it's in the
- table of longopts. */
-
- for (nextchar = nameend = optarg; *nameend && *nameend != '='; nameend++)
- /* Do nothing. */ ;
-
- /* Test all long options for either exact match
- or abbreviated matches. */
- for (p = longopts, option_index = 0; p->name; p++, option_index++)
- if (!strncmp (p->name, nextchar, nameend - nextchar))
- {
- if ((unsigned int) (nameend - nextchar) == strlen (p->name))
- {
- /* Exact match found. */
- pfound = p;
- indfound = option_index;
- exact = 1;
- break;
- }
- else if (pfound == NULL)
- {
- /* First nonexact match found. */
- pfound = p;
- indfound = option_index;
- }
- else
- /* Second or later nonexact match found. */
- ambig = 1;
- }
- if (ambig && !exact)
- {
- if (opterr)
- fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"),
- argv[0], argv[optind]);
- nextchar += strlen (nextchar);
- optind++;
- return '?';
- }
- if (pfound != NULL)
- {
- option_index = indfound;
- if (*nameend)
- {
- /* Don't test has_arg with >, because some C compilers don't
- allow it to be used on enums. */
- if (pfound->has_arg)
- optarg = nameend + 1;
- else
- {
- if (opterr)
- fprintf (stderr, _("\
-%s: option `-W %s' doesn't allow an argument\n"),
- argv[0], pfound->name);
-
- nextchar += strlen (nextchar);
- return '?';
- }
- }
- else if (pfound->has_arg == 1)
- {
- if (optind < argc)
- optarg = argv[optind++];
- else
- {
- if (opterr)
- fprintf (stderr,
- _("%s: option `%s' requires an argument\n"),
- argv[0], argv[optind - 1]);
- nextchar += strlen (nextchar);
- return optstring[0] == ':' ? ':' : '?';
- }
- }
- nextchar += strlen (nextchar);
- if (longind != NULL)
- *longind = option_index;
- if (pfound->flag)
- {
- *(pfound->flag) = pfound->val;
- return 0;
- }
- return pfound->val;
- }
- nextchar = NULL;
- return 'W'; /* Let the application handle it. */
- }
- if (temp[1] == ':')
- {
- if (temp[2] == ':')
- {
- /* This is an option that accepts an argument optionally. */
- if (*nextchar != '\0')
- {
- optarg = nextchar;
- optind++;
- }
- else
- optarg = NULL;
- nextchar = NULL;
- }
- else
- {
- /* This is an option that requires an argument. */
- if (*nextchar != '\0')
- {
- optarg = nextchar;
- /* If we end this ARGV-element by taking the rest as an arg,
- we must advance to the next element now. */
- optind++;
- }
- else if (optind == argc)
- {
- if (opterr)
- {
- /* 1003.2 specifies the format of this message. */
- fprintf (stderr,
- _("%s: option requires an argument -- %c\n"),
- argv[0], c);
- }
- optopt = c;
- if (optstring[0] == ':')
- c = ':';
- else
- c = '?';
- }
- else
- /* We already incremented `optind' once;
- increment it again when taking next ARGV-elt as argument. */
- optarg = argv[optind++];
- nextchar = NULL;
- }
- }
- return c;
- }
-}
-
-int
-getopt (argc, argv, optstring)
- int argc;
- char *const *argv;
- const char *optstring;
-{
- return _getopt_internal (argc, argv, optstring,
- (const struct option *) 0,
- (int *) 0,
- 0);
-}
-
-#endif /* Not ELIDE_CODE. */
-\f
-#ifdef TEST
-
-/* Compile with -DTEST to make an executable for use in testing
- the above definition of `getopt'. */
-
-int
-main (argc, argv)
- int argc;
- char **argv;
-{
- int c;
- int digit_optind = 0;
-
- while (1)
- {
- int this_option_optind = optind ? optind : 1;
-
- c = getopt (argc, argv, "abc:d:0123456789");
- if (c == -1)
- break;
-
- switch (c)
- {
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- if (digit_optind != 0 && digit_optind != this_option_optind)
- printf ("digits occur in two different argv-elements.\n");
- digit_optind = this_option_optind;
- printf ("option %c\n", c);
- break;
-
- case 'a':
- printf ("option a\n");
- break;
-
- case 'b':
- printf ("option b\n");
- break;
-
- case 'c':
- printf ("option c with value `%s'\n", optarg);
- break;
-
- case '?':
- break;
-
- default:
- printf ("?? getopt returned character code 0%o ??\n", c);
- }
- }
-
- if (optind < argc)
- {
- printf ("non-option ARGV-elements: ");
- while (optind < argc)
- printf ("%s ", argv[optind++]);
- printf ("\n");
- }
-
- exit (0);
-}
-
-#endif /* TEST */
+++ /dev/null
-/* Declarations for getopt.
- Copyright (C) 1989,90,91,92,93,94,96,97 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The GNU C Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the GNU C Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
-
-#ifndef _GETOPT_H
-#define _GETOPT_H 1
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* For communication from `getopt' to the caller.
- When `getopt' finds an option that takes an argument,
- the argument value is returned here.
- Also, when `ordering' is RETURN_IN_ORDER,
- each non-option ARGV-element is returned here. */
-
-extern char *optarg;
-
-/* Index in ARGV of the next element to be scanned.
- This is used for communication to and from the caller
- and for communication between successive calls to `getopt'.
-
- On entry to `getopt', zero means this is the first call; initialize.
-
- When `getopt' returns -1, this is the index of the first of the
- non-option elements that the caller should itself scan.
-
- Otherwise, `optind' communicates from one call to the next
- how much of ARGV has been scanned so far. */
-
-extern int optind;
-
-/* Callers store zero here to inhibit the error message `getopt' prints
- for unrecognized options. */
-
-extern int opterr;
-
-/* Set to an option character which was unrecognized. */
-
-extern int optopt;
-
-/* Describe the long-named options requested by the application.
- The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector
- of `struct option' terminated by an element containing a name which is
- zero.
-
- The field `has_arg' is:
- no_argument (or 0) if the option does not take an argument,
- required_argument (or 1) if the option requires an argument,
- optional_argument (or 2) if the option takes an optional argument.
-
- If the field `flag' is not NULL, it points to a variable that is set
- to the value given in the field `val' when the option is found, but
- left unchanged if the option is not found.
-
- To have a long-named option do something other than set an `int' to
- a compiled-in constant, such as set a value from `optarg', set the
- option's `flag' field to zero and its `val' field to a nonzero
- value (the equivalent single-letter option character, if there is
- one). For long options that have a zero `flag' field, `getopt'
- returns the contents of the `val' field. */
-
-struct option
-{
-#if defined (__STDC__) && __STDC__
- const char *name;
-#else
- char *name;
-#endif
- /* has_arg can't be an enum because some compilers complain about
- type mismatches in all the code that assumes it is an int. */
- int has_arg;
- int *flag;
- int val;
-};
-
-/* Names for the values of the `has_arg' field of `struct option'. */
-
-#define no_argument 0
-#define required_argument 1
-#define optional_argument 2
-
-#if defined (__STDC__) && __STDC__
-#ifdef __GNU_LIBRARY__
-/* Many other libraries have conflicting prototypes for getopt, with
- differences in the consts, in stdlib.h. To avoid compilation
- errors, only prototype getopt for the GNU C library. */
-extern int getopt (int argc, char *const *argv, const char *shortopts);
-#else /* not __GNU_LIBRARY__ */
-extern int getopt ();
-#endif /* __GNU_LIBRARY__ */
-extern int getopt_long (int argc, char *const *argv, const char *shortopts,
- const struct option *longopts, int *longind);
-extern int getopt_long_only (int argc, char *const *argv,
- const char *shortopts,
- const struct option *longopts, int *longind);
-
-/* Internal only. Users should not call this directly. */
-extern int _getopt_internal (int argc, char *const *argv,
- const char *shortopts,
- const struct option *longopts, int *longind,
- int long_only);
-#else /* not __STDC__ */
-extern int getopt ();
-extern int getopt_long ();
-extern int getopt_long_only ();
-
-extern int _getopt_internal ();
-#endif /* __STDC__ */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _GETOPT_H */
+++ /dev/null
-/*
- * Wine Message Compiler language and codepage support
- *
- * Copyright 2000 Bertho A. Stultiens (BS)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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 Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-#include <windows.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-
-#include "wmc.h"
-#include "lang.h"
-
-
-/*
- * Languages supported
- *
- * MUST be sorting ascending on language ID
- */
-static const language_t languages[] = {
-
- {0x0402, 866, 1251, "Bulgarian", "Bulgaria"},
- {0x0403, 850, 1252, "Catalan", "Spain"},
- {0x0405, 852, 1250, "Czech", "Czech Republic"},
- {0x0406, 850, 1252, "Danish", "Denmark"},
- {0x0407, 850, 1252, "German", "Germany"},
- {0x0408, 737, 1253, "Greek", "Greece"},
- {0x0409, 437, 1252, "English", "United States"},
- {0x040A, 850, 1252, "Spanish - Traditional Sort", "Spain"},
- {0x040B, 850, 1252, "Finnish", "Finland"},
- {0x040C, 850, 1252, "French", "France"},
- {0x040E, 852, 1250, "Hungarian", "Hungary"},
- {0x040F, 850, 1252, "Icelandic", "Iceland"},
- {0x0410, 850, 1252, "Italian", "Italy"},
- {0x0411, 932, 932, "Japanese", "Japan"},
- {0x0412, 949, 949, "Korean", "Korea (south)"},
- {0x0413, 850, 1252, "Dutch", "Netherlands"},
- {0x0414, 850, 1252, "Norwegian (Bokmål)", "Norway"},
- {0x0415, 852, 1250, "Polish", "Poland"},
- {0x0416, 850, 1252, "Portuguese", "Brazil"},
- {0x0418, 852, 1250, "Romanian", "Romania"},
- {0x0419, 866, 1251, "Russian", "Russia"},
- {0x041A, 852, 1250, "Croatian", "Croatia"},
- {0x041B, 852, 1250, "Slovak", "Slovakia"},
- {0x041C, 852, 1250, "Albanian", "Albania"},
- {0x041D, 850, 1252, "Swedish", "Sweden"},
- {0x041F, 857, 1254, "Turkish", "Turkey"},
- {0x0421, 850, 1252, "Indonesian", "Indonesia"},
- {0x0422, 866, 1251, "Ukrainian", "Ukraine"},
- {0x0423, 866, 1251, "Belarusian", "Belarus"},
- {0x0424, 852, 1250, "Slovene", "Slovenia"},
- {0x0425, 775, 1257, "Estonian", "Estonia"},
- {0x0426, 775, 1257, "Latvian", "Latvia"},
- {0x0427, 775, 1257, "Lithuanian", "Lithuania"},
-/* {0x042A, ?, ?, "Vietnamese", "Vietnam"},*/
- {0x042D, 850, 1252, "Basque", "Spain"},
- {0x042F, 866, 1251, "Macedonian", "Former Yugoslav Republic of Macedonia"},
- {0x0436, 850, 1252, "Afrikaans", "South Africa"},
-/* {0x0438, 852, 1252, "Faroese", "Faroe Islands"}, FIXME: Not sure about codepages */
- {0x043C, 437, 1252, "Irish", "Ireland"},
-/* {0x048F, ?, ?, "Esperanto", "<none>"},*/
-/* {0x0804, ?, ?, "Chinese (People's replublic of China)", People's republic of China"},*/
- {0x0807, 850, 1252, "German", "Switzerland"},
- {0x0809, 850, 1252, "English", "United Kingdom"},
- {0x080A, 850, 1252, "Spanish", "Mexico"},
- {0x080C, 850, 1252, "French", "Belgium"},
- {0x0810, 850, 1252, "Italian", "Switzerland"},
- {0x0813, 850, 1252, "Dutch", "Belgium"},
- {0x0814, 850, 1252, "Norwegian (Nynorsk)", "Norway"},
- {0x0816, 850, 1252, "Portuguese", "Portugal"},
-/* {0x081A, ?, ?, "Serbian (latin)", "Yugoslavia"},*/
- {0x081D, 850, 1252, "Swedish (Finland)", "Finland"},
- {0x0C07, 850, 1252, "German", "Austria"},
- {0x0C09, 850, 1252, "English", "Australia"},
- {0x0C0A, 850, 1252, "Spanish - International Sort", "Spain"},
- {0x0C0C, 850, 1252, "French", "Canada"},
- {0x0C1A, 855, 1251, "Serbian (Cyrillic)", "Serbia"},
- {0x1007, 850, 1252, "German", "Luxembourg"},
- {0x1009, 850, 1252, "English", "Canada"},
- {0x100A, 850, 1252, "Spanish", "Guatemala"},
- {0x100C, 850, 1252, "French", "Switzerland"},
- {0x1407, 850, 1252, "German", "Liechtenstein"},
- {0x1409, 850, 1252, "English", "New Zealand"},
- {0x140A, 850, 1252, "Spanish", "Costa Rica"},
- {0x140C, 850, 1252, "French", "Luxembourg"},
- {0x1809, 850, 1252, "English", "Ireland"},
- {0x180A, 850, 1252, "Spanish", "Panama"},
- {0x1C09, 437, 1252, "English", "South Africa"},
- {0x1C0A, 850, 1252, "Spanish", "Dominican Republic"},
- {0x2009, 850, 1252, "English", "Jamaica"},
- {0x200A, 850, 1252, "Spanish", "Venezuela"},
- {0x2409, 850, 1252, "English", "Caribbean"},
- {0x240A, 850, 1252, "Spanish", "Colombia"},
- {0x2809, 850, 1252, "English", "Belize"},
- {0x280A, 850, 1252, "Spanish", "Peru"},
- {0x2C09, 437, 1252, "English", "Trinidad & Tobago"},
- {0x2C0A, 850, 1252, "Spanish", "Argentina"},
- {0x300A, 850, 1252, "Spanish", "Ecuador"},
- {0x340A, 850, 1252, "Spanish", "Chile"},
- {0x380A, 850, 1252, "Spanish", "Uruguay"},
- {0x3C0A, 850, 1252, "Spanish", "Paraguay"},
- {0x400A, 850, 1252, "Spanish", "Bolivia"},
- {0x440A, 850, 1252, "Spanish", "El Salvador"},
- {0x480A, 850, 1252, "Spanish", "Honduras"},
- {0x4C0A, 850, 1252, "Spanish", "Nicaragua"},
- {0x500A, 850, 1252, "Spanish", "Puerto Rico"}
-};
-
-#define NLAN (sizeof(languages)/sizeof(languages[0]))
-
-void show_languages(void)
-{
- int i;
- printf(" Code | DOS-cp | WIN-cp | Language | Country\n");
- printf("-------+--------+--------+--------------+---------\n");
- for(i = 0; i < NLAN; i++)
- printf("0x%04x | %5d | %5d | %-12s | %s\n",
- languages[i].id,
- languages[i].doscp,
- languages[i].wincp,
- languages[i].name,
- languages[i].country);
-}
-
-static int langcmp(const void *p1, const void *p2)
-{
- return *(unsigned *)p1 - ((language_t *)p2)->id;
-}
-
-const language_t *find_language(unsigned id)
-{
- return (const language_t *)bsearch(&id, languages, NLAN, sizeof(languages[0]), langcmp);
-}
-
-void show_codepages(void)
-{
-#if 0
- unsigned i;
- const union cptable *cpp;
- printf("Codepages:\n");
- for(i = 0; (cpp = cp_enum_table(i)); i++)
- {
- printf("%-5d %s\n", cpp->info.codepage, cpp->info.name);
- }
-#endif
-}
-
-#if 0
-const union cptable *find_codepage(int id)
-{
- return cp_get_table(id);
-}
-#endif
+++ /dev/null
-/*
- * Wine Message Compiler language and codepage support
- *
- * Copyright 2000 Bertho A. Stultiens (BS)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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 Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef __WMC_LANG_H
-#define __WMC_LANG_H
-
-//#include "wine/unicode.h"
-
-typedef struct language {
- unsigned id;
- unsigned doscp;
- unsigned wincp;
- char *name;
- char *country;
-} language_t;
-
-void show_languages(void);
-const language_t *find_language(unsigned id);
-void show_codepages(void);
-const union cptable *find_codepage(int id);
-
-#endif
+++ /dev/null
-{"South Africa", 0x0436, 1252},
-{"Saudi Arabia", 0x0401, 1256},
-{"Lebanon", 0x0401, 1256},
-{"Egypt", 0x0401, 1256},
-{"Algeria", 0x0401, 1256},
-{"Iraq", 0x0401, 1256},
-{"Kuwait", 0x0401, 1256},
-{"Marocco", 0x0401, 1256},
-{"Oman", 0x0401, 1256},
-{"Quatar", 0x0401, 1256},
-{"Syria", 0x0401, 1256},
-{"Tunisia", 0x0401, 1256},
-{"United Arab Emirates",0x0401, 1256},
-{"Belaruss", 0x0423, 1251},
-{"Bulgaria", 0x0402
-{"France", 0x040c, 1252},
-{"Spain", 0x0403, 1252},
-{"China (Taiwan)", 0x0404
-{"United Kingdom", 0x0409, 1252},
-{"Wales", 0x0409, 1252}, /* FIXME */
-{"Czech Republic", 0x0405, 1250},
-{"Denmark", 0x0406, 1252},
-{"Austria", 0x0407, 1252},
-{"Liechtenstein", 0x0407, 1252},
-{"Luxemburg", 0x0407, 1252},
-{"Switzerland", 0x0807, 1252},
-{"Germany", 0x0407, 1252},
-{"Australia", 0x0c09, 1252},
-{"Caribbean", 0x2409, 1252},
-{"Canada", 0x1009, 1252},
-{"United Kingdom", 0x0809, 1252},
-{"Ireland", 0x1809, 1252},
-{"Jamaica", 0x2009, 1252},
-{"Belize", 0x2809, 1252},
-{"South Africa", 0x1c09, 1252},
-{"Trinidad & Tobago", 0x2c09, 1252},
-{"United States", 0x0409, 1252},
-{"New Zealand", 0x1409, 1252},
-{"Panama", 0x040a, 1252},
-{"Bolivia", 0x040a, 1252},
-{"Costa Rica", 0x140a, 1252},
-{"Dominican Republic", 0x040a, 1252},
-{"El Salvador", 0x040a, 1252},
-{"Ecuador", 0x040a, 1252},
-{"Guatemala", 0x040a, 1252},
-{"Honduras", 0x040a, 1252},
-{"Nicaragua", 0x040a, 1252},
-{"Chile", 0x040a, 1252},
-{"Mexico", 0x040a, 1252},
-{"Spain", 0x040a, 1252},
-{"Colombia", 0x040a, 1252},
-{"Spain", 0x040a, 1252},
-{"Peru", 0x040a, 1252},
-{"Argentina", 0x040a, 1252},
-{"Estonia", 0x0425, 1252},
-{"Puerto Rico", 0x040a, 1252},
-{"Venezuela", 0x040a, 1252},
-{"Uruguay", 0x380a, 1252},
-{"Paraguay", 0x040a, 1252},
-{"Spain (Basque)", 0x04d2, 1252},
-{"Finland", 0x040b, 1252},
-{"Faroe Islands", 0x0438, 1252},
-{"France", 0x040c, 1252},
-{"Belgium", 0x040c, 1252},
-{"Canada", 0x040c, 1252},
-{"Luxemburg", 0x040c, 1252},
-{"Switzerland", 0x040c, 1252},
-{"Ireland", 0x0000, 1252},
-{"United Kingdom", 0x0409, 1252},
-{"Isle of Man", 0x0409, 1252},
-{"Greece", 0x0408, 1253},
-{"Croatia", 0x041a, 1250},
-{"Hungary", 0x040e, 1250},
-{"Indonesia", 0x0421, 1252},
-{"Iceland", 0x040f, 1252},
-{"Italy", 0x0410, 1252},
-{"Switzerand", 0x0410, 1252},
-{"Japan", 0x0411, 0},
-{"Korea", 0x0000, 0},
-{"Korea (South)", 0x0412, 0},
-{"Lithuania", 0x0427, 1257},
-{"Latvia", 0x0426, 1257},
-{"Belgium", 0x0413, 1252},
-{"Netherlands", 0x0413, 1252},
-{"Suriname", 0x0413, 1252},
-{"Norway", 0x0814, 1252},
-{"Norway", 0x0414, 1252},
-{"Poland", 0x0415, 1250},
-{"Brazil", 0x0416, 1252},
-{"Portugal", 0x0416, 1252},
-{"Romania", 0x0418, 1250},
-{"Russia", 0x0000, 1251},
-{"Slovakia", 0x041b, 1250},
-{"Slovenia", 0x0424, 1250},
-{"Albania", 0x041c, 0},
-{"Yugoslavia", 0x0c1a, 0},
-{"Yugoslavia", 0x081a, 1250},
-{"Sweden", 0x041d, 1252},
-{"Finland", 0x081d, 1252},
-{"Thailand", 0x041e, 0},
-{"Turkey", 0x041f, 1254},
-{"Ukrainia", 0x0422, 1251},
-{"Vietnam", 0x042a, 0},
-{"Belgium", 0x0490, 1252},
-{"Hong Kong", 0x0404, 0},
-{"People's republic of China", 0x0804, 0},
-{"Singapore", 0x0404, 0}
+++ /dev/null
-DEFS = -D__WINE__
-TOPSRCDIR = @top_srcdir@
-TOPOBJDIR = ../..
-SRCDIR = @srcdir@
-VPATH = @srcdir@
-YACCOPT = #-v
-LIBEXT = @LIBEXT@
-
-PROGRAMS = wmc
-MODULE = none
-
-C_SRCS = \
- lang.c \
- mcl.c \
- utils.c \
- wmc.c \
- write.c
-
-EXTRA_SRCS = mcy.y
-EXTRA_OBJS = y.tab.o
-
-all: $(PROGRAMS)
-
-depend mcl.o: y.tab.h
-
-@MAKE_RULES@
-
-wmc: $(OBJS) $(TOPOBJDIR)/libwine_unicode.$(LIBEXT)
- $(CC) $(CFLAGS) -o wmc $(OBJS) -L$(TOPOBJDIR) -lwine_unicode $(LEXLIB)
-
-$(TOPOBJDIR)/libwine_unicode.$(LIBEXT):
- cd $(TOPOBJDIR) && $(MAKE) libwine_unicode.$(LIBEXT)
-
-y.tab.c y.tab.h: mcy.y
- $(YACC) $(YACCOPT) -d -t $(SRCDIR)/mcy.y
-
-clean::
- $(RM) y.tab.c y.tab.h y.output
-
-install:: $(PROGRAMS)
- [ -d $(bindir) ] || $(MKDIR) $(bindir)
- [ -d $(mandir)/man$(prog_manext) ] || $(MKDIR) $(mandir)/man$(prog_manext)
- $(INSTALL_DATA) $(SRCDIR)/wmc.man $(mandir)/man$(prog_manext)/wmc.$(prog_manext)
- $(INSTALL_PROGRAM) wmc $(bindir)/wmc
-
-uninstall::
- $(RM) $(bindir)/wmc $(mandir)/man$(prog_manext)/wmc.$(prog_manext)
-
-### Dependencies:
+++ /dev/null
-/*
- * Wine Message Compiler lexical scanner
- *
- * Copyright 2000 Bertho A. Stultiens (BS)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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 Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-#include <windows.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <assert.h>
-#include <string.h>
-
-#include "config.h"
-
-#include "utils.h"
-#include "wmc.h"
-#include "lang.h"
-
-#include "y_tab.h"
-
-/*
- * Keywords are case insenitive. All normal input is treated as
- * being in codepage iso-8859-1 for ascii input files (unicode
- * page 0) and as equivalent unicode if unicode input is selected.
- * All normal input, which is not part of a message text, is
- * enforced to be unicode page 0. Otherwise an error will be
- * generated. The normal file data should only be ASCII because
- * that is the basic definition of the grammar.
- *
- * Byteorder or unicode input is determined automatically by
- * reading the first 8 bytes and checking them against unicode
- * page 0 byteorder (hibyte must be 0).
- * -- FIXME --
- * Alternatively, the input is checked against a special byte
- * sequence to identify the file.
- * -- FIXME --
- *
- *
- * Keywords:
- * Codepages
- * Facility
- * FacilityNames
- * LanguageNames
- * MessageId
- * MessageIdTypedef
- * Severity
- * SeverityNames
- * SymbolicName
- *
- * Default added identifiers for classes:
- * SeverityNames:
- * Success = 0x0
- * Informational = 0x1
- * Warning = 0x2
- * Error = 0x3
- * FacilityNames:
- * System = 0x0FF
- * Application = 0xFFF
- *
- * The 'Codepages' keyword is a wmc extension.
- */
-
-static WCHAR ustr_application[] = { 'A', 'p', 'p', 'l', 'i', 'c', 'a', 't', 'i', 'o', 'n', 0 };
-static WCHAR ustr_codepages[] = { 'C', 'o', 'd', 'e', 'p', 'a', 'g', 'e', 's', 0 };
-static WCHAR ustr_english[] = { 'E', 'n', 'g', 'l', 'i', 's', 'h', 0 };
-static WCHAR ustr_error[] = { 'E', 'r', 'r', 'o', 'r', 0 };
-static WCHAR ustr_facility[] = { 'F', 'a', 'c', 'i', 'l', 'i', 't', 'y', 0 };
-static WCHAR ustr_facilitynames[] = { 'F', 'a', 'c', 'i', 'l', 'i', 't', 'y', 'N', 'a', 'm', 'e', 's', 0 };
-static WCHAR ustr_informational[] = { 'I', 'n', 'f', 'o', 'r', 'm', 'a', 't', 'i', 'o', 'n', 'a', 'l', 0 };
-static WCHAR ustr_language[] = { 'L', 'a', 'n', 'g', 'u', 'a', 'g', 'e', 0};
-static WCHAR ustr_languagenames[] = { 'L', 'a', 'n', 'g', 'u', 'a', 'g', 'e', 'N', 'a', 'm', 'e', 's', 0};
-static WCHAR ustr_messageid[] = { 'M', 'e', 's', 's', 'a', 'g', 'e', 'I', 'd', 0 };
-static WCHAR ustr_messageidtypedef[] = { 'M', 'e', 's', 's', 'a', 'g', 'e', 'I', 'd', 'T', 'y', 'p', 'e', 'd', 'e', 'f', 0 };
-static WCHAR ustr_outputbase[] = { 'O', 'u', 't', 'p', 'u', 't', 'B', 'a', 's', 'e', 0 };
-static WCHAR ustr_severity[] = { 'S', 'e', 'v', 'e', 'r', 'i', 't', 'y', 0 };
-static WCHAR ustr_severitynames[] = { 'S', 'e', 'v', 'e', 'r', 'i', 't', 'y', 'N', 'a', 'm', 'e', 's', 0 };
-static WCHAR ustr_success[] = { 'S', 'u', 'c', 'c', 'e', 's', 's', 0 };
-static WCHAR ustr_symbolicname[] = { 'S', 'y', 'm', 'b', 'o', 'l', 'i', 'c', 'N', 'a', 'm', 'e', 0 };
-static WCHAR ustr_system[] = { 'S', 'y', 's', 't', 'e', 'm', 0 };
-static WCHAR ustr_warning[] = { 'W', 'a', 'r', 'n', 'i', 'n', 'g', 0 };
-static WCHAR ustr_msg00001[] = { 'm', 's', 'g', '0', '0', '0', '0', '1', 0 };
-/*
- * This table is to beat any form of "expression building" to check for
- * correct filename characters. It is also used for ident checks.
- * FIXME: use it more consistently.
- */
-
-#define CH_SHORTNAME 0x01
-#define CH_LONGNAME 0x02
-#define CH_IDENT 0x04
-#define CH_NUMBER 0x08
-/*#define CH_WILDCARD 0x10*/
-/*#define CH_DOT 0x20*/
-#define CH_PUNCT 0x40
-#define CH_INVALID 0x80
-
-static const char char_table[256] = {
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, /* 0x00 - 0x07 */
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, /* 0x08 - 0x0F */
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, /* 0x10 - 0x17 */
- 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, /* 0x18 - 0x1F */
- 0x80, 0x03, 0x80, 0x03, 0x03, 0x03, 0x03, 0x03, /* 0x20 - 0x27 " !"#$%&'" */
- 0x43, 0x43, 0x10, 0x80, 0x03, 0x03, 0x22, 0x80, /* 0x28 - 0x2F "()*+,-./" */
- 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, /* 0x30 - 0x37 "01234567" */
- 0x0b, 0x0b, 0xc0, 0x80, 0x80, 0x80, 0x80, 0x10, /* 0x38 - 0x3F "89:;<=>?" */
- 0x03, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, /* 0x40 - 0x47 "@ABCDEFG" */
- 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, /* 0x48 - 0x4F "HIJKLMNO" */
- 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, /* 0x50 - 0x57 "PQRSTUVW" */
- 0x07, 0x07, 0x07, 0x80, 0x80, 0x80, 0x80, 0x07, /* 0x58 - 0x5F "XYZ[\]^_" */
- 0x03, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, /* 0x60 - 0x67 "`abcdefg" */
- 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, /* 0x68 - 0x6F "hijklmno" */
- 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, /* 0x70 - 0x77 "pqrstuvw" */
- 0x07, 0x07, 0x07, 0x03, 0x80, 0x03, 0x03, 0x80, /* 0x78 - 0x7F "xyz{|}~ " */
- 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, /* 0x80 - 0x87 */
- 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, /* 0x88 - 0x8F */
- 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, /* 0x90 - 0x97 */
- 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, /* 0x98 - 0x9F */
- 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, /* 0xA0 - 0xA7 */
- 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, /* 0xA8 - 0xAF */
- 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, /* 0xB0 - 0xB7 */
- 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, /* 0xB8 - 0xBF */
- 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, /* 0xC0 - 0xC7 */
- 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, /* 0xC8 - 0xCF */
- 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, /* 0xD0 - 0xD7 */
- 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, /* 0xD8 - 0xDF */
- 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, /* 0xE0 - 0xE7 */
- 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, /* 0xE8 - 0xEF */
- 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, /* 0xF0 - 0xF7 */
- 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x80, /* 0xF8 - 0xFF */
-};
-
-static int isisochar(int ch)
-{
- return !(ch & (~0xff));
-}
-
-static int codepage;
-//static const union cptable *codepage_def;
-
-void set_codepage(int cp)
-{
- codepage = cp;
-#if 0
- codepage_def = find_codepage(codepage);
- if(!codepage_def)
- xyyerror("Codepage %d not found; cannot process", codepage);
-#endif
-}
-
-/*
- * Input functions
- */
-static int nungetstack = 0;
-static int allocungetstack = 0;
-static char *ungetstack = NULL;
-static int ninputbuffer = 0;
-static WCHAR *inputbuffer = NULL;
-static char *xlatebuffer = NULL;
-
-#define INPUTBUFFER_SIZE 2048 /* Must be larger than 4 and approx. large enough to hold a line */
-
-/*
- * Fill the input buffer with *one* line of input.
- * The line is '\n' terminated so that scanning
- * messages with translation works as expected
- * (otherwise we cannot pre-translate because the
- * language is first known one line before the
- * actual message).
- */
-static int fill_inputbuffer(void)
-{
- int n;
- static char err_fatalread[] = "Fatal: reading input failed";
- static int endian = -1;
-
- if(!inputbuffer)
- {
- inputbuffer = xmalloc(INPUTBUFFER_SIZE);
- xlatebuffer = xmalloc(INPUTBUFFER_SIZE);
- }
-
-try_again:
- if(!unicodein)
- {
- char *cptr;
- cptr = fgets(xlatebuffer, INPUTBUFFER_SIZE, yyin);
- if(!cptr && ferror(yyin))
- xyyerror(err_fatalread);
- else if(!cptr)
- return 0;
-// assert(codepage_def != NULL);
-// n = cp_mbstowcs(codepage_def, 0, xlatebuffer, strlen(xlatebuffer)+1, inputbuffer, INPUTBUFFER_SIZE);
- n = MultiByteToWideChar(codepage, 0, xlatebuffer, strlen(xlatebuffer)+1, inputbuffer, INPUTBUFFER_SIZE); if(n < 0)
- internal_error(__FILE__, __LINE__, "Could not translate to unicode (%d)", n);
- if(n <= 1)
- goto try_again; /* Should not hapen */
- n--; /* Strip added conversion '\0' from input length */
- /*
- * FIXME:
- * Detect UTF-8 in the first time we read some bytes by
- * checking the special sequence "FE..." or something like
- * that. I need to check www.unicode.org for details.
- */
- }
- else
- {
- if(endian == -1)
- {
- n = fread(inputbuffer, 1, 8, yyin);
- if(n != 8)
- {
- if(!n && ferror(yyin))
- xyyerror(err_fatalread);
- else
- xyyerror("Fatal: file to short to determine byteorder (should never happen)");
- }
- if(isisochar(inputbuffer[0]) &&
- isisochar(inputbuffer[1]) &&
- isisochar(inputbuffer[2]) &&
- isisochar(inputbuffer[3]))
- {
-#ifdef WORDS_BIGENDIAN
- endian = WMC_BO_BIG;
-#else
- endian = WMC_BO_LITTLE;
-#endif
- }
- else if(isisochar(BYTESWAP_WORD(inputbuffer[0])) &&
- isisochar(BYTESWAP_WORD(inputbuffer[1])) &&
- isisochar(BYTESWAP_WORD(inputbuffer[2])) &&
- isisochar(BYTESWAP_WORD(inputbuffer[3])))
- {
-#ifdef WORDS_BIGENDIAN
- endian = WMC_BO_LITTLE;
-#else
- endian = WMC_BO_BIG;
-#endif
- }
- else
- xyyerror("Fatal: cannot determine file's byteorder");
- /* FIXME:
- * Determine the file-endian with the leader-bytes
- * "FF FE..."; can't remember the exact sequence.
- */
- n /= 2;
-#ifdef WORDS_BIGENDIAN
- if(endian == WMC_BO_LITTLE)
-#else
- if(endian == WMC_BO_BIG)
-#endif
- {
- inputbuffer[0] = BYTESWAP_WORD(inputbuffer[0]);
- inputbuffer[1] = BYTESWAP_WORD(inputbuffer[1]);
- inputbuffer[2] = BYTESWAP_WORD(inputbuffer[2]);
- inputbuffer[3] = BYTESWAP_WORD(inputbuffer[3]);
- }
-
- }
- else
- {
- int i;
- n = 0;
- for(i = 0; i < INPUTBUFFER_SIZE; i++)
- {
- int t;
- t = fread(&inputbuffer[i], 2, 1, yyin);
- if(!t && ferror(yyin))
- xyyerror(err_fatalread);
- else if(!t && n)
- break;
- n++;
-#ifdef WORDS_BIGENDIAN
- if(endian == WMC_BO_LITTLE)
-#else
- if(endian == WMC_BO_BIG)
-#endif
- {
- if((inputbuffer[i] = BYTESWAP_WORD(inputbuffer[i])) == '\n')
- break;
- }
- else
- {
- if(inputbuffer[i] == '\n')
- break;
- }
- }
- }
-
- }
-
- if(!n)
- {
- yywarning("Re-read line (input was or converted to zilch)");
- goto try_again; /* Should not happen, but could be due to stdin reading and a signal */
- }
-
- ninputbuffer += n;
- return 1;
-}
-
-static int get_unichar(void)
-{
- static WCHAR *b = NULL;
- char_number++;
-
- if(nungetstack)
- return ungetstack[--nungetstack];
-
- if(!ninputbuffer)
- {
- if(!fill_inputbuffer())
- return EOF;
- b = inputbuffer;
- }
-
- ninputbuffer--;
- return (int)(*b++ & 0xffff);
-}
-
-static void unget_unichar(int ch)
-{
- if(ch == EOF)
- return;
-
- char_number--;
-
- if(nungetstack == allocungetstack)
- {
- allocungetstack += 32;
- ungetstack = xrealloc(ungetstack, allocungetstack * sizeof(*ungetstack));
- }
-
- ungetstack[nungetstack++] = (WCHAR)ch;
-}
-
-
-/*
- * Normal character stack.
- * Used for number scanning.
- */
-static int ncharstack = 0;
-static int alloccharstack = 0;
-static char *charstack = NULL;
-
-static void empty_char_stack(void)
-{
- ncharstack = 0;
-}
-
-static void push_char(int ch)
-{
- if(ncharstack == alloccharstack)
- {
- alloccharstack += 32;
- charstack = xrealloc(charstack, alloccharstack * sizeof(*charstack));
- }
- charstack[ncharstack++] = (char)ch;
-}
-
-static int tos_char_stack(void)
-{
- if(!ncharstack)
- return 0;
- else
- return (int)(charstack[ncharstack-1] & 0xff);
-}
-
-static char *get_char_stack(void)
-{
- return charstack;
-}
-
-/*
- * Unicode character stack.
- * Used for general scanner.
- */
-static int nunicharstack = 0;
-static int allocunicharstack = 0;
-static WCHAR *unicharstack = NULL;
-
-static void empty_unichar_stack(void)
-{
- nunicharstack = 0;
-}
-
-static void push_unichar(int ch)
-{
- if(nunicharstack == allocunicharstack)
- {
- allocunicharstack += 128;
- unicharstack = xrealloc(unicharstack, allocunicharstack * sizeof(*unicharstack));
- }
- unicharstack[nunicharstack++] = (WCHAR)ch;
-}
-
-#if 0
-static int tos_unichar_stack(void)
-{
- if(!nunicharstack)
- return 0;
- else
- return (int)(unicharstack[nunicharstack-1] & 0xffff);
-}
-#endif
-
-static WCHAR *get_unichar_stack(void)
-{
- return unicharstack;
-}
-
-/*
- * Number scanner
- *
- * state | ch | next state
- * ------+-----------------+--------------------------
- * 0 | [0] | 1
- * 0 | [1-9] | 4
- * 0 | . | error (should never occur)
- * 1 | [xX] | 2
- * 1 | [0-7] | 3
- * 1 | [89a-wyzA-WYZ_] | error invalid digit
- * 1 | . | return 0
- * 2 | [0-9a-fA-F] | 2
- * 2 | [g-zG-Z_] | error invalid hex digit
- * 2 | . | return (hex-number) if TOS != [xX] else error
- * 3 | [0-7] | 3
- * 3 | [89a-zA-Z_] | error invalid octal digit
- * 3 | . | return (octal-number)
- * 4 | [0-9] | 4
- * 4 | [a-zA-Z_] | error invalid decimal digit
- * 4 | . | return (decimal-number)
- *
- * All non-identifier characters [^a-zA-Z_0-9] terminate the scan
- * and return the value. This is not entirely correct, but close
- * enough (should check punctuators as trailing context, but the
- * char_table is not adapted to that and it is questionable whether
- * it is worth the trouble).
- * All non-iso-8859-1 characters are an error.
- */
-static int scan_number(int ch)
-{
- int state = 0;
- int base = 10;
- empty_char_stack();
-
- while(1)
- {
- if(!isisochar(ch))
- xyyerror("Invalid digit");
-
- switch(state)
- {
- case 0:
- if(isdigit(ch))
- {
- push_char(ch);
- if(ch == '0')
- state = 1;
- else
- state = 4;
- }
- else
- internal_error(__FILE__, __LINE__, "Non-digit in first number-scanner state");
- break;
- case 1:
- if(ch == 'x' || ch == 'X')
- {
- push_char(ch);
- state = 2;
- }
- else if(ch >= '0' && ch <= '7')
- {
- push_char(ch);
- state = 3;
- }
- else if(isalpha(ch) || ch == '_')
- xyyerror("Invalid number digit");
- else
- {
- unget_unichar(ch);
- yylval.num = 0;
- return tNUMBER;
- }
- break;
- case 2:
- if(isxdigit(ch))
- push_char(ch);
- else if(isalpha(ch) || ch == '_' || !isxdigit(tos_char_stack()))
- xyyerror("Invalid hex digit");
- else
- {
- base = 16;
- goto finish;
- }
- break;
- case 3:
- if(ch >= '0' && ch <= '7')
- push_char(ch);
- else if(isalnum(ch) || ch == '_')
- xyyerror("Invalid octal digit");
- else
- {
- base = 8;
- goto finish;
- }
- break;
- case 4:
- if(isdigit(ch))
- push_char(ch);
- else if(isalnum(ch) || ch == '_')
- xyyerror("Invalid decimal digit");
- else
- {
- base = 10;
- goto finish;
- }
- break;
- default:
- internal_error(__FILE__, __LINE__, "Invalid state in number-scanner");
- }
- ch = get_unichar();
- }
-finish:
- unget_unichar(ch);
- push_char(0);
- yylval.num = strtoul(get_char_stack(), NULL, base);
- return tNUMBER;
-}
-
-static void newline(void)
-{
- line_number++;
- char_number = 1;
-}
-
-static int unisort(const void *p1, const void *p2)
-{
- return unistricmp(((token_t *)p1)->name, ((token_t *)p2)->name);
-}
-
-static token_t *tokentable = NULL;
-static int ntokentable = 0;
-
-token_t *lookup_token(const WCHAR *s)
-{
- token_t tok;
-
- tok.name = s;
- return (token_t *)bsearch(&tok, tokentable, ntokentable, sizeof(*tokentable), unisort);
-}
-
-void add_token(tok_e type, const WCHAR *name, int tok, int cp, const WCHAR *alias, int fix)
-{
- ntokentable++;
- tokentable = xrealloc(tokentable, ntokentable * sizeof(*tokentable));
- tokentable[ntokentable-1].type = type;
- tokentable[ntokentable-1].name = name;
- tokentable[ntokentable-1].token = tok;
- tokentable[ntokentable-1].codepage = cp;
- tokentable[ntokentable-1].alias = alias;
- tokentable[ntokentable-1].fixed = fix;
- qsort(tokentable, ntokentable, sizeof(*tokentable), unisort);
-}
-
-void get_tokentable(token_t **tab, int *len)
-{
- assert(tab != NULL);
- assert(len != NULL);
- *tab = tokentable;
- *len = ntokentable;
-}
-
-/*
- * The scanner
- *
- */
-int yylex(void)
-{
- static WCHAR ustr_dot1[] = { '.', '\n', 0 };
- static WCHAR ustr_dot2[] = { '.', '\r', '\n', 0 };
- static int isinit = 0;
- int ch;
-
- if(!isinit)
- {
- isinit++;
- set_codepage(WMC_DEFAULT_CODEPAGE);
- add_token(tok_keyword, ustr_codepages, tCODEPAGE, 0, NULL, 0);
- add_token(tok_keyword, ustr_facility, tFACILITY, 0, NULL, 1);
- add_token(tok_keyword, ustr_facilitynames, tFACNAMES, 0, NULL, 1);
- add_token(tok_keyword, ustr_language, tLANGUAGE, 0, NULL, 1);
- add_token(tok_keyword, ustr_languagenames, tLANNAMES, 0, NULL, 1);
- add_token(tok_keyword, ustr_messageid, tMSGID, 0, NULL, 1);
- add_token(tok_keyword, ustr_messageidtypedef, tTYPEDEF, 0, NULL, 1);
- add_token(tok_keyword, ustr_outputbase, tBASE, 0, NULL, 1);
- add_token(tok_keyword, ustr_severity, tSEVERITY, 0, NULL, 1);
- add_token(tok_keyword, ustr_severitynames, tSEVNAMES, 0, NULL, 1);
- add_token(tok_keyword, ustr_symbolicname, tSYMNAME, 0, NULL, 1);
- add_token(tok_severity, ustr_error, 0x03, 0, NULL, 0);
- add_token(tok_severity, ustr_warning, 0x02, 0, NULL, 0);
- add_token(tok_severity, ustr_informational, 0x01, 0, NULL, 0);
- add_token(tok_severity, ustr_success, 0x00, 0, NULL, 0);
- add_token(tok_facility, ustr_application, 0xFFF, 0, NULL, 0);
- add_token(tok_facility, ustr_system, 0x0FF, 0, NULL, 0);
- add_token(tok_language, ustr_english, 0x409, 437, ustr_msg00001, 0);
- }
-
- empty_unichar_stack();
-
- while(1)
- {
- if(want_line)
- {
- while((ch = get_unichar()) != '\n')
- {
- if(ch == EOF)
- xyyerror("Unexpected EOF");
- push_unichar(ch);
- }
- newline();
- push_unichar(ch);
- push_unichar(0);
- if(!unistrcmp(ustr_dot1, get_unichar_stack()) || !unistrcmp(ustr_dot2, get_unichar_stack()))
- {
- want_line = 0;
- /* Reset the codepage to our default after each message */
- set_codepage(WMC_DEFAULT_CODEPAGE);
- return tMSGEND;
- }
- yylval.str = xunistrdup(get_unichar_stack());
- return tLINE;
- }
-
- ch = get_unichar();
-
- if(ch == EOF)
- return EOF;
-
- if(ch == '\n')
- {
- newline();
- if(want_nl)
- {
- want_nl = 0;
- return tNL;
- }
- continue;
- }
-
- if(isisochar(ch))
- {
- if(want_file)
- {
- int n = 0;
- while(n < 8 && isisochar(ch))
- {
- int t = char_table[ch];
- if((t & CH_PUNCT) || !(t & CH_SHORTNAME))
- break;
-
- push_unichar(ch);
- n++;
- ch = get_unichar();
- }
- unget_unichar(ch);
- push_unichar(0);
- want_file = 0;
- yylval.str = xunistrdup(get_unichar_stack());
- return tFILE;
- }
-
- if(char_table[ch] & CH_IDENT)
- {
- token_t *tok;
- while(isisochar(ch) && (char_table[ch] & (CH_IDENT|CH_NUMBER)))
- {
- push_unichar(ch);
- ch = get_unichar();
- }
- unget_unichar(ch);
- push_unichar(0);
- if(!(tok = lookup_token(get_unichar_stack())))
- {
- yylval.str = xunistrdup(get_unichar_stack());
- return tIDENT;
- }
- switch(tok->type)
- {
- case tok_keyword:
- return tok->token;
-
- case tok_language:
- codepage = tok->codepage;
- /* Fall through */
- case tok_severity:
- case tok_facility:
- yylval.tok = tok;
- return tTOKEN;
-
- default:
- internal_error(__FILE__, __LINE__, "Invalid token type encountered");
- }
- }
-
- if(isspace(ch)) /* Ignore space */
- continue;
-
- if(isdigit(ch))
- return scan_number(ch);
- }
-
- switch(ch)
- {
- case ':':
- case '=':
- case '+':
- case '(':
- case ')':
- return ch;
- case ';':
- while(ch != '\n' && ch != EOF)
- {
- push_unichar(ch);
- ch = get_unichar();
- }
- newline();
- push_unichar(ch); /* Include the newline */
- push_unichar(0);
- yylval.str = xunistrdup(get_unichar_stack());
- return tCOMMENT;
- default:
- xyyerror("Invalid character '%c' (0x%04x)", isisochar(ch) && isprint(ch) ? ch : '.', ch);
- }
- }
-}
-
+++ /dev/null
-/*
- * Wine Message Compiler parser
- *
- * Copyright 2000 Bertho A. Stultiens (BS)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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 Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- *
- * NOTES:
- *
- * The basic grammar of the file is yet another example of, humpf,
- * design. There is is mix of context-insensitive and -sentitive
- * stuff, which makes it rather complicated.
- * The header definitions are all context-insensitive because they have
- * delimited arguments, whereas the message headers are (semi-) context-
- * sensitive and the messages themselves are, well, RFC82[12] delimited.
- * This mixture seems to originate from the time that ms and ibm were
- * good friends and developing os/2 according to the "compatibility"
- * switch and reading some comments here and there.
- *
- * I'll ignore most of the complications and concentrate on the concept
- * which allows me to use yacc. Basically, everything is context-
- * insensitive now, with the exception of the message-text itself and
- * the preceding language declaration.
- *
- */
-
-%{
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-
-#include "config.h"
-
-#include "utils.h"
-#include "wmc.h"
-#include "lang.h"
-
-static const char err_syntax[] = "Syntax error";
-static const char err_number[] = "Number expected";
-static const char err_ident[] = "Identifier expected";
-static const char err_assign[] = "'=' expected";
-static const char err_popen[] = "'(' expected";
-static const char err_pclose[] = "')' expected";
-static const char err_colon[] = "':' expected";
-static const char err_msg[] = "Message expected";
-
-/* Scanner switches */
-int want_nl = 0; /* Request next newlinw */
-int want_line = 0; /* Request next complete line */
-int want_file = 0; /* Request next ident as filename */
-
-node_t *nodehead = NULL; /* The list of all parsed elements */
-static node_t *nodetail = NULL;
-lan_blk_t *lanblockhead; /* List of parsed elements transposed */
-
-static int base = 16; /* Current printout base to use (8, 10 or 16) */
-static WCHAR *cast = NULL; /* Current typecast to use */
-
-static int last_id = 0; /* The last message ID parsed */
-static int last_sev = 0; /* Last severity code parsed */
-static int last_fac = 0; /* Last facility code parsed */
-static WCHAR *last_sym = NULL;/* Last alias symbol parsed */
-static int have_sev; /* Set if severity parsed for current message */
-static int have_fac; /* Set if facility parsed for current message */
-static int have_sym; /* Set is symbol parsed for current message */
-
-static cp_xlat_t *cpxlattab = NULL; /* Codepage translation table */
-static int ncpxlattab = 0;
-
-/* Prototypes */
-static WCHAR *merge(WCHAR *s1, WCHAR *s2);
-static lanmsg_t *new_lanmsg(lan_cp_t *lcp, WCHAR *msg);
-static msg_t *add_lanmsg(msg_t *msg, lanmsg_t *lanmsg);
-static msg_t *complete_msg(msg_t *msg, int id);
-static void add_node(node_e type, void *p);
-static void do_add_token(tok_e type, token_t *tok, const char *code);
-static void test_id(int id);
-static int check_languages(node_t *head);
-static lan_blk_t *block_messages(node_t *head);
-static void add_cpxlat(int lan, int cpin, int cpout);
-static cp_xlat_t *find_cpxlat(int lan);
-
-%}
-
-
-%union {
- WCHAR *str;
- unsigned num;
- token_t *tok;
- lanmsg_t *lmp;
- msg_t *msg;
- lan_cp_t lcp;
-}
-
-
-%token tSEVNAMES tFACNAMES tLANNAMES tBASE tCODEPAGE
-%token tTYPEDEF tNL tSYMNAME tMSGEND
-%token tSEVERITY tFACILITY tLANGUAGE tMSGID
-%token <str> tIDENT tLINE tFILE tCOMMENT
-%token <num> tNUMBER
-%token <tok> tTOKEN
-
-%type <str> alias lines
-%type <num> optcp id msgid clan
-%type <tok> token
-%type <lmp> body
-%type <msg> bodies msg
-%type <lcp> lang
-
-%%
-file : items {
- if(!check_languages(nodehead))
- xyyerror("No messages defined");
- lanblockhead = block_messages(nodehead);
- }
- ;
-
-items : decl
- | items decl
- ;
-
-decl : global
- | msg { add_node(nd_msg, $1); }
- | tCOMMENT { add_node(nd_comment, $1); }
- | error { xyyerror(err_syntax); /* `Catch all' error */ }
- ;
-
-global : tSEVNAMES '=' '(' smaps ')'
- | tSEVNAMES '=' '(' smaps error { xyyerror(err_pclose); }
- | tSEVNAMES '=' error { xyyerror(err_popen); }
- | tSEVNAMES error { xyyerror(err_assign); }
- | tFACNAMES '=' '(' fmaps ')'
- | tFACNAMES '=' '(' fmaps error { xyyerror(err_pclose); }
- | tFACNAMES '=' error { xyyerror(err_popen); }
- | tFACNAMES error { xyyerror(err_assign); }
- | tLANNAMES '=' '(' lmaps ')'
- | tLANNAMES '=' '(' lmaps error { xyyerror(err_pclose); }
- | tLANNAMES '=' error { xyyerror(err_popen); }
- | tLANNAMES error { xyyerror(err_assign); }
- | tCODEPAGE '=' '(' cmaps ')'
- | tCODEPAGE '=' '(' cmaps error { xyyerror(err_pclose); }
- | tCODEPAGE '=' error { xyyerror(err_popen); }
- | tCODEPAGE error { xyyerror(err_assign); }
- | tTYPEDEF '=' tIDENT { cast = $3; }
- | tTYPEDEF '=' error { xyyerror(err_number); }
- | tTYPEDEF error { xyyerror(err_assign); }
- | tBASE '=' tNUMBER {
- switch(base)
- {
- case 8:
- case 10:
- case 16:
- base = $3;
- break;
- default:
- xyyerror("Numberbase must be 8, 10 or 16");
- }
- }
- | tBASE '=' error { xyyerror(err_number); }
- | tBASE error { xyyerror(err_assign); }
- ;
-
-/*----------------------------------------------------------------------
- * SeverityNames mapping
- */
-smaps : smap
- | smaps smap
- | error { xyyerror(err_ident); }
- ;
-
-smap : token '=' tNUMBER alias {
- $1->token = $3;
- $1->alias = $4;
- if($3 & (~0x3))
- xyyerror("Severity value out of range (0x%08x > 0x3)", $3);
- do_add_token(tok_severity, $1, "severity");
- }
- | token '=' error { xyyerror(err_number); }
- | token error { xyyerror(err_assign); }
- ;
-
-/*----------------------------------------------------------------------
- * FacilityNames mapping
- */
-fmaps : fmap
- | fmaps fmap
- | error { xyyerror(err_ident); }
- ;
-
-fmap : token '=' tNUMBER alias {
- $1->token = $3;
- $1->alias = $4;
- if($3 & (~0xfff))
- xyyerror("Facility value out of range (0x%08x > 0xfff)", $3);
- do_add_token(tok_facility, $1, "facility");
- }
- | token '=' error { xyyerror(err_number); }
- | token error { xyyerror(err_assign); }
- ;
-
-alias : /* Empty */ { $$ = NULL; }
- | ':' tIDENT { $$ = $2; }
- | ':' error { xyyerror(err_ident); }
- ;
-
-/*----------------------------------------------------------------------
- * LanguageNames mapping
- */
-lmaps : lmap
- | lmaps lmap
- | error { xyyerror(err_ident); }
- ;
-
-lmap : token '=' tNUMBER setfile ':' tFILE optcp {
- $1->token = $3;
- $1->alias = $6;
- $1->codepage = $7;
- do_add_token(tok_language, $1, "language");
- if(!find_language($1->token) && !find_cpxlat($1->token))
- yywarning("Language 0x%x not built-in, using codepage %d; use explicit codepage to override", $1->token, WMC_DEFAULT_CODEPAGE);
- }
- | token '=' tNUMBER setfile ':' error { xyyerror("Filename expected"); }
- | token '=' tNUMBER error { xyyerror(err_colon); }
- | token '=' error { xyyerror(err_number); }
- | token error { xyyerror(err_assign); }
- ;
-
-optcp : /* Empty */ { $$ = 0; }
- | ':' tNUMBER { $$ = $2; }
- | ':' error { xyyerror("Codepage-number expected"); }
- ;
-
-/*----------------------------------------------------------------------
- * Codepages mapping
- */
-cmaps : cmap
- | cmaps cmap
- | error { xyyerror(err_ident); }
- ;
-
-cmap : clan '=' tNUMBER ':' tNUMBER {
- static const char err_nocp[] = "Codepage %d not builtin; cannot convert";
- if(find_cpxlat($1))
- xyyerror("Codepage translation already defined for language 0x%x", $1);
- if($3 && !find_codepage($3))
- xyyerror(err_nocp, $3);
- if($5 && !find_codepage($5))
- xyyerror(err_nocp, $5);
- add_cpxlat($1, $3, $5);
- }
- | clan '=' tNUMBER ':' error { xyyerror(err_number); }
- | clan '=' tNUMBER error { xyyerror(err_colon); }
- | clan '=' error { xyyerror(err_number); }
- | clan error { xyyerror(err_assign); }
- ;
-
-clan : tNUMBER { $$ = $1; }
- | tTOKEN {
- if($1->type != tok_language)
- xyyerror("Language name or code expected");
- $$ = $1->token;
- }
- ;
-
-/*----------------------------------------------------------------------
- * Message-definition parsing
- */
-msg : msgid sevfacsym { test_id($1); } bodies { $$ = complete_msg($4, $1); }
- ;
-
-msgid : tMSGID '=' id {
- if($3 & (~0xffff))
- xyyerror("Message ID value out of range (0x%08x > 0xffff)", $3);
- $$ = $3;
- }
- | tMSGID error { xyyerror(err_assign); }
- ;
-
-id : /* Empty */ { $$ = ++last_id; }
- | tNUMBER { $$ = last_id = $1; }
- | '+' tNUMBER { $$ = last_id += $2; }
- | '+' error { xyyerror(err_number); }
- ;
-
-sevfacsym: /* Empty */ { have_sev = have_fac = have_sym = 0; }
- | sevfacsym sev { if(have_sev) xyyerror("Severity already defined"); have_sev = 1; }
- | sevfacsym fac { if(have_fac) xyyerror("Facility already defined"); have_fac = 1; }
- | sevfacsym sym { if(have_sym) xyyerror("Symbolname already defined"); have_sym = 1; }
- ;
-
-sym : tSYMNAME '=' tIDENT { last_sym = $3; }
- | tSYMNAME '=' error { xyyerror(err_ident); }
- | tSYMNAME error { xyyerror(err_assign); }
- ;
-
-sev : tSEVERITY '=' token {
- token_t *tok = lookup_token($3->name);
- if(!tok)
- xyyerror("Undefined severityname");
- if(tok->type != tok_severity)
- xyyerror("Identifier is not of class 'severity'");
- last_sev = tok->token;
- }
- | tSEVERITY '=' error { xyyerror(err_ident); }
- | tSEVERITY error { xyyerror(err_assign); }
- ;
-
-fac : tFACILITY '=' token {
- token_t *tok = lookup_token($3->name);
- if(!tok)
- xyyerror("Undefined facilityname");
- if(tok->type != tok_facility)
- xyyerror("Identifier is not of class 'facility'");
- last_fac = tok->token;
- }
- | tFACILITY '=' error { xyyerror(err_ident); }
- | tFACILITY error { xyyerror(err_assign); }
- ;
-
-/*----------------------------------------------------------------------
- * Message-text parsing
- */
-bodies : body { $$ = add_lanmsg(NULL, $1); }
- | bodies body { $$ = add_lanmsg($1, $2); }
- | error { xyyerror("'Language=...' (start of message text-definition) expected"); }
- ;
-
-body : lang setline lines tMSGEND { $$ = new_lanmsg(&$1, $3); }
- ;
-
- /*
- * The newline is to be able to set the codepage
- * to the language based codepage for the next
- * message to be parsed.
- */
-lang : tLANGUAGE setnl '=' token tNL {
- token_t *tok = lookup_token($4->name);
- cp_xlat_t *cpx;
- if(!tok)
- xyyerror("Undefined language");
- if(tok->type != tok_language)
- xyyerror("Identifier is not of class 'language'");
- if((cpx = find_cpxlat(tok->token)))
- {
- set_codepage($$.codepage = cpx->cpin);
- }
- else if(!tok->codepage)
- {
- const language_t *lan = find_language(tok->token);
- if(!lan)
- {
- /* Just set default; warning was given while parsing languagenames */
- set_codepage($$.codepage = WMC_DEFAULT_CODEPAGE);
- }
- else
- {
- /* The default seems to be to use the DOS codepage... */
- set_codepage($$.codepage = lan->doscp);
- }
- }
- else
- set_codepage($$.codepage = tok->codepage);
- $$.language = tok->token;
- }
- | tLANGUAGE setnl '=' token error { xyyerror("Missing newline"); }
- | tLANGUAGE setnl '=' error { xyyerror(err_ident); }
- | tLANGUAGE error { xyyerror(err_assign); }
- ;
-
-lines : tLINE { $$ = $1; }
- | lines tLINE { $$ = merge($1, $2); }
- | error { xyyerror(err_msg); }
- | lines error { xyyerror(err_msg); }
- ;
-
-/*----------------------------------------------------------------------
- * Helper rules
- */
-token : tIDENT { $$ = xmalloc(sizeof(token_t)); $$->name = $1; }
- | tTOKEN { $$ = $1; }
- ;
-
-setnl : /* Empty */ { want_nl = 1; }
- ;
-
-setline : /* Empty */ { want_line = 1; }
- ;
-
-setfile : /* Empty */ { want_file = 1; }
- ;
-
-%%
-
-static WCHAR *merge(WCHAR *s1, WCHAR *s2)
-{
- int l1 = unistrlen(s1);
- int l2 = unistrlen(s2);
- s1 = xrealloc(s1, (l1 + l2 + 1) * sizeof(*s1));
- unistrcpy(s1+l1, s2);
- free(s2);
- return s1;
-}
-
-static void do_add_token(tok_e type, token_t *tok, const char *code)
-{
- token_t *tp = lookup_token(tok->name);
- if(tp)
- {
- if(tok->type != type)
- yywarning("Type change in token");
- if(tp != tok)
- xyyerror("Overlapping token not the same");
- /* else its already defined and changed */
- if(tok->fixed)
- xyyerror("Redefinition of %s", code);
- tok->fixed = 1;
- }
- else
- {
- add_token(type, tok->name, tok->token, tok->codepage, tok->alias, 1);
- free(tok);
- }
-}
-
-static lanmsg_t *new_lanmsg(lan_cp_t *lcp, WCHAR *msg)
-{
- lanmsg_t *lmp = (lanmsg_t *)xmalloc(sizeof(lanmsg_t));
- lmp->lan = lcp->language;
- lmp->cp = lcp->codepage;
- lmp->msg = msg;
- lmp->len = unistrlen(msg) + 1; /* Include termination */
- if(lmp->len > 4096)
- yywarning("Message exceptionally long; might be a missing termination");
- return lmp;
-}
-
-static msg_t *add_lanmsg(msg_t *msg, lanmsg_t *lanmsg)
-{
- int i;
- if(!msg)
- msg = xmalloc(sizeof(msg_t));
- msg->msgs = xrealloc(msg->msgs, (msg->nmsgs+1) * sizeof(*(msg->msgs)));
- msg->msgs[msg->nmsgs] = lanmsg;
- msg->nmsgs++;
- for(i = 0; i < msg->nmsgs-1; i++)
- {
- if(msg->msgs[i]->lan == lanmsg->lan)
- xyyerror("Message for language 0x%x already defined", lanmsg->lan);
- }
- return msg;
-}
-
-static int sort_lanmsg(const void *p1, const void *p2)
-{
- return (*(lanmsg_t **)p1)->lan - (*(lanmsg_t **)p2)->lan;
-}
-
-static msg_t *complete_msg(msg_t *mp, int id)
-{
- assert(mp != NULL);
- mp->id = id;
- if(have_sym)
- mp->sym = last_sym;
- else
- xyyerror("No symbolic name defined for message id %d", id);
- mp->sev = last_sev;
- mp->fac = last_fac;
- qsort(mp->msgs, mp->nmsgs, sizeof(*(mp->msgs)), sort_lanmsg);
- mp->realid = id | (last_sev << 30) | (last_fac << 16);
- if(custombit)
- mp->realid |= 1 << 29;
- mp->base = base;
- mp->cast = cast;
- return mp;
-}
-
-static void add_node(node_e type, void *p)
-{
- node_t *ndp = (node_t *)xmalloc(sizeof(node_t));
- ndp->type = type;
- ndp->u.all = p;
-
- if(nodetail)
- {
- ndp->prev = nodetail;
- nodetail->next = ndp;
- nodetail = ndp;
- }
- else
- {
- nodehead = nodetail = ndp;
- }
-}
-
-static void test_id(int id)
-{
- node_t *ndp;
- for(ndp = nodehead; ndp; ndp = ndp->next)
- {
- if(ndp->type != nd_msg)
- continue;
- if(ndp->u.msg->id == id && ndp->u.msg->sev == last_sev && ndp->u.msg->fac == last_fac)
- xyyerror("MessageId %d with facility 0x%x and severity 0x%x already defined", id, last_fac, last_sev);
- }
-}
-
-static int check_languages(node_t *head)
-{
- static char err_missing[] = "Missing definition for language 0x%x; MessageID %d, facility 0x%x, severity 0x%x";
- node_t *ndp;
- int nm = 0;
- msg_t *msg = NULL;
-
- for(ndp = head; ndp; ndp = ndp->next)
- {
- if(ndp->type != nd_msg)
- continue;
- if(!nm)
- {
- msg = ndp->u.msg;
- }
- else
- {
- int i;
- msg_t *m1;
- msg_t *m2;
- if(ndp->u.msg->nmsgs > msg->nmsgs)
- {
- m1 = ndp->u.msg;
- m2 = msg;
- }
- else
- {
- m1 = msg;
- m2 = ndp->u.msg;
- }
-
- for(i = 0; i < m1->nmsgs; i++)
- {
- if(i > m2->nmsgs)
- error(err_missing, m1->msgs[i]->lan, m2->id, m2->fac, m2->sev);
- else if(m1->msgs[i]->lan < m2->msgs[i]->lan)
- error(err_missing, m1->msgs[i]->lan, m2->id, m2->fac, m2->sev);
- else if(m1->msgs[i]->lan > m2->msgs[i]->lan)
- error(err_missing, m2->msgs[i]->lan, m1->id, m1->fac, m1->sev);
- }
- }
- nm++;
- }
- return nm;
-}
-
-#define MSGRID(x) ((*(msg_t **)(x))->realid)
-static int sort_msg(const void *p1, const void *p2)
-{
- return MSGRID(p1) > MSGRID(p2) ? 1 : (MSGRID(p1) == MSGRID(p2) ? 0 : -1);
- /* return (*(msg_t **)p1)->realid - (*(msg_t **)p1)->realid; */
-}
-
-/*
- * block_messages() basically transposes the messages
- * from ID/language based list to a language/ID
- * based list.
- */
-static lan_blk_t *block_messages(node_t *head)
-{
- lan_blk_t *lbp;
- lan_blk_t *lblktail = NULL;
- lan_blk_t *lblkhead = NULL;
- msg_t **msgtab = NULL;
- node_t *ndp;
- int nmsg = 0;
- int i;
- int nl;
- int factor = unicodeout ? 2 : 1;
-
- for(ndp = head; ndp; ndp = ndp->next)
- {
- if(ndp->type != nd_msg)
- continue;
- msgtab = xrealloc(msgtab, (nmsg+1) * sizeof(*msgtab));
- msgtab[nmsg++] = ndp->u.msg;
- }
-
- assert(nmsg != 0);
- qsort(msgtab, nmsg, sizeof(*msgtab), sort_msg);
-
- for(nl = 0; nl < msgtab[0]->nmsgs; nl++) /* This should be equal for all after check_languages() */
- {
- lbp = xmalloc(sizeof(lan_blk_t));
-
- if(!lblktail)
- {
- lblkhead = lblktail = lbp;
- }
- else
- {
- lblktail->next = lbp;
- lbp->prev = lblktail;
- lblktail = lbp;
- }
- lbp->nblk = 1;
- lbp->blks = xmalloc(sizeof(*lbp->blks));
- lbp->blks[0].idlo = msgtab[0]->realid;
- lbp->blks[0].idhi = msgtab[0]->realid;
- /* The plus 4 is the entry header; (+3)&~3 is DWORD alignment */
- lbp->blks[0].size = ((factor * msgtab[0]->msgs[nl]->len + 3) & ~3) + 4;
- lbp->blks[0].msgs = xmalloc(sizeof(*lbp->blks[0].msgs));
- lbp->blks[0].nmsg = 1;
- lbp->blks[0].msgs[0] = msgtab[0]->msgs[nl];
- lbp->lan = msgtab[0]->msgs[nl]->lan;
-
- for(i = 1; i < nmsg; i++)
- {
- block_t *blk = &(lbp->blks[lbp->nblk-1]);
- if(msgtab[i]->realid == blk->idhi+1)
- {
- blk->size += ((factor * msgtab[i]->msgs[nl]->len + 3) & ~3) + 4;
- blk->idhi++;
- blk->msgs = xrealloc(blk->msgs, (blk->nmsg+1) * sizeof(*blk->msgs));
- blk->msgs[blk->nmsg++] = msgtab[i]->msgs[nl];
- }
- else
- {
- lbp->nblk++;
- lbp->blks = xrealloc(lbp->blks, lbp->nblk * sizeof(*lbp->blks));
- blk = &(lbp->blks[lbp->nblk-1]);
- blk->idlo = msgtab[i]->realid;
- blk->idhi = msgtab[i]->realid;
- blk->size = ((factor * msgtab[i]->msgs[nl]->len + 3) & ~3) + 4;
- blk->msgs = xmalloc(sizeof(*blk->msgs));
- blk->nmsg = 1;
- blk->msgs[0] = msgtab[i]->msgs[nl];
- }
- }
- }
- free(msgtab);
- return lblkhead;
-}
-
-static int sc_xlat(const void *p1, const void *p2)
-{
- return ((cp_xlat_t *)p1)->lan - ((cp_xlat_t *)p2)->lan;
-}
-
-static void add_cpxlat(int lan, int cpin, int cpout)
-{
- cpxlattab = xrealloc(cpxlattab, (ncpxlattab+1) * sizeof(*cpxlattab));
- cpxlattab[ncpxlattab].lan = lan;
- cpxlattab[ncpxlattab].cpin = cpin;
- cpxlattab[ncpxlattab].cpout = cpout;
- ncpxlattab++;
- qsort(cpxlattab, ncpxlattab, sizeof(*cpxlattab), sc_xlat);
-}
-
-static cp_xlat_t *find_cpxlat(int lan)
-{
- cp_xlat_t t;
-
- if(!cpxlattab) return NULL;
-
- t.lan = lan;
- return (cp_xlat_t *)bsearch(&t, cpxlattab, ncpxlattab, sizeof(*cpxlattab), sc_xlat);
-}
-
+++ /dev/null
-#ifdef __unix__
-#include <string.h>
-#include <stdlib.h>
-#include <wchar.h>
-
-typedef unsigned short UINT;
-typedef unsigned int DWORD;
-typedef char* LPCSTR;
-typedef wchar_t* LPWSTR;
-typedef char* LPSTR;
-typedef const wchar_t* LPCWSTR;
-typedef unsigned int* LPBOOL;
-
-int
-stricmp(const char* s1, const char* s2)
-{
- return(strcasecmp(s1, s2));
-}
-
-int
-WideCharToMultiByte(
- UINT CodePage,
- DWORD dwFlags,
- LPCWSTR lpWideCharStr,
- int cchWideChar,
- LPSTR lpMultiByteStr,
- int cchMultiByte,
- LPCSTR lpDefaultChar,
- LPBOOL lpUsedDefaultChar)
-{
- unsigned int i = 0;
- if (cchWideChar == -1)
- {
- while(*lpWideCharStr != 0)
- {
- wctomb(lpMultiByteStr, *lpWideCharStr);
- lpMultiByteStr++;
- lpWideCharStr++;
- i++;
- }
- }
- else
- {
- while(i < cchWideChar)
- {
- wctomb(lpMultiByteStr, *lpWideCharStr);
- lpMultiByteStr++;
- lpWideCharStr++;
- i++;
- }
- }
- return(i);
-}
-
-int
-MultiByteToWideChar(
- UINT CodePage,
- DWORD dwFlags,
- LPCSTR lpMultiByteStr,
- int cchMultiByte,
- LPWSTR lpWideCharStr,
- int cchWideChar)
-{
- int i, j;
-
- i = j = 0;
- while (i < cchMultiByte && lpMultiByteStr[i] != 0)
- {
- i = i + mbtowc(&lpWideCharStr[j], &lpMultiByteStr[i],
- cchMultiByte - i);
- j++;
- }
- lpWideCharStr[j] = 0;
- j++;
- return(j);
-}
-#endif
+++ /dev/null
-/*
- * Utility routines
- *
- * Copyright 1998,2000 Bertho A. Stultiens
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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 Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "config.h"
-
-#include <windows.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <assert.h>
-#include <ctype.h>
-
-#include "wmctypes.h"
-#include "utils.h"
-#include "wmc.h"
-
-#define SUPPRESS_YACC_ERROR_MESSAGE
-
-static void generic_msg(const char *s, const char *t, va_list ap)
-{
- fprintf(stderr, "%s %s: %d, %d: ", t, input_name ? input_name : "stdin", line_number, char_number);
- vfprintf(stderr, s, ap);
- fprintf(stderr, "\n");
-}
-
-/*
- * The yyerror routine should not exit because we use the error-token
- * to determine the syntactic error in the source. However, YACC
- * uses the same routine to print an error just before the error
- * token is reduced.
- * The extra routine 'xyyerror' is used to exit after giving a real
- * message.
- */
-int yyerror(const char *s, ...)
-{
-#ifndef SUPPRESS_YACC_ERROR_MESSAGE
- va_list ap;
- va_start(ap, s);
- generic_msg(s, "Yacc error", ap);
- va_end(ap);
-#endif
- return 1;
-}
-
-int xyyerror(const char *s, ...)
-{
- va_list ap;
- va_start(ap, s);
- generic_msg(s, "Error", ap);
- va_end(ap);
- exit(1);
- return 1;
-}
-
-int yywarning(const char *s, ...)
-{
- va_list ap;
- va_start(ap, s);
- generic_msg(s, "Warning", ap);
- va_end(ap);
- return 0;
-}
-
-void internal_error(const char *file, int line, const char *s, ...)
-{
- va_list ap;
- va_start(ap, s);
- fprintf(stderr, "Internal error (please report) %s %d: ", file, line);
- vfprintf(stderr, s, ap);
- fprintf(stderr, "\n");
- va_end(ap);
- exit(3);
-}
-
-void error(const char *s, ...)
-{
- va_list ap;
- va_start(ap, s);
- fprintf(stderr, "Error: ");
- vfprintf(stderr, s, ap);
- fprintf(stderr, "\n");
- va_end(ap);
- exit(2);
-}
-
-void warning(const char *s, ...)
-{
- va_list ap;
- va_start(ap, s);
- fprintf(stderr, "Warning: ");
- vfprintf(stderr, s, ap);
- fprintf(stderr, "\n");
- va_end(ap);
-}
-
-char *dup_basename(const char *name, const char *ext)
-{
- int namelen;
- int extlen = strlen(ext);
- char *base;
- char *slash;
-
- if(!name)
- name = "wmc.tab";
-
- slash = strrchr(name, '/');
- if (slash)
- name = slash + 1;
-
- namelen = strlen(name);
-
- /* +4 for later extension and +1 for '\0' */
- base = (char *)xmalloc(namelen +4 +1);
- strcpy(base, name);
-#ifdef _MSC_VER
- if(!stricmp(name + namelen-extlen, ext))
-#else
- if(!strcasecmp(name + namelen-extlen, ext))
-#endif
- {
- base[namelen - extlen] = '\0';
- }
- return base;
-}
-
-void *xmalloc(size_t size)
-{
- void *res;
-
- assert(size > 0);
- assert(size < 102400);
- res = malloc(size);
- if(res == NULL)
- {
- error("Virtual memory exhausted.\n");
- }
- /*
- * We set it to 0.
- * This is *paramount* because we depend on it
- * just about everywhere in the rest of the code.
- */
- memset(res, 0, size);
- return res;
-}
-
-
-void *xrealloc(void *p, size_t size)
-{
- void *res;
-
- assert(size > 0);
- assert(size < 102400);
- res = realloc(p, size);
- if(res == NULL)
- {
- error("Virtual memory exhausted.\n");
- }
- return res;
-}
-
-char *xstrdup(const char *str)
-{
- char *s;
-
- assert(str != NULL);
- s = (char *)xmalloc(strlen(str)+1);
- return strcpy(s, str);
-}
-
-int unistrlen(const WCHAR *s)
-{
- int n;
- for(n = 0; *s; n++, s++)
- ;
- return n;
-}
-
-WCHAR *unistrcpy(WCHAR *dst, const WCHAR *src)
-{
- WCHAR *t = dst;
- while(*src)
- *t++ = *src++;
- *t = 0;
- return dst;
-}
-
-WCHAR *xunistrdup(const WCHAR * str)
-{
- WCHAR *s;
-
- assert(str != NULL);
- s = (WCHAR *)xmalloc((unistrlen(str)+1) * sizeof(WCHAR));
- return unistrcpy(s, str);
-}
-
-int unistricmp(const WCHAR *s1, const WCHAR *s2)
-{
- int i;
- int once = 0;
- static char warn[] = "Don't know the uppercase equivalent of non acsii characters;"
- "comparison might yield wrong results";
- while(*s1 && *s2)
- {
- if((*s1 & 0xffff) > 0x7f || (*s2 & 0xffff) > 0x7f)
- {
- if(!once)
- {
- once++;
- yywarning(warn);
- }
- i = *s1++ - *s2++;
- }
- else
- i = toupper(*s1++) - toupper(*s2++);
- if(i)
- return i;
- }
-
- if((*s1 & 0xffff) > 0x7f || (*s2 & 0xffff) > 0x7f)
- {
- if(!once)
- yywarning(warn);
- return *s1 - *s2;
- }
- else
- return toupper(*s1) - toupper(*s2);
-}
-
-int unistrcmp(const WCHAR *s1, const WCHAR *s2)
-{
- int i;
- while(*s1 && *s2)
- {
- i = *s1++ - *s2++;
- if(i)
- return i;
- }
-
- return *s1 - *s2;
-}
-
+++ /dev/null
-/*
- * Utility routines' prototypes etc.
- *
- * Copyright 1998,2000 Bertho A. Stultiens (BS)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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 Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef __WMC_UTILS_H
-#define __WMC_UTILS_H
-
-#ifndef __WMC_WMCTYPES_H
-#include "wmctypes.h"
-#endif
-
-#include <stddef.h> /* size_t */
-
-void *xmalloc(size_t);
-void *xrealloc(void *, size_t);
-char *xstrdup(const char *str);
-
-#if 0
-int yyerror(const char *s, ...) __attribute__((format (printf, 1, 2)));
-int xyyerror(const char *s, ...) __attribute__((format (printf, 1, 2)));
-int yywarning(const char *s, ...) __attribute__((format (printf, 1, 2)));
-void internal_error(const char *file, int line, const char *s, ...) __attribute__((format (printf, 3, 4)));
-void error(const char *s, ...) __attribute__((format (printf, 1, 2)));
-void warning(const char *s, ...) __attribute__((format (printf, 1, 2)));
-#endif
-int yyerror(const char *s, ...);
-int xyyerror(const char *s, ...);
-int yywarning(const char *s, ...);
-void internal_error(const char *file, int line, const char *s, ...);
-void error(const char *s, ...);
-void warning(const char *s, ...);
-
-char *dup_basename(const char *name, const char *ext);
-
-WCHAR *xunistrdup(const WCHAR * str);
-WCHAR *unistrcpy(WCHAR *dst, const WCHAR *src);
-int unistrlen(const WCHAR *s);
-int unistricmp(const WCHAR *s1, const WCHAR *s2);
-int unistrcmp(const WCHAR *s1, const WCHAR *s2);
-
-#endif
+++ /dev/null
-#include <wchar.h>
-typedef wchar_t WCHAR;
-typedef unsigned short int WORD;
-typedef unsigned int UINT;
-typedef unsigned int DWORD;
-typedef char CHAR;
-typedef CHAR *LPSTR;
-typedef WCHAR *LPWSTR;
-typedef const CHAR *LPCSTR;
-typedef const WCHAR *LPCWSTR;
-typedef unsigned int *LPBOOL;
-
-#ifndef __unix__
-#define STDCALL __attribute__((stdcall))
-#else
-#define STDCALL
-#endif
-
-int STDCALL MultiByteToWideChar(
- UINT CodePage,
- DWORD dwFlags,
- LPCSTR lpMultiByteStr,
- int cbMultiByte,
- LPWSTR lpWideCharStr,
- int cchWideChar);
-
-int STDCALL WideCharToMultiByte(
- UINT CodePage,
- DWORD dwFlags,
- LPCWSTR lpWideCharStr,
- int cchWideChar,
- LPSTR lpMultiByteStr,
- int cbMultiByte,
- LPCSTR lpDefaultChar,
- LPBOOL lpUsedDefaultChar);
+++ /dev/null
-/*
- * Wine Message Compiler main program
- *
- * Copyright 2000 Bertho A. Stultiens (BS)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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 Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-#include <windows.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <signal.h>
-
-#include "config.h"
-
-#include "wmc.h"
-#include "utils.h"
-#include "lang.h"
-#include "write.h"
-
-static char usage[] =
- "Usage: wmc [options...] [inputfile.mc]\n"
- " -B x Set output byte-order x={n[ative], l[ittle], b[ig]}\n"
- " (default is n[ative] which equals "
-#ifdef WORDS_BIGENDIAN
- "big"
-#else
- "little"
-#endif
- "-endian)\n"
- " -c Set 'custom-bit' in values\n"
- " -d Use decimal values in output\n"
- " -D Set debug flag\n"
- " -h This message\n"
- " -H file Write headerfile to file (default is inputfile.h)\n"
- " -i Inline messagetable(s)\n"
- " -o file Output to file (default is inputfile.rc)\n"
- " -u Inputfile is in unicode\n"
- " -U Output unicode messagetable(s)\n"
- " -v Show supported codepages and languages\n"
- " -V Print version end exit\n"
- " -W Enable pedantic warnings\n"
- "Input is taken from stdin if no inputfile is specified.\n"
- "Byteorder of unicode input is based upon the first couple of\n"
- "bytes read, which should be 0x0000..0x00ff.\n"
- ;
-
-static char version_string[] =
- "Wine Message Compiler Version " WMC_FULLVERSION "\n"
- "Copyright 2000 Bertho A. Stultiens\n"
- ;
-
-/*
- * The output byte-order of resources (set with -B)
- */
-int byteorder = WMC_BO_NATIVE;
-
-/*
- * Custom bit (bit 29) in output values must be set (-c option)
- */
-int custombit = 0;
-
-/*
- * Output decimal values (-d option)
- */
-int decimal = 0;
-
-/*
- * Enable pedantic warnings; check arg references (-W option)
- */
-int pedantic = 0;
-
-/*
- * Unicode input (-u option)
- */
-int unicodein = 0;
-
-/*
- * Unicode output (-U option)
- */
-int unicodeout = 0;
-
-/*
- * Inline the messagetables (don't write *.bin files; -i option)
- */
-int rcinline = 0;
-
-/*
- * Debugging flag (-D option)
- */
-int dodebug = 0;
-
-char *output_name = NULL; /* The name given by the -o option */
-char *input_name = NULL; /* The name given on the command-line */
-char *header_name = NULL; /* The name given by the -H option */
-
-int line_number = 1; /* The current line */
-int char_number = 1; /* The current char pos within the line */
-
-char *cmdline; /* The entire commandline */
-time_t now; /* The time of start of wmc */
-
-int getopt (int argc, char *const *argv, const char *optstring);
-static void segvhandler(int sig);
-
-int main(int argc,char *argv[])
-{
- extern char* optarg;
- extern int optind;
- int optc;
- int lose = 0;
- int ret;
- int i;
- int cmdlen;
-
- signal(SIGSEGV, segvhandler);
-
- now = time(NULL);
-
- /* First rebuild the commandline to put in destination */
- /* Could be done through env[], but not all OS-es support it */
- cmdlen = 4; /* for "wmc " */
- for(i = 1; i < argc; i++)
- cmdlen += strlen(argv[i]) + 1;
- cmdline = (char *)xmalloc(cmdlen);
- strcpy(cmdline, "wmc ");
- for(i = 1; i < argc; i++)
- {
- strcat(cmdline, argv[i]);
- if(i < argc-1)
- strcat(cmdline, " ");
- }
-
- while((optc = getopt(argc, argv, "B:cdDhH:io:p:uUvVW")) != EOF)
- {
- switch(optc)
- {
- case 'B':
- switch(optarg[0])
- {
- case 'n':
- case 'N':
- byteorder = WMC_BO_NATIVE;
- break;
- case 'l':
- case 'L':
- byteorder = WMC_BO_LITTLE;
- break;
- case 'b':
- case 'B':
- byteorder = WMC_BO_BIG;
- break;
- default:
- fprintf(stderr, "Byteordering must be n[ative], l[ittle] or b[ig]\n");
- lose++;
- }
- break;
- case 'c':
- custombit = 1;
- break;
- case 'd':
- decimal = 1;
- break;
- case 'D':
- dodebug = 1;
- break;
- case 'h':
- printf("%s", usage);
- exit(0);
- /* No return */
- case 'H':
- header_name = xstrdup(optarg);
- break;
- case 'i':
- rcinline = 1;
- break;
- case 'o':
- output_name = xstrdup(optarg);
- break;
- case 'u':
- unicodein = 1;
- break;
- case 'U':
- unicodeout = 1;
- break;
- case 'v':
- show_languages();
- show_codepages();
- exit(0);
- /* No return */
- case 'V':
- printf(version_string);
- exit(0);
- /* No return */
- case 'W':
- pedantic = 1;
- break;
- default:
- lose++;
- break;
- }
- }
-
- if(lose)
- {
- fprintf(stderr, "%s", usage);
- return 1;
- }
-
- yydebug = dodebug;
- if(dodebug)
- {
- setbuf(stdout, 0);
- setbuf(stderr, 0);
- }
-
- /* Check for input file on command-line */
- if(optind < argc)
- {
- input_name = argv[optind];
- }
-
- /* Generate appropriate outfile names */
- if(!output_name)
- {
- output_name = dup_basename(input_name, ".mc");
- strcat(output_name, ".rc");
- }
-
- if(!header_name)
- {
- header_name = dup_basename(input_name, ".mc");
- strcat(header_name, ".h");
- }
-
- if(input_name)
- {
- if(!(yyin = fopen(input_name, "rb")))
- error("Could not open %s for input\n", input_name);
- }
- else
- yyin = stdin;
-
- ret = yyparse();
-
- if(input_name)
- fclose(yyin);
-
- if(ret)
- {
- /* Error during parse */
- exit(1);
- }
-
- write_h_file(header_name);
- write_rc_file(output_name);
- if(!rcinline)
- write_bin_files();
-
- return 0;
-}
-
-static void segvhandler(int sig)
-{
- fprintf(stderr, "\n%s:%d: Oops, segment violation\n", input_name, line_number);
- fflush(stdout);
- fflush(stderr);
- abort();
-}
-
+++ /dev/null
-/*
- * Main definitions and externals
- *
- * Copyright 2000 Bertho A. Stultiens (BS)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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 Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef __WMC_WMC_H
-#define __WMC_WMC_H
-
-#ifndef __WMC_WMCTYPES_H
-#include "wmctypes.h"
-#endif
-
-#include <time.h> /* For time_t */
-
-#define WMC_MAJOR_VERSION 1
-#define WMC_MINOR_VERSION 0
-#define WMC_MICRO_VERSION 0
-#define WMC_RELEASEDATE "(12-Jun-2000)"
-
-#define WMC_STRINGIZE(a) #a
-#define WMC_VERSIONIZE(a,b,c) WMC_STRINGIZE(a) "." WMC_STRINGIZE(b) "." WMC_STRINGIZE(c)
-#define WMC_VERSION WMC_VERSIONIZE(WMC_MAJOR_VERSION, WMC_MINOR_VERSION, WMC_MICRO_VERSION)
-#define WMC_FULLVERSION WMC_VERSION " " WMC_RELEASEDATE
-
-/*
- * The default codepage setting is only to
- * read and convert input which is non-message
- * text. It doesn't really matter that much because
- * all codepages map 0x00-0x7f to 0x0000-0x007f from
- * char to unicode and all non-message text should
- * be plain ASCII.
- * However, we do implement iso-8859-1 for 1-to-1
- * mapping for all other chars, so this is very close
- * to what we really want.
- */
-#define WMC_DEFAULT_CODEPAGE 28591
-
-extern int pedantic;
-extern int leave_case;
-extern int byteorder;
-extern int decimal;
-extern int custombit;
-extern int unicodein;
-extern int unicodeout;
-extern int rcinline;
-
-extern char *output_name;
-extern char *input_name;
-extern char *header_name;
-extern char *cmdline;
-extern time_t now;
-
-extern int line_number;
-extern int char_number;
-
-int yyparse(void);
-extern int yydebug;
-extern int want_nl;
-extern int want_line;
-extern int want_file;
-extern node_t *nodehead;
-extern lan_blk_t *lanblockhead;
-
-int yylex(void);
-FILE *yyin;
-void set_codepage(int cp);
-
-void add_token(tok_e type, const WCHAR *name, int tok, int cp, const WCHAR *alias, int fix);
-token_t *lookup_token(const WCHAR *s);
-void get_tokentable(token_t **tab, int *len);
-
-
-#ifdef __GNUC__
-#define _alloca alloca
-//#define alloca __builtin_alloca
-#else /* not GNU C. */
-//#define alloca __builtin_alloca
-
-#pragma warning (disable:4305) // 'initializing' : truncation from 'const int ' to 'const char '
-
-#endif /*__GNUC__*/
-
-#endif
+++ /dev/null
-WMC_BASE = $(TOOLS_BASE_)wmc
-WMC_BASE_ = $(WMC_BASE)$(SEP)
-WMC_INT = $(INTERMEDIATE_)$(WMC_BASE)
-WMC_INT_ = $(WMC_INT)$(SEP)
-WMC_OUT = $(OUTPUT_)$(WMC_BASE)
-WMC_OUT_ = $(WMC_OUT)$(SEP)
-
-$(WMC_INT): | $(TOOLS_INT)
- $(ECHO_MKDIR)
- ${mkdir} $@
-
-ifneq ($(INTERMEDIATE),$(OUTPUT))
-$(WMC_OUT): | $(TOOLS_OUT)
- $(ECHO_MKDIR)
- ${mkdir} $@
-endif
-
-WMC_TARGET = \
- $(EXEPREFIX)$(WMC_OUT_)wmc$(EXEPOSTFIX)
-
-WMC_SOURCES = $(addprefix $(WMC_BASE_), \
- getopt.c \
- lang.c \
- mcl.c \
- utils.c \
- wmc.c \
- write.c \
- y_tab.c \
- misc.c \
- )
-
-WMC_OBJECTS = \
- $(addprefix $(INTERMEDIATE_), $(WMC_SOURCES:.c=.o))
-
-WMC_HOST_CFLAGS = -I$(WMC_BASE) $(TOOLS_CFLAGS)
-
-WMC_HOST_LFLAGS = $(TOOLS_LFLAGS)
-
-.PHONY: wmc
-wmc: $(WMC_TARGET)
-
-$(WMC_TARGET): $(WMC_OBJECTS) | $(WMC_OUT)
- $(ECHO_LD)
- ${host_gcc} $(WMC_OBJECTS) $(WMC_HOST_LFLAGS) -o $@
-
-$(WMC_INT_)getopt.o: $(WMC_BASE_)getopt.c | $(WMC_INT)
- $(ECHO_CC)
- ${host_gcc} $(WMC_HOST_CFLAGS) -c $< -o $@
-
-$(WMC_INT_)lang.o: $(WMC_BASE_)lang.c | $(WMC_INT)
- $(ECHO_CC)
- ${host_gcc} $(WMC_HOST_CFLAGS) -c $< -o $@
-
-$(WMC_INT_)mcl.o: $(WMC_BASE_)mcl.c | $(WMC_INT)
- $(ECHO_CC)
- ${host_gcc} $(WMC_HOST_CFLAGS) -c $< -o $@
-
-$(WMC_INT_)utils.o: $(WMC_BASE_)utils.c | $(WMC_INT)
- $(ECHO_CC)
- ${host_gcc} $(WMC_HOST_CFLAGS) -c $< -o $@
-
-$(WMC_INT_)wmc.o: $(WMC_BASE_)wmc.c | $(WMC_INT)
- $(ECHO_CC)
- ${host_gcc} $(WMC_HOST_CFLAGS) -c $< -o $@
-
-$(WMC_INT_)write.o: $(WMC_BASE_)write.c | $(WMC_INT)
- $(ECHO_CC)
- ${host_gcc} $(WMC_HOST_CFLAGS) -c $< -o $@
-
-$(WMC_INT_)y_tab.o: $(WMC_BASE_)y_tab.c | $(WMC_INT)
- $(ECHO_CC)
- ${host_gcc} $(WMC_HOST_CFLAGS) -c $< -o $@
-
-$(WMC_INT_)misc.o: $(WMC_BASE_)misc.c | $(WMC_INT)
- $(ECHO_CC)
- ${host_gcc} $(WMC_HOST_CFLAGS) -c $< -o $@
-
-.PHONY: wmc_clean
-wmc_clean:
- -@$(rm) $(WMC_TARGET) $(WMC_OBJECTS) 2>$(NUL)
-clean: wmc_clean
+++ /dev/null
-.TH WMC 1 "June 12, 2000" "Version 1.0.0" "Wine Message Compiler"
-.SH NAME
-wrc \- Wine Message Compiler
-.SH SYNOPSIS
-.BI "wmc " "[options] " "[inputfile]"
-.SH DESCRIPTION
-.B wmc
-compiles messages from
-.B inputfile
-into FormatMessage[AW] compatible format encapsulated in a resourcescript
-format.
-.B wmc
-outputs the data either in a standard \fB.bin\fR formatted binary
-file, or can generated inline resource data.
-.PP
-.B wmc
-takes only one \fBinputfile\fR as argument (see \fBBUGS\fR). The
-\fBinputfile\fR normally has extension \fB.mc\fR. The messages are read from
-standard input if no inputfile is given. If the outputfile is not specified
-with \fI-o\fR, then \fBwmc\fR will write the output to \fBinputfile.{rc,h}\fR.
-The outputfile is named \fBwmc.tab.{rc,h}\fR if no inputfile was given.
-.SH OPTIONS
-.TP
-.I \-B x
-Set output byte-order x={n[ative], l[ittle], b[ig]}. Default is n[ative].
-.TP
-.I \-c
-Set 'custom-bit' in message-code values.
-.TP
-.I \-d
-NON-FUNCTIONAL; Use decimal values in output
-.TP
-.I \-D
-Set debug flag. This results is a parser trace and a lot of extra messages.
-.TP
-.I \-h
-Print an informative usage message.
-.TP
-.I \-H file
-Write headerfile to \fIfile\fR. Default is \fIinputfile.h\fR.
-.TP
-.I \-i
-Inline messagetable(s). This option skips the generation of all \fI.bin\fR files
-and writes all output into the \fI.rc\fR file. This encoding is parsable with
-wrc(1).
-.TP
-.I \-o file
-Output to \fIfile\fR. Default is \fIinputfile.rc\fR.
-.TP
-.I \-u
-Assume that the inputfile is in unicode.
-.TP
-.I \-U
-Write resource output in unicode formatted messagetable(s).
-.TP
-.I \-v
-Show all supported codepages and languages.
-.TP
-.I \-V
-Print version end exit.
-.TP
-.I \-W
-Enable pedantic warnings.
-.SH EXTENSIONS
-The original syntax is extended to support codepages more smoothly. Normally,
-codepages are based on the DOS\-codepage from the language setting. The
-original syntax only allows the destination codepage to be set. However, this
-is not enough for non\-DOS systems which do not use unicode source-files.
-.PP
-A new keyword \fICodepages\fR is introduced to set both input and output
-codepages to anything one wants for each language. The syntax is similar to
-the other constructs:
-.PP
-Codepages '=' '(' language '=' cpin ':' cpout ... ')'
-.PP
-The \fIlanguage\fR is the numerical language\-ID or the alias set with
-LanguageNames. The input\-codepage \fIcpin\fR and output\-codepage
-\fIcpout\fR are the numerical codepage\-IDs. There can be multiple mapping
-within the definition and the definition may occur more than once.
-.SH AUTHORS
-.B wmc
-was written by Bertho A. Stultiens.
-.SH BUGS
-The message compiler should be able to have multiple inputfiles and combine
-them into one outputfile. This would enable the splitting of languages into
-separate files.
-.PP
-Unicode detection of the input is suboptimal, to say the least. It should
-recognize byte\-order\-marks (BOM) and decide what to do.
-.PP
-Decimal output is completely lacking. Don't know whether it should be
-implemented because it is a, well, non-informative format change. It is
-recognized on the commandline for some form of compatibility.
-.SH AVAILABILITY
-.B wmc
-is part of the wine distribution, which is available through
-WineHQ, the
-.B wine
-development headquarters, at
-.I http://www.winehq.com/.
-.SH "SEE ALSO"
-.BR wine (1),
-.BR wrc (1)
+++ /dev/null
-/*
- * Main definitions and externals
- *
- * Copyright 2000 Bertho A. Stultiens (BS)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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 Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef __WMC_WMCTYPES_H
-#define __WMC_WMCTYPES_H
-
-
-/* Byteordering defines */
-#define WMC_BO_NATIVE 0x00
-#define WMC_BO_LITTLE 0x01
-#define WMC_BO_BIG 0x02
-
-#define WMC_LOBYTE(w) ((WORD)(w) & 0xff)
-#define WMC_HIBYTE(w) (((WORD)(w) >> 8) & 0xff)
-#define WMC_LOWORD(d) ((DWORD)(d) & 0xffff)
-#define WMC_HIWORD(d) (((DWORD)(d) >> 16) & 0xffff)
-#define BYTESWAP_WORD(w) ((WORD)(((WORD)WMC_LOBYTE(w) << 8) + (WORD)WMC_HIBYTE(w)))
-#define BYTESWAP_DWORD(d) ((DWORD)(((DWORD)BYTESWAP_WORD(WMC_LOWORD(d)) << 16) + ((DWORD)BYTESWAP_WORD(WMC_HIWORD(d)))))
-
-/*
- * Tokenizer types
- */
-typedef enum tok_enum {
- tok_null = 0,
- tok_keyword,
- tok_severity,
- tok_facility,
- tok_language
-} tok_e;
-
-typedef struct token {
- tok_e type;
- const WCHAR *name; /* Parsed name of token */
- int token; /* Tokenvalue or language code */
- int codepage;
- const WCHAR *alias; /* Alias or filename */
- int fixed; /* Cleared if token may change */
-} token_t;
-
-typedef struct lan_cp {
- int language;
- int codepage;
-} lan_cp_t;
-
-typedef struct cp_xlat {
- int lan;
- int cpin;
- int cpout;
-} cp_xlat_t;
-
-typedef struct lanmsg {
- int lan; /* Language code of message */
- int cp; /* Codepage of message */
- WCHAR *msg; /* Message text */
- int len; /* Message length including trailing '\0' */
-} lanmsg_t;
-
-typedef struct msg {
- int id; /* Message ID */
- unsigned realid; /* Combined message ID */
- WCHAR *sym; /* Symbolic name */
- int sev; /* Severity code */
- int fac; /* Facility code */
- lanmsg_t **msgs; /* Array message texts */
- int nmsgs; /* Number of message texts in array */
- int base; /* Base of number to print */
- WCHAR *cast; /* Typecase to use */
-} msg_t;
-
-typedef enum {
- nd_msg,
- nd_comment
-} node_e;
-
-typedef struct node {
- struct node *next;
- struct node *prev;
- node_e type;
- union {
- void *all;
- WCHAR *comment;
- msg_t *msg;
- } u;
-} node_t;
-
-typedef struct block {
- unsigned idlo; /* Lowest ID in this set */
- unsigned idhi; /* Highest ID in this set */
- int size; /* Size of this set */
- lanmsg_t **msgs; /* Array of messages in this set */
- int nmsg; /* Number of array entries */
-} block_t;
-
-typedef struct lan_blk {
- struct lan_blk *next; /* Linkage for languages */
- struct lan_blk *prev;
- int lan; /* The language of this block */
- block_t *blks; /* Array of blocks for this language */
- int nblk; /* Nr of blocks in array */
-} lan_blk_t;
-
-#endif
+++ /dev/null
-/*
- * Wine Message Compiler output generation
- *
- * Copyright 2000 Bertho A. Stultiens (BS)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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 Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <windows.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include <ctype.h>
-
-#include "wmc.h"
-#include "utils.h"
-#include "lang.h"
-#include "write.h"
-
-/*
- * The binary resource layout is as follows:
- *
- * +===============+
- * Header | NBlocks |
- * +===============+
- * Block 0 | Low ID |
- * +---------------+
- * | High ID |
- * +---------------+
- * | Offset |---+
- * +===============+ |
- * Block 1 | Low ID | |
- * +---------------+ |
- * | High ID | |
- * +---------------+ |
- * | Offset |------+
- * +===============+ | |
- * | | | |
- * ... ... | |
- * | | | |
- * +===============+ <-+ |
- * B0 LoID | Len | Flags | |
- * +---+---+---+---+ |
- * | b | l | a | b | |
- * +---+---+---+---+ |
- * | l | a | \0| \0| |
- * +===============+ |
- * | | |
- * ... ... |
- * | | |
- * +===============+ |
- * B0 HiID | Len | Flags | |
- * +---+---+---+---+ |
- * | M | o | r | e | |
- * +---+---+---+---+ |
- * | b | l | a | \0| |
- * +===============+ <----+
- * B1 LoID | Len | Flags |
- * +---+---+---+---+
- * | J | u | n | k |
- * +---+---+---+---+
- * | \0| \0| \0| \0|
- * +===============+
- * | |
- * ... ...
- * | |
- * +===============+
- *
- * All Fields are aligned on their natural boundaries. The length
- * field (Len) covers both the length of the string and the header
- * fields (Len and Flags). Strings are '\0' terminated. Flags is 0
- * for normal character strings and 1 for unicode strings.
- */
-
-static char str_header[] =
- "/* This file is generated with wmc version " WMC_FULLVERSION ". Do not edit! */\n"
- "/* Source : %s */\n"
- "/* Cmdline: %s */\n"
- "/* Date : %s */\n"
- "\n"
- ;
-
-static char *dup_u2c(int cp, const WCHAR *uc)
-{
- int len = unistrlen(uc);
- char *cptr = xmalloc(len+1);
-// const union cptable *cpdef = find_codepage(cp);
-// if(!cpdef)
-// internal_error(__FILE__, __LINE__, "Codepage %d not found (vanished?)", cp);
-// if((len = cp_wcstombs(cpdef, 0, uc, unistrlen(uc)+1, cptr, len+1, NULL, NULL)) < 0)
- if((len = WideCharToMultiByte(cp, 0, uc, unistrlen(uc)+1, cptr, len+1, NULL, NULL)) < 0)
-
- internal_error(__FILE__, __LINE__, "Buffer overflow? code %d.", len);
- return cptr;
-}
-
-static void killnl(char *s, int ddd)
-{
- char *tmp;
- tmp = strstr(s, "\r\n");
- if(tmp)
- {
- if(ddd && tmp - s > 3)
- {
- tmp[0] = tmp[1] = tmp[2] = '.';
- tmp[3] = '\0';
- }
- else
- *tmp = '\0';
- }
- tmp = strchr(s, '\n');
- if(tmp)
- {
- if(ddd && tmp - s > 3)
- {
- tmp[0] = tmp[1] = tmp[2] = '.';
- tmp[3] = '\0';
- }
- else
- *tmp = '\0';
- }
-}
-
-static int killcomment(char *s)
-{
- char *tmp = s;
- int b = 0;
- while((tmp = strstr(tmp, "/*")))
- {
- tmp[1] = 'x';
- b++;
- }
- tmp = s;
- while((tmp = strstr(tmp, "*/")))
- {
- tmp[0] = 'x';
- b++;
- }
- return b;
-}
-
-void write_h_file(const char *fname)
-{
- node_t *ndp;
- char *cptr;
- char *cast;
- FILE *fp;
- token_t *ttab;
- int ntab;
- int i;
- int once = 0;
- int idx_en = 0;
-
- fp = fopen(fname, "w");
- if(!fp)
- {
- perror(fname);
- exit(1);
- }
- cptr = ctime(&now);
- killnl(cptr, 0);
- fprintf(fp, str_header, input_name ? input_name : "<stdin>", cmdline, cptr);
- fprintf(fp, "#ifndef __WMCGENERATED_%08lx_H\n", now);
- fprintf(fp, "#define __WMCGENERATED_%08lx_H\n", now);
- fprintf(fp, "\n");
-
- /* Write severity and facility aliases */
- get_tokentable(&ttab, &ntab);
- fprintf(fp, "/* Severity codes */\n");
- for(i = 0; i < ntab; i++)
- {
- if(ttab[i].type == tok_severity && ttab[i].alias)
- {
- cptr = dup_u2c(WMC_DEFAULT_CODEPAGE, ttab[i].alias);
- fprintf(fp, "#define %s\t0x%x\n", cptr, ttab[i].token);
- free(cptr);
- }
- }
- fprintf(fp, "\n");
-
- fprintf(fp, "/* Facility codes */\n");
- for(i = 0; i < ntab; i++)
- {
- if(ttab[i].type == tok_facility && ttab[i].alias)
- {
- cptr = dup_u2c(WMC_DEFAULT_CODEPAGE, ttab[i].alias);
- fprintf(fp, "#define %s\t0x%x\n", cptr, ttab[i].token);
- free(cptr);
- }
- }
- fprintf(fp, "\n");
-
- /* Write the message codes */
- fprintf(fp, "/* Message definitions */\n");
- for(ndp = nodehead; ndp; ndp = ndp->next)
- {
- switch(ndp->type)
- {
- case nd_comment:
- cptr = dup_u2c(WMC_DEFAULT_CODEPAGE, ndp->u.comment+1);
- killnl(cptr, 0);
- killcomment(cptr);
- if(*cptr)
- fprintf(fp, "/* %s */\n", cptr);
- else
- fprintf(fp, "\n");
- free(cptr);
- break;
- case nd_msg:
- if(!once)
- {
- /*
- * Search for an english text.
- * If not found, then use the first in the list
- */
- once++;
- for(i = 0; i < ndp->u.msg->nmsgs; i++)
- {
- if(ndp->u.msg->msgs[i]->lan == 0x409)
- {
- idx_en = i;
- break;
- }
- }
- fprintf(fp, "\n");
- }
- fprintf(fp, "/* MessageId : 0x%08x */\n", ndp->u.msg->realid);
- cptr = dup_u2c(ndp->u.msg->msgs[idx_en]->cp, ndp->u.msg->msgs[idx_en]->msg);
- killnl(cptr, 0);
- killcomment(cptr);
- fprintf(fp, "/* Approx. msg: %s */\n", cptr);
- free(cptr);
- cptr = dup_u2c(WMC_DEFAULT_CODEPAGE, ndp->u.msg->sym);
- if(ndp->u.msg->cast)
- cast = dup_u2c(WMC_DEFAULT_CODEPAGE, ndp->u.msg->cast);
- else
- cast = NULL;
- switch(ndp->u.msg->base)
- {
- case 8:
- if(cast)
- fprintf(fp, "#define %s\t((%s)0%oL)\n\n", cptr, cast, ndp->u.msg->realid);
- else
- fprintf(fp, "#define %s\t0%oL\n\n", cptr, ndp->u.msg->realid);
- break;
- case 10:
- if(cast)
- fprintf(fp, "#define %s\t((%s)%dL)\n\n", cptr, cast, ndp->u.msg->realid);
- else
- fprintf(fp, "#define %s\t%dL\n\n", cptr, ndp->u.msg->realid);
- break;
- case 16:
- if(cast)
- fprintf(fp, "#define %s\t((%s)0x%08xL)\n\n", cptr, cast, ndp->u.msg->realid);
- else
- fprintf(fp, "#define %s\t0x%08xL\n\n", cptr, ndp->u.msg->realid);
- break;
- default:
- internal_error(__FILE__, __LINE__, "Invalid base for number print");
- }
- free(cptr);
- if(cast)
- free(cast);
- break;
- default:
- internal_error(__FILE__, __LINE__, "Invalid node type %d", ndp->type);
- }
- }
- fprintf(fp, "\n#endif\n");
- fclose(fp);
-}
-
-static void write_rcbin(FILE *fp)
-{
- lan_blk_t *lbp;
- token_t *ttab;
- int ntab;
- int i;
-
- get_tokentable(&ttab, &ntab);
-
- for(lbp = lanblockhead; lbp; lbp = lbp->next)
- {
- char *cptr = NULL;
- fprintf(fp, "LANGUAGE 0x%x, 0x%x\n", lbp->lan & 0x3ff, lbp->lan >> 10);
- for(i = 0; i < ntab; i++)
- {
- if(ttab[i].type == tok_language && ttab[i].token == lbp->lan)
- {
- if(ttab[i].alias)
- cptr = dup_u2c(WMC_DEFAULT_CODEPAGE, ttab[i].alias);
- break;
- }
- }
- if(!cptr)
- internal_error(__FILE__, __LINE__, "Filename vanished for language 0x%0x", lbp->lan);
- fprintf(fp, "1 MESSAGETABLE \"%s.bin\"\n", cptr);
- free(cptr);
- }
-}
-
-static char *make_string(WCHAR *uc, int len, int codepage)
-{
- char *str = xmalloc(7*len + 1);
- char *cptr = str;
- int i;
- int b;
-
- if(!codepage)
- {
- *cptr++ = ' ';
- *cptr++ = 'L';
- *cptr++ = '"';
- for(i = b = 0; i < len; i++, uc++)
- {
- int n;
- if(*uc < 0x100)
- {
- if(isprint(*uc))
- {
- *cptr++ = (char)*uc;
- b++;
- }
- else
- {
- switch(*uc)
- {
- case '\a': *cptr++ = '\\'; *cptr++ = 'a'; b += 2; break;
- case '\b': *cptr++ = '\\'; *cptr++ = 'b'; b += 2; break;
- case '\f': *cptr++ = '\\'; *cptr++ = 'f'; b += 2; break;
- case '\n': *cptr++ = '\\'; *cptr++ = 'n'; b += 2; break;
- case '\r': *cptr++ = '\\'; *cptr++ = 'r'; b += 2; break;
- case '\t': *cptr++ = '\\'; *cptr++ = 't'; b += 2; break;
- case '\v': *cptr++ = '\\'; *cptr++ = 'v'; b += 2; break;
- case '\\': *cptr++ = '\\'; *cptr++ = '\\'; b += 2; break;
- case '"': *cptr++ = '\\'; *cptr++ = '"'; b += 2; break;
- default:
- n = sprintf(cptr, "\\x%04x", (unsigned)*uc & 0xffff);
- cptr += n;
- b += n;
- }
- }
- }
- else
- {
- n = sprintf(cptr, "\\x%04x", (unsigned)*uc & 0xffff);
- cptr += n;
- b += n;
- }
- if(i < len-1 && b >= 72 && cptr[-1] != '\\')
- {
- *cptr++ = '"';
- *cptr++ = ',';
- *cptr++ = '\n';
- *cptr++ = ' ';
- *cptr++ = 'L';
- *cptr++ = '"';
- b = 0;
- }
- }
- len = (len + 3) & ~3;
- for(; i < len; i++)
- {
- *cptr++ = '\\';
- *cptr++ = 'x';
- *cptr++ = '0';
- *cptr++ = '0';
- *cptr++ = '0';
- *cptr++ = '0';
- }
- *cptr++ = '"';
- *cptr = '\0';
- }
- else
- {
- char *tmp = xmalloc(2*len+1);
- char *cc = tmp;
-// const union cptable *cpdef = find_codepage(codepage);
-
-// assert(cpdef != NULL);
-// if((i = cp_wcstombs(cpdef, 0, uc, unistrlen(uc)+1, tmp, 2*len+1, NULL, NULL)) < 0)
- if((i = WideCharToMultiByte(codepage, 0, uc, unistrlen(uc)+1, tmp, 2*len+1, NULL, NULL)) < 0)
-
- internal_error(__FILE__, __LINE__, "Buffer overflow? code %d.", i);
- *cptr++ = ' ';
- *cptr++ = '"';
- for(i = b = 0; i < len; i++, cc++)
- {
- int n;
- if(isprint(*cc))
- {
- *cptr++ = *cc;
- b++;
- }
- else
- {
- switch(*cc)
- {
- case '\a': *cptr++ = '\\'; *cptr++ = 'a'; b += 2; break;
- case '\b': *cptr++ = '\\'; *cptr++ = 'b'; b += 2; break;
- case '\f': *cptr++ = '\\'; *cptr++ = 'f'; b += 2; break;
- case '\n': *cptr++ = '\\'; *cptr++ = 'n'; b += 2; break;
- case '\r': *cptr++ = '\\'; *cptr++ = 'r'; b += 2; break;
- case '\t': *cptr++ = '\\'; *cptr++ = 't'; b += 2; break;
- case '\v': *cptr++ = '\\'; *cptr++ = 'v'; b += 2; break;
- case '\\': *cptr++ = '\\'; *cptr++ = '\\'; b += 2; break;
- case '"': *cptr++ = '\\'; *cptr++ = '"'; b += 2; break;
- default:
- n = sprintf(cptr, "\\x%02x", *cc & 0xff);
- cptr += n;
- b += n;
- }
- }
- if(i < len-1 && b >= 72 && cptr[-1] != '\\')
- {
- *cptr++ = '"';
- *cptr++ = ',';
- *cptr++ = '\n';
- *cptr++ = ' ';
- *cptr++ = '"';
- b = 0;
- }
- }
- len = (len + 3) & ~3;
- for(; i < len; i++)
- {
- *cptr++ = '\\';
- *cptr++ = 'x';
- *cptr++ = '0';
- *cptr++ = '0';
- }
- *cptr++ = '"';
- *cptr = '\0';
- free(tmp);
- }
- return str;
-}
-
-
-static char *make_bin_string(WCHAR *uc, int len, int *retlen, int codepage)
-
-{
- char *str = xmalloc(7 * len + 1);
- int i;
- int b;
-
- if(!codepage)
- {
- WCHAR *cptr = (WCHAR*)str;
-
- for(i = b = 0; i < len; i++, uc++)
- {
- *cptr++ = *uc;
- }
- len = (len + 1) & ~1;
- for(; i < len; i++)
- {
- *cptr++ = 0;
- }
- *retlen = len * 2;
- }
- else
- {
- char *tmp = xmalloc(2*len+1);
- char *cc = tmp;
- char *cptr = str;
-// const union cptable *cpdef = find_codepage(codepage);
-
-// assert(cpdef != NULL);
-// if((i = cp_wcstombs(cpdef, 0, uc, unistrlen(uc)+1, tmp, 2*len+1, NULL, NULL)) < 0)
- if((i = WideCharToMultiByte(codepage, 0, uc, unistrlen(uc)+1, tmp, 2*len+1, NULL, NULL)) < 0)
- internal_error(__FILE__, __LINE__, "Buffer overflow? code %d.", i);
- for(i = b = 0; i < len; i++, cc++)
- {
- *cptr++ = *cc;
- b++;
- }
- len = (len + 3) & ~3;
- for(; i < len; i++)
- {
- *cptr++ = 0;
- }
- free(tmp);
- *retlen = len;
- }
- return str;
-}
-
-static void write_rcinline(FILE *fp)
-{
- lan_blk_t *lbp;
- int i;
- int j;
-
- for(lbp = lanblockhead; lbp; lbp = lbp->next)
- {
- unsigned offs = 4 * (lbp->nblk * 3 + 1);
- fprintf(fp, "\n1 MESSAGETABLE\n");
- fprintf(fp, "LANGUAGE 0x%x, 0x%x\n", lbp->lan & 0x3ff, lbp->lan >> 10);
- fprintf(fp, "{\n");
- fprintf(fp, " /* NBlocks */ 0x%08xL,\n", lbp->nblk);
- for(i = 0; i < lbp->nblk; i++)
- {
- fprintf(fp, " /* Lo,Hi,Offs */ 0x%08xL, 0x%08xL, 0x%08xL,\n",
- lbp->blks[i].idlo,
- lbp->blks[i].idhi,
- offs);
- offs += lbp->blks[i].size;
- }
- for(i = 0; i < lbp->nblk; i++)
- {
- block_t *blk = &lbp->blks[i];
- for(j = 0; j < blk->nmsg; j++)
- {
- char *cptr;
- int l = blk->msgs[j]->len;
- char *comma = j == blk->nmsg-1 && i == lbp->nblk-1 ? "" : ",";
- cptr = make_string(blk->msgs[j]->msg, l, unicodeout ? 0 : blk->msgs[j]->cp);
- fprintf(fp, "\n /* Msg 0x%08x */ 0x%04x, 0x000%c,\n",
- blk->idlo + j,
- (unicodeout ? (l*2+3)&~3 : (l+3)&~3)+4,
- unicodeout ? '1' : '0');
- fprintf(fp, "%s%s\n", cptr, comma);
- free(cptr);
- }
- }
- fprintf(fp, "}\n");
- }
-}
-
-void write_rc_file(const char *fname)
-{
- FILE *fp;
- char *cptr;
-
- fp = fopen(fname, "w");
- if(!fp)
- {
- perror(fname);
- exit(1);
- }
- cptr = ctime(&now);
- killnl(cptr, 0);
- fprintf(fp, str_header, input_name ? input_name : "<stdin>", cmdline, cptr);
-
- if(rcinline)
- write_rcinline(fp);
- else
- write_rcbin(fp);
- fclose(fp);
-}
-
-void write_bin_files(void)
-{
- lan_blk_t *lbp;
- token_t *ttab;
- int ntab;
- int i;
- int j;
- char fname[16];
- FILE *fp;
-
- get_tokentable(&ttab, &ntab);
-
- for (lbp = lanblockhead; lbp; lbp = lbp->next)
- {
- unsigned offs = 4 * (lbp->nblk * 3 + 1);
-
- char *cptr = NULL;
- for(i = 0; i < ntab; i++)
- {
- if (ttab[i].type == tok_language && ttab[i].token == lbp->lan)
- {
- if (ttab[i].alias)
- cptr = dup_u2c(WMC_DEFAULT_CODEPAGE, ttab[i].alias);
- break;
- }
- }
-
- if (!cptr)
- internal_error(__FILE__, __LINE__, "Filename vanished for language 0x%0x", lbp->lan);
- sprintf(fname, "%s.bin", cptr);
- free(cptr);
-
- fp = fopen(fname, "wb");
- if (!fp)
- {
- perror(fname);
- exit(1);
- }
-
- /* NBlocks */
- fwrite(&lbp->nblk, sizeof(unsigned long), 1, fp);
- for(i = 0; i < lbp->nblk; i++)
- {
- /* Lo */
- fwrite(&lbp->blks[i].idlo, sizeof(unsigned long), 1, fp);
- /* Hi */
- fwrite(&lbp->blks[i].idhi, sizeof(unsigned long), 1, fp);
- /* Offs */
- fwrite(&offs, sizeof(unsigned long), 1, fp);
- offs += lbp->blks[i].size;
- }
-
- for (i = 0; i < lbp->nblk; i++)
- {
- block_t *blk = &lbp->blks[i];
- for (j = 0; j < blk->nmsg; j++)
- {
- char *cptr;
- int l = blk->msgs[j]->len;
- int retlen = 0;
-
- unsigned short length = (unicodeout ? (l*2+3)&~3 : (l+3)&~3)+4;
- unsigned short flags = unicodeout ? 1 : 0;
-
- /* Lo */
- fwrite(&length, sizeof(unsigned short), 1, fp);
- /* Hi */
- fwrite(&flags, sizeof(unsigned short), 1, fp);
-
- /* message text */
- cptr = make_bin_string(blk->msgs[j]->msg, l, &retlen, unicodeout ? 0 : blk->msgs[j]->cp);
- fwrite(cptr, retlen, 1, fp);
-
- free(cptr);
- }
- }
-
- fclose(fp);
- }
-}
-
-/* EOF */
+++ /dev/null
-/*
- * Wine Message Compiler output generation
- *
- * Copyright 2000 Bertho A. Stultiens (BS)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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 Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-#ifndef __WMC_WRITE_H
-#define __WMC_WRITE_H
-
-void write_h_file(const char *fname);
-void write_rc_file(const char *fname);
-void write_bin_files(void);
-
-#endif
+++ /dev/null
-
-/* A Bison parser, made from ./mcy.y
- by GNU Bison version 1.25
- */
-
-#define YYBISON 1 /* Identify Bison output. */
-
-#define tSEVNAMES 258
-#define tFACNAMES 259
-#define tLANNAMES 260
-#define tBASE 261
-#define tCODEPAGE 262
-#define tTYPEDEF 263
-#define tNL 264
-#define tSYMNAME 265
-#define tMSGEND 266
-#define tSEVERITY 267
-#define tFACILITY 268
-#define tLANGUAGE 269
-#define tMSGID 270
-#define tIDENT 271
-#define tLINE 272
-#define tFILE 273
-#define tCOMMENT 274
-#define tNUMBER 275
-#define tTOKEN 276
-
-#line 23 "./mcy.y"
-
-
-#include <windows.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <assert.h>
-
-#include "config.h"
-
-#include "utils.h"
-#include "wmc.h"
-#include "lang.h"
-
-static const char err_syntax[] = "Syntax error";
-static const char err_number[] = "Number expected";
-static const char err_ident[] = "Identifier expected";
-static const char err_assign[] = "'=' expected";
-static const char err_popen[] = "'(' expected";
-static const char err_pclose[] = "')' expected";
-static const char err_colon[] = "':' expected";
-static const char err_msg[] = "Message expected";
-
-/* Scanner switches */
-int want_nl = 0; /* Request next newlinw */
-int want_line = 0; /* Request next complete line */
-int want_file = 0; /* Request next ident as filename */
-
-node_t *nodehead = NULL; /* The list of all parsed elements */
-static node_t *nodetail = NULL;
-lan_blk_t *lanblockhead; /* List of parsed elements transposed */
-
-static int base = 16; /* Current printout base to use (8, 10 or 16) */
-static WCHAR *cast = NULL; /* Current typecast to use */
-
-static int last_id = 0; /* The last message ID parsed */
-static int last_sev = 0; /* Last severity code parsed */
-static int last_fac = 0; /* Last facility code parsed */
-static WCHAR *last_sym = NULL;/* Last alias symbol parsed */
-static int have_sev; /* Set if severity parsed for current message */
-static int have_fac; /* Set if facility parsed for current message */
-static int have_sym; /* Set is symbol parsed for current message */
-
-static cp_xlat_t *cpxlattab = NULL; /* Codepage translation table */
-static int ncpxlattab = 0;
-
-/* Prototypes */
-static WCHAR *merge(WCHAR *s1, WCHAR *s2);
-static lanmsg_t *new_lanmsg(lan_cp_t *lcp, WCHAR *msg);
-static msg_t *add_lanmsg(msg_t *msg, lanmsg_t *lanmsg);
-static msg_t *complete_msg(msg_t *msg, int id);
-static void add_node(node_e type, void *p);
-static void do_add_token(tok_e type, token_t *tok, const char *code);
-static void test_id(int id);
-static int check_languages(node_t *head);
-static lan_blk_t *block_messages(node_t *head);
-static void add_cpxlat(int lan, int cpin, int cpout);
-static cp_xlat_t *find_cpxlat(int lan);
-
-
-#line 83 "./mcy.y"
-typedef union {
- WCHAR *str;
- unsigned num;
- token_t *tok;
- lanmsg_t *lmp;
- msg_t *msg;
- lan_cp_t lcp;
-} YYSTYPE;
-#ifndef YYDEBUG
-#define YYDEBUG 1
-#endif
-
-#include <stdio.h>
-
-#ifndef __cplusplus
-#ifndef __STDC__
-#define const
-#endif
-#endif
-
-
-
-#define YYFINAL 155
-#define YYFLAG -32768
-#define YYNTBASE 27
-
-#define YYTRANSLATE(x) ((unsigned)(x) <= 276 ? yytranslate[x] : 58)
-
-static const char yytranslate[] = { 0,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 23,
- 24, 2, 26, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 25, 2, 2,
- 22, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 1, 2, 3, 4, 5,
- 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21
-};
-
-#if YYDEBUG != 0
-static const short yyprhs[] = { 0,
- 0, 2, 4, 7, 9, 11, 13, 15, 21, 27,
- 31, 34, 40, 46, 50, 53, 59, 65, 69, 72,
- 78, 84, 88, 91, 95, 99, 102, 106, 110, 113,
- 115, 118, 120, 125, 129, 132, 134, 137, 139, 144,
- 148, 151, 152, 155, 158, 160, 163, 165, 173, 180,
- 185, 189, 192, 193, 196, 199, 201, 204, 206, 212,
- 218, 223, 227, 230, 232, 234, 235, 240, 244, 247,
- 248, 250, 253, 256, 257, 260, 263, 266, 270, 274,
- 277, 281, 285, 288, 292, 296, 299, 301, 304, 306,
- 311, 317, 323, 328, 331, 333, 336, 338, 341, 343,
- 345, 346, 347
-};
-
-static const short yyrhs[] = { 28,
- 0, 29, 0, 28, 29, 0, 30, 0, 42, 0,
- 19, 0, 1, 0, 3, 22, 23, 31, 24, 0,
- 3, 22, 23, 31, 1, 0, 3, 22, 1, 0,
- 3, 1, 0, 4, 22, 23, 33, 24, 0, 4,
- 22, 23, 33, 1, 0, 4, 22, 1, 0, 4,
- 1, 0, 5, 22, 23, 36, 24, 0, 5, 22,
- 23, 36, 1, 0, 5, 22, 1, 0, 5, 1,
- 0, 7, 22, 23, 39, 24, 0, 7, 22, 23,
- 39, 1, 0, 7, 22, 1, 0, 7, 1, 0,
- 8, 22, 16, 0, 8, 22, 1, 0, 8, 1,
- 0, 6, 22, 20, 0, 6, 22, 1, 0, 6,
- 1, 0, 32, 0, 31, 32, 0, 1, 0, 54,
- 22, 20, 35, 0, 54, 22, 1, 0, 54, 1,
- 0, 34, 0, 33, 34, 0, 1, 0, 54, 22,
- 20, 35, 0, 54, 22, 1, 0, 54, 1, 0,
- 0, 25, 16, 0, 25, 1, 0, 37, 0, 36,
- 37, 0, 1, 0, 54, 22, 20, 57, 25, 18,
- 38, 0, 54, 22, 20, 57, 25, 1, 0, 54,
- 22, 20, 1, 0, 54, 22, 1, 0, 54, 1,
- 0, 0, 25, 20, 0, 25, 1, 0, 40, 0,
- 39, 40, 0, 1, 0, 41, 22, 20, 25, 20,
- 0, 41, 22, 20, 25, 1, 0, 41, 22, 20,
- 1, 0, 41, 22, 1, 0, 41, 1, 0, 20,
- 0, 21, 0, 0, 44, 46, 43, 50, 0, 15,
- 22, 45, 0, 15, 1, 0, 0, 20, 0, 26,
- 20, 0, 26, 1, 0, 0, 46, 48, 0, 46,
- 49, 0, 46, 47, 0, 10, 22, 16, 0, 10,
- 22, 1, 0, 10, 1, 0, 12, 22, 54, 0,
- 12, 22, 1, 0, 12, 1, 0, 13, 22, 54,
- 0, 13, 22, 1, 0, 13, 1, 0, 51, 0,
- 50, 51, 0, 1, 0, 52, 56, 53, 11, 0,
- 14, 55, 22, 54, 9, 0, 14, 55, 22, 54,
- 1, 0, 14, 55, 22, 1, 0, 14, 1, 0,
- 17, 0, 53, 17, 0, 1, 0, 53, 1, 0,
- 16, 0, 21, 0, 0, 0, 0
-};
-
-#endif
-
-#if YYDEBUG != 0
-static const short yyrline[] = { 0,
- 108, 115, 116, 119, 120, 121, 122, 125, 126, 127,
- 128, 129, 130, 131, 132, 133, 134, 135, 136, 137,
- 138, 139, 140, 141, 142, 143, 144, 156, 157, 163,
- 164, 165, 168, 175, 176, 182, 183, 184, 187, 194,
- 195, 198, 199, 200, 206, 207, 208, 211, 219, 220,
- 221, 222, 225, 226, 227, 233, 234, 235, 238, 248,
- 249, 250, 251, 254, 255, 265, 265, 268, 273, 276,
- 277, 278, 279, 282, 283, 284, 285, 288, 289, 290,
- 293, 301, 302, 305, 313, 314, 320, 321, 322, 325,
- 333, 362, 363, 364, 367, 368, 369, 370, 376, 377,
- 380, 383, 386
-};
-#endif
-
-
-#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
-
-static const char * const yytname[] = { "$","error","$undefined.","tSEVNAMES",
-"tFACNAMES","tLANNAMES","tBASE","tCODEPAGE","tTYPEDEF","tNL","tSYMNAME","tMSGEND",
-"tSEVERITY","tFACILITY","tLANGUAGE","tMSGID","tIDENT","tLINE","tFILE","tCOMMENT",
-"tNUMBER","tTOKEN","'='","'('","')'","':'","'+'","file","items","decl","global",
-"smaps","smap","fmaps","fmap","alias","lmaps","lmap","optcp","cmaps","cmap",
-"clan","msg","@1","msgid","id","sevfacsym","sym","sev","fac","bodies","body",
-"lang","lines","token","setnl","setline","setfile", NULL
-};
-#endif
-
-static const short yyr1[] = { 0,
- 27, 28, 28, 29, 29, 29, 29, 30, 30, 30,
- 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
- 30, 30, 30, 30, 30, 30, 30, 30, 30, 31,
- 31, 31, 32, 32, 32, 33, 33, 33, 34, 34,
- 34, 35, 35, 35, 36, 36, 36, 37, 37, 37,
- 37, 37, 38, 38, 38, 39, 39, 39, 40, 40,
- 40, 40, 40, 41, 41, 43, 42, 44, 44, 45,
- 45, 45, 45, 46, 46, 46, 46, 47, 47, 47,
- 48, 48, 48, 49, 49, 49, 50, 50, 50, 51,
- 52, 52, 52, 52, 53, 53, 53, 53, 54, 54,
- 55, 56, 57
-};
-
-static const short yyr2[] = { 0,
- 1, 1, 2, 1, 1, 1, 1, 5, 5, 3,
- 2, 5, 5, 3, 2, 5, 5, 3, 2, 5,
- 5, 3, 2, 3, 3, 2, 3, 3, 2, 1,
- 2, 1, 4, 3, 2, 1, 2, 1, 4, 3,
- 2, 0, 2, 2, 1, 2, 1, 7, 6, 4,
- 3, 2, 0, 2, 2, 1, 2, 1, 5, 5,
- 4, 3, 2, 1, 1, 0, 4, 3, 2, 0,
- 1, 2, 2, 0, 2, 2, 2, 3, 3, 2,
- 3, 3, 2, 3, 3, 2, 1, 2, 1, 4,
- 5, 5, 4, 2, 1, 2, 1, 2, 1, 1,
- 0, 0, 0
-};
-
-static const short yydefact[] = { 0,
- 7, 0, 0, 0, 0, 0, 0, 0, 6, 0,
- 2, 4, 5, 74, 11, 0, 15, 0, 19, 0,
- 29, 0, 23, 0, 26, 0, 69, 70, 3, 66,
- 10, 0, 14, 0, 18, 0, 28, 27, 22, 0,
- 25, 24, 71, 0, 68, 0, 0, 0, 0, 77,
- 75, 76, 32, 99, 100, 0, 30, 0, 38, 0,
- 36, 0, 47, 0, 45, 0, 58, 64, 65, 0,
- 56, 0, 73, 72, 80, 0, 83, 0, 86, 0,
- 89, 0, 67, 87, 102, 9, 8, 31, 35, 0,
- 13, 12, 37, 41, 0, 17, 16, 46, 52, 0,
- 21, 20, 57, 63, 0, 79, 78, 82, 81, 85,
- 84, 94, 0, 88, 0, 34, 42, 40, 42, 51,
- 0, 62, 0, 0, 97, 95, 0, 0, 33, 39,
- 50, 0, 61, 0, 93, 0, 98, 90, 96, 44,
- 43, 0, 60, 59, 92, 91, 49, 53, 0, 48,
- 55, 54, 0, 0, 0
-};
-
-static const short yydefgoto[] = { 153,
- 10, 11, 12, 56, 57, 60, 61, 129, 64, 65,
- 150, 70, 71, 72, 13, 49, 14, 45, 30, 50,
- 51, 52, 83, 84, 85, 127, 58, 113, 115, 132
-};
-
-static const short yypact[] = { 132,
--32768, 18, 44, 46, 47, 48, 49, 50,-32768, 113,
--32768,-32768,-32768,-32768,-32768, 11,-32768, 14,-32768, 19,
--32768, 85,-32768, 20,-32768, 147,-32768, -13,-32768, 87,
--32768, 66,-32768, 80,-32768, 82,-32768,-32768,-32768, 64,
--32768,-32768,-32768, 107,-32768, 51, 52, 53, 3,-32768,
--32768,-32768,-32768,-32768,-32768, 7,-32768, 54,-32768, 8,
--32768, 55,-32768, 17,-32768, 56,-32768,-32768,-32768, 15,
--32768, 57,-32768,-32768,-32768, 148,-32768, 88,-32768, 90,
--32768, 58, -4,-32768,-32768,-32768,-32768,-32768,-32768, 109,
--32768,-32768,-32768,-32768, 114,-32768,-32768,-32768,-32768, 121,
--32768,-32768,-32768,-32768, 122,-32768,-32768,-32768,-32768,-32768,
--32768,-32768, -11,-32768, 129,-32768, 35,-32768, 35,-32768,
- 0,-32768, 2, 91,-32768,-32768, 144, 149,-32768,-32768,
--32768, 36,-32768, 123,-32768, 5,-32768,-32768,-32768,-32768,
--32768, 4,-32768,-32768,-32768,-32768,-32768, 37, 124,-32768,
--32768,-32768, 63, 93,-32768
-};
-
-static const short yypgoto[] = {-32768,
--32768, 78,-32768,-32768, 38,-32768, 42, -55,-32768, 31,
--32768,-32768, 61,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
--32768,-32768,-32768, 43,-32768,-32768, -34,-32768,-32768,-32768
-};
-
-
-#define YYLAST 165
-
-
-static const short yytable[] = { 62,
- 131, 66, 133, 81, 147, 145, 43, 86, 91, 82,
- 124, 31, 44, 146, 33, 101, 82, 96, 15, 35,
- 39, 148, 54, 54, -103, 62, 134, 55, 55, 66,
- 87, 92, 54, 32, 68, 69, 34, 55, 102, 16,
- 97, 36, 40, 109, 17, 111, 19, 21, 23, 25,
- 27, 75, 77, 79, 89, 94, 99, 104, 112, 128,
- 142, 149, 154, 130, 67, 18, 53, 20, 22, 24,
- 26, 28, 76, 78, 80, 90, 95, 100, 105, -101,
- 59, 54, 63, 68, 69, 37, 55, 29, 108, 136,
- 110, 135, 155, 88, 98, 54, 46, 54, 47, 48,
- 55, 93, 55, 54, 38, 54, 54, 73, 55, 116,
- 55, 55, -1, 1, 118, 2, 3, 4, 5, 6,
- 7, 120, 122, 143, 151, 114, 74, 8, 117, 125,
- 103, 9, 1, 119, 2, 3, 4, 5, 6, 7,
- 121, 123, 144, 152, 137, 126, 8, 41, 106, 140,
- 9, 0, 0, 0, 138, 0, 0, 0, 0, 0,
- 139, 0, 42, 107, 141
-};
-
-static const short yycheck[] = { 34,
- 1, 36, 1, 1, 1, 1, 20, 1, 1, 14,
- 22, 1, 26, 9, 1, 1, 14, 1, 1, 1,
- 1, 18, 16, 16, 25, 60, 25, 21, 21, 64,
- 24, 24, 16, 23, 20, 21, 23, 21, 24, 22,
- 24, 23, 23, 78, 1, 80, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 25,
- 25, 25, 0, 119, 1, 22, 1, 22, 22, 22,
- 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
- 1, 16, 1, 20, 21, 1, 21, 10, 1, 124,
- 1, 1, 0, 56, 64, 16, 10, 16, 12, 13,
- 21, 60, 21, 16, 20, 16, 16, 1, 21, 1,
- 21, 21, 0, 1, 1, 3, 4, 5, 6, 7,
- 8, 1, 1, 1, 1, 83, 20, 15, 20, 1,
- 70, 19, 1, 20, 3, 4, 5, 6, 7, 8,
- 20, 20, 20, 20, 1, 17, 15, 1, 1, 1,
- 19, -1, -1, -1, 11, -1, -1, -1, -1, -1,
- 17, -1, 16, 16, 16
-};
-/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
-#line 3 "/usr/share/bison.simple"
-
-/* Skeleton output parser for bison,
- Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
-
- This program 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, or (at your option)
- any later version.
-
- This program 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.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* As a special exception, when this file is copied by Bison into a
- Bison output file, you may use that output file without restriction.
- This special exception was added by the Free Software Foundation
- in version 1.24 of Bison. */
-
-#ifndef alloca
-#ifdef __GNUC__
-#define alloca __builtin_alloca
-#else /* not GNU C. */
-#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
-#include <alloca.h>
-#else /* not sparc */
-#if defined (MSDOS) && !defined (__TURBOC__)
-#include <malloc.h>
-#else /* not MSDOS, or __TURBOC__ */
-#if defined(_AIX)
-#include <malloc.h>
- #pragma alloca
-#else /* not MSDOS, __TURBOC__, or _AIX */
-#ifdef __hpux
-#ifdef __cplusplus
-extern "C" {
-void *alloca (unsigned int);
-};
-#else /* not __cplusplus */
-void *alloca ();
-#endif /* not __cplusplus */
-#endif /* __hpux */
-#endif /* not _AIX */
-#endif /* not MSDOS, or __TURBOC__ */
-#endif /* not sparc. */
-#endif /* not GNU C. */
-#endif /* alloca not defined. */
-
-/* This is the parser code that is written into each bison parser
- when the %semantic_parser declaration is not specified in the grammar.
- It was written by Richard Stallman by simplifying the hairy parser
- used when %semantic_parser is specified. */
-
-/* Note: there must be only one dollar sign in this file.
- It is replaced by the list of actions, each action
- as one case of the switch. */
-
-#define yyerrok (yyerrstatus = 0)
-#define yyclearin (yychar = YYEMPTY)
-#define YYEMPTY -2
-#define YYEOF 0
-#define YYACCEPT return(0)
-#define YYABORT return(1)
-#define YYERROR goto yyerrlab1
-/* Like YYERROR except do call yyerror.
- This remains here temporarily to ease the
- transition to the new meaning of YYERROR, for GCC.
- Once GCC version 2 has supplanted version 1, this can go. */
-#define YYFAIL goto yyerrlab
-#define YYRECOVERING() (!!yyerrstatus)
-#define YYBACKUP(token, value) \
-do \
- if (yychar == YYEMPTY && yylen == 1) \
- { yychar = (token), yylval = (value); \
- yychar1 = YYTRANSLATE (yychar); \
- YYPOPSTACK; \
- goto yybackup; \
- } \
- else \
- { yyerror ("syntax error: cannot back up"); YYERROR; } \
-while (0)
-
-#define YYTERROR 1
-#define YYERRCODE 256
-
-#ifndef YYPURE
-#define YYLEX yylex()
-#endif
-
-#ifdef YYPURE
-#ifdef YYLSP_NEEDED
-#ifdef YYLEX_PARAM
-#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
-#else
-#define YYLEX yylex(&yylval, &yylloc)
-#endif
-#else /* not YYLSP_NEEDED */
-#ifdef YYLEX_PARAM
-#define YYLEX yylex(&yylval, YYLEX_PARAM)
-#else
-#define YYLEX yylex(&yylval)
-#endif
-#endif /* not YYLSP_NEEDED */
-#endif
-
-/* If nonreentrant, generate the variables here */
-
-#ifndef YYPURE
-
-int yychar; /* the lookahead symbol */
-YYSTYPE yylval; /* the semantic value of the */
- /* lookahead symbol */
-
-#ifdef YYLSP_NEEDED
-YYLTYPE yylloc; /* location data for the lookahead */
- /* symbol */
-#endif
-
-int yynerrs; /* number of parse errors so far */
-#endif /* not YYPURE */
-
-#if YYDEBUG != 0
-int yydebug; /* nonzero means print parse trace */
-/* Since this is uninitialized, it does not stop multiple parsers
- from coexisting. */
-#endif
-
-/* YYINITDEPTH indicates the initial size of the parser's stacks */
-
-#ifndef YYINITDEPTH
-#define YYINITDEPTH 200
-#endif
-
-/* YYMAXDEPTH is the maximum size the stacks can grow to
- (effective only if the built-in stack extension method is used). */
-
-#if YYMAXDEPTH == 0
-#undef YYMAXDEPTH
-#endif
-
-#ifndef YYMAXDEPTH
-#define YYMAXDEPTH 10000
-#endif
-
-#ifndef YYPARSE_RETURN_TYPE
-#define YYPARSE_RETURN_TYPE int
-#endif
-
-/* Prevent warning if -Wstrict-prototypes. */
-#ifdef __GNUC__
-YYPARSE_RETURN_TYPE yyparse (void);
-#endif
-\f
-#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
-#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
-#else /* not GNU C or C++ */
-#ifndef __cplusplus
-
-/* This is the most reliable way to avoid incompatibilities
- in available built-in functions on various systems. */
-static void
-__yy_memcpy (to, from, count)
- char *to;
- char *from;
- int count;
-{
- register char *f = from;
- register char *t = to;
- register int i = count;
-
- while (i-- > 0)
- *t++ = *f++;
-}
-
-#else /* __cplusplus */
-
-/* This is the most reliable way to avoid incompatibilities
- in available built-in functions on various systems. */
-static void
-__yy_memcpy (char *to, char *from, int count)
-{
- register char *f = from;
- register char *t = to;
- register int i = count;
-
- while (i-- > 0)
- *t++ = *f++;
-}
-
-#endif
-#endif
-\f
-#line 196 "/usr/share/bison.simple"
-
-/* The user can define YYPARSE_PARAM as the name of an argument to be passed
- into yyparse. The argument should have type void *.
- It should actually point to an object.
- Grammar actions can access the variable by casting it
- to the proper pointer type. */
-
-#ifdef YYPARSE_PARAM
-#ifdef __cplusplus
-#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
-#define YYPARSE_PARAM_DECL
-#else /* not __cplusplus */
-#define YYPARSE_PARAM_ARG YYPARSE_PARAM
-#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
-#endif /* not __cplusplus */
-#else /* not YYPARSE_PARAM */
-#define YYPARSE_PARAM_ARG
-#define YYPARSE_PARAM_DECL
-#endif /* not YYPARSE_PARAM */
-
-YYPARSE_RETURN_TYPE
-yyparse(YYPARSE_PARAM_ARG)
- YYPARSE_PARAM_DECL
-{
- register int yystate;
- register int yyn;
- register short *yyssp;
- register YYSTYPE *yyvsp;
- int yyerrstatus; /* number of tokens to shift before error messages enabled */
- int yychar1 = 0; /* lookahead token as an internal (translated) token number */
-
- short yyssa[YYINITDEPTH]; /* the state stack */
- YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
-
- short *yyss = yyssa; /* refer to the stacks thru separate pointers */
- YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
-
-#ifdef YYLSP_NEEDED
- YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
- YYLTYPE *yyls = yylsa;
- YYLTYPE *yylsp;
-
-#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
-#else
-#define YYPOPSTACK (yyvsp--, yyssp--)
-#endif
-
- int yystacksize = YYINITDEPTH;
-
-#ifdef YYPURE
- int yychar;
- YYSTYPE yylval;
- int yynerrs;
-#ifdef YYLSP_NEEDED
- YYLTYPE yylloc;
-#endif
-#endif
-
- YYSTYPE yyval; /* the variable used to return */
- /* semantic values from the action */
- /* routines */
-
- int yylen;
-
-#if YYDEBUG != 0
- if (yydebug)
- fprintf(stderr, "Starting parse\n");
-#endif
-
- yystate = 0;
- yyerrstatus = 0;
- yynerrs = 0;
- yychar = YYEMPTY; /* Cause a token to be read. */
-
- /* Initialize stack pointers.
- Waste one element of value and location stack
- so that they stay on the same level as the state stack.
- The wasted elements are never initialized. */
-
- yyssp = yyss - 1;
- yyvsp = yyvs;
-#ifdef YYLSP_NEEDED
- yylsp = yyls;
-#endif
-
-/* Push a new state, which is found in yystate . */
-/* In all cases, when you get here, the value and location stacks
- have just been pushed. so pushing a state here evens the stacks. */
-yynewstate:
-
- *++yyssp = yystate;
-
- if (yyssp >= yyss + yystacksize - 1)
- {
- /* Give user a chance to reallocate the stack */
- /* Use copies of these so that the &'s don't force the real ones into memory. */
- YYSTYPE *yyvs1 = yyvs;
- short *yyss1 = yyss;
-#ifdef YYLSP_NEEDED
- YYLTYPE *yyls1 = yyls;
-#endif
-
- /* Get the current used size of the three stacks, in elements. */
- int size = yyssp - yyss + 1;
-
-#ifdef yyoverflow
- /* Each stack pointer address is followed by the size of
- the data in use in that stack, in bytes. */
-#ifdef YYLSP_NEEDED
- /* This used to be a conditional around just the two extra args,
- but that might be undefined if yyoverflow is a macro. */
- yyoverflow("parser stack overflow",
- &yyss1, size * sizeof (*yyssp),
- &yyvs1, size * sizeof (*yyvsp),
- &yyls1, size * sizeof (*yylsp),
- &yystacksize);
-#else
- yyoverflow("parser stack overflow",
- &yyss1, size * sizeof (*yyssp),
- &yyvs1, size * sizeof (*yyvsp),
- &yystacksize);
-#endif
-
- yyss = yyss1; yyvs = yyvs1;
-#ifdef YYLSP_NEEDED
- yyls = yyls1;
-#endif
-#else /* no yyoverflow */
- /* Extend the stack our own way. */
- if (yystacksize >= YYMAXDEPTH)
- {
- yyerror("parser stack overflow");
- return 2;
- }
- yystacksize *= 2;
- if (yystacksize > YYMAXDEPTH)
- yystacksize = YYMAXDEPTH;
- yyss = (short *) _alloca (yystacksize * sizeof (*yyssp));
- __yy_memcpy ((char *)yyss, (char *)yyss1, size * sizeof (*yyssp));
- yyvs = (YYSTYPE *) _alloca (yystacksize * sizeof (*yyvsp));
- __yy_memcpy ((char *)yyvs, (char *)yyvs1, size * sizeof (*yyvsp));
-#ifdef YYLSP_NEEDED
- yyls = (YYLTYPE *) _alloca (yystacksize * sizeof (*yylsp));
- __yy_memcpy ((char *)yyls, (char *)yyls1, size * sizeof (*yylsp));
-#endif
-#endif /* no yyoverflow */
-
- yyssp = yyss + size - 1;
- yyvsp = yyvs + size - 1;
-#ifdef YYLSP_NEEDED
- yylsp = yyls + size - 1;
-#endif
-
-#if YYDEBUG != 0
- if (yydebug)
- fprintf(stderr, "Stack size increased to %d\n", yystacksize);
-#endif
-
- if (yyssp >= yyss + yystacksize - 1)
- YYABORT;
- }
-
-#if YYDEBUG != 0
- if (yydebug)
- fprintf(stderr, "Entering state %d\n", yystate);
-#endif
-
- goto yybackup;
- yybackup:
-
-/* Do appropriate processing given the current state. */
-/* Read a lookahead token if we need one and don't already have one. */
-/* yyresume: */
-
- /* First try to decide what to do without reference to lookahead token. */
-
- yyn = yypact[yystate];
- if (yyn == YYFLAG)
- goto yydefault;
-
- /* Not known => get a lookahead token if don't already have one. */
-
- /* yychar is either YYEMPTY or YYEOF
- or a valid token in external form. */
-
- if (yychar == YYEMPTY)
- {
-#if YYDEBUG != 0
- if (yydebug)
- fprintf(stderr, "Reading a token: ");
-#endif
- yychar = YYLEX;
- }
-
- /* Convert token to internal form (in yychar1) for indexing tables with */
-
- if (yychar <= 0) /* This means end of input. */
- {
- yychar1 = 0;
- yychar = YYEOF; /* Don't call YYLEX any more */
-
-#if YYDEBUG != 0
- if (yydebug)
- fprintf(stderr, "Now at end of input.\n");
-#endif
- }
- else
- {
- yychar1 = YYTRANSLATE(yychar);
-
-#if YYDEBUG != 0
- if (yydebug)
- {
- fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
- /* Give the individual parser a way to print the precise meaning
- of a token, for further debugging info. */
-#ifdef YYPRINT
- YYPRINT (stderr, yychar, yylval);
-#endif
- fprintf (stderr, ")\n");
- }
-#endif
- }
-
- yyn += yychar1;
- if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
- goto yydefault;
-
- yyn = yytable[yyn];
-
- /* yyn is what to do for this token type in this state.
- Negative => reduce, -yyn is rule number.
- Positive => shift, yyn is new state.
- New state is final state => don't bother to shift,
- just return success.
- 0, or most negative number => error. */
-
- if (yyn < 0)
- {
- if (yyn == YYFLAG)
- goto yyerrlab;
- yyn = -yyn;
- goto yyreduce;
- }
- else if (yyn == 0)
- goto yyerrlab;
-
- if (yyn == YYFINAL)
- YYACCEPT;
-
- /* Shift the lookahead token. */
-
-#if YYDEBUG != 0
- if (yydebug)
- fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
-#endif
-
- /* Discard the token being shifted unless it is eof. */
- if (yychar != YYEOF)
- yychar = YYEMPTY;
-
- *++yyvsp = yylval;
-#ifdef YYLSP_NEEDED
- *++yylsp = yylloc;
-#endif
-
- /* count tokens shifted since error; after three, turn off error status. */
- if (yyerrstatus) yyerrstatus--;
-
- yystate = yyn;
- goto yynewstate;
-
-/* Do the default action for the current state. */
-yydefault:
-
- yyn = yydefact[yystate];
- if (yyn == 0)
- goto yyerrlab;
-
-/* Do a reduction. yyn is the number of a rule to reduce with. */
-yyreduce:
- yylen = yyr2[yyn];
- if (yylen > 0)
- yyval = yyvsp[1-yylen]; /* implement default value of the action */
-
-#if YYDEBUG != 0
- if (yydebug)
- {
- int i;
-
- fprintf (stderr, "Reducing via rule %d (line %d), ",
- yyn, yyrline[yyn]);
-
- /* Print the symbols being reduced, and their result. */
- for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
- fprintf (stderr, "%s ", yytname[yyrhs[i]]);
- fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
- }
-#endif
-
-
- switch (yyn) {
-
-case 1:
-#line 108 "./mcy.y"
-{
- if(!check_languages(nodehead))
- xyyerror("No messages defined");
- lanblockhead = block_messages(nodehead);
- ;
- break;}
-case 5:
-#line 120 "./mcy.y"
-{ add_node(nd_msg, yyvsp[0].msg); ;
- break;}
-case 6:
-#line 121 "./mcy.y"
-{ add_node(nd_comment, yyvsp[0].str); ;
- break;}
-case 7:
-#line 122 "./mcy.y"
-{ xyyerror(err_syntax); /* `Catch all' error */ ;
- break;}
-case 9:
-#line 126 "./mcy.y"
-{ xyyerror(err_pclose); ;
- break;}
-case 10:
-#line 127 "./mcy.y"
-{ xyyerror(err_popen); ;
- break;}
-case 11:
-#line 128 "./mcy.y"
-{ xyyerror(err_assign); ;
- break;}
-case 13:
-#line 130 "./mcy.y"
-{ xyyerror(err_pclose); ;
- break;}
-case 14:
-#line 131 "./mcy.y"
-{ xyyerror(err_popen); ;
- break;}
-case 15:
-#line 132 "./mcy.y"
-{ xyyerror(err_assign); ;
- break;}
-case 17:
-#line 134 "./mcy.y"
-{ xyyerror(err_pclose); ;
- break;}
-case 18:
-#line 135 "./mcy.y"
-{ xyyerror(err_popen); ;
- break;}
-case 19:
-#line 136 "./mcy.y"
-{ xyyerror(err_assign); ;
- break;}
-case 21:
-#line 138 "./mcy.y"
-{ xyyerror(err_pclose); ;
- break;}
-case 22:
-#line 139 "./mcy.y"
-{ xyyerror(err_popen); ;
- break;}
-case 23:
-#line 140 "./mcy.y"
-{ xyyerror(err_assign); ;
- break;}
-case 24:
-#line 141 "./mcy.y"
-{ cast = yyvsp[0].str; ;
- break;}
-case 25:
-#line 142 "./mcy.y"
-{ xyyerror(err_number); ;
- break;}
-case 26:
-#line 143 "./mcy.y"
-{ xyyerror(err_assign); ;
- break;}
-case 27:
-#line 144 "./mcy.y"
-{
- switch(base)
- {
- case 8:
- case 10:
- case 16:
- base = yyvsp[0].num;
- break;
- default:
- xyyerror("Numberbase must be 8, 10 or 16");
- }
- ;
- break;}
-case 28:
-#line 156 "./mcy.y"
-{ xyyerror(err_number); ;
- break;}
-case 29:
-#line 157 "./mcy.y"
-{ xyyerror(err_assign); ;
- break;}
-case 32:
-#line 165 "./mcy.y"
-{ xyyerror(err_ident); ;
- break;}
-case 33:
-#line 168 "./mcy.y"
-{
- yyvsp[-3].tok->token = yyvsp[-1].num;
- yyvsp[-3].tok->alias = yyvsp[0].str;
- if(yyvsp[-1].num & (~0x3))
- xyyerror("Severity value out of range (0x%08x > 0x3)", yyvsp[-1].num);
- do_add_token(tok_severity, yyvsp[-3].tok, "severity");
- ;
- break;}
-case 34:
-#line 175 "./mcy.y"
-{ xyyerror(err_number); ;
- break;}
-case 35:
-#line 176 "./mcy.y"
-{ xyyerror(err_assign); ;
- break;}
-case 38:
-#line 184 "./mcy.y"
-{ xyyerror(err_ident); ;
- break;}
-case 39:
-#line 187 "./mcy.y"
-{
- yyvsp[-3].tok->token = yyvsp[-1].num;
- yyvsp[-3].tok->alias = yyvsp[0].str;
- if(yyvsp[-1].num & (~0xfff))
- xyyerror("Facility value out of range (0x%08x > 0xfff)", yyvsp[-1].num);
- do_add_token(tok_facility, yyvsp[-3].tok, "facility");
- ;
- break;}
-case 40:
-#line 194 "./mcy.y"
-{ xyyerror(err_number); ;
- break;}
-case 41:
-#line 195 "./mcy.y"
-{ xyyerror(err_assign); ;
- break;}
-case 42:
-#line 198 "./mcy.y"
-{ yyval.str = NULL; ;
- break;}
-case 43:
-#line 199 "./mcy.y"
-{ yyval.str = yyvsp[0].str; ;
- break;}
-case 44:
-#line 200 "./mcy.y"
-{ xyyerror(err_ident); ;
- break;}
-case 47:
-#line 208 "./mcy.y"
-{ xyyerror(err_ident); ;
- break;}
-case 48:
-#line 211 "./mcy.y"
-{
- yyvsp[-6].tok->token = yyvsp[-4].num;
- yyvsp[-6].tok->alias = yyvsp[-1].str;
- yyvsp[-6].tok->codepage = yyvsp[0].num;
- do_add_token(tok_language, yyvsp[-6].tok, "language");
- if(!find_language(yyvsp[-6].tok->token) && !find_cpxlat(yyvsp[-6].tok->token))
- yywarning("Language 0x%x not built-in, using codepage %d; use explicit codepage to override", yyvsp[-6].tok->token, WMC_DEFAULT_CODEPAGE);
- ;
- break;}
-case 49:
-#line 219 "./mcy.y"
-{ xyyerror("Filename expected"); ;
- break;}
-case 50:
-#line 220 "./mcy.y"
-{ xyyerror(err_colon); ;
- break;}
-case 51:
-#line 221 "./mcy.y"
-{ xyyerror(err_number); ;
- break;}
-case 52:
-#line 222 "./mcy.y"
-{ xyyerror(err_assign); ;
- break;}
-case 53:
-#line 225 "./mcy.y"
-{ yyval.num = 0; ;
- break;}
-case 54:
-#line 226 "./mcy.y"
-{ yyval.num = yyvsp[0].num; ;
- break;}
-case 55:
-#line 227 "./mcy.y"
-{ xyyerror("Codepage-number expected"); ;
- break;}
-case 58:
-#line 235 "./mcy.y"
-{ xyyerror(err_ident); ;
- break;}
-case 59:
-#line 238 "./mcy.y"
-{
- static const char err_nocp[] = "Codepage %d not builtin; cannot convert";
- if(find_cpxlat(yyvsp[-4].num))
- xyyerror("Codepage translation already defined for language 0x%x", yyvsp[-4].num);
-// if(yyvsp[-2].num && !find_codepage(yyvsp[-2].num))
- if(yyvsp[-2].num)
- xyyerror(err_nocp, yyvsp[-2].num);
-// if(yyvsp[0].num && !find_codepage(yyvsp[0].num))
- if(yyvsp[0].num)
- xyyerror(err_nocp, yyvsp[0].num);
- add_cpxlat(yyvsp[-4].num, yyvsp[-2].num, yyvsp[0].num);
- ;
- break;}
-case 60:
-#line 248 "./mcy.y"
-{ xyyerror(err_number); ;
- break;}
-case 61:
-#line 249 "./mcy.y"
-{ xyyerror(err_colon); ;
- break;}
-case 62:
-#line 250 "./mcy.y"
-{ xyyerror(err_number); ;
- break;}
-case 63:
-#line 251 "./mcy.y"
-{ xyyerror(err_assign); ;
- break;}
-case 64:
-#line 254 "./mcy.y"
-{ yyval.num = yyvsp[0].num; ;
- break;}
-case 65:
-#line 255 "./mcy.y"
-{
- if(yyvsp[0].tok->type != tok_language)
- xyyerror("Language name or code expected");
- yyval.num = yyvsp[0].tok->token;
- ;
- break;}
-case 66:
-#line 265 "./mcy.y"
-{ test_id(yyvsp[-1].num); ;
- break;}
-case 67:
-#line 265 "./mcy.y"
-{ yyval.msg = complete_msg(yyvsp[0].msg, yyvsp[-3].num); ;
- break;}
-case 68:
-#line 268 "./mcy.y"
-{
- if(yyvsp[0].num & (~0xffff))
- xyyerror("Message ID value out of range (0x%08x > 0xffff)", yyvsp[0].num);
- yyval.num = yyvsp[0].num;
- ;
- break;}
-case 69:
-#line 273 "./mcy.y"
-{ xyyerror(err_assign); ;
- break;}
-case 70:
-#line 276 "./mcy.y"
-{ yyval.num = ++last_id; ;
- break;}
-case 71:
-#line 277 "./mcy.y"
-{ yyval.num = last_id = yyvsp[0].num; ;
- break;}
-case 72:
-#line 278 "./mcy.y"
-{ yyval.num = last_id += yyvsp[0].num; ;
- break;}
-case 73:
-#line 279 "./mcy.y"
-{ xyyerror(err_number); ;
- break;}
-case 74:
-#line 282 "./mcy.y"
-{ have_sev = have_fac = have_sym = 0; ;
- break;}
-case 75:
-#line 283 "./mcy.y"
-{ if(have_sev) xyyerror("Severity already defined"); have_sev = 1; ;
- break;}
-case 76:
-#line 284 "./mcy.y"
-{ if(have_fac) xyyerror("Facility already defined"); have_fac = 1; ;
- break;}
-case 77:
-#line 285 "./mcy.y"
-{ if(have_sym) xyyerror("Symbolname already defined"); have_sym = 1; ;
- break;}
-case 78:
-#line 288 "./mcy.y"
-{ last_sym = yyvsp[0].str; ;
- break;}
-case 79:
-#line 289 "./mcy.y"
-{ xyyerror(err_ident); ;
- break;}
-case 80:
-#line 290 "./mcy.y"
-{ xyyerror(err_assign); ;
- break;}
-case 81:
-#line 293 "./mcy.y"
-{
- token_t *tok = lookup_token(yyvsp[0].tok->name);
- if(!tok)
- xyyerror("Undefined severityname");
- if(tok->type != tok_severity)
- xyyerror("Identifier is not of class 'severity'");
- last_sev = tok->token;
- ;
- break;}
-case 82:
-#line 301 "./mcy.y"
-{ xyyerror(err_ident); ;
- break;}
-case 83:
-#line 302 "./mcy.y"
-{ xyyerror(err_assign); ;
- break;}
-case 84:
-#line 305 "./mcy.y"
-{
- token_t *tok = lookup_token(yyvsp[0].tok->name);
- if(!tok)
- xyyerror("Undefined facilityname");
- if(tok->type != tok_facility)
- xyyerror("Identifier is not of class 'facility'");
- last_fac = tok->token;
- ;
- break;}
-case 85:
-#line 313 "./mcy.y"
-{ xyyerror(err_ident); ;
- break;}
-case 86:
-#line 314 "./mcy.y"
-{ xyyerror(err_assign); ;
- break;}
-case 87:
-#line 320 "./mcy.y"
-{ yyval.msg = add_lanmsg(NULL, yyvsp[0].lmp); ;
- break;}
-case 88:
-#line 321 "./mcy.y"
-{ yyval.msg = add_lanmsg(yyvsp[-1].msg, yyvsp[0].lmp); ;
- break;}
-case 89:
-#line 322 "./mcy.y"
-{ xyyerror("'Language=...' (start of message text-definition) expected"); ;
- break;}
-case 90:
-#line 325 "./mcy.y"
-{ yyval.lmp = new_lanmsg(&yyvsp[-3].lcp, yyvsp[-1].str); ;
- break;}
-case 91:
-#line 333 "./mcy.y"
-{
- token_t *tok = lookup_token(yyvsp[-1].tok->name);
- cp_xlat_t *cpx;
- if(!tok)
- xyyerror("Undefined language");
- if(tok->type != tok_language)
- xyyerror("Identifier is not of class 'language'");
- if((cpx = find_cpxlat(tok->token)))
- {
- set_codepage(yyval.lcp.codepage = cpx->cpin);
- }
- else if(!tok->codepage)
- {
- const language_t *lan = find_language(tok->token);
- if(!lan)
- {
- /* Just set default; warning was given while parsing languagenames */
- set_codepage(yyval.lcp.codepage = WMC_DEFAULT_CODEPAGE);
- }
- else
- {
- /* The default seems to be to use the DOS codepage... */
- set_codepage(yyval.lcp.codepage = lan->doscp);
- }
- }
- else
- set_codepage(yyval.lcp.codepage = tok->codepage);
- yyval.lcp.language = tok->token;
- ;
- break;}
-case 92:
-#line 362 "./mcy.y"
-{ xyyerror("Missing newline"); ;
- break;}
-case 93:
-#line 363 "./mcy.y"
-{ xyyerror(err_ident); ;
- break;}
-case 94:
-#line 364 "./mcy.y"
-{ xyyerror(err_assign); ;
- break;}
-case 95:
-#line 367 "./mcy.y"
-{ yyval.str = yyvsp[0].str; ;
- break;}
-case 96:
-#line 368 "./mcy.y"
-{ yyval.str = merge(yyvsp[-1].str, yyvsp[0].str); ;
- break;}
-case 97:
-#line 369 "./mcy.y"
-{ xyyerror(err_msg); ;
- break;}
-case 98:
-#line 370 "./mcy.y"
-{ xyyerror(err_msg); ;
- break;}
-case 99:
-#line 376 "./mcy.y"
-{ yyval.tok = xmalloc(sizeof(token_t)); yyval.tok->name = yyvsp[0].str; ;
- break;}
-case 100:
-#line 377 "./mcy.y"
-{ yyval.tok = yyvsp[0].tok; ;
- break;}
-case 101:
-#line 380 "./mcy.y"
-{ want_nl = 1; ;
- break;}
-case 102:
-#line 383 "./mcy.y"
-{ want_line = 1; ;
- break;}
-case 103:
-#line 386 "./mcy.y"
-{ want_file = 1; ;
- break;}
-}
- /* the action file gets copied in in place of this dollarsign */
-#line 498 "/usr/share/bison.simple"
-
- yyvsp -= yylen;
- yyssp -= yylen;
-#ifdef YYLSP_NEEDED
- yylsp -= yylen;
-#endif
-
-#if YYDEBUG != 0
- if (yydebug)
- {
- short *ssp1 = yyss - 1;
- fprintf (stderr, "state stack now");
- while (ssp1 != yyssp)
- fprintf (stderr, " %d", *++ssp1);
- fprintf (stderr, "\n");
- }
-#endif
-
- *++yyvsp = yyval;
-
-#ifdef YYLSP_NEEDED
- yylsp++;
- if (yylen == 0)
- {
- yylsp->first_line = yylloc.first_line;
- yylsp->first_column = yylloc.first_column;
- yylsp->last_line = (yylsp-1)->last_line;
- yylsp->last_column = (yylsp-1)->last_column;
- yylsp->text = 0;
- }
- else
- {
- yylsp->last_line = (yylsp+yylen-1)->last_line;
- yylsp->last_column = (yylsp+yylen-1)->last_column;
- }
-#endif
-
- /* Now "shift" the result of the reduction.
- Determine what state that goes to,
- based on the state we popped back to
- and the rule number reduced by. */
-
- yyn = yyr1[yyn];
-
- yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
- if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
- yystate = yytable[yystate];
- else
- yystate = yydefgoto[yyn - YYNTBASE];
-
- goto yynewstate;
-
-yyerrlab: /* here on detecting error */
-
- if (! yyerrstatus)
- /* If not already recovering from an error, report this error. */
- {
- ++yynerrs;
-
-#ifdef YYERROR_VERBOSE
- yyn = yypact[yystate];
-
- if (yyn > YYFLAG && yyn < YYLAST)
- {
- int size = 0;
- char *msg;
- int x, count;
-
- count = 0;
- /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
- for (x = (yyn < 0 ? -yyn : 0);
- x < (sizeof(yytname) / sizeof(char *)); x++)
- if (yycheck[x + yyn] == x)
- size += strlen(yytname[x]) + 15, count++;
- msg = (char *) malloc(size + 15);
- if (msg != 0)
- {
- strcpy(msg, "parse error");
-
- if (count < 5)
- {
- count = 0;
- for (x = (yyn < 0 ? -yyn : 0);
- x < (sizeof(yytname) / sizeof(char *)); x++)
- if (yycheck[x + yyn] == x)
- {
- strcat(msg, count == 0 ? ", expecting `" : " or `");
- strcat(msg, yytname[x]);
- strcat(msg, "'");
- count++;
- }
- }
- yyerror(msg);
- free(msg);
- }
- else
- yyerror ("parse error; also virtual memory exceeded");
- }
- else
-#endif /* YYERROR_VERBOSE */
- yyerror("parse error");
- }
-
- goto yyerrlab1;
-yyerrlab1: /* here on error raised explicitly by an action */
-
- if (yyerrstatus == 3)
- {
- /* if just tried and failed to reuse lookahead token after an error, discard it. */
-
- /* return failure if at end of input */
- if (yychar == YYEOF)
- YYABORT;
-
-#if YYDEBUG != 0
- if (yydebug)
- fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
-#endif
-
- yychar = YYEMPTY;
- }
-
- /* Else will try to reuse lookahead token
- after shifting the error token. */
-
- yyerrstatus = 3; /* Each real token shifted decrements this */
-
- goto yyerrhandle;
-
-yyerrdefault: /* current state does not do anything special for the error token. */
-
-#if 0
- /* This is wrong; only states that explicitly want error tokens
- should shift them. */
- yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
- if (yyn) goto yydefault;
-#endif
-
-yyerrpop: /* pop the current state because it cannot handle the error token */
-
- if (yyssp == yyss) YYABORT;
- yyvsp--;
- yystate = *--yyssp;
-#ifdef YYLSP_NEEDED
- yylsp--;
-#endif
-
-#if YYDEBUG != 0
- if (yydebug)
- {
- short *ssp1 = yyss - 1;
- fprintf (stderr, "Error: state stack now");
- while (ssp1 != yyssp)
- fprintf (stderr, " %d", *++ssp1);
- fprintf (stderr, "\n");
- }
-#endif
-
-yyerrhandle:
-
- yyn = yypact[yystate];
- if (yyn == YYFLAG)
- goto yyerrdefault;
-
- yyn += YYTERROR;
- if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
- goto yyerrdefault;
-
- yyn = yytable[yyn];
- if (yyn < 0)
- {
- if (yyn == YYFLAG)
- goto yyerrpop;
- yyn = -yyn;
- goto yyreduce;
- }
- else if (yyn == 0)
- goto yyerrpop;
-
- if (yyn == YYFINAL)
- YYACCEPT;
-
-#if YYDEBUG != 0
- if (yydebug)
- fprintf(stderr, "Shifting error token, ");
-#endif
-
- *++yyvsp = yylval;
-#ifdef YYLSP_NEEDED
- *++yylsp = yylloc;
-#endif
-
- yystate = yyn;
- goto yynewstate;
-}
-#line 389 "./mcy.y"
-
-
-static WCHAR *merge(WCHAR *s1, WCHAR *s2)
-{
- int l1 = unistrlen(s1);
- int l2 = unistrlen(s2);
- s1 = xrealloc(s1, (l1 + l2 + 1) * sizeof(*s1));
- unistrcpy(s1+l1, s2);
- free(s2);
- return s1;
-}
-
-static void do_add_token(tok_e type, token_t *tok, const char *code)
-{
- token_t *tp = lookup_token(tok->name);
- if(tp)
- {
- if(tok->type != type)
- yywarning("Type change in token");
- if(tp != tok)
- xyyerror("Overlapping token not the same");
- /* else its already defined and changed */
- if(tok->fixed)
- xyyerror("Redefinition of %s", code);
- tok->fixed = 1;
- }
- else
- {
- add_token(type, tok->name, tok->token, tok->codepage, tok->alias, 1);
- free(tok);
- }
-}
-
-static lanmsg_t *new_lanmsg(lan_cp_t *lcp, WCHAR *msg)
-{
- lanmsg_t *lmp = (lanmsg_t *)xmalloc(sizeof(lanmsg_t));
- lmp->lan = lcp->language;
- lmp->cp = lcp->codepage;
- lmp->msg = msg;
- lmp->len = unistrlen(msg) + 1; /* Include termination */
- if(lmp->len > 4096)
- yywarning("Message exceptionally long; might be a missing termination");
- return lmp;
-}
-
-static msg_t *add_lanmsg(msg_t *msg, lanmsg_t *lanmsg)
-{
- int i;
- if(!msg)
- msg = xmalloc(sizeof(msg_t));
- msg->msgs = xrealloc(msg->msgs, (msg->nmsgs+1) * sizeof(*(msg->msgs)));
- msg->msgs[msg->nmsgs] = lanmsg;
- msg->nmsgs++;
- for(i = 0; i < msg->nmsgs-1; i++)
- {
- if(msg->msgs[i]->lan == lanmsg->lan)
- xyyerror("Message for language 0x%x already defined", lanmsg->lan);
- }
- return msg;
-}
-
-static int sort_lanmsg(const void *p1, const void *p2)
-{
- return (*(lanmsg_t **)p1)->lan - (*(lanmsg_t **)p2)->lan;
-}
-
-static msg_t *complete_msg(msg_t *mp, int id)
-{
- assert(mp != NULL);
- mp->id = id;
- if(have_sym)
- mp->sym = last_sym;
- else
- xyyerror("No symbolic name defined for message id %d", id);
- mp->sev = last_sev;
- mp->fac = last_fac;
- qsort(mp->msgs, mp->nmsgs, sizeof(*(mp->msgs)), sort_lanmsg);
- mp->realid = id | (last_sev << 30) | (last_fac << 16);
- if(custombit)
- mp->realid |= 1 << 29;
- mp->base = base;
- mp->cast = cast;
- return mp;
-}
-
-static void add_node(node_e type, void *p)
-{
- node_t *ndp = (node_t *)xmalloc(sizeof(node_t));
- ndp->type = type;
- ndp->u.all = p;
-
- if(nodetail)
- {
- ndp->prev = nodetail;
- nodetail->next = ndp;
- nodetail = ndp;
- }
- else
- {
- nodehead = nodetail = ndp;
- }
-}
-
-static void test_id(int id)
-{
- node_t *ndp;
- for(ndp = nodehead; ndp; ndp = ndp->next)
- {
- if(ndp->type != nd_msg)
- continue;
- if(ndp->u.msg->id == id && ndp->u.msg->sev == last_sev && ndp->u.msg->fac == last_fac)
- xyyerror("MessageId %d with facility 0x%x and severity 0x%x already defined", id, last_fac, last_sev);
- }
-}
-
-static int check_languages(node_t *head)
-{
- static char err_missing[] = "Missing definition for language 0x%x; MessageID %d, facility 0x%x, severity 0x%x";
- node_t *ndp;
- int nm = 0;
- msg_t *msg = NULL;
-
- for(ndp = head; ndp; ndp = ndp->next)
- {
- if(ndp->type != nd_msg)
- continue;
- if(!nm)
- {
- msg = ndp->u.msg;
- }
- else
- {
- int i;
- msg_t *m1;
- msg_t *m2;
- if(ndp->u.msg->nmsgs > msg->nmsgs)
- {
- m1 = ndp->u.msg;
- m2 = msg;
- }
- else
- {
- m1 = msg;
- m2 = ndp->u.msg;
- }
-
- for(i = 0; i < m1->nmsgs; i++)
- {
- if(i > m2->nmsgs)
- error(err_missing, m1->msgs[i]->lan, m2->id, m2->fac, m2->sev);
- else if(m1->msgs[i]->lan < m2->msgs[i]->lan)
- error(err_missing, m1->msgs[i]->lan, m2->id, m2->fac, m2->sev);
- else if(m1->msgs[i]->lan > m2->msgs[i]->lan)
- error(err_missing, m2->msgs[i]->lan, m1->id, m1->fac, m1->sev);
- }
- }
- nm++;
- }
- return nm;
-}
-
-#define MSGRID(x) ((*(msg_t **)(x))->realid)
-static int sort_msg(const void *p1, const void *p2)
-{
- return MSGRID(p1) > MSGRID(p2) ? 1 : (MSGRID(p1) == MSGRID(p2) ? 0 : -1);
- /* return (*(msg_t **)p1)->realid - (*(msg_t **)p1)->realid; */
-}
-
-/*
- * block_messages() basically transposes the messages
- * from ID/language based list to a language/ID
- * based list.
- */
-static lan_blk_t *block_messages(node_t *head)
-{
- lan_blk_t *lbp;
- lan_blk_t *lblktail = NULL;
- lan_blk_t *lblkhead = NULL;
- msg_t **msgtab = NULL;
- node_t *ndp;
- int nmsg = 0;
- int i;
- int nl;
- int factor = unicodeout ? 2 : 1;
-
- for(ndp = head; ndp; ndp = ndp->next)
- {
- if(ndp->type != nd_msg)
- continue;
- msgtab = xrealloc(msgtab, (nmsg+1) * sizeof(*msgtab));
- msgtab[nmsg++] = ndp->u.msg;
- }
-
- assert(nmsg != 0);
- qsort(msgtab, nmsg, sizeof(*msgtab), sort_msg);
-
- for(nl = 0; nl < msgtab[0]->nmsgs; nl++) /* This should be equal for all after check_languages() */
- {
- lbp = xmalloc(sizeof(lan_blk_t));
-
- if(!lblktail)
- {
- lblkhead = lblktail = lbp;
- }
- else
- {
- lblktail->next = lbp;
- lbp->prev = lblktail;
- lblktail = lbp;
- }
- lbp->nblk = 1;
- lbp->blks = xmalloc(sizeof(*lbp->blks));
- lbp->blks[0].idlo = msgtab[0]->realid;
- lbp->blks[0].idhi = msgtab[0]->realid;
- /* The plus 4 is the entry header; (+3)&~3 is DWORD alignment */
- lbp->blks[0].size = ((factor * msgtab[0]->msgs[nl]->len + 3) & ~3) + 4;
- lbp->blks[0].msgs = xmalloc(sizeof(*lbp->blks[0].msgs));
- lbp->blks[0].nmsg = 1;
- lbp->blks[0].msgs[0] = msgtab[0]->msgs[nl];
- lbp->lan = msgtab[0]->msgs[nl]->lan;
-
- for(i = 1; i < nmsg; i++)
- {
- block_t *blk = &(lbp->blks[lbp->nblk-1]);
- if(msgtab[i]->realid == blk->idhi+1)
- {
- blk->size += ((factor * msgtab[i]->msgs[nl]->len + 3) & ~3) + 4;
- blk->idhi++;
- blk->msgs = xrealloc(blk->msgs, (blk->nmsg+1) * sizeof(*blk->msgs));
- blk->msgs[blk->nmsg++] = msgtab[i]->msgs[nl];
- }
- else
- {
- lbp->nblk++;
- lbp->blks = xrealloc(lbp->blks, lbp->nblk * sizeof(*lbp->blks));
- blk = &(lbp->blks[lbp->nblk-1]);
- blk->idlo = msgtab[i]->realid;
- blk->idhi = msgtab[i]->realid;
- blk->size = ((factor * msgtab[i]->msgs[nl]->len + 3) & ~3) + 4;
- blk->msgs = xmalloc(sizeof(*blk->msgs));
- blk->nmsg = 1;
- blk->msgs[0] = msgtab[i]->msgs[nl];
- }
- }
- }
- free(msgtab);
- return lblkhead;
-}
-
-static int sc_xlat(const void *p1, const void *p2)
-{
- return ((cp_xlat_t *)p1)->lan - ((cp_xlat_t *)p2)->lan;
-}
-
-static void add_cpxlat(int lan, int cpin, int cpout)
-{
- cpxlattab = xrealloc(cpxlattab, (ncpxlattab+1) * sizeof(*cpxlattab));
- cpxlattab[ncpxlattab].lan = lan;
- cpxlattab[ncpxlattab].cpin = cpin;
- cpxlattab[ncpxlattab].cpout = cpout;
- ncpxlattab++;
- qsort(cpxlattab, ncpxlattab, sizeof(*cpxlattab), sc_xlat);
-}
-
-static cp_xlat_t *find_cpxlat(int lan)
-{
- cp_xlat_t t;
-
- if(!cpxlattab) return NULL;
-
- t.lan = lan;
- return (cp_xlat_t *)bsearch(&t, cpxlattab, ncpxlattab, sizeof(*cpxlattab), sc_xlat);
-}
-
+++ /dev/null
-typedef union {
- WCHAR *str;
- unsigned num;
- token_t *tok;
- lanmsg_t *lmp;
- msg_t *msg;
- lan_cp_t lcp;
-} YYSTYPE;
-#define tSEVNAMES 258
-#define tFACNAMES 259
-#define tLANNAMES 260
-#define tBASE 261
-#define tCODEPAGE 262
-#define tTYPEDEF 263
-#define tNL 264
-#define tSYMNAME 265
-#define tMSGEND 266
-#define tSEVERITY 267
-#define tFACILITY 268
-#define tLANGUAGE 269
-#define tMSGID 270
-#define tIDENT 271
-#define tLINE 272
-#define tFILE 273
-#define tCOMMENT 274
-#define tNUMBER 275
-#define tTOKEN 276
-
-
-extern YYSTYPE yylval;