traninit.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* Copyright 1993 Open Software Foundation, Inc., Cambridge, Massachusetts.
* All rights reserved.
*/
/*
#pragma ident "%Z%%M% %I% %E% SMI"
* Copyright (c) 1994
* Open Software Foundation, Inc.
*
* Permission is hereby granted to use, copy, modify and freely distribute
* the software in this file and its documentation for any purpose without
* fee, provided that the above copyright notice appears in all copies and
* that both the copyright notice and this permission notice appear in
* supporting documentation. Further, provided that the name of Open
* Software Foundation, Inc. ("OSF") not be used in advertising or
* publicity pertaining to distribution of the software without prior
* written permission from OSF. OSF makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*/
/*
* Copyright (c) 1996 X Consortium
* Copyright (c) 1995, 1996 Dalrymple Consulting
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* X CONSORTIUM OR DALRYMPLE CONSULTING BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the names of the X Consortium and
* Dalrymple Consulting shall not be used in advertising or otherwise to
* promote the sale, use or other dealings in this Software without prior
* written authorization.
*/
/* ________________________________________________________________________
*
* Program to manipulate SGML instances.
*
* This module contains the initialization routines for translation module.
* They mostly deal with reading data files (translation specs, SDATA
* mappings, character mappings).
*
* Entry points:
* ________________________________________________________________________
*/
#ifndef lint
static char *RCSid =
"$Header: /usr/src/docbook-to-man/Instant/RCS/traninit.c,v 1.6 1998/06/28 19:15:41 fld Exp fld $";
#endif
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <memory.h>
#include <errno.h>
#include <tptregexp.h>
#include "general.h"
#include "translate.h"
#ifndef TRUE
#endif
/* forward references */
void RememberTransSpec(Trans_t *, int);
/* ______________________________________________________________________ */
/* Read the translation specs from the input file, storing in memory.
* Arguments:
* Name of translation spec file.
*/
void
char *transfile
)
{
int lineno=0, c, i;
Trans_t T;
return;
}
memset(&T, 0, sizeof T); /* initialize/clear structure */
{
lineno++;
/* skip comment and blank lines */
/* '-' indicates end of a spec. When we hit one, remember what we've
* accumulated so far, and null-out the accumulating structure. */
if (buf[0] == '-') {
RememberTransSpec(&T, lineno);
memset(&T, 0, sizeof T);
continue;
}
/* See if next line is continued from this one -- ie. it starts with
* whitespace. If so, append to current line. (This is similar to
* how e-mail headers work...) */
while (1) {
if (IsWhite(c)) { /* space or tab? */
/* keep getting characters until it's a non-whitespace */
buf[i++] = ' ';
lineno++;
}
else {
break;
}
}
/* Isolate field value */
cp++; /* point past colon */
}
else {
"Trans spec error, missing colon (skipping line):\n %s\n", fn);
continue;
}
/* Check field names in order that they're likely to occur. */
/* if we are folding the case of GIs, make all upper (unless
it's an internal pseudo-GI name, which starts with '_') */
}
}
}
if (!T.nattpairs) {
}
else
T.nattpairs++;
}
/* If there's only one item in context, it's the parent. Treat
* it specially, since it's easier to just check parent gi.
*/
else
}
char **tok;
i = 2;
}
char **tok;
i = 2;
T.var_RE_name = tok[0];
tok[1]);
}
}
}
}
}
else
}
}
/* ______________________________________________________________________ */
/* Store translation spec 't' in memory.
* Arguments:
* Pointer to translation spec to remember.
* Line number where translation spec ends.
*/
void
Trans_t *t,
int lineno
)
{
char *cp;
int i, do_regex;
char buf[1000];
/* If context testing, check some details and set things up for later. */
if (t->context) {
/* See if the context specified is a regular expression.
* If so, compile the reg expr. It is assumed to be a regex if
* it contains a character other than what's allowed for GIs in the
* OSF sgml declaration (alphas, nums, '-', and '.').
*/
do_regex = 1;
break;
}
}
if (do_regex) {
}
}
else {
/* If there's only one item in context, it's the parent. Treat
* it specially, since it's faster to just check parent gi.
*/
}
else {
/* Figure out depth of context string */
t->depth = 0;
while (*cp) {
}
}
}
}
/* Compile regular expressions for each attribute */
for (i=0; i<t->nattpairs; i++) {
/* Initially, name points to "name value". Split them... */
if (*cp) { /* value found */
}
else { /* value not found */
}
}
}
/* Compile regular expression for content */
t->content_re = 0;
if (t->content) {
t->content);
}
/* If multiple GIs, break up into a vector, then remember it. We either
* sture the individual, or the list - not both. */
}
/* Now, store structure in linked list. */
if (!TrSpecs) {
}
else {
}
*last_t = *t;
}
/* ______________________________________________________________________ */
/* Read mapping file, filling in structure slots (just name-value pairs).
* Arguments:
* Name of character mapping file.
*/
void
char *filename
)
{
int lineno=0;
int n_alloc=0; /* number of slots allocated so far */
return;
}
/* We allocate slots in blocks of N, so we don't have to call
* malloc so many times. */
n_alloc = 32;
nCharMap = 0;
{
lineno++;
/* skip comment and blank lines */
/* Need more slots for mapping structures? */
n_alloc += 32;
}
if (*val) {
}
if (name) {
nCharMap++;
}
}
}
/* ______________________________________________________________________ */
/* Read SDATA mapping file, remembering the mappings in memory.
* Input file format is 2 columns, name and value, separated by one or
* more tabs (not spaces).
* This can be called multuple times, reading several files.
* Arguments:
* Name of SDATA entity mapping file.
*/
void
char *filename
)
{
int lineno=0;
return;
}
{
lineno++;
/* skip comment and blank lines */
if (*val) {
}
}
}
/* ______________________________________________________________________ */