docbook-to-man-2.0.0.orig/0040755000176100001440000000000007031671612014570 5ustar debacleusersdocbook-to-man-2.0.0.orig/Doc/0040755000176100001440000000000007031671611015274 5ustar debacleusersdocbook-to-man-2.0.0.orig/Doc/docbook-concrete-refentry0100644000176100001440000057020306737404356022313 0ustar debacleusers docbook-to-man-2.0.0.orig/Doc/instant.10100644000176100001440000002460706737404356017060 0ustar debacleusers...\" ...\" 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) 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 ...\" to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ...\" 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. ...\" ...\" Translated with /usr/local/lib/tpt/ref-man.ts by fld on cord, Wed 07 Feb 1996, 21:59 .TH "instant" "user cmd" .SH "Name" instant - manipulates ESIS from parsed SGML instance .SH "Synopsis" .na .PP \fBinstant\fP [ \fB-bhuvxHISW\fP ] [ \fB-t\fP \fIfile\fP] [ \fB-s\fP \fIfile\fP] [ \fB-c\fP \fIfile\fP] [ \fB-o\fP \fIfile\fP] [ \fB-D\fP \fIvariable\fP\fB=\fP\fIvalue\fP ...] [ \fB-i\fP \fIid\fP] [ \fB-l\fP \fIdirectory\fP] [\fIfile\fP] .ad .SH "Description" .PP The \fBinstant\fP program manipulates an SGML document instance in a variety of ways, including translating into a form suitable for a formatting application and printing information about this instance. Input to \fBinstant\fP is the output of \fBsgmls\fP, whose format is called Element Structure Information Set (ESIS). .SH "Flags" .PP The following are the possible command line options to \fBinstant\fP. Output is sent to the standard output, except where otherwise noted. 'br\" labeled list .IP "\fB-t\fP \fIfile\fP" Translate the SGML instance to another form, usually suitable for a formatting application. The \fIfile\fP is called a translation spec, which specifies how the tags are to be translated. See \fBtranspec\fP(4). By convention, names for \fIfile\fP use the suffix \fB.ts\fP, for \fItranslation spec\fP. .IP "\fB-s\fP \fIfile\fP " Specifies a file of mappings for SDATA entities in the instance. The file is of two columns, separated by one or more tabs. Spaces can \fInot\fP be used as the separator because spaces are allowable as the content of the columns. The first column is the entity data to map, the second is the string that the data is mapped to. The entity data is typically what is found in public ISO entity sets, such as the General Technical and Publishing sets. The mappings are specific to the formatting application used. For example, to map the em dash entity, \fB[mdash ]\fP, in the Publishing set to the TeX representation, the first column would be \fB[mdash ]\fP and the second column \fB---\fR. Lines beginning with a \fB#\fP are comments, and are ignored. Empty lines are also ignored. .IP "\fB-c\fP \fIfile\fP " Specifies a file of string mappings for characters in the instance. The file is of two columns, separated by white space. The first is the character to map, the second is the string that the character is mapped to. The mappings are specific to the formatting application used. Lines beginning with a \fB#\fP are comments, and are ignored. Empty lines are also ignored. .IP "\fB-d\fP" "Data hack" \*EM strip newline at the beginning of data records .IP "\fB-f \fIlength\fR" Set the threshold for the length, in characters, of an , over which it is called a block of filled text, to \fIlength\fR. .IP "\fB-o\fP \fIfile\fP " Write all output (except error and warning messages) to file \fIfile\fP. By default, output goes to stdout. .IP "\fB-h\fP" Print a text representation of the hierarchy of the instance elements. The deeper an element is in the tree, the more it is indented. The data content is not printed. .IP "\fB-u\fP" Print a summary of the usage of each element in the instance. Information given includes attributes, number of children, and depth in the hierarchy. .IP "\fB-S\fP" Print some statistics about element usage in the instance, including how often each element is used and how much PCDATA is contained. .IP "\fB-x\fP" Print the context of each element in the instance, from each element to the root of the document tree. .IP "\fB-v\fP" Validate the SGML instance based on the set of constraints or descriptions in the transpec file. This flags tells \fBinstant\fP to turn off normal output, leaving only diagnostics. .IP "\fB-l\fP \fIdirectory\fP" Try to read the translation specs or other files from in the directory \fIdirectory\fP if not found in the current directory. This is called the library directory. The environment variable \fITPT_LIB\fP may also be used to specify this. .IP "\fB-b\fP" Interactive browser mode. The user is prompted for actions, which include moving among and examining the various nodes in the hierarchy of the instance, displaying information about them, etc. .IP "\fB-I\fP" List the IDs of all elements in the instance that have an ID. The format is more suitable for other programs than humans. Lines show the ID, element GI, filename, and line, separated by colons. (This depends on the \fB-l\fP option to \fBsgmls\fP which provide filenames and line numbers.) .IP "\fB-i\fP \fIid\fP" When translating the instance, begin processing at the element whose ID is \fIid\fP instead of the topmost element. .IP "\fB-D\fP \fIvariable\fP\fB=\fP\fIvalue\fP" Define the variable \fIvariable\fP with value \fIvalue\fP. .IP "\fB-W\fP" Do not print warning messages. .IP "\fB-H\fP" Print a help message briefly describing the options. .IP "\fIfile\fP" Read the instance from the file \fIfile\fP. This is expected to be the output of the program \fBsgmls\fP. If not specified, \fBinstant\fP reads the instance from its standard input. 'br\" labeled list end .PP In some cases it makes no sense to combine options. This is especially true if one of the options is to perform a translation. No checking is done for this. .SH "Interactive Browser" .PP These are the commands to the interactive browser: 'br\" labeled list .IP "\fBcd\fP \fIargs ...\fP" Change to a different element in the hierarchy. \fBcd\fP \fBid\fP \fIid\fP will change to the element whose ID is \fIid\fP. \fBcd\fP \fIN\fP will change to the \fIN\fPth child element of the current element. Several values of \fIN\fP may be specified, so the program will change to successively descending elements in the hierarchy. The string \fB..\fP may appear for \fIN\fP to move up a level in the hierarchy (like in a unix file system). A \fB/\fP may be specified for \fIN\fP to change to the top of the hierarchy. .IP "\fBcont\fP" Print the context of each element. .IP "\fBdata\fP \fIN\fP" Show the data content (PCDATA, RCDATA, and DATA) of child node N. .IP "\fBfind\fP \fIspec\fP" Find paths to elements matching \fIspec\fP, where \fIspec\fP may be one of: 'br\" labeled list .RS +\n(INu .IP "\fBparent\fP \fIgi\fP" Find all elements whose parent element is \fIgi\fP. .IP "\fBchild\fP \fIgi\fP" Find all elements which have a child element \fIgi\fP. .IP "\fBgi\fP \fIgi\fP" Find all elements whose name is \fIgi\fP. .IP "\fBattr\fP \fIname\fP \fIvalue\fP" Find all elements that have a attribute \fIname\fP that have a value \fIvalue\fP. .RE 'br\" labeled list end .IP "\fBid\fP \fIID\fP" Show location of element whose ID is \fIID\fP. If \fIID\fP is \fB?\fP, it will list all IDs with the paths to them. .IP "\fBls\fP" List information about the current element in the hierarchy. This includes element name, line number in instance, context, attributes and their values, child elements, data directly within this element, and the order of the current element among its siblings. .IP "\fBq\fP \fIrelation\fP \fIelement\fP" Report whether or not the current element has the relation \fIrelation\fP to the named element \fIelement\fP. Values of \fIrelation\fP are the same as for \fB_followrel\fP in \fBtranspec\fP reference page. .IP "\fBstat\fP" Show statistics about the hierarchy. .IP "\fBsum\fP" Show a tag usage summary about the hierarchy. .IP "\fBtran\fP \fItranspec\fP \fIoutfile\fP" Write translated output using trans spec \fItranspec\fP to file \fIoutfile\fP. If \fIoutfile\fP is not specified, output is sent to stdout. .IP "\fBtree\fP" Print a textual representation of the hierarchy of the instance, where deeper elements are indented more. .IP "\fBwhere\fP" Show current position in the hierarchy. .IP "<\fBcontrol-D\fP>" Exits the program. 'br\" labeled list end .PP The \fBstat\fP, \fBsum\fP, \fBtree\fP, \fBcont\fP commands take an optional first argument (of any value), which means to only consider the entire instance instead of the hierarchy from the current element. .SH "Files" 'br\" labeled list .IP "\fIfile\fP\fB.ts\fP" Translation specification file. .IP "\fIfile\fP\fB.sdata\fP" SDATA entity mapping file. .IP "\fIfile\fP\fB.cmap\fP" Character mapping file. 'br\" labeled list end .SH "Related Information" .PP \fBtranspec\fP(4), \fBsgmls\fP(1), Standard Generalized Markup Language (SGML), ISO 8879. docbook-to-man-2.0.0.orig/Doc/transpec.10100644000176100001440000007546006737404356017222 0ustar debacleusers...\" ...\" ...\" 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) 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 ...\" to use, copy, modify, merge, publish, distribute, sublicense, and/or sell ...\" 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. ...\" ...\" Translated with /usr/local/lib/tpt/ref-man.ts by fld on cord, Wed 07 Feb 1996, 22:00 .TH "\fBtranspec\fP" "file format" .SH "Name" \fBtranspec\fP - translation specification for \fBinstant\fP .SH "Synopsis" .na .PP \fBfile.ts\fP .ad .SH "Description" .PP The \fBtranspec\fP file is used by the \fBinstant\fP program to translate an SGML document instance to a format suitable for a formatting application. The convention is to name the file with the suffix \fB.ts\fP. .PP A \fBtranspec\fP file is composed of a number of individual translation specs. Each translation spec (transpec) is made up of a number of fields, one per line. Translation specs are separated by a line with a leading dash. Text after the dash is ignored. Fields are composed of two parts, a name and a value, separated by a colon. The colon must immediately follow the name, and any amount of whitespace (blanks and tabs) may be present between the colon and value. Values should not be quoted, and you should be careful of trailing spaces. (Trailing space will be considered part of the value.) Quotes, if they appear, will be considered part of the value of the fields. Lines that begin with whitespace (blanks and tabs) are a continuation of the previous line; the leading space is ignored. These characteristics are very similar to those of e-mail headers. Lines beginning with a \fB#\fP (number sign) are comments and blank lines are ignored. .SH "Field Descriptions" .PP Some fields are for identifying criteria that determines if a particular spec matches an element in the instance. Others specify what action is to take place when a match happens, such as sending text to the output stream. .SS "Criteria fields" .PP Criteria fields restrict the conditions under which a single translation spec will apply. If each field specified in a particular transpec matches an element under consideration in the document instance, then that translation spec is said to match. The appropriate actions, as specified in that spec, are then taken. The program, \fBinstant\fP, searches the list of transpecs in the order given in the file. Therefore, the more restrictive specs (those with more criteria) should appear before less restrictive ones. .PP For quick reference, this is a brief summary of the possible criteria fields for translation. A complete discussion of each follows. .P .TS tab(@); l l l. \fBField Label\fR@\fBField Value\fR@\fBDescription\fR GI@gi ...@name of this GI AttValue@attname reg-expr@current element has attribute with value Content@reg-expr@is reg-expr in char content> Context@context@element context, up the tree NthChild@number@current element is Nth child of its parent PAttSet@attname (val)@parent has this attribute set (optional to value val) Relation@relationship gi@gi has relationship to current element VarREValue@var REvalue@variable is set to regular expression value VarValue@var value@variable is set to value .TE 'br\" labeled list .IP "\fBGI:\fP \fIgi\fP [...]" \fIgi\fP is the name of the generic identifier, or element name, to consider. More than one GI may appear in this field. .IP "\fBAttValue:\fP \fIattname\fP \fIregular-expression\fP" This is an attribute name-value pair, where \fIattname\fP is an attribute if the GI. The \fIregular-expression\fP is of the form accepted by the unix program \fBegrep\fP. This pair is compared to the corresponding attribute name-value pairs of the GI under consideration. To simply test if an attribute us set, use \fB.\fP (a dot) for \fIregular-expression\fP. There may be more than one of these lines for each transpec. .IP "\fBContent:\fP \fIregular-expression\fP" This specifies that the character content of GI contains a string matching the \fIregular-expression\fP. .IP "\fBContext:\fP \fIcontext\fP" This specifies the \fIcontext\fP in which to apply this translation spec. It is either a list of generic identifiers or a regular expression describing a list of generic identifiers, looking up the hierarchy. The first is the parent of the GI. .IP "\fBNthChild:\fP \fInumber\fP" This specifies that the GI is the \fInumber\fPth child element of its parent. Children are numbered starting with \fB1\fP. Negative numbers may be used to indicate order counting backwards. For example, -1 denotes the last child. .IP "\fBPAttSet:\fP \fIattname\fP" This specifies that the parent has this attribute, \fIattname\fP, set to any value (not IMPLIED). A value to match may optionally be specified after attname. .IP "\fBRelation:\fP \fIrelationship\fP \fIgi\fP" This specifies that the current element has the \fIrelationship\fP to the named \fIgi\fP. The acceptable relationships are: \fBancestor\fP (anywhere up the tree), \fBchild\fP (immediate child), \fBdescendant\fP (anywhere down the tree), \fBparent\fP (immediate ancestor), \fBsibling\fP (share same parent element), \fBsibling+\fP (any later sibling), \fBsibling+1\fP (the immediately following sibling), \fBsibling-\fP (any earlier sibling), \fBsibling-1\fP (the immediately following sibling). .IP "\fBVarREValue:\fP \fIvarname\fP \fIREvalue\fP" This specifies that the global variable \fIvarname\fP has the value \fIREvalue\fP, where \fIREvalue\fP is a regular expression (see the \fBVarValue\fP statement). .IP "\fBVarValue:\fP \fIvarname\fP \fIvalue\fP" This specifies that the global variable \fIvarname\fP has the (literal) value \fIvalue\fP (see the \fBVarREValue\fP statement). 'br\" labeled list end .PP There are two special GIs. If specified, \fB_Start\fP and \fB_End\fP are processed as if they were GIs in the instance at the start and end of the translation, respectively. Their criteria are never checked. Only their actions are performed. .SS "Action fields" .PP For quick reference, this is a brief summary of the action fields for translation. They are only performed if all the criteria are satisfied. A complete discussion of each follows. .P .TS tab(@); l l l. \fBField Label\fR@\fBField Value\fR@\fBDescription\fR Action@spec-id@use transpec whose spec ID is `spec-id' EndText@text@text for end of element Increment@name@increment variable `name' Ignore@key@flag for ignoring element's children and/or data Message@text@text to send to stderr Quit@text@print text and quit program Replace@text@replace this subtree with text Set@name value@set variable \fIname\fP to \fIvalue\fP SpecID@spec-id@unique Spec ID (int) of this spec StartText@text@text for start of element .TE 'br\" labeled list .IP "\fBAction:\fP \fIspec-id\fP" Use the actions of the spec identified by the \fBSpecID\fP with matching identifier \fIspec-id\fP. .IP "\fBEndText:\fP \fItext\fP" This specifies text to be output when the end tag is processed. .IP "\fBIgnore:\fP \fIkey\fP" This specifies that the data or children for this element are to be ignored. Set \fIkey\fP to \fBall\fP to ignore the element (data and child elements), to \fBdata\fP to ignore the immediate character data content (child elements are still descended into), and to \fBchildren\fP to process the immediate character data content but not descended into child elements. Other actions specified in this transpec are still performed, however. .IP "\fBIncrement:\fP \fIname\fP" This is used to increment a variable whose value is a number. If the variable is not a number, no action will be taken. The variable must have been previously defined. This action is done immediately before \fBEndText\fP. There may be more than one of these lines for each transpec. .IP "\fBMessage:\fP \fItext\fP" This specifies a string to be printed to the standard error when the matching element is processed. It is intended for informing the user of the progress of the translation. It is also used for validation of instances (see the \fB-v\fP flag of \fBinstant\fP(1)); a spec would be written to recognize a construct that is not allowed. This action is done immediately after \fBStartText\fP. Messages are also useful for debugging spec files; one is able to easily tell when a matching spec is processed, without looking at the actual output of the translation. Note that the spec writer is responsible for putting newlines (\fB\en\fP) in the message text. .IP "\fBReplace:\fP \fItext\fP" This specifies text to replace the current subtree with. This is equivalent to \fBStartText\fP and \fBIgnore\fP. .IP "\fBQuit:\fP \fItext\fP" This specifies text to be printed to the standard error. The program then terminates with exit status 1. This is intended for bailing out when an undesirable instance is encountered (such as when it is known that the formatting application can never handle a class of components, like tables). .IP "\fBSet:\fP \fIname\fP \fIvalue\fP" This is used to set a variable whose name is \fIname\fP and value is \fIvalue\fP. Names that would be valid for GIs in the document instance are valid for variable names. \fIvalue\fP is the rest of the line and may be any string. This action is done immediately before \fBEndText\fP. There may be more than one of these lines for each transpec. See the discussion on variables below. .IP "\fBSpecID:\fP \fIspec-id\fP" This names the spec with the number \fIspec-id\fP. Other specs may refer to this one by this number by an \fBAction\fP field or an \fB_action\fP special variable. This is used for cases where several specs to perform the exact same action. .IP "\fBStartText:\fP \fItext\fP" This specifies text to be output when the start tag is processed. 'br\" labeled list end .SS "Other Fields" .PP These fields may appear anywhere. The action occurs when the translation spec file is read, before any elements are translated. Theses are independent of any element processing. 'br\" labeled list .IP "\fBVar:\fP \fIname\fP \fIvalue\fP" This is used to define a variable whose name is \fIname\fP and value is \fIvalue\fP. It is similar to \fBSet\fP, but it may occur anywhere in the file and takes effect when the spec file is read. 'br\" labeled list end .SS "Text Strings" .PP The \fItext\fP referred to in the \fBStartText\fP, \fBEndText\fP, \fBReplace\fP, and \fBMessage\fP actions is more than simple character strings. Special sequences allow more complex output. .PP One type of special sequence is for C-style string processing. Most special characters are escaped with a \e (backslash). Like in C or shell programs, to print a \e (backslash), you must escape it with another backslash. These special character strings are: 'br\" labeled list .IP "\fB\en (backslash-n)\fP" This specifies that a newline character is to be printed to the output stream. .IP "\fB\er (backslash-r)\fP" This specifies that a carriage return character is to be printed to the output stream. .IP "\fB\et (backslash-t)\fP" This specifies that a tab character is to be printed to the output stream. .IP "\fB\es (backslash-s)\fP" This specifies that a space is to be printed to the output stream. This is useful for the end of a transpec line, where it can be difficult to tell if a blank is present at the end. .IP "\fB\e007 (backslash-007)\fP" This specifies that the character whose octal value is 007 is to be printed to the output stream. This works for any octal character value. .IP "\fB^ (caret)\fP" This specifies the that position in the string will be at the start of a line in the output stream. 'br\" labeled list end .PP If the first token of the text string is \fB#include\fP, then the second token is taken to be a file name and that file is included. If the file is not found, the library directory, as mentioned above, is searched. If the text string starts with a \fB!\fP (exclamation point), the rest of the line is taken to be a command and the output of that command is inserted. .PP An element's attributes may also be used in the text of output fields. To use an attribute value, precede its name with a \fB${\fP (dollar sign-left curly bracket) and follow it with a \fB}\fP (right curly bracket). (This style is followed by the Bourne shell.) For example, \fB${TYPE}\fP. If the attribute is not set (not IMPLIED), nothing will be printed to the output stream. To specify a value to use if the attribute is not set, place the value after the attribute name, separated by a space. To return the attribute value in lower-case, add a colon followed by lower-case l (\fB${TYPE:l}\fP. .SH "Variables" .PP Variables in \fBinstant\fP are similar to those in many other string-oriented programming languages, such as \fBsh\fP and \fBawk\fP. They are set by: \fBVar:\fP \fIname\fP \fIvalue\fP and \fBSet:\fP \fIname\fP \fIvalue\fP. Values may be set and reset to any string. In a \fBVar\fP line, if the value begins with a \fB!\fP, then the rest of the line is executed as a command, and its output is taken as the \fIvalue\fP. .PP A reference to the value of a variable follows the same syntax as a reference to the value of an attribute: \fB${\fIname\fB}\fR. If that variable has not been defined, a null value will be returned. A default value can be returned instead of null for an undefined variable by using the form: \fB${\fIname default\fB}\fR. .PP Variables may be used as attributes are, that is in any of the text strings mentioned above. In fact, if an attribute name is referred to and it is not set for a given element, \fBinstant\fP looks for a variable with the same name. This way global defaults can be set. If you want to be sure that you are accessing a local variable value, not an attribute value, you can use lower or mixed case names. Attribute names, as passed by \fBsgmls\fP, are in upper case. .PP Any number of \fBVar\fP actions may appear in the spec file. These set the values of the variables before any translation takes place. The \fBSet\fP actions within transpecs are performed when that spec is processed when an element matches the given criteria. .SS "Preset Variables" .PP Several variables are preset by \fBinstant\fP upon start of the program. Their values may be overridden in transpec files or on the command line. 'br\" labeled list .IP "\fBdate\fP" This is the date and time that the program started. The format is: \f(CWTue 10 Aug 1993, 16:52\fP. .IP "\fBhost\fP" This is the name of the host where the program is run. It is what is returned by the \fBgethostname\fP library call. .IP "\fBtranspec\fP" This is the translation spec filename. .IP "\fBuser\fP" This is the login name of the user running the program. 'br\" labeled list end .SS "Special Variables" .PP There is a collection of special variables called \fIspecial variables\fP. These are identified by starting the names with a \fB_\fP (underscore). This is a summary of the special variables. A complete discussion of each special variable follows. \fBspec-id\fP refers to a number specified in a \fBSpecID\fP field. When used in a special variable, it means to perform the action in that translation spec. .PP Note that when a \fIspec-id\fR is given in a special variable, the default is to perform the translation spec named by the \fIspec-id\fR ignoring of any criteria statements found there. For most special variables that use a \fIspec-id\fP, postpending a "\fBt\fR" to the \fIspec-id\fR (with no spaces between them, eg, "\fB${_followrel child TITLE 15t}\fR"), will cause the criteria statements in the named translation spec to evaluate successfully before that translation spec will be processed. .P .TS tab(@); l l. \fBVariable Usage\fR@\fBDescription\fR \fB_action\fP \fIspec-id\fP@do spec with id spec-id \fB_allatts\fP@print all attribute/value pairs \fB_attval\fP \fIatt\fP [\fIvalue\fP] \fIspec-id\fP@use spec-id if attribute matches \fB_chasetogi\fP \fIgi\fP \fIspec-id\fP@follow IDREFs until gi found \fB_eachatt\fP \fIatt\fP \fIspec-id\fP [\fIspec-id\fP]@do spec-id for each word of attribute value \fB_eachcon\fP \fIspec-id\fP [\fIspec-id\fP]@do spec-id for each word of content \fB_env\fP \fIenv-variable\fP@return value of env variable \fB_filename\fP@filename of notation \fB_find\fP \fIrel\fP \fIgi\fP \fIspec-id\fP@find gi based on relationship \fB_followlink\fP [\fIattname\fP] \fIspec-id\fP@follow IDREFs [attname] and use spec-id \fB_followrel\fP \fIrel\fP \fIgi\fP \fIspec-id\fP@do spec-id on rel if it matches \fB_gi\fP [\fBM|L|U\fP]@return GI name; M, L, U case \fB_id\fP \fIid [\fP\fIspec-id\fP]@find element with ID and use spec-id \fB_include\fP \fIfilename\fP@insert file here \fB_infile\fP [\fBline\fP]@instance filename [and line number] \fB_insertnode\fP S|E \fIspec-id\fP@do spec-id when element is traversed \fB_isset\fP \fIvar\fP [\fIvalue\fP] \fIspec-id\fP@do spec-id if variable matches \fB_location\fP@print location of current element \fB_namelist\fP \fIspec-id\fP [\fIspec-id\fP]@content is namelist, do spec-id for each \fB_nchild\fP [\fIgi\fP]@number of child elements [named \fIattname\fP] \fB_osftable\fP \fIformat\fP [\fIflag\fP]@print table format specification \fB_path\fP@print path to current element \fB_pattr\fP \fIattname\fP@value of parent's attribute \fB_pfind\fP \fIargs ...\fP@same as \fB_find\fP, but start at parent \fB_relation\fP \fIrel\fP \fIgi\fP \fIspec-id\fP [\fIspec-id\fP]@do spec-id if relation matches \fB_set\fP \fIvar\fP \fIvalue\fP@set variable to value \fB_!\fP\fIcommand\fP@command to run .TE 'br\" labeled list .IP "\fB_action\fP \fIspec-id\fP" Use the actions of the spec identified by the \fBSpecID\fP with matching identifier \fIspec-id\fP. This behaves similarly to the \fBAction\fP action, but is in addition to the present translation spec. .IP "\fB_allatts\fP" Print all attribute name-value pairs of the current element to the output stream. The name and value are separated by a \fB=\fP (equals sign), and the value is surrounded by quotes. This can be useful for creating a normalized version of the instance. .IP "\fB_attval\fP \fIattname\fP [\fIvalue\fP] \fIspec-id\fP" If the current element has an attribute named \fIattname\fP, optionally whose value matches \fIvalue\fP, use the actions of the transpec identified by \fIspec-id\fP. .IP "\fB_chasetogi\fP \fIgi\fP \fIspec-id\fP" Follow IDREF attributes until if finds an element whose GI is \fIgi\fP or which has a child element with that GI. It will apply the transpec \fIspec-id\fP to that element. By default, \fBinstant\fP assumes the attributes named \fBLINKEND\fP, \fBLINKENDS\fP, and \fBIDREF\fP are of type IDREF or IDREFS. (This corresponds with the OSF DTDs.) You can change this by setting the variable \fBlink_atts\fP to a space-separated list of attribute names. .IP "\fB_eachatt\fP \fIatt\fP \fIspec-id\fP [\fIspec-id2\fP]" The transpec named by \fIspec-id\fR is invoked once per each word found in the value of the attribute \fIatt\fR. Inside the target transpec, the current word being processed is available in the variable named \fBeach_A\fR (\fB${each_A}\fR). If \fIspec-id2\fP is specified, it will use \fIspec-id\fP for the first word in the attribute and \fIspec-id2\fP for the others. .IP "\fB_eachcon\fP \fIspec-id\fP [\fIspec-id2\fP]" The transpec named by \fIspec-id\fR is invoked once per each word found in the content of the current element. Inside the target transpec, the current word being processed is available in the variable named \fBeach_C\fR (\fB${each_C}\fR). If \fIspec-id2\fP is specified, it will use \fIspec-id\fP for the first word in the content and \fIspec-id2\fP for the others. .IP "\fB_env\fP \fIenv-variable\fP" Print the value of the environment variable \fIenv-variable\fP to the output stream. .IP "\fB_filename\fP" Print the filename of the notation associated with this element, if any. This is used to get the filename of an external notation entity reference. For example, to print the filename in the latex macro from the epsf macro package, use \f(CW\e\eepsfboxi{${_filename}}\fP. .IP "\fB_find\fP [\fBtop\fP] \fIrelationship\fP \fIargs ...\fP \fIspec-id\fP" Descend the document hierarchy finding elements that match one of several criteria. When one is found, the action specified by \fIspec-id\fP is performed. If \fBtop\fP is specified, the search starts at the top of the document hierarchy, rather than at the current element. The possible values for \fIrelationship\fP are \fBgi\fP, \fBgi-parent\fP, \fBparent\fP, and \fBattr\fP, and take different arguments. Explanations may be best done by example: \fB_find gi CHAPTER 123\fP means to find elements whose GI is CHAPTER, and perform action 123; \fB_find gi-parent TITLE CHAPTER 124\fP means to find elements whose GI is TITLE and whose parent is CHAPTER, and perform action 124; \fB_find parent BODY 125\fP means to find elements whose parent's GI is BODY, and perform action 125; \fB_find attr TYPE UGLY 125\fP means to find elements whose attribute named TYPE is set to UGLY, and perform action 126. .IP "\fB_followlink\fP [\fIattname\fP] \fIspec-id\fP" When processing an element, \fBinstant\fP will follow the IDREF attributes until an element with no IDREF attributes is found. It will then apply the transpec specified by \fIspec-id\fP to that element. If specified, it will follow the link pointed to by \fIattname\fP. By default, \fBinstant\fP assumes the attributes named \fBLINKEND\fP and \fBLINKENDS\fP are if type IDREF or IDREFS. You can change this by setting the variable \fBlink_atts\fP to a space-separated list of attribute names. .IP "\fB_followrel\fP \fIrelationship\fP \fIgi\fP \fIspec-id\fP" If the \fIgi\fP has the specified \fIrelationship\fP to the current element, perform the action specified by \fIspec-id\fP on the related element. See the discussion of the criteria field \fBRelation\fP for acceptable relationship names. .IP "\fB_gi\fP [\fBM|L|U\fP]" Print the name of the current GI to the output stream. If specified, \fBM\fP, \fBL\fP, or \fBU\fP will ensure the GI name is printed in mixed, lower, or upper case, respectively. .IP "\fB_id\fP \fIid\fP [\fIspec-id\fP]" Find the element with \fIid\fP and use \fIspec-id\fP, if set. If not set, use the spec for that element's context. .IP "\fB_include\fP \fIfilename\fP" Insert the file \fIfilename\fP into the output stream. .IP "\fB_infile\fP [\fBline\fP]" Print the name of the sgml instance file to the output stream. If \fBline\fP is specified, also print the line number. This depends on \fBsgmls\fP being called with the \fB-l\fP option. .IP "\fB_insertnode\fP \fBS\fP|\fBE\fP \fIspec-id\fP" Do \fIspec-id\fP when the current element is traversed at a later pass. This can be considered inserting a node, without content, into the hierarchy. This is only useful if done to elements \fIbefore\fP they are processed. Typically \fB_chasetogi\fP or \fB_followlink\fP is specified early in an instance's processing, so that when the elements found by one of these actions are processed in their turn, the added actions are performed. \fB_insertnode\fP would be specified as the action of a \fIspec-id\fP pointed to in a \fB_chasetogi\fP or \fB_followlink\fP usage. .IP "\fB_location\fP" The location of the current element is printed to the output stream in several ways: the path to the element (see \fB_path\fP), a position hint, which is the nearest title, the line number, if the ESIS (output from \fBsgmls\fP) contains line numbers, and the ID of the element, if it has one. This is especially useful when using the \fBMessage\fP action to validate an instance. .IP "\fB_namelist\fP \fIspec-id\fP [\fIspec-id2\fP]" This assumes that the content of the current element is a namelist (a list of element IDs), and applies the action based on \fIspec-id\fP for each element pointed to. If \fIspec-id2\fP is specified, it will use \fIspec-id\fP for the first ID in the namelist and \fIspec-id2\fP for the others. .IP "\fB_nchild\fP [\fIgi\fP]" Print the number of child elements of the element to the output stream. If \fIgi\fP is specified, print the number of child element with that name. .IP "\fB_osftable\fP \fBtex\fP|\fBtbl\fP|\fBcheck\fP [\fIflag\fP]" Print table markup into the output stream. The format depends on whether \fBtex\fP or \fBtbl\fP is specified. The \fIflag\fP may be one of \fBcellstart\fP, \fBcellend\fP, \fBrowstart\fP, \fBrowend\fP, \fBtop\fP, or \fBbottom\fP. The value determines what markup or text will be generated. If \fBcellstart\fP is specified, the correct markup for the beginning of a cell is output. If \fBtop\fP, \fBbottom\fP, or \fBrowend\fP are specified, the correct markup for the end of the appropriate position is printed to the output stream. If \fBcheck\fP is specified, the attributes and child elements are checked for errors and consistency. .IP "\fB_path\fP" Print the path to current GI to the output stream. A path is each element, going down the tree from the topmost element. A number in parentheses after each element name shows which child element the next one is in the order of children for that element. Ordering starts at 0. For example: \f(CWOSF-BOOK(3) BODY(0) CHAPTER(4) SECTION\fP. This says the path is \fB\fP's third child, \fB\fP's zeroth, and \fB\fP's fourth, which is named \fB
\fP. .IP "\fB_pattr\fP \fIname\fP" Print the value of parent's attribute whose name is \fIname\fP to the output stream. .IP "\fB_pfind\fP \fIrel\fP \fIgi\fP \fIspec-id\fP" This is exactly the same as \fB_find\fP except that the search starts at the current element's parent. .IP "\fB_relation\fP \fIrelationship\fP \fIgi\fP \fIspec-id\fP [\fIspec-id2\fP]" If the \fIgi\fP has the specified \fIrelationship\fP to the current element, perform the action specified by \fIspec-id\fP on the current element. If the relationship test fails and \fIspec-id2\fP is specified, perform that action. See the discussion of the criteria field \fBRelation\fP for acceptable relationship names. .IP "\fB_set\fP \fIvarname\fP \fIvalue\fP" Set the value of the variable \fIvarname\fP to \fIvalue\fP. .IP "\fB_isset\fP \fIvarname\fP [\fIvalue\fP] \fIspec-id\fP" If the value of the variable \fIvarname\fP is set to \fIvalue\fP, then perform action referred to by \fIspec-id\fP. If \fIvalue\fP is not specified, action will be performed if \fIvarname\fP is set to any value. .IP "\fB_!\fP \fIcommand\fP" Run the command \fIcommand\fP, directing its standard output into the output stream. 'br\" labeled list end .SS "Immediate Variables" .PP \fIImmediate variables\fR are like special variables, except that they are expanded when the transpec is originally processed (special variables are processed later, near when the final output is being generated). The general syntax of immediate variables is \fB${+\fIimmediate_variable\ ...\fB}\fR. .PP There is currently only one immediate variable defined: .IP "\fB+content\fP" This special variable is replaced by the data content of the current element. .SH "Examples" .PP The following will output the given string for elements whose generic identifier is \fBP\fP (for paragraph). At the start of processing this element, the program ensures that the output starts on a new line, the \fBtroff\fP macro \fB<.P>\fP is output, then a newline. At the end of this element processing, the program ensures that the output starts on a new line. .DS .nf .ft CW GI: P StartText: ^.P^ EndText: ^ - .ft R .fi .DE .PP The following will output the given string for elements whose generic identifier is \fBCMD-ARGUMENT\fP and which have an attribute \fBPRESENCE\fP set to the value \fBOPTIONAL\fP. .DS .nf .ft CW GI: CMD-ARGUMENT AttValue: PRESENCE OPTIONAL StartText: $\e\e[ EndText: $\e\e] - .ft R .fi .DE .PP The following prints the section number, title, and page number of the target of a cross reference. Assume the cross reference points to a section element, which contains a title element. The criteria for this spec to match is that the attribute \fBOSFROLE\fP is set to the value \fBgetfull\fP. The action is to replace the content of the \fB\fP element with the given string. When processing the string, \fBinstant\fP will follow the IDREF attributes of \fB\fP until an element with no IDREF attributes is found. It will then apply the transpec numbered \fB87\fP to that element, which will print the name of the GI in mixed case into the output stream. It will then print the LaTeX reference instruction with the value of the \fBLINKEND\fP attribute as an argument. (This will become the section number after processing by LaTeX.) It will then follow IDREFs until if finds an element whose GI is \fBTITLE\fP or which has a child element with that GI. It will apply the transpec numbered \fB1\fP to that element, which copies the title into the output stream where the cross reference occurs. Finally, it will print the word \fBpage\fP followed by the LaTeX instruction to obtain the page number of a reference. .DS .nf .ft CW GI: XREF AttValue: OSFROLE getfull Replace: ${_followlink 87} \e\eref{${LINKEND}},\es {\e\ebf ${_chasetogi TITLE 1}}, page \e\epageref{${LINKEND}} - # Print GI name, in mixed case GI: _pr_gi_name SpecID: 87 Ignore: 1 EndText: ${_gi M} - GI: _pass-text SpecID: 1 - .ft R .fi .DE .SH "Related Information" .PP \fBinstant\fP(1), \fBsgmls\fP(1), \fBegrep\fP(1). docbook-to-man-2.0.0.orig/Imakefile0100644000176100001440000000020006737404356016401 0ustar debacleusers#define IHaveSubdirs #define PassCDebugFlags SUBDIRS = cmd Instant Transpec MakeSubdirs($(SUBDIRS)) DependSubdirs($(SUBDIRS)) docbook-to-man-2.0.0.orig/Makefile0100644000176100001440000000420106737404356016235 0ustar debacleusers############################################################################# # # Makefile for docbook-to-man pieces # ############################################################################# # # Copyright (c) 1996 X Consortium # Copyright (c) 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 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # 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. # ############################################################################# # # Written 5/29/96 by Fred Dalrymple # ############################################################################# ROOT = /usr/local SHELL = /bin/sh MAKE = make PIECES = cmd Instant Transpec all: for dir in $(PIECES); \ do (cd $$dir; $(MAKE) all); \ done install: for dir in $(PIECES); \ do (cd $$dir; $(MAKE) ROOT=$(ROOT) install); \ done clean: for dir in $(PIECES); \ do (cd $$dir; $(MAKE) clean); \ done clobber: for dir in $(PIECES); \ do (cd $$dir; $(MAKE) clobber); \ done docbook-to-man-2.0.0.orig/README0100644000176100001440000001054506737404356015465 0ustar debacleusers June 14, 1996 Fred Dalrymple Overview ======== This directory contains all pieces of the docbook-to-man tool -- a batch converter that transforms UNIX-style manpages from the DocBook SGML DTD into nroff/troff -man macros. Acknowledgements ================ The following companies generously funded the development of this public tool as part of the CDE/Motif Project under the auspices of the Open Software Foundation: Hewlett-Packard Company International Business Machines Corp. Sun Microsystems, Inc. Novell, Inc. Digital Equipment Corp. Fujitsu Limited Hitachi, Ltd. SETUP NOTES =========== This tool presumes that nsgmls and the DocBook DTDs have been installed into "default" places. Mainly, this means where the DTD files are expected to be found (/usr/local/sgmls, /usr/local/sgmls/Davenport/dtd). If you've installed them elsewhere, please modify the paths at the top of cmd/docbook-to-man.sh before installing this tool (or, change it and reinstall it). INSTALLATION ============ This tool installs binaries for the instant and docbook-to-man programs into /usr/local/bin, and the "transpec" into /usr/local/lib/tpt. It is assumed that /usr/local and /usr/local/lib exist, but the Transpec/Makefile will attempt to create /usr/local/lib/tpt if it does not already exist. You must have permissions to write into /usr/local/bin and /usr/local/lib to install these tools. Assuming you've made and changes as noted in "SETUP NOTES" above, you should be able to install this tool by issuing a "make install" from the the current directory (the one containing this README file). Generated binaries can be cleaned up from the source directories by issuing a "make clobber". The documentation in Doc/ is not installed automatically, you should copy the files named Doc/instant.1 and Doc/transpec.1 into the proper place (eg, /usr/local/man/man1) if you want to make them available online. Components of the Tool ====================== User-level command: docbook-to-man A new shell command that runs the low-level components to translate a single DocBook SGML document instance (whose document element is ) into pretty-much vanilla -man macros, with tables rendered in tbl. SGML parsing engine: nsgmls (or sgmls) ** not included in this package -- see ftp://ftp.jclark.com/pub/sp ** The nsgmls or sgmls tool is called to parse a DocBook instance and generate ESIS which is the input to the instant program. Converter engine: instant A tool originally developed at OSF (by John Bowe) but appearing here in significantly enhanced form (work performed by John Lavagnino, Carl Scholz, and particularly Fred Dalrymple). The most significant enhancement is probably support for CALS tables (which DocBook uses). Sorry, only the CALS -> tbl functionality works in this version. Converter script: docbook-to-man.ts The instant script which drives the mapping between SGML and -man. DocBook DTD: docbook.cat, docbook.dcl, docbook.dtd The tool supports DocBook V 2.4.1. ** not included in this package -- see ftp://ftp.ora.com/pub/davenport/docbook/docbk241.tar.Z ** KNOWN DEFICIENCIES ================== 1. The current transpec generates \fP to return to a previous font, yet there may be nested font changes. It is possible that this script will generate two \fPs in a row, returning the font to not the original, but the "inner" font. The transpec with the "-PUSHPOP" name in the Transpec source directory is some initial work to resolve this problem, but it has other problems.. 2. There are some CALS table features which aren't implemented (yet). Including tables within tables (). 3. Numbered lists use an indent of 6 characters, while indented paragraphs (eg, a second within an ) will generate a 10 character indent. Indents should be made consistent. 4. The graphic inclusion is untested because I don't own a real Documentor's Workbench (and the code for generating the graphic include doesn't seem to work with Linux). BUG POLICY ========== I would like to hear of any problems, improvements, or suggestions. This tool will continue to be enhanced. Significant improvements will appear in the FTP-able version. However, there is no guarantee of turnaround time for problem reports... Please send correspondence to fld@veloce.com docbook-to-man-2.0.0.orig/README.ANS0100644000176100001440000001425706737404356016111 0ustar debacleusers ANS Modifications David Bolen (db3l@ans.net) 2/23/99 This package is derived from the docbook-to-man package made available on the Davenport (later OASIS) DocBook web site. Various modifications were made (as described below) to resolve some issues when processing our own documents. I have attempted to contact Fred Dalrymple with respect to these changes, but have not received a reply. This modified version of the package is being released AS-IS, without any promise of support nor guarantee as to function. All I can say is that this changed version appears to suit our needs for the generation of man pages from our DocBook sources. I have compiled and run this version on the following platforms: * AIX 3.2.5 (RS/6000) * Solaris 2.5.1 (Sparc) * BSDI 2.1 and 4.0 (i386) * Linux 2.0.36 (Slackware - i386) * FreeBSD 2.2.7-RELEASE (i386) We use the package as follows: * Install Jade and DocBook as normal - the command below assumes that the 'nsgmls' binary is available to parse a DocBook document. * Install 'instant' binary into appropriate directory (/usr/local/bin or wherever). * Place these auxiliary files into /usr/local/share/sgml/transpec: * One of either docbook-to-man.ts or the pair of docbook-to-man.ts-PUSHPOP and docbook-to-man.prolog. We use the PUSHPOP version but rename to just .ts. * roff.cmap * roff.sdata * Translate a source with a command such as (shown on multiple lines but entered as a single line command): nsgmls -i roff {document} | instant -t docbook-to-man.ts -c roff.cmap -s roff.sdata > {output} This assumes a document with a RefEntry as the top level element. To extract a single RefEntry from a larger document, the "-i id" option should be given to instant. For documents containing a number of RefEntry elements, the initial nsgmls output may be saved and reused for each instant execution (thus saving the SGML parsing overhead). Note: the "-i roff" to nsgmls is not required, but we use that to control conditional entities in our documents) -- David - - - - - - - - - - - - - - - - - - - - - - - - - Modifications Most significant changes are notated within the source with "[ANS-db3l]" along with explanatory comments, but such markup is not exhaustive. The primary changes made were as described below. A patch file with the exact set of changes (already contained in the files, patch based on FLD's 6/4/1996 release) can be found in the root directory of the package as ans.patch. General ------- * Adjusted default file location (used for .ts, .cmap, .sdata files) to /usr/local/share/sgml/transpec. Controlled by TPTLIB definition in Makefiles, or can be overridden at run-time by TPT_LIB environment variable or "-l" command line option. * Use STRERROR define (in Instant and Instant/tptregexp Makefiles) to conditionally include strerror() replacement function. Does not include by default. Should be re-defined for older Sun systems for example, but its presence by default was causing crashes on systems such as FreeBSD and BSDI in calls to perror(). Instant ------- * Process ESIS data for document (output from nsgmls) during the first stage of input rather than waiting until eventual output in the DoData/OutputString functions. The "pre-processing" handles quoting, CMAP and SDATA and cleans up a lot of the trickier issues with "\" translation in the earlier code, since "\" is used both by nsgmls for quoting as well as by the instant output processing for items such as the cmap file. * Absorb whitespace during ESIS parsing unless within an environment that has a FORMAT of LINESPECIFIC (or has inherited such a format from a parent environment). Previously, docbook-to-man would only work best if the input document had no extraneous indentation. This caused problems if, for example, the input document was written in Emacs with PSGML with sgml-indent-data. Such extraneous whitespace in the output often caused erroneous paragraph breaks or wide regions of spacing within paragraphs. The current parsing has worked in the documents I have thrown at it so far. If necessary, the existing (but undocumented) "-d" option may be used to implement the previously existing "datahack" option or "-d -d" may be used to restore the previously default behavior of no whitespace adjustment at all. * Some adjustment made for the CALS table support, generally dealing with rows containing spanning columns, or tables that changed their row definitions within the table. *.ts ---- * Prolog includes header to automatically include table support on Solaris. This appears system specific (works under Solaris), but ignored on other systems (it's a roff comment), so on most other systems the output will still need to be manually sent through tbl or an adjustment must be made appropriate to the system (such as an appropriate file extension or another option to man). * Always reset tab definitions after use of ".nf" * Fixed XREF to use the title if no XREFLABEL available. * Added TITLE in REFSYNOPSYSDIV, and PROMPT in general. * Tidied up cross reference text. * Moved pf/fP macros into external .prolog file, now included by the PUSHPOP version. This removes the dependence on the controlling shell script to manually append the definition. Note that while both the normal and "PUSHPOP" versions of the transpec files were adjusted, we use the PUSHPOP version for our own conversions. So far, I haven't noticed any significant problems (as alluded to in the older README) - some of this may be due to side-effects of the above parsing changes to Instant. roff.cmap --------- * Added back in the \ -> \e sequence so that actual backslashes in the input source are properly escaped in the roff output. (This works cleanly now with the above parsing changes to Instant). roff.sdata ---------- * Map vellip to be hellip (personal preference given lack of options). docbook-to-man-2.0.0.orig/ans.patch0100644000176100001440000012467506737404356016421 0ustar debacleusersIndex: sgml/docbook-to-man/Instant/Makefile diff -c sgml/docbook-to-man/Instant/Makefile:1.1.1.1 sgml/docbook-to-man/Instant/Makefile:1.3 *** sgml/docbook-to-man/Instant/Makefile:1.1.1.1 Fri Nov 13 21:31:59 1998 --- sgml/docbook-to-man/Instant/Makefile Tue Feb 23 22:21:26 1999 *************** *** 47,53 **** # # J.Bowe, 1993 # ! # $Header: /aolnet/dev/src/CVS/sgml/docbook-to-man/Instant/Makefile,v 1.1.1.1 1998/11/13 21:31:59 db3l Exp $ # # This assumes you have the (tpt)regexp package (includes and library) # available. --- 47,53 ---- # # J.Bowe, 1993 # ! # $Header: /aolnet/dev/src/CVS/sgml/docbook-to-man/Instant/Makefile,v 1.3 1999/02/23 22:21:26 db3l Exp $ # # This assumes you have the (tpt)regexp package (includes and library) # available. *************** *** 59,71 **** # BINDIR = /usr/local/bin # where you keep your programs # (You should set DEF_TPT_LIB to something, or set it in general.h. # At OSF we use the default in that file.) ! MAKE = make SHELL = /bin/sh ROOT = /usr/local ! TPTLIB = $(ROOT)/lib/tpt REGEX_INC = -Itptregexp REGEX_LIB = tptregexp BINDIR = $(ROOT)/bin --- 59,73 ---- # BINDIR = /usr/local/bin # where you keep your programs # (You should set DEF_TPT_LIB to something, or set it in general.h. # At OSF we use the default in that file.) ! # ! # -DSTRERROR to DEFINES if library does not have strerror() [ANS-db3l] ! # MAKE = make SHELL = /bin/sh ROOT = /usr/local ! TPTLIB = $(ROOT)/share/sgml/transpec REGEX_INC = -Itptregexp REGEX_LIB = tptregexp BINDIR = $(ROOT)/bin Index: sgml/docbook-to-man/Instant/general.h diff -c sgml/docbook-to-man/Instant/general.h:1.1.1.1 sgml/docbook-to-man/Instant/general.h:1.2 *** sgml/docbook-to-man/Instant/general.h:1.1.1.1 Fri Nov 13 21:31:59 1998 --- sgml/docbook-to-man/Instant/general.h Mon Nov 16 22:23:50 1998 *************** *** 53,59 **** #ifdef STORAGE #ifndef lint static char *gen_h_RCSid = ! "$Header: /aolnet/dev/src/CVS/sgml/docbook-to-man/Instant/general.h,v 1.1.1.1 1998/11/13 21:31:59 db3l Exp $"; #endif #endif --- 53,59 ---- #ifdef STORAGE #ifndef lint static char *gen_h_RCSid = ! "$Header: /aolnet/dev/src/CVS/sgml/docbook-to-man/Instant/general.h,v 1.2 1998/11/16 22:23:50 db3l Exp $"; #endif #endif *************** *** 281,286 **** --- 281,287 ---- Relation_t FindRelByName(char *); char *FindAttValByName(Element_t *, char *); char *FindContext(Element_t *, int, char *); + char *LookupSDATA(char *); char *AddElemName(char *); char *AddAttName(char *); void OutputString(char *, FILE *, int); Index: sgml/docbook-to-man/Instant/main.c diff -c sgml/docbook-to-man/Instant/main.c:1.1.1.1 sgml/docbook-to-man/Instant/main.c:1.3 *** sgml/docbook-to-man/Instant/main.c:1.1.1.1 Fri Nov 13 21:31:58 1998 --- sgml/docbook-to-man/Instant/main.c Tue Feb 23 20:31:37 1999 *************** *** 62,72 **** * * Takes input from James Clark's "sgmls" program (v. 1.1). * ________________________________________________________________________ */ #ifndef lint static char *RCSid = ! "$Header: /aolnet/dev/src/CVS/sgml/docbook-to-man/Instant/main.c,v 1.1.1.1 1998/11/13 21:31:58 db3l Exp $"; #endif #include --- 62,81 ---- * * Takes input from James Clark's "sgmls" program (v. 1.1). * ________________________________________________________________________ + * + * + * [ANS-db3l] + * General modifications for better interaction with DocBook markup. + * Significant changes (but not every change) marked in source with + * ANS tag as above. Primary for this module is processing of ESIS + * data for elements (ESIS quoting/CMAP/SDATA) here rather than holding + * off until DoData() or OutputString(). + * */ #ifndef lint static char *RCSid = ! "$Header: /aolnet/dev/src/CVS/sgml/docbook-to-man/Instant/main.c,v 1.3 1999/02/23 20:31:37 db3l Exp $"; #endif #include *************** *** 83,88 **** --- 92,106 ---- #define STORAGE #include "general.h" + /* [ANS-db3l] Included for character mapping in ReadESIS */ + #include + #include "translate.h" + + /* [ANS-db3l] Don't have "makeVersionFile", so just stamp the overall */ + /* release here. Starting with 2.0 to isolate from earlier releases, */ + /* and tagging with ANS to distinguish it a bit further. */ + #define VERSION "2.0(0)-ANS" + static int do_context, do_tree, do_summ, do_stats, do_validate, do_idlist; static int do_DATAhack = 0; static char *this_prog; *************** *** 120,125 **** --- 138,146 ---- HandleArgs(ac, av); Initialize2(); + if (sdatafile) ReadSDATA(sdatafile); + if (cmapfile) ReadCharMap(cmapfile); + ReadInstance(in_file); if (interactive) { *************** *** 139,146 **** } } else e = DocTree; - if (sdatafile) ReadSDATA(sdatafile); - if (cmapfile) ReadCharMap(cmapfile); /* If we're doing validation, make output file pointer null. * This means that we generate no output, except error messages. */ if (do_validate) outfp = NULL; --- 160,165 ---- *************** *** 276,282 **** case 'l': tpt_lib = optarg; break; case 'i': start_id = optarg; break; case 'o': out_file = optarg; break; ! case 'd': do_DATAhack = 1; break; case 'f': BOFTTextThresh = atoi(optarg); break; case 'b': interactive = 1; break; case 'W': warnings = 0; break; --- 295,301 ---- case 'l': tpt_lib = optarg; break; case 'i': start_id = optarg; break; case 'o': out_file = optarg; break; ! case 'd': do_DATAhack++; break; case 'f': BOFTTextThresh = atoi(optarg); break; case 'b': interactive = 1; break; case 'W': warnings = 0; break; *************** *** 334,342 **** DoHelpMessage() { char **s = help_msg; printf("usage: %s [option ...] [file]", this_prog); while (*s) puts(*s++); ! printf("\nVersion: %s\n", _HeadVeRsIoN_); } /* ______________________________________________________________________ */ --- 353,364 ---- DoHelpMessage() { char **s = help_msg; + printf("Instant: SGML document processor/translator, Version %s\n", + VERSION); printf("usage: %s [option ...] [file]", this_prog); while (*s) puts(*s++); ! /* printf("\nVersion: %s\n", _HeadVeRsIoN_); */ ! } /* ______________________________________________________________________ */ *************** *** 526,532 **** } } fprintf(stderr, "Error: End of AccumElemInfo - should not be here: %s\n", ! e->gi); /* return e;*/ exit(1); } --- 548,554 ---- } } fprintf(stderr, "Error: End of AccumElemInfo - should not be here: %s\n", ! (e && e->gi) ? e->gi : "(No element)"); /* return e;*/ exit(1); } *************** *** 534,557 **** /* Read ESIS lines. * Limitation? Max 5000 children per node. (done for efficiency -- * should do some malloc and bookkeeping games later). */ static Element_t * ReadESIS( FILE *fp, ! int depth ) { ! char *buf; ! int i, c, ncont; ! Element_t *e; Content_t cont[5000]; Malloc( LINESIZE+1, buf, char ); /* Read input stream - the output of "sgmls", called "ESIS". */ e = AccumElemInfo(fp); e->depth = depth; ncont = 0; while (1) { --- 556,587 ---- /* Read ESIS lines. * Limitation? Max 5000 children per node. (done for efficiency -- * should do some malloc and bookkeeping games later). + * + * [ANS-db3l] + * Changes to process ESIS input quoting/cmap/sdata at this point. Also + * pass in parent element to function so it can look up the hierarchy + * for parent attributes if necessary (such as for FORMAT). */ static Element_t * ReadESIS( FILE *fp, ! int depth, ! Element_t *parent ) { ! char *buf, *xlatebuf, *dst, *src, *pch, *sdata; ! int i, c, ncont, inspace, nomap; ! Element_t *e, *cur_e; Content_t cont[5000]; Malloc( LINESIZE+1, buf, char ); + Malloc( LINESIZE+1, xlatebuf, char ); /* Read input stream - the output of "sgmls", called "ESIS". */ e = AccumElemInfo(fp); e->depth = depth; + e->parent = parent; ncont = 0; while (1) { *************** *** 563,574 **** case CMD_DATA: /* -data */ fgets(buf, LINESIZE, fp); stripNL(buf); ! if (do_DATAhack && (buf[0] == '\\') && (buf[1] == 'n')) { if ( ! buf[2] ) break; buf[0] = ' '; memcpy(&buf[1], &buf[2], strlen(buf)-1); } cont[ncont].ch.data = strdup(buf); cont[ncont].type = CMD_DATA; ncont++; --- 593,779 ---- case CMD_DATA: /* -data */ fgets(buf, LINESIZE, fp); stripNL(buf); ! ! /* [ANS-db3l] Process/sanitize element data */ ! /* */ ! /* The new default behavior (unless "-d" - do_DATAhack is */ ! /* given) is to process inbound translation of ESIS data */ ! /* elements at the input stage. This handles all quoting */ ! /* from [n]sgmls, as well as character mapping. Doing it */ ! /* now avoids a lot of headaches later. OutputString will */ ! /* still do Transpec mappings but this way character maps */ ! /* only apply to input data, thus freeing the SDATA and */ ! /* translation spec from knowing what is in the CMAP. */ ! /* */ ! /* After translating quoting and mapping characters, as */ ! /* long as this attribute doesn't have a defined format of */ ! /* linespecific (preserve whitespace/line formatting), the */ ! /* result is further processed to translate all spans of */ ! /* whitespace into a single space. */ ! /* */ ! /* Using "-d" restores the previous do_DATAhack behavior, */ ! /* while "-d -d" restores original non-translating mode. */ ! ! if (!do_DATAhack) { ! #ifdef DEBUG ! fprintf(stderr,"Data: Element '%s'\n Input='%s'\n", ! e->gi,buf); ! #endif ! /* Use the secondary buffer to avoid moving things */ ! /* around too much. Note that unless no further cmap */ ! /* translation should be performed (nomap==1), *dst */ ! /* should point to the last character stored and not */ ! /* one past (it should be one past for no cmap). */ ! src = buf; ! dst = xlatebuf; ! while (*src) { ! nomap = 0; ! if (*src == '\\') { ! src++; ! switch (*src) { ! case '\\': ! /* Quoted backslash */ ! *dst = *src++; ! break; ! case 'n': ! /* Newline */ ! *dst = '\n'; src++; ! break; ! case '0': case '1': case '2': case '3': ! case '4': case '5': case '6': case '7': ! /* Octal encoding */ ! *dst = ((*src-'0') << 6) + ! ((*(src+1)-'0') << 3) + ! ((*(src+2)-'0')); ! src += 3; ! break; ! case '#': case '%': ! /* Decimal internal(#)/document(%) char */ ! /* XXX: Handle better */ ! *dst++ = '['; ! while (*src != ';') { ! *dst++ = *src++; ! } ! *dst++ = ']'; ! src++; ! /* XXX: Whimp out - no translation */ ! nomap = 1; ! break; ! case '|': ! /* SDATA reference */ ! sdata = ++src; ! while (*src && *src != '\\' && ! *(src+1) != '|') { ! src++; ! } ! if (!*src) break; ! *src = '\0'; /* Terminate SDATA name */ ! src += 2; /* and skip past */ ! if (pch = LookupSDATA(sdata)) { ! strcpy(dst,pch); ! dst += strlen(pch); ! } else { ! /* Output in brackets */ ! *dst++ = '['; ! strcpy(dst,sdata); ! dst += strlen(sdata); ! *dst++ = ']'; ! } ! /* No cmap translation of sdata */ ! nomap = 1; ! break; ! default: ! fprintf(stderr, ! "? Warning: Unknown ESIS escape " ! "sequence in stream: ('%c')\n", ! *src); ! *dst++ = *src++; ! nomap = 1; ! } ! } else { ! *dst = *src++; ! } ! ! /* Handle any character mapping of last character */ ! if (!nomap) { ! if (nCharMap) { ! for (i=0; igi); ! #endif ! break; ! } ! cur_e = cur_e->parent; ! } ! if (!(pch && !(strcmp(pch,"LINESPECIFIC")))) { ! #ifdef DEBUG ! fprintf(stderr," D: Compressing whitespace\n"); ! #endif ! /* Replace any span of whitespace with a single space */ ! dst = src = buf; ! inspace = 0; ! while (*src) { ! i = isspace(*src); ! if (!(inspace && i)) { ! *dst++ = i ? ' ' : *src; ! } ! inspace = i; ! src++; ! } ! *dst = '\0'; ! } /* if !linespecific */ ! #ifdef DEBUG ! fprintf(stderr," D: Output='%s'\n",buf); ! #endif ! } /* if !do_DATAhack */ ! ! /* Remove any empty elements (not sure you can ever */ ! /* get this from NSGMLS, but while I'm here...) */ ! if (*buf == '\0') { ! /* Nothing left - skip this chunk */ ! break; ! } ! ! /* Original "do_DATAhack" support. We check explicitly */ ! /* here for a do_DATAhack value of 1, since using -d */ ! /* twice on the command line can now restore the older */ ! /* default behavior of not doing anything. */ ! if (do_DATAhack==1 && (buf[0] == '\\') && (buf[1] == 'n')) { if ( ! buf[2] ) break; buf[0] = ' '; memcpy(&buf[1], &buf[2], strlen(buf)-1); } + cont[ncont].ch.data = strdup(buf); cont[ncont].type = CMD_DATA; ncont++; *************** *** 591,596 **** --- 796,802 ---- for (i=0; icont[i] = cont[i]; } free(buf); + free(xlatebuf); return e; break; *************** *** 607,613 **** case CMD_PUBID: /* ppubid */ case CMD_FILENAME: /* ffilename */ ungetc(c, fp); ! cont[ncont].ch.elem = ReadESIS(fp, depth+1); cont[ncont].type = CMD_OPEN; cont[ncont].ch.elem->parent = e; ncont++; --- 813,819 ---- case CMD_PUBID: /* ppubid */ case CMD_FILENAME: /* ffilename */ ungetc(c, fp); ! cont[ncont].ch.elem = ReadESIS(fp, depth+1,e); cont[ncont].type = CMD_OPEN; cont[ncont].ch.elem->parent = e; ncont++; *************** *** 633,638 **** --- 839,845 ---- } fprintf(stderr, "Error: End of ReadESIS - should not be here: %s\n", e->gi); free(buf); + free(xlatebuf); return NULL; } *************** *** 659,665 **** } else fp = stdin; last_file = filename; ! DocTree = ReadESIS(fp, 0); if (filename) fclose(fp); /* Traverse tree, filling in econt and figuring out which child --- 866,872 ---- } else fp = stdin; last_file = filename; ! DocTree = ReadESIS(fp, 0, NULL); if (filename) fclose(fp); /* Traverse tree, filling in econt and figuring out which child Index: sgml/docbook-to-man/Instant/tables.c diff -c sgml/docbook-to-man/Instant/tables.c:1.1.1.1 sgml/docbook-to-man/Instant/tables.c:1.2 *** sgml/docbook-to-man/Instant/tables.c:1.1.1.1 Fri Nov 13 21:31:58 1998 --- sgml/docbook-to-man/Instant/tables.c Mon Nov 16 22:23:51 1998 *************** *** 73,79 **** #ifndef lint static char *RCSid = ! "$Header: /aolnet/dev/src/CVS/sgml/docbook-to-man/Instant/tables.c,v 1.1.1.1 1998/11/13 21:31:58 db3l Exp $"; #endif #include --- 73,79 ---- #ifndef lint static char *RCSid = ! "$Header: /aolnet/dev/src/CVS/sgml/docbook-to-man/Instant/tables.c,v 1.2 1998/11/16 22:23:51 db3l Exp $"; #endif #include *************** *** 1091,1096 **** --- 1091,1103 ---- * TO DO: * * deallocate colspecs and spanspecs + * + * [ANS-db3l] + * I found that if you ended a table with a spanning entry, tbl got + * confused and seemed to use the spanning row definition for the default + * row entry in the table. So we output a final row adjustment if the + * current (last) row format wasn't the same as the tgroup element. The + * code is adapted from from the original code in TblTFoot(). */ *************** *** 1100,1105 **** --- 1107,1132 ---- { register struct tblcolspec * tcsp, * tcsp2; register struct tblspanspec * tssp, * tssp2; + register struct tblformat * ffp, * ffp2; + static struct tblformat * tfp, * tfp2; + + tfp = TblBuild1Format(ep, FALSE, TGroup);/* gen format for the row */ + + for ( tfp2=formP; tfp2 && tfp2->next; tfp2=tfp2->next ) + ; + + if (!TblFormatMatch(tfp,tfp2)) { + + for ( ffp=formP; ffp; ffp=ffp2 ) { + ffp2 = ffp->next; + free(ffp); /* clear entire list */ + } + + formP = tfp; /* this becomes the prevailing format */ + + OutputString("^.T&^", fP, 1); + TblPrintFormat(fP, formP); + } for ( tcsp=tblColSpec; tcsp; tcsp=tcsp2 ) { *************** *** 1198,1203 **** --- 1225,1237 ---- /* TblBuild1Format() -- build one row's worth of format information * + * + * [ANS-db3l] + * Added check for spanning columns, and if they exist, move any width + * information to the previous non-spanning column (scanning left) since + * that seems to be the way that tbl wants it. E.g., tbl works if you + * have "lw(6i) s s" but not with "lw(2i) sw(2i) sw(2i)". + * */ *************** *** 1207,1213 **** bool addinRowsep, /* insert rowsep into model? */ tblsource source) /* type type of row */ { ! register int i; register bool allProp; float totalProp; register struct tblformat * tfp; --- 1241,1247 ---- bool addinRowsep, /* insert rowsep into model? */ tblsource source) /* type type of row */ { ! register int i, j; register bool allProp; float totalProp; register struct tblformat * tfp; *************** *** 1228,1233 **** --- 1262,1290 ---- allProp = tfp->colpwidth[i][0]; totalProp += atof(tfp->colpwidth[i]); } + if (i>1 && tfp->colformat[i] == 's') { + for (j=i; j>=1; j--) { + if (tfp->colformat[j] != 's') { + if (tfp->colwidth[i][0]) { + sprintf(tfp->colwidth[j],"%fi", + atof(tfp->colwidth[j])+ + atof(tfp->colwidth[i])); + } + if (tfp->colpwidth[i][0]) { + sprintf(tfp->colpwidth[j],"%fi", + atof(tfp->colpwidth[j])+ + atof(tfp->colpwidth[i])); + } + tfp->colwidth[i][0] = '\0'; + tfp->colpwidth[i][0] = '\0'; + break; + } + } + if (j<1) { + fprintf(stderr, "? Warning: missed earlier column to " + "add span width to\n"); + } + } strcpy(tfp->font[i], TblGetFont(i, ep, source)); tfp->colsep[i] = tblgcolsep || TblGetColSep(i, ep, source); if ( addinRowsep ) *************** *** 1243,1248 **** --- 1300,1306 ---- if ( allProp ) { for ( i=1; i <= tblcols; i++ ) { + if (tfp->colpwidth[i][0]) sprintf(tfp->colwidth[i], "%fi", (atof(tfp->colpwidth[i]) / totalProp) * TEXTWIDTH); } *************** *** 1597,1602 **** --- 1655,1666 ---- * * nothing.. * + * [ANS-db3l] + * We need to look and see if the upcoming row is going to be any different + * than the current row formatting in place, and if so, output a new + * row control line and make it the default format. This is adapted from + * the existing code in TblTFoot(). + * */ *************** *** 1605,1612 **** TblTRowStart(Element_t * ep, FILE * fP) { ! /* nothing to do */ tblrow++; /* except note that we're within a new row */ --- 1669,1694 ---- TblTRowStart(Element_t * ep, FILE * fP) { + register struct tblformat * ffp, * ffp2; + static struct tblformat * tfp, * tfp2; + + tfp = TblBuild1Format(ep, FALSE, TGroup);/* gen format for the row */ + + for ( tfp2=formP; tfp2 && tfp2->next; tfp2=tfp2->next ) + ; + + if (!TblFormatMatch(tfp,tfp2)) { ! for ( ffp=formP; ffp; ffp=ffp2 ) { ! ffp2 = ffp->next; ! free(ffp); /* clear entire list */ ! } ! ! formP = tfp; /* this becomes the prevailing format */ ! ! OutputString("^.T&^", fP, 1); ! TblPrintFormat(fP, formP); ! } tblrow++; /* except note that we're within a new row */ Index: sgml/docbook-to-man/Instant/traninit.c diff -c sgml/docbook-to-man/Instant/traninit.c:1.1.1.1 sgml/docbook-to-man/Instant/traninit.c:1.2 *** sgml/docbook-to-man/Instant/traninit.c:1.1.1.1 Fri Nov 13 21:31:59 1998 --- sgml/docbook-to-man/Instant/traninit.c Mon Nov 16 22:38:12 1998 *************** *** 61,67 **** #ifndef lint static char *RCSid = ! "$Header: /aolnet/dev/src/CVS/sgml/docbook-to-man/Instant/traninit.c,v 1.1.1.1 1998/11/13 21:31:59 db3l Exp $"; #endif #include --- 61,67 ---- #ifndef lint static char *RCSid = ! "$Header: /aolnet/dev/src/CVS/sgml/docbook-to-man/Instant/traninit.c,v 1.2 1998/11/16 22:38:12 db3l Exp $"; #endif #include *************** *** 100,108 **** Trans_t T; if ((fp=OpenFile(transfile)) == NULL) { ! fprintf(stderr, "Can not open translation spec file '%s'.\n%s\n", ! transfile, strerror(errno)); ! return; } memset(&T, 0, sizeof T); /* initialize/clear structure */ --- 100,108 ---- Trans_t T; if ((fp=OpenFile(transfile)) == NULL) { ! sprintf(buf,"Can not open translation spec '%s'", transfile); ! perror(buf); ! return; } memset(&T, 0, sizeof T); /* initialize/clear structure */ *************** *** 361,369 **** int n_alloc=0; /* number of slots allocated so far */ if ((fp=OpenFile(filename)) == NULL) { ! fprintf(stderr, "Can not open character mapping file '%s'.\n%s\n", ! filename, strerror(errno)); ! return; } /* We allocate slots in blocks of N, so we don't have to call --- 361,370 ---- int n_alloc=0; /* number of slots allocated so far */ if ((fp=OpenFile(filename)) == NULL) { ! sprintf(buf,"Can not open character mapping file file '%s': ", ! filename); ! perror(buf); ! return; } /* We allocate slots in blocks of N, so we don't have to call *************** *** 419,427 **** int lineno=0; if ((fp=OpenFile(filename)) == NULL) { ! fprintf(stderr, "Can not open SDATA file '%s': %s", filename, ! strerror(errno)); ! return; } if (!SDATAmap) SDATAmap = NewMap(IMS_sdata); --- 420,428 ---- int lineno=0; if ((fp=OpenFile(filename)) == NULL) { ! sprintf(buf,"Can not open SDATA file '%s': ", filename); ! perror(buf); ! return; } if (!SDATAmap) SDATAmap = NewMap(IMS_sdata); Index: sgml/docbook-to-man/Instant/translate.c diff -c sgml/docbook-to-man/Instant/translate.c:1.1.1.1 sgml/docbook-to-man/Instant/translate.c:1.2 *** sgml/docbook-to-man/Instant/translate.c:1.1.1.1 Fri Nov 13 21:31:59 1998 --- sgml/docbook-to-man/Instant/translate.c Mon Nov 16 22:23:51 1998 *************** *** 58,64 **** #ifndef lint static char *RCSid = ! "$Header: /aolnet/dev/src/CVS/sgml/docbook-to-man/Instant/translate.c,v 1.1.1.1 1998/11/13 21:31:59 db3l Exp $"; #endif #include --- 58,64 ---- #ifndef lint static char *RCSid = ! "$Header: /aolnet/dev/src/CVS/sgml/docbook-to-man/Instant/translate.c,v 1.2 1998/11/16 22:23:51 db3l Exp $"; #endif #include *************** *** 610,615 **** --- 610,620 ---- * Arguments: * Pointer to data content to process * FILE pointer to where to write output. + * + * [ANS-db3l] + * No longer perform character mapping here - that's done on the input + * side when parsing the ESIS data block for an element. + * */ void *************** *** 628,633 **** --- 633,640 ---- /* CLEANUP: this should really all be done in OutputString(). (I think) */ + #if 0 + /* [ANS-db3l] Moved to input processing of ESIS in main.c */ if (nCharMap) { /* for each character, see if it's mapped to something else */ for (prev=0,cp=data,dp=buf; *cp; cp++) { *************** *** 650,656 **** dp = buf; } else dp = data; ! OutputString(dp, fp, 1); } /* ______________________________________________________________________ */ --- 657,665 ---- dp = buf; } else dp = data; ! #endif ! ! OutputString(data, fp, 1); } /* ______________________________________________________________________ */ Index: sgml/docbook-to-man/Instant/util.c diff -c sgml/docbook-to-man/Instant/util.c:1.1.1.1 sgml/docbook-to-man/Instant/util.c:1.4 *** sgml/docbook-to-man/Instant/util.c:1.1.1.1 Fri Nov 13 21:31:59 1998 --- sgml/docbook-to-man/Instant/util.c Tue Feb 23 22:21:27 1999 *************** *** 72,78 **** #ifndef lint static char *RCSid = ! "$Header: /aolnet/dev/src/CVS/sgml/docbook-to-man/Instant/util.c,v 1.1.1.1 1998/11/13 21:31:59 db3l Exp $"; #endif #include --- 72,78 ---- #ifndef lint static char *RCSid = ! "$Header: /aolnet/dev/src/CVS/sgml/docbook-to-man/Instant/util.c,v 1.4 1999/02/23 22:21:27 db3l Exp $"; #endif #include *************** *** 89,96 **** #include "general.h" ! /* forward references */ ! static char *LookupSDATA(char *); /* ______________________________________________________________________ */ /* "Split" a string into tokens. Given a string that has space-separated --- 89,100 ---- #include "general.h" ! #ifdef _AIX ! ! /* This should be prototyped in string.h but isn't */ ! int strcasecmp (char *String1, char *String2); ! ! #endif /* ______________________________________________________________________ */ /* "Split" a string into tokens. Given a string that has space-separated *************** *** 533,538 **** --- 537,543 ---- * FILE pointer of where to print. * Flag saying whether or not to keep track of our position in the output * stream. (We want to when writing to a file, but not for stderr.) + * */ void *************** *** 573,578 **** --- 578,587 ---- break; case '|': /* SDATA */ + /* [ANS-db3l] In non-"DATAhack" (-d) operation, this is */ + /* now normally done while reading the ESIS input, but */ + /* I've left it here just in case some existing users of */ + /* OutputString need it (don't think so, but...) */ s++; /* point past \| */ sdata = s; /* find matching/closing \| */ *************** *** 612,618 **** } else if (c == ANCHOR) c = NL; } ! if (c) putc(c, fp); } } --- 621,632 ---- } else if (c == ANCHOR) c = NL; } ! if (c) { ! if (track_pos) { ! char_pos = ((c == '\n') ? 0 : char_pos+1); ! } ! putc(c, fp); ! } /* if c */ } } *************** *** 628,634 **** * Mapped value of the SDATA entity. */ ! static char * LookupSDATA( char *s ) --- 642,648 ---- * Mapped value of the SDATA entity. */ ! char * LookupSDATA( char *s ) *************** *** 1009,1021 **** { ID_t *id; for (id=IDList; id; id=id->next) ! if (id->id[0] == idval[0] && !strcmp(id->id, idval)) return id->elem; return 0; } /* ______________________________________________________________________ */ ! #ifndef linux char * strerror(int number) --- 1023,1040 ---- { ID_t *id; for (id=IDList; id; id=id->next) ! if (toupper(id->id[0]) == toupper(idval[0]) && !strcasecmp(id->id, idval)) return id->elem; return 0; } /* ______________________________________________________________________ */ ! /* [ANS-db3l] Change this to a config'd request for a replacement function */ ! /* since later Sun systems have this and on other systems not explicitly */ ! /* checked here (existing code only excluded Linux) such as FreeBSD/BSDI */ ! /* it would crash on perror() calls. */ ! ! #ifdef STRERROR char * strerror(int number) Index: sgml/docbook-to-man/Instant/tptregexp/Makefile diff -c sgml/docbook-to-man/Instant/tptregexp/Makefile:1.1.1.1 sgml/docbook-to-man/Instant/tptregexp/Makefile:1.2 *** sgml/docbook-to-man/Instant/tptregexp/Makefile:1.1.1.1 Fri Nov 13 21:31:59 1998 --- sgml/docbook-to-man/Instant/tptregexp/Makefile Tue Feb 23 22:21:27 1999 *************** *** 18,24 **** # Dalrymple Consulting # # ! # $Header: /aolnet/dev/src/CVS/sgml/docbook-to-man/Instant/tptregexp/Makefile,v 1.1.1.1 1998/11/13 21:31:59 db3l Exp $ # ROOT = /usr/local --- 18,24 ---- # Dalrymple Consulting # # ! # $Header: /aolnet/dev/src/CVS/sgml/docbook-to-man/Instant/tptregexp/Makefile,v 1.2 1999/02/23 22:21:27 db3l Exp $ # ROOT = /usr/local *************** *** 36,41 **** --- 36,42 ---- # -DSTRCSPN library does not have strcspn() # -Dstrchr=index library does not have strchr() # -DERRAVAIL have utzoo-compatible error() function and friends + # -DSTRERROR library does not have strerror() [ANS-db3l] #ENV=-Dvoid=int -DCHARBITS=0377 -DSTATIC=extern #LENV=-Dvoid=int -DCHARBITS=0377 Index: sgml/docbook-to-man/Instant/tptregexp/strerror.c diff -c sgml/docbook-to-man/Instant/tptregexp/strerror.c:1.1.1.1 sgml/docbook-to-man/Instant/tptregexp/strerror.c:1.2 *** sgml/docbook-to-man/Instant/tptregexp/strerror.c:1.1.1.1 Fri Nov 13 21:31:59 1998 --- sgml/docbook-to-man/Instant/tptregexp/strerror.c Tue Feb 23 22:21:28 1999 *************** *** 1,3 **** --- 1,8 ---- + /* [ANS-db3l] Change this to a config'd request for a replacement function */ + /* since later Sun systems have this and on other systems not explicitly */ + /* checked here such as FreeBSD/BSDI it would crash on perror() calls. */ + + #ifdef STRERROR /* standin for strerror(3) which is missing on some systems * (eg, SUN) *************** *** 9,11 **** --- 14,18 ---- perror(num); return ""; } + + #endif Index: sgml/docbook-to-man/Transpec/Makefile diff -c sgml/docbook-to-man/Transpec/Makefile:1.1.1.1 sgml/docbook-to-man/Transpec/Makefile:1.2 *** sgml/docbook-to-man/Transpec/Makefile:1.1.1.1 Fri Nov 13 21:31:58 1998 --- sgml/docbook-to-man/Transpec/Makefile Mon Nov 16 22:23:53 1998 *************** *** 37,43 **** ############################################################################# ROOT = /usr/local ! TPTLIB = $(ROOT)/lib/tpt MAKE = make SHELL = /bin/sh --- 37,43 ---- ############################################################################# ROOT = /usr/local ! TPTLIB = $(ROOT)/share/sgml/transpec MAKE = make SHELL = /bin/sh Index: sgml/docbook-to-man/Transpec/docbook-to-man.ts diff -c sgml/docbook-to-man/Transpec/docbook-to-man.ts:1.1.1.1 sgml/docbook-to-man/Transpec/docbook-to-man.ts:1.2 *** sgml/docbook-to-man/Transpec/docbook-to-man.ts:1.1.1.1 Fri Nov 13 21:31:58 1998 --- sgml/docbook-to-man/Transpec/docbook-to-man.ts Mon Nov 16 22:23:53 1998 *************** *** 36,41 **** --- 36,45 ---- # ############################################################################# # + # $Id: docbook-to-man.ts,v 1.2 1998/11/16 22:23:53 db3l Exp $ + # + ############################################################################# + # # Variables # Var: callout 0 *************** *** 53,59 **** # #### ##### ##### ##### ##### ##### #### ##### # GI: REFENTRY ! StartText: ^.ta 8n 16n 24n 32n 40n 48n 56n 64n 72n ^.TH "${_followrel descendant REFENTRYTITLE 1000}" "${_followrel descendant MANVOLNUM 1000}"^ EndText: ^...\\" created by instant / docbook-to-man, ${date}^ --- 57,63 ---- # #### ##### ##### ##### ##### ##### #### ##### # GI: REFENTRY ! StartText: ^'\\" t^${_action 1001} ^.TH "${_followrel descendant REFENTRYTITLE 1000}" "${_followrel descendant MANVOLNUM 1000}"^ EndText: ^...\\" created by instant / docbook-to-man, ${date}^ *************** *** 133,138 **** --- 137,147 ---- - # GI: TITLE + Context: REFSYNOPSISDIV + Ignore: all + - + # + GI: TITLE Context: REFSECT1 Ignore: all - *************** *** 297,309 **** - # GI: PROGRAMLISTING ! StartText: ^.PP^.nf^\\f(CW EndText: \\fR^.fi^.PP^ - # GI: LITERALLAYOUT ! StartText: ^.PP^.nf^ EndText: ^.fi^ - # GI: BLOCKQUOTE --- 306,320 ---- - # GI: PROGRAMLISTING ! StartText: ^.PP^.nf^${_action 1001}^\\f(CW EndText: \\fR^.fi^.PP^ + Verbatim: - # GI: LITERALLAYOUT ! StartText: ^.PP^.nf^${_action 1001}^ EndText: ^.fi^ + Verbatim: - # GI: BLOCKQUOTE *************** *** 376,383 **** - # GI: SCREEN ! StartText: ^.PP^.nf^ EndText: ^.fi^ - # GI: SCREENCO --- 387,395 ---- - # GI: SCREEN ! StartText: ^.PP^.nf^${_action 1001}^ EndText: ^.fi^ + Verbatim: - # GI: SCREENCO *************** *** 489,496 **** # #### ##### ##### ##### ##### ##### #### ##### # GI: ADDRESS ! StartText: ^.PP^.nf^ EndText: ^.fi^ - # GI: STREET --- 501,509 ---- # #### ##### ##### ##### ##### ##### #### ##### # GI: ADDRESS ! StartText: ^.PP^.nf^${_action 1001}^ EndText: ^.fi^ + Verbatim: - # GI: STREET *************** *** 1155,1162 **** # #### ##### ##### ##### ##### ##### #### ##### # GI: SYNOPSIS ! StartText: ^.PP^.nf^ EndText: ^.fi^ - # GI: CMDSYNOPSIS --- 1168,1176 ---- # #### ##### ##### ##### ##### ##### #### ##### # GI: SYNOPSIS ! StartText: ^.PP^.nf^${_action 1001}^ EndText: ^.fi^ + Verbatim: - # GI: CMDSYNOPSIS *************** *** 1237,1244 **** - # GI: FUNCSYNOPSIS ! StartText: ^.PP^.nf^ EndText: ^.fi^ - # GI: FUNCSYNOPSISINFO --- 1251,1259 ---- - # GI: FUNCSYNOPSIS ! StartText: ^.PP^.nf^${_action 1001}^ EndText: ^.fi^ + Verbatim: - # GI: FUNCSYNOPSISINFO *************** *** 1313,1328 **** # GI: XREF AttValue: ENDTERM ! StartText: \\fI(cross-reference to ``${_followlink ENDTERM 1000}'')\\fR\s - # GI: XREF ! StartText: \\fI(cross-reference to ``${_followlink LINKEND 600})''\\fR\s - # GI: _xref SpecID: 600 ! StartText: ${XREFLABEL} Ignore: all - # --- 1328,1356 ---- # GI: XREF AttValue: ENDTERM ! StartText: \\fI"${_followlink ENDTERM 1000}"\\fR\s - # GI: XREF ! StartText: \\fI"${_followlink LINKEND 600}"\\fR\s - # GI: _xref SpecID: 600 ! StartText: ${_set xreflabel no}${_isset XREFLABEL 601}${_isset xreflabel no 602} ! Ignore: all ! - ! # ! GI: _xref_label ! SpecID: 601 ! StartText: ${_set xreflabel yes}${XREFLABEL} ! Ignore: all ! - ! # ! GI: _xref_title ! SpecID: 602 ! Set: ! StartText: ${_followrel child TITLE 1000} Ignore: all - # *************** *** 1757,1762 **** --- 1785,1794 ---- # no special presentation - # + GI: PROMPT + # no special presentation + - + # GI: SHORTCUT # no special presentation - *************** *** 1965,1970 **** --- 1997,2013 ---- # GI: _passthrough SpecID: 1000 + - + # + # Used to reset trap positions, either at start of file or when .nf is + # restarted, such as for literal output. Assumes caller is responsible + # for line starting characters as appropriate. (it helps the calling + # definitions read more logically). + # + GI: _tabset + SpecID: 1001 + StartText: .ta 8n 16n 24n 32n 40n 48n 56n 64n 72n + Ignore: all - # GI: _doTitle Index: sgml/docbook-to-man/Transpec/docbook-to-man.ts-PUSHPOP diff -c sgml/docbook-to-man/Transpec/docbook-to-man.ts-PUSHPOP:1.1.1.1 sgml/docbook-to-man/Transpec/docbook-to-man.ts-PUSHPOP:1.5 *** sgml/docbook-to-man/Transpec/docbook-to-man.ts-PUSHPOP:1.1.1.1 Fri Nov 13 21:31:58 1998 --- sgml/docbook-to-man/Transpec/docbook-to-man.ts-PUSHPOP Tue Feb 23 20:31:38 1999 *************** *** 36,41 **** --- 36,45 ---- # ############################################################################# # + # $Id: docbook-to-man.ts-PUSHPOP,v 1.5 1999/02/23 20:31:38 db3l Exp $ + # + ############################################################################# + # # Variables # Var: callout 0 *************** *** 53,62 **** # #### ##### ##### ##### ##### ##### #### ##### # GI: REFENTRY ! StartText: ^.ta 8n 16n 24n 32n 40n 48n 56n 64n 72n ! ^.TH "${_followrel descendant REFENTRYTITLE 1000}" ! "${_followrel descendant MANVOLNUM 1000}"^ ! EndText: ^...\\" created by instant / docbook-to-man, ${date} - # GI: DOCINFO --- 57,66 ---- # #### ##### ##### ##### ##### ##### #### ##### # GI: REFENTRY ! StartText: ^'\\" t^.TH "${_followrel descendant REFENTRYTITLE 1000}" ! "${_followrel descendant MANVOLNUM 1000}" "${date}" ! ^${_action 1002}^${_action 1001}^ ! EndText: ^...\\" created by instant / docbook-to-man, ${date}^ - # GI: DOCINFO *************** *** 133,138 **** --- 137,147 ---- - # GI: TITLE + Context: REFSYNOPSISDIV + Ignore: all + - + # + GI: TITLE Context: REFSECT1 Ignore: all - *************** *** 292,303 **** - # GI: PROGRAMLISTING ! StartText: ^.PP^.nf^\\f(CW EndText: \\fR^.fi^.PP^ - # GI: LITERALLAYOUT ! StartText: ^.PP^.nf^ EndText: ^.fi^ - # --- 301,312 ---- - # GI: PROGRAMLISTING ! StartText: ^.PP^.nf^${_action 1001}^\\f(CW EndText: \\fR^.fi^.PP^ - # GI: LITERALLAYOUT ! StartText: ^.PP^.nf^${_action 1001}^ EndText: ^.fi^ - # *************** *** 371,377 **** - # GI: SCREEN ! StartText: ^.PP^.nf^ EndText: ^.fi^ - # --- 380,386 ---- - # GI: SCREEN ! StartText: ^.PP^.nf^${_action 1001}^ EndText: ^.fi^ - # *************** *** 484,490 **** # #### ##### ##### ##### ##### ##### #### ##### # GI: ADDRESS ! StartText: ^.PP^.nf^ EndText: ^.fi^ - # --- 493,499 ---- # #### ##### ##### ##### ##### ##### #### ##### # GI: ADDRESS ! StartText: ^.PP^.nf^${_action 1001}^ EndText: ^.fi^ - # *************** *** 1230,1236 **** - # GI: FUNCSYNOPSIS ! StartText: ^.PP^.nf^ EndText: ^.fi^ - # --- 1239,1245 ---- - # GI: FUNCSYNOPSIS ! StartText: ^.PP^.nf^${_action 1001}^ EndText: ^.fi^ - # *************** *** 1306,1321 **** # GI: XREF AttValue: ENDTERM ! StartText: \\fI(cross-reference to ``${_followlink ENDTERM 1000}'')\\fR\s - # GI: XREF ! StartText: \\fI(cross-reference to ``${_followlink LINKEND 600})''\\fR\s - # GI: _xref SpecID: 600 ! StartText: ${XREFLABEL} Ignore: all - # --- 1315,1343 ---- # GI: XREF AttValue: ENDTERM ! StartText: \\fI"${_followlink ENDTERM 1000}"\\fR\s - # GI: XREF ! StartText: \\fI"${_followlink LINKEND 600}"\\fR\s - # GI: _xref SpecID: 600 ! StartText: ${_set xreflabel no}${_isset XREFLABEL 601}${_isset xreflabel no 602} ! Ignore: all ! - ! # ! GI: _xref_label ! SpecID: 601 ! StartText: ${_set xreflabel yes}${XREFLABEL} ! Ignore: all ! - ! # ! GI: _xref_title ! SpecID: 602 ! Set: ! StartText: ${_followrel child TITLE 1000} Ignore: all - # *************** *** 1685,1691 **** - # GI: COMMAND ! Action: 910 - # GI: COMPUTEROUTPUT --- 1707,1714 ---- - # GI: COMMAND ! StartText: ${_action 910}\s ! Ignore: all - # GI: COMPUTEROUTPUT *************** *** 1851,1856 **** --- 1874,1883 ---- # no special presentation - # + GI: PROMPT + # no special presentation + - + # GI: SHORTCUT # no special presentation - *************** *** 2125,2130 **** --- 2152,2178 ---- # GI: _passthrough SpecID: 1000 + - + # + # Used to reset trap positions, either at start of file or when .nf is + # restarted, such as for literal output. Assumes caller is responsible + # for line starting characters as appropriate. (it helps the calling + # definitions read more logically). + # + GI: _tabset + SpecID: 1001 + StartText: .ta 8n 16n 24n 32n 40n 48n 56n 64n 72n + Ignore: all + - + # + # Sets up macros for push/pop of fonts to better handle nested cases. + # Moved reference into this file rather than assuming the wrapper script + # will add it, since it's tightly coupled with this file anyway. + # + GI: _fontmac + SpecID: 1002 + StartText: ^${_include docbook-to-man.prolog}^ + Ignore: all - # GI: _doTitle Index: sgml/docbook-to-man/Transpec/roff.cmap diff -c sgml/docbook-to-man/Transpec/roff.cmap:1.1.1.1 sgml/docbook-to-man/Transpec/roff.cmap:1.2 *** sgml/docbook-to-man/Transpec/roff.cmap:1.1.1.1 Fri Nov 13 21:31:58 1998 --- sgml/docbook-to-man/Transpec/roff.cmap Mon Nov 16 22:23:54 1998 *************** *** 43,50 **** # # Character strings to map for troff/nroff. # # From To ! #\\ \\e ^ \^ . \\&. ' \\&' --- 43,54 ---- # # Character strings to map for troff/nroff. # + # + # $Id: roff.cmap,v 1.2 1998/11/16 22:23:54 db3l Exp $ + # + # # From To ! \\ \\e ^ \^ . \\&. ' \\&' Index: sgml/docbook-to-man/Transpec/roff.sdata diff -c sgml/docbook-to-man/Transpec/roff.sdata:1.1.1.1 sgml/docbook-to-man/Transpec/roff.sdata:1.2 *** sgml/docbook-to-man/Transpec/roff.sdata:1.1.1.1 Fri Nov 13 21:31:58 1998 --- sgml/docbook-to-man/Transpec/roff.sdata Mon Nov 16 22:23:55 1998 *************** *** 47,52 **** --- 47,55 ---- # # Numeric and Special Graphic ________________________________ # + # + # $Id: roff.sdata,v 1.2 1998/11/16 22:23:55 db3l Exp $ + # [half ] \\(12 [frac12] \\(12 [frac14] \\(14 *************** *** 202,208 **** # [mldr ] em leader [rdquor] \\&'' [rsquor] \\&' ! # [vellip] vertical ellipsis # [hybull] rectangle, filled (hyphen bullet) # [loz ] /lozenge - lozenge or total mark # [lozf ] /blacklozenge - lozenge, filled --- 205,212 ---- # [mldr ] em leader [rdquor] \\&'' [rsquor] \\&' ! # Vertical ellipsis - cheat for now and treat like horizontal ! [vellip] \\&... # [hybull] rectangle, filled (hyphen bullet) # [loz ] /lozenge - lozenge or total mark # [lozf ] /blacklozenge - lozenge, filled docbook-to-man-2.0.0.orig/Instant/0040755000176100001440000000000007031671612016210 5ustar debacleusersdocbook-to-man-2.0.0.orig/Instant/Imakefile0100644000176100001440000000076606737404357020043 0ustar debacleusers#define IHaveSubdirs #define PassCDebugFlags SUBDIRS = tptregexp ROOT = /usr/local BINDIR = $(ROOT)/bin INCLUDES = -Itptregexp LOCAL_LIBRARIES = -Ltptregexp -ltptregexp TPTLIB = $(ROOT)/lib/tpt DEFINES = -DDEF_TPT_LIB=\"$(TPTLIB)\" SRCS = main.c util.c info.c translate.c traninit.c tranvar.c tables.c \ browse.c OBJS = main.o util.o info.o translate.o traninit.o tranvar.o tables.o \ browse.o masterVersion.o MakeSubdirs($(SUBDIRS)) DependSubdirs($(SUBDIRS)) ComplexProgramTarget(instant) docbook-to-man-2.0.0.orig/Instant/Makefile0100644000176100001440000001063706737404357017670 0ustar debacleusers# # Copyright 1993 Open Software Foundation, Inc., Cambridge, Massachusetts. # All rights reserved. # # 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) 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 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # 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. # # # For building 'instant'. # # J.Bowe, 1993 # # $Header: /aolnet/dev/src/CVS/sgml/docbook-to-man/Instant/Makefile,v 1.3 1999/02/23 22:21:26 db3l Exp $ # # This assumes you have the (tpt)regexp package (includes and library) # available. # # Some things you could set at your site. # XDEFINES = ... # for extra defines # REGEX_INC = -I../tptregexp # should be here with release # REGEX_LIB = ../lib/tptregexp # assumes you built it there # BINDIR = /usr/local/bin # where you keep your programs # (You should set DEF_TPT_LIB to something, or set it in general.h. # At OSF we use the default in that file.) # # -DSTRERROR to DEFINES if library does not have strerror() [ANS-db3l] # MAKE = make SHELL = /bin/sh ROOT = /usr/local TPTLIB = $(ROOT)/share/sgml/transpec REGEX_INC = -Itptregexp REGEX_LIB = tptregexp BINDIR = $(ROOT)/bin DEFINES = -DDEF_TPT_LIB=\"$(TPTLIB)\" $(XDEFINES) CC = gcc OPT = -g CFLAGS = $(OPT) $(REGEX_INC) $(DEFINES) LDFLAGS = $(OPT) REGEX = -L$(REGEX_LIB) -ltptregexp CFILES = main.c util.c info.c translate.c traninit.c tranvar.c tables.c \ browse.c HFILES = general.h translate.h OBJ = main.o util.o info.o translate.o traninit.o tranvar.o tables.o \ browse.o masterVersion.o PROGS = instant all: dotptregexp $(PROGS) dotptregexp: cd tptregexp; $(MAKE) all instant: $(OBJ) $(CC) -o $@ $(LDFLAGS) $(OBJ) $(REGEX) install: all cp $(PROGS) $(BINDIR) Version: allVersion.o allVersion.c: $(HFILES) $(CFILES) Makefile co -l allVersion.c makeVersionFile $(HFILES) $(CFILES) Makefile > allVersion.c ci -u -m"new master version number" allVersion.c makeVersionFile -n instant allVersion.c > masterVersion.c clean: rm -f $(OBJ) allVersion.o lint.out core tags cd tptregexp; make clean clobber: clean rm -f $(PROGS) cd tptregexp; make clobber tags: $(CFILES) $(HFILES) ctags $(CFILES) $(HFILES) lint: gcc -Wall -Dlint $(REGEX_INC) -c $(CFILES) >lint.out 2>&1 # lint $(CFILES) > lint.out # dependencies main.o: main.c general.h util.o: util.c general.h info.o: info.c general.h translate.o: translate.c general.h translate.h traninit.o: traninit.c general.h translate.h tranvar.o: tranvar.c general.h translate.h tables.o: tables.c general.h translate.h browse.o: browse.c general.h docbook-to-man-2.0.0.orig/Instant/README0100644000176100001440000001736706737404357017117 0ustar debacleusers# # 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 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # 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. # instant - a formatting application for OSF SGML instances ____________________________________________________________________________ Requirements ANSI C compiler (gcc is one) sgmls 1.1 -- sgml parser from James Clark. Based on Goldfarb's ARC parser. Vanilla unix make POSIX C libraries Files for instant program Module Function ------ -------- browse.c interactive browser general.h general definitions info.c print information about the instances main.c main entry, arg parsing, instance reading tables.c table-specific formatting routines (TeX and tbl) traninit.c translator initialization (read spec, etc.) translate.c main translator translate.h structure definitions for translation code tranvar.c routines for handling "special variables" util.c general utilities Also required 1. Translation spec (transpec) files. (../transpecs/*.ts) 2. SDATA mapping files for mapping sdata entities. (../transpecs/*.sdata) 3. Character mapping files for mapping characters. (../transpecs/*.cmap) Platforms tried on OSF1 1.3 (i486) Ultrix 4.2 (mips) HP-UX 9.01 (hp 9000/700) AIX 3.2 (rs6000) SunOS [missing strerror()] ____________________________________________________________________________ General outline of program ------- ------- -- ------- To summarize in a sentence, instant reads the output of sgmls, builds a tree of the instnace in memory, then traverses the tree in in-order, processing the nodes according to a translation spec. Element tree storage ------- ---- ------- The first thing instant must do is read the ESIS (output of sgmls) from the specified file or stdin, forming a tree in memory. (Nothing makes sense without an instance...) Each element of the instance is a node in the tree, stored as a structure called Element_t. Elements contain content (what else?), which is a mixture of data (#PCDATA, #CDATA, #RCDATA - all the same in the ESIS), child elements, and PIs. Each 'chunk' of content is referred to by a Content_t structure. A Content_t contains an enum that can point to a string (data or PI), another Element_t. For example, if a

element contains some characters, an element, some more characters, a element, then some more characters, it has 5 Content_t children as an array. Element_t's have pointers to their parents, and a next element in a linked list (they're stored as a linked list, for cases when you'd want to quickly travers all the nodes, in no particular order). For convenience, Element_t's have an array of pointers to it's child Element_t's. These are just pointers to the same thing contained in the Content_t array, without the intervening data or PIs. This makes it easier for the program to traverse the elements of the tree (it does not have to be concerned with skipping data, etc.). There is an analagous array of pointers for the data content, an array of (char *)'s. This makes it easier to consider the immediate character content of an element. Attributes are kept as an array of name-value mappings (using the typedef Mapping_t). ID attributes are also stored in a separate list of ID value - element pointer pairs so that it is quick to find an element by ID. Other information kept about each element (in the Element_t struct) includes the line number in the EISI where the element occurs, the input filename. (These depend on sgmls being run with the "-l" option.) Also stored is an element's order in its parent's collection of children and an element's depth in the tree. Translation specs ----------- ----- A translation spec is read into a linked list in memory. As the instance tree is traversed, the transpecs are searched in order for a match. As a rule, one should position the less specific transpecs later in the file. Also, specs for seldom-used element are best placed later in the file, since it takes cpu cycles to skip over them for each of the more-used elements. During translation of a particular element, the list of Content_t structures are processed in order. If a content 'chunk' is data, it is printed to the output stream. If it is an element, the translation routine is called for that elemen, recursively. Hence, in-order traversal. Miscellaneous information displays ------------- ----------- -------- There are several informational display options available. They include: - a list of element usage (-u) -- lists each element in the instance, it's attributes, number of children, parent, data content 'nodes'. - statistics about elements (-S) -- lists elements, number of times each is used, percent of elements that this is, total char content in that element, average number of characters in they element. - show context of each element (-x) -- lists each element and its context, looking up the tree (this is the same context that would match the Context field of a transpec). - show the hierarchy of the instance (-h) -- show an ascii 'tree' of the instance, where elements deeper in the tree are indented more. Numbers after the element name in parentheses are the number of element content nodes and the number of data content nodes. Interactive browser ----------- ------- Originally, the interactive browser was intended as a debugging aid for the code developer. It was a way to examine a particular node of the instance tree or process a subtree without being distracted by the rest of the instance. Many of the commands test functionality of the query and search code (such as testing whether a certain element has a given relationship to the current position in the tree). ____________________________________________________________________________ docbook-to-man-2.0.0.orig/Instant/allVersion.c0100644000176100001440000000075706737404357020514 0ustar debacleusers/* version summary file created by makeVersionFile on Fri Jun 14 23:45:41 1996 */ char _HeadVeRsIoN_[] = "$Id: general.h 1.5 1996/06/11 20:25:03; translate.h 1.3 1996/06/02 21:47:32; main.c 1.8 1996/06/12 03:32:48; util.c 1.4 1996/06/02 21:47:32; info.c 1.2 1996/06/02 21:46:10; translate.c 1.10 1996/06/11 22:43:59; traninit.c 1.5 1996/06/02 21:47:32; tranvar.c 1.5 1996/06/11 22:43:15; tables.c 1.11 1996/06/15 03:45:02; browse.c 1.2 1996/06/02 21:46:10; Makefile 1.9 1996/06/06 14:45:16 $"; docbook-to-man-2.0.0.orig/Instant/browse.c0100644000176100001440000003336506737404357017700 0ustar debacleusers/* * Copyright 1993 Open Software Foundation, Inc., Cambridge, Massachusetts. * All rights reserved. */ /* * 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 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * 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. */ /* ________________________________________________________________________ * * Module for interactive browsing. * * Entry points for this module: * Browse() interactive browser * ________________________________________________________________________ */ #ifndef lint static char *RCSid = "$Header: /aolnet/dev/src/CVS/sgml/docbook-to-man/Instant/browse.c,v 1.1.1.1 1998/11/13 21:31:58 db3l Exp $"; #endif #include #include #include #include #include "general.h" static void PrElemPlusID(Element_t *); static void ls_node(Element_t *, int, char **); static void do_query(Element_t *, char *, char *); static void do_find(Element_t *, char **); /* ______________________________________________________________________ */ static char *br_help_msg[] = { " ls List info about current element in tree", " (context, children, attributes, etc.)", " cd N ... Change to Nth elememt child, where N is shown by 'ls'.", " N may also be '/' (top) or '..' (up).", " cd id I Change to elememt whose ID is I", " data N Show data of Nth data node", " where Show current position in the tree", " id I Show path to element with id I", " (using '?' for I will lists all IDs and their paths)", " find S Find elements matching spec S. Recognized syntaxes:", " find attr ", " find cont ", " find parent ", " find child ", " find gi ", " q rel gi Query: report if elem 'gi' has relation to current elem", " ('rel' is one of 'child parent ancestor descendant", " sibling sibling+ sibling+1 sibling- sibling-1 cousin')", "", " tran file [outfile]", " With trans spec in 'file' translate into 'outfile' (stdout)", " sdata file Read SDATA map file (for translations).", " cmap file Read character map file (for translations).", " stat Print statistics (how often elements occur, etc.)", " sum Print elem usage summary (# of children, depth, etc.)", " tree Print document hierarchy as a tree", " cont Print context of each element", NULL }; /* ______________________________________________________________________ */ void Browse() { char buf[256], *cmd, **av, **sv, *cmapfile, *sdatafile; char *Prompt; Element_t *ce; /* current element */ Element_t *e; int i, n, ac; if (slave) Prompt = "=>\n"; else Prompt = "=> "; ce = DocTree; while (fputs(Prompt, stdout)) { if (!fgets(buf, 256, stdin)) break; stripNL(buf); if (buf[0] == EOS) { fputs(Prompt, stdout); continue; } ac = 20; av = Split(buf, &ac, S_ALVEC); if (ac > 0) cmd = av[0]; if (!cmd || !(*cmd)) continue; if (!strcmp(cmd, "ls")) ls_node(ce, ac, av); else if (!strcmp(cmd, "cd")) { if (av[1]) { if (ac == 3 && !strcmp(av[1], "id")) { if ((e = FindElemByID(av[2]))) ce = e; else printf("Element with ID '%s' not found.\n", av[2]); continue; } for (i=1; iparent) ce = ce->parent; continue; } if (!strcmp(av[i], "/")) { if (ce->parent) ce = DocTree; continue; } if (!isdigit(*av[i])) { printf("Expecting digit, '..', or '/', got '%s'.\n", av[i]); break; } n = atoi(av[i]); if (n < ce->necont) ce = ce->econt[n]; else { printf("Must be in range 0 - %d.\n", ce->necont); break; } } } } else if (!strcmp(cmd, "data")) { if (av[1] && isdigit(*av[1])) { n = atoi(av[1]); if (n < ce->ndcont) { printf(ce->dcont[n]); fputs("\n", stdout); } else if (ce->ndcont == 0) printf("No data at this node.\n"); else printf("Must be in range 0 - %d.\n", ce->ndcont); } } /* show where we are in the tree */ else if (!strcmp(cmd, "where")) PrintLocation(ce, stdout); /* show where we are in the tree */ else if (!strcmp(cmd, "pwd")) PrElemPlusID(ce); /* perform query with yes/no answer */ else if (!strcmp(cmd, "q") && av[1] && av[2]) do_query(ce, av[1], av[2]); /* perform query printing paths to matching elements */ else if (!strcmp(cmd, "find") && av[1] && av[2]) do_find(ce, av); /* list locations where specified ID(s) occur */ else if (!strcmp(cmd, "id")) { if (ac <= 1) continue; if (*av[1] == '?') PrintIDList(); else { /* short: "id i1 i2 ...", long: "id -l i1 i2 ..." */ if (!strcmp(av[1], "-l")) n = 2; else n = 1; for (i=n; i 1) PrintElemSummary(ce); else PrintElemSummary(DocTree); } /* print element tree */ else if (!strcmp(cmd, "tree")) { if (ac > 1) PrintElemTree(ce); else PrintElemTree(DocTree); } /* print statistics */ else if (!strcmp(cmd, "stat")) { if (ac > 1) PrintStats(ce); else PrintStats(DocTree); } /* print context of each element of tree */ else if (!strcmp(cmd, "cont")) { if (ac > 1) PrintContext(ce); else PrintContext(DocTree); } /* print translation, given transpec */ else if (!strcmp(cmd, "tran")) { FILE *fp; if (ac > 2){ if (!(fp = fopen(av[2], "w"))) { perror("Can not open output file"); continue; } } else fp = stdout; DoTranslate(ce, av[1], fp); if (ac > 2) fclose(fp); } else if (!strcmp(cmd, "sdata")){ sdatafile = strdup(av[1]); ReadSDATA(sdatafile); } else if (!strcmp(cmd, "cmap")){ cmapfile = strdup(av[1]); ReadCharMap(cmapfile); } else if (!strcmp(cmd, "help") || *cmd == '?') { sv = br_help_msg; while (*sv) puts(*sv++); } /* quit (control-D also works) */ else if (!strcmp(cmd, "quit")) break; else fprintf(stderr, "Unknown command '%s' - ingored.\n", cmd); } putc(NL, stdout); } /* ______________________________________________________________________ */ /* Do the "ls" command. * Arguments: * Pointer to element under consideration. * Arg count from command line (this command, not the shell command). * Arg vector. */ static void ls_node( Element_t *e, int ac, char **av ) { int i; char buf[LINESIZE]; if (ac > 1 && !strcmp(av[1], "-n")) { for(i=0; incont; i++) { if (IsContElem(e,i)) printf("%s\n", ContElem(e,i)->gi); else if (IsContData(e,i)) printf("#data %s\n", ContData(e,i)); else if (IsContPI(e,i)) printf("#pi %s\n", ContData(e,i)); } return; } printf("Element: %s\tLineNumber: %d\n", e->gi, e->lineno); if (e->parent) printf("Context: %s\n", FindContext(e, 20, buf)); if (e->natts) { printf("%d attributes:\n", e->natts); for (i=0; inatts; i++) printf("\t%2d: %s = '%s'\n", i, e->atts[i].name, e->atts[i].sval); } if (e->entity) { printf("Entity & notation information:\n"); if (e->entity->ename) printf("Entity name: %s\n", e->entity->ename); if (e->entity->nname) printf("Notation name: %s\n", e->entity->nname); if (e->entity->sysid) printf("Sys id: %s\n", e->entity->sysid); if (e->entity->pubid) printf("Pub id: %s\n", e->entity->pubid); if (e->entity->fname) printf("Filename: %s\n", e->entity->fname); } if (e->my_eorder >= 0) printf("My order among my siblings: %d\n", e->my_eorder); if (e->necont) { printf("%d child element nodes:\n", e->necont); for(i=0; inecont; i++) printf("\t%2d: %s\n", i, e->econt[i]->gi); } if (e->ndcont) { printf("%d child data nodes:\n", e->ndcont); for(i=0; indcont; i++) { if (strlen(e->dcont[i]) < 40) printf("\t%2d: %s\n", i, e->dcont[i]); else printf("\t%2d: %-40.40s...\n", i, e->dcont[i]); } } } /* ______________________________________________________________________ */ /* Perform query. Syntax: find relationship gi. Tells whether gi has * given relationship to current element. Result (message) sent to stdout. * Args: * Pointer to element under consideration. * Pointer to name of relationship. (see FindRelByName() for names) * Pointer to GI to look for. */ static void do_query( Element_t *e, char *rel, char *gi ) { char *cp; Relation_t r; Element_t *ep; for (cp=gi; *cp; cp++) if (islower(*cp)) *cp = toupper(*cp); if ((r = FindRelByName(rel)) == REL_Unknown) { return; } ep = QRelation(e, gi, r); printf("%s, '%s' is%s %s of '%s'.\n", (ep ? "Yes" : "No"), gi, (ep ? "" : " not"), rel, e->gi); } /* ______________________________________________________________________ */ /* Print path to the element and its ID (if it has one) on a single line. * Arguments: * Pointer to element under consideration. */ static void PrElemPlusID( Element_t *e ) { char buf[LINESIZE]; if (e->id) printf("%s -- ID=%s\n", FindElementPath(e, buf), e->id); else printf("%s\n", FindElementPath(e, buf)); } /* ______________________________________________________________________ */ /* Print path to the element and its ID (if it has one) on a single line. * Arguments: * Pointer to element under consideration. */ static void match_gi( Element_t *e, char **av ) { if (!strcmp(av[1], e->gi)) PrElemPlusID(e); } /* Shorthand for defining simple finctions, which are just interfaces to * calling QRelation(). DescendTree() only passes ptr to element. */ #define MATCH(Fun,Rel) \ static void Fun(Element_t *e, char **av) \ { if (QRelation(e, av[1], Rel)) PrElemPlusID(e); } MATCH(match_parent, REL_Parent) MATCH(match_child, REL_Child) MATCH(match_anc, REL_Ancestor) MATCH(match_desc, REL_Descendant) MATCH(match_sib, REL_Sibling) static void match_attr( Element_t *e, char **av ) { char *atval; if ((atval = FindAttValByName(e, av[1])) && !strcmp(av[2], atval)) PrElemPlusID(e); } static void match_cont( Element_t *e, char **av ) { int i; for (i=0; incont; i++) { if (IsContData(e,i) && strstr(ContData(e,i), av[1])) { PrElemPlusID(e); return; } } } /* Find an element, given the criteria on its command line. * Arguments: * Pointer to element under consideration. */ static void do_find( Element_t *e, char **av ) { av++; if (!strcmp(av[0], ".")) av++; else e = DocTree; if (!strcmp(av[0], "gi")) DescendTree(e, match_gi, 0, 0, av); else if (!strcmp(av[0], "attr")) DescendTree(e, match_attr, 0, 0, av); else if (!strcmp(av[0], "parent")) DescendTree(e, match_parent, 0, 0, av); else if (!strcmp(av[0], "child")) DescendTree(e, match_child, 0, 0, av); else if (!strcmp(av[0], "cont")) DescendTree(e, match_cont, 0, 0, av); else if (!strcmp(av[0], "sib")) DescendTree(e, match_sib, 0, 0, av); else if (!strcmp(av[0], "desc")) DescendTree(e, match_desc, 0, 0, av); else if (!strcmp(av[0], "anc")) DescendTree(e, match_anc, 0, 0, av); else fprintf(stderr, "Unknown find command: %s.\n", av[0]); } /* ______________________________________________________________________ */ docbook-to-man-2.0.0.orig/Instant/general.h0100644000176100001440000002554106737404357020016 0ustar debacleusers/* * Copyright 1993 Open Software Foundation, Inc., Cambridge, Massachusetts. * All rights reserved. */ /* * 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 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * 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. */ /* ________________________________________________________________________ * * Common definitions for "instant" program. * ________________________________________________________________________ */ #ifdef STORAGE #ifndef lint static char *gen_h_RCSid = "$Header: /aolnet/dev/src/CVS/sgml/docbook-to-man/Instant/general.h,v 1.2 1998/11/16 22:23:50 db3l Exp $"; #endif #endif /* string/numeric/character definitions */ #define EOS '\0' #define NL '\n' #define TAB '\t' #define CR '\r' #define ANCHOR '^' /* bigmask/flags for the Split() function */ #define S_STRDUP 0x01 #define S_ALVEC 0x02 /* Command codes (1st char of esis lines) from sgmls. See its manpage. */ #define CMD_DATA '-' #define CMD_OPEN '(' #define CMD_CLOSE ')' #define CMD_ATT 'A' #define CMD_D_ATT 'D' #define CMD_NOTATION 'N' #define CMD_EXT_ENT 'E' #define CMD_INT_ENT 'I' #define CMD_SYSID 's' #define CMD_PUBID 'p' #define CMD_FILENAME 'f' #define CMD_LINE 'L' #define CMD_PI '?' #define CMD_SUBDOC 'S' #define CMD_SUBDOC_S '{' #define CMD_SUBDOC_E '}' #define CMD_EXT_REF '&' #define CMD_APPINFO '#' #define CMD_CONFORM 'C' /* Some sizes */ #define MAX_DEPTH 40 #define LINESIZE 60000 /* Name of library env variable, and default value. */ #ifndef TPT_LIB #define TPT_LIB "TPT_LIB" #endif #ifndef DEF_TPT_LIB #define DEF_TPT_LIB "/project/tools/libdata/tpt" #endif /* Relationships - for querying */ typedef enum { REL_None, REL_Parent, REL_Child, REL_Ancestor, REL_Descendant, REL_Sibling, REL_Preceding, REL_ImmPreceding, REL_Following, REL_ImmFollowing, REL_Cousin, REL_Unknown } Relation_t; /* Initial map sizes (IMS) */ #define IMS_relations 3 #define IMS_setvar 3 #define IMS_incvar 3 #define IMS_sdata 50 #define IMS_sdatacache 30 #define IMS_variables 20 #define IMS_attnames 50 #define IMS_elemnames 50 /* ----- typedef and other misc definitions ----- */ #ifndef TRUE #define TRUE (1 == 1) #endif #ifndef FALSE #define FALSE (1 == 0) #endif typedef short bool; /* ----- structure definitions ----- */ /* We use this for variables, attributes, etc., so the caller only needs an * opaque handle to the thing below, not worrying about array management. */ typedef struct { char *name; /* name of the thing */ char *sval; /* string value */ } Mapping_t; typedef struct { int n_alloc; /* number of elements allocated */ int n_used; /* number of elements used */ int slot_incr; /* increment for allocating slots */ int flags; /* info about this set of mappings */ Mapping_t *maps; /* array of mappings */ } Map_t; /* ______________________________________________________________________ */ /* Information about an entity reference. Not all fields will be used * at once. */ typedef struct _ent { char *type; /* entity type */ char *ename; /* entity name */ char *nname; /* notation name */ char *sysid; /* sys id */ char *pubid; /* pub id */ char *fname; /* filename */ struct _ent *next; /* next in linked list */ } Entity_t; /* Content (child nodes) of an element (node in the tree) -- both data * and other elements. */ typedef struct { char type; /* element, data, or pi? */ union { struct _elem *elem; /* direct children of this elem */ char *data; /* character data of this elem */ } ch; } Content_t; /* An element (node in the tree) */ typedef struct _elem { char *gi; /* element GI */ Content_t *cont; /* content - element & data children */ int ncont; /* # of content/children */ struct _elem **econt; /* element children */ int necont; /* # of element children */ char **dcont; /* character data children */ int ndcont; /* # of data children */ Mapping_t *atts; /* array of attributes */ int natts; /* # of attributes */ Entity_t *entity; /* ext entity & notation info */ char *id; /* for linking */ int index; /* an internal bookkeeping mechanism */ int depth; /* how deep in tree */ int lineno; /* line number */ char *infile; /* input filename */ int my_eorder; /* order of this elem of its parent */ struct _elem *parent; /* this elem's direct parent */ struct _elem *next; /* kept in linked list */ void *trans; /* pointer to translation spec */ /* I'm not crazy about this, but it works */ int gen_trans[2]; /* refs to generated trans specs */ int processed; /* was this node processed? */ } Element_t; /* For mapping of element IDs to elements themselves. */ typedef struct id_s { char *id; /* ID of the element */ Element_t *elem; /* pointer to it */ struct id_s *next; } ID_t; /* ----- global variable declarations ----- */ #ifdef STORAGE # define def #else # define def extern #endif def Element_t *DocTree; /* root of document tree */ def char **UsedElem; /* a unique list of used elem names */ def int nUsedElem; /* number of used elem names */ def char **UsedAtt; /* a unique list of used attrib names */ def int nUsedAtt; /* number of used attrib names */ def ID_t *IDList; /* list of IDs used in the doc */ def Map_t *Variables; /* general, global variables */ def Map_t *SDATAmap; /* SDATA mappings */ def Map_t *PImap; /* Processing Instruction mappings */ def Entity_t *Entities; /* list of entities */ def FILE *outfp; /* where output is written */ def char *tpt_lib; /* TPT library directory */ def int verbose; /* flag - verbose output? */ def int warnings; /* flag - show warnings? */ def int interactive; /* flag - interactive browsing? */ def int slave; /* are we slave to another process? */ def int fold_case; /* flag - fold case of GIs? */ /* ----- some macros for convenience and ease of code reading ----- */ #define stripNL(s) { char *_cp; if ((_cp=strchr(s, NL))) *_cp = EOS; } /* Similar to calloc(), malloc(), and realloc(), but check for success. * Args to all: * (1) number of 'elements' to allocate * (2) variable to point at allocated space * (3) type of 'element' * Eg: Calloc(5, e, Element_t) replaces * if (!(e = (Element_t *)calloc(5, sizeof(Element_t))) { * ... handle error ... ; * } */ #define Calloc(N,V,T) \ { if (!((V) = (T *)calloc((size_t)N, sizeof(T)))) { \ perror("Calloc failed -- out of memory. Bailing out."); exit(1); \ }; memset((void *) (V), 0, (size_t) sizeof(T)); } #define Malloc(N,V,T) \ { if (!((V) = (T *)malloc((size_t)N*sizeof(T)))) { \ perror("Malloc failed -- out of memory. Bailing out."); exit(1); \ }; memset((void *) (V), 0, (size_t) sizeof(T)); } #define Realloc(N,V,T) \ { if (!((V) = (T *)realloc(V,(size_t)N*sizeof(T)))) { \ perror("Realloc failed -- out of memory. Bailing out."); exit(1); \ } } /* similar to strcmp(), but check first chars first, for efficiency */ #define StrEq(s1,s2) (s1[0] == s2[0] && !strcmp(s1,s2)) /* similar to isspace(), but check for blank or tab - without overhead * of procedure call */ #define IsWhite(c) (c == ' ' || c == TAB) #define ContType(e,i) (e->cont[i].type) #define ContData(e,i) (e->cont[i].ch.data) #define ContElem(e,i) (e->cont[i].ch.elem) #define IsContData(e,i) (e->cont[i].type == CMD_DATA) #define IsContElem(e,i) (e->cont[i].type == CMD_OPEN) #define IsContPI(e,i) (e->cont[i].type == CMD_PI) /* ----- function prototypes ----- */ /* things defined in util.c */ Element_t *QRelation(Element_t *, char *, Relation_t); Relation_t FindRelByName(char *); char *FindAttValByName(Element_t *, char *); char *FindContext(Element_t *, int, char *); char *LookupSDATA(char *); char *AddElemName(char *); char *AddAttName(char *); void OutputString(char *, FILE *, int); FILE *OpenFile(char *); char *FindElementPath(Element_t *, char *); char *NearestOlderElem(Element_t *, char *); void PrintLocation(Element_t *, FILE *); char **Split(char *, int *, int); void DescendTree(Element_t *, void(*)(), void(*)(), void(*)(), void *); Map_t *NewMap(int); Mapping_t *FindMapping(Map_t *, char *); char *FindMappingVal(Map_t *, char *); void SetMapping(Map_t *, char *); void SetMappingNV(Map_t *, char *, char *); void AddID(Element_t *, char *); Element_t *FindElemByID(char *); /* things defined in translate.c */ void DoTranslate(Element_t*, char *, FILE *); /* things defined in traninit.c */ void ReadTransSpec(char *); void ReadSDATA(char *); void ReadCharMap(char *); /* things defined in tranvar.c */ char *Get_A_C_value(char *); /* things defined in info.c */ void PrintContext(Element_t *e); void PrintElemSummary(Element_t *); void PrintElemTree(Element_t *); void PrintStats(Element_t *); void PrintIDList(); /* ----- other declarations ----- */ #ifdef ultrix #define strdup(s) strcpy((char *)malloc(strlen(s)+1), s) #endif docbook-to-man-2.0.0.orig/Instant/hyper.c0100644000176100001440000000665506737404357017530 0ustar debacleusers/* * Copyright 1993 Open Software Foundation, Inc., Cambridge, Massachusetts. * All rights reserved. */ /* * 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 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * 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. */ /* ________________________________________________________________________ * * Hypermedia-related facilities. * * Entry points for this module: * AddID(elem, idval) add elem-id pair to list of known ids * FindElemByID(idval) find elem by id * ________________________________________________________________________ */ #ifndef lint static char *RCSid = "$Header: /aolnet/dev/src/CVS/sgml/docbook-to-man/Instant/hyper.c,v 1.1.1.1 1998/11/13 21:31:58 db3l Exp $"; #endif #include #include #include #include #include #include #include "general.h" /* ______________________________________________________________________ */ void AddID(Element *e, char *idval) { static ID *id_last; if (!IDList) { Calloc(1, id_last, ID); IDList = id_last; } else { Calloc(1, id_last->next, ID); id_last = id_last->next; } id_last->elem = e; id_last->id = idval; } Element * FindElemByID(char *idval) { ID *id; for (id=IDList; id; id=id->next) if (!strcmp(id->id, idval)) return id->elem; return 0; } /* ______________________________________________________________________ */ docbook-to-man-2.0.0.orig/Instant/info.c0100644000176100001440000002165606737404357017332 0ustar debacleusers/* * Copyright 1993 Open Software Foundation, Inc., Cambridge, Massachusetts. * All rights reserved. */ /* * 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 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * 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. */ /* ________________________________________________________________________ * * Functions for printing information about an instance in the 'instant' * program. Most of these are fairly short and simple. * * Entry points for this module: * PrintElemSummary(elem) print summary info of each element * PrintContext(elem) print context of each element * PrintElemTree(elem) print tree of document * PrintStats(elem) print statistics about doc tree * PrintIDList(elem) print list of IDs and element context * Most Print*() functions start at subtree pointed to by 'elem'. * ________________________________________________________________________ */ #ifndef lint static char *RCSid = "$Header: /aolnet/dev/src/CVS/sgml/docbook-to-man/Instant/info.c,v 1.1.1.1 1998/11/13 21:31:58 db3l Exp $"; #endif #include #include #include #include #include "general.h" /* ______________________________________________________________________ */ /* Print a summary of each tag use in the instance. Things like depth in * the tree, number of children, parent, attributes. */ /* Do the actual printing. Print the info about the node. If null, * print a header for the columns. * Arguments: * Pointer to element structure of the node to print. */ static void print_summ( Element_t *e ) { int i, n, dsize; char *hfmt="%-18.18s %4s %5s %4s %4s %s\n"; char *fmt ="%-18.18s %4d %5d %4d %4d %s\n"; if (e == NULL) { fprintf(outfp, hfmt, "Element", "Att", "Data", "Chd", "Dep", "Parent"); return; } for (i=0,n=0; incont; i++) if (IsContElem(e,i)) n++; for (i=0,dsize=0; incont; i++) if (IsContElem(e,i)) dsize += strlen(e->cont[i].ch.data); fprintf(outfp, fmt, e->gi, e->natts, dsize, n, e->depth, e->parent ? e->parent->gi : "-"); for (i=0; inatts; i++) { fprintf(outfp, "%45d: %s = %s\n", i, e->atts[i].name, e->atts[i].sval ? e->atts[i].sval : "empty"); } } /* Descend the tree, calling processing routine. * Arguments: * Pointer to element structure at top of tree to traverse. */ void PrintElemSummary( Element_t *e ) { print_summ(0); DescendTree(e, print_summ, 0, 0, 0); } /* ______________________________________________________________________ */ /* Print the context of each tag in the instance (i.e. the tag with its * ancestors). */ /* Do the actual printing. Print the context of the node. * Arguments: * Pointer to element structure of the node to print. */ static void print_context( Element_t *e ) { char buf[LINESIZE]; fprintf(outfp, "%-22s %s\n", e->gi, FindContext(e, 10, buf)); } /* Descend the tree, calling processing routine. * Arguments: * Pointer to element structure at top of tree to traverse. */ void PrintContext( Element_t *e ) { fprintf(outfp, "%-22s %s\n", "Element", "Context"); fprintf(outfp, "%-22s %s\n", "---------------", "-----------"); DescendTree(e, print_context, 0, 0, 0); putc(NL, outfp); } /* ______________________________________________________________________ */ /* Print tree of the instance. GI's are printed indented by their depth * in the tree. */ /* Do the actual printing. Print the element name, indented the right amount. * Arguments: * Pointer to element structure of the node to print. */ static void print_indent( Element_t *e ) { int i, ne, nd; for(i=0; idepth; i++) fputs(". ", outfp); for(i=0,ne=0; incont; i++) if (IsContElem(e,i)) ne++; for(i=0,nd=0; incont; i++) if IsContData(e,i) nd++; fprintf(outfp, "%s (%d,%d)\n", e->gi, ne, nd); } /* Descend the tree, calling processing routine. * Arguments: * Pointer to element structure at top of tree to traverse. */ void PrintElemTree( Element_t *e ) { DescendTree(e, print_indent, 0, 0, 0); putc(NL, outfp); } /* ______________________________________________________________________ */ /* Print some statistics about the instance. */ /* Accumulate the totals for the statistics. * Arguments: * Pointer to element structure of the node to print. * Pointer to the total number of elements. * Pointer to the total amount of content data. * Pointer to the maximum depth of tree. */ static void acc_tots( Element_t *e, int *tot_el, int *tot_data, int *max_depth ) { int i; for(i=0; inecont; i++) acc_tots(e->econt[i], tot_el, tot_data, max_depth); for (i=0; inecont; i++) (*tot_el)++; for (i=0; indcont; i++) (*tot_data) += strlen(e->dcont[i]); if (e->depth > (*max_depth)) *max_depth = e->depth; } /* Descend the tree (recursively), collecting the statistics. * Arguments: * Pointer to element structure of the node to print. * Pointer to the total number of elements. * Pointer to the total amount of content data. * Pointer to the maximum depth of tree. */ static void elem_usage( Element_t *e, char *name, int *n_used, int *nchars ) { int i; if (!strcmp(name, e->gi)) { (*n_used)++; for (i=0; incont; i++) if (IsContData(e,i)) (*nchars) += strlen(ContData(e,i)); } for(i=0; inecont; i++) elem_usage(e->econt[i], name, n_used, nchars); } /* Descend the tree, calling processing routine. * Arguments: * Pointer to element structure at top of tree to traverse. */ void PrintStats( Element_t *top ) { int i, n; int dif_el=0, tot_el=0, tot_data=0, nchars, max_depth=0; float pct; fprintf(outfp, "%-22s %s %s\n", "Element name", "Occurrances", "Character Content"); fprintf(outfp, "%-22s %s %s\n", "---------------", "-----------", "-----------------"); acc_tots(top, &tot_el, &tot_data, &max_depth); for (i=0; i 0) { pct = 100.0 * (float)n / (float)tot_el; fprintf(outfp, "%-22s %4d %4.1f%% %6d %4d\n", UsedElem[i], n, pct, nchars, (nchars/n)); dif_el++; } } fprintf(outfp, "\nTotal of %d elements used, %d different ones.\n", tot_el, dif_el); fprintf(outfp, "Total character data: %d.\n", tot_data); fprintf(outfp, "Maximum element depth: %d.\n", max_depth); putc(NL, outfp); } /* ______________________________________________________________________ */ /* Print list of: ID, GI, input file, line number, separated by colons. * This is better for other programs to manipulate (like for keeping a * database of IDs in documents) than humans to read. */ void PrintIDList() { ID_t *id; Element_t *ep; for (id=IDList; id; id=id->next) { ep = id->elem; fprintf(outfp, "%s:%s:%s:%d\n", id->id, ep->gi, ep->infile?ep->infile:"-", ep->lineno); } } /* ______________________________________________________________________ */ docbook-to-man-2.0.0.orig/Instant/main.c0100644000176100001440000006400106737404357017312 0ustar debacleusers/* * Copyright 1993 Open Software Foundation, Inc., Cambridge, Massachusetts. * All rights reserved. */ /* * 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 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * 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 read an SGML document instance, creating any of several things: * * "translated" output for formatting applications (given a trans. spec) * validation report (given a appropriate trans spec) * tree of the document's structure * statistics about the element usage * summary of the elements used * context of each element used * IDs of each element * * A C structure is created for each element, which includes: * name, attributes, parent, children, content * The tree is descended, and the desired actions performed. * * Takes input from James Clark's "sgmls" program (v. 1.1). * ________________________________________________________________________ * * * [ANS-db3l] * General modifications for better interaction with DocBook markup. * Significant changes (but not every change) marked in source with * ANS tag as above. Primary for this module is processing of ESIS * data for elements (ESIS quoting/CMAP/SDATA) here rather than holding * off until DoData() or OutputString(). * */ #ifndef lint static char *RCSid = "$Header: /aolnet/dev/src/CVS/sgml/docbook-to-man/Instant/main.c,v 1.3 1999/02/23 20:31:37 db3l Exp $"; #endif #include #include #include #include #include #include #include #include #include #include #define STORAGE #include "general.h" /* [ANS-db3l] Included for character mapping in ReadESIS */ #include #include "translate.h" /* [ANS-db3l] Don't have "makeVersionFile", so just stamp the overall */ /* release here. Starting with 2.0 to isolate from earlier releases, */ /* and tagging with ANS to distinguish it a bit further. */ #define VERSION "2.0(0)-ANS" static int do_context, do_tree, do_summ, do_stats, do_validate, do_idlist; static int do_DATAhack = 0; static char *this_prog; static char *in_file, *out_file; static char *tranfile, *cmapfile, *sdatafile; static char *start_id; static char *last_file; static int last_lineno; extern int BOFTTextThresh; /* forward references */ static void HandleArgs(int, char *[]); static void Initialize1(); static void Initialize2(); static void ReadInstance(char *); static void DoHelpMessage(); extern void Browse(); /* external reference to version number */ extern char _HeadVeRsIoN_[]; /* ______________________________________________________________________ */ /* Program entry point. Look at args, read instance, dispatch to the * correct routines to do the work, and finish. */ int main( int ac, char *av[] ) { Initialize1(av[0]); HandleArgs(ac, av); Initialize2(); if (sdatafile) ReadSDATA(sdatafile); if (cmapfile) ReadCharMap(cmapfile); ReadInstance(in_file); if (interactive) { Browse(); /* this will handle interactive commands */ } else { /* Perform tasks based on command line flags... */ if (tranfile) { Element_t *e; /* If user wants to start at a particular ID, point to that * element. Else, point to the top of the tree. */ if (start_id) { if (!(e=FindElemByID(start_id))) { fprintf(stderr, "Error: Can not find element with ID %s\n", start_id); exit(1); } } else e = DocTree; /* If we're doing validation, make output file pointer null. * This means that we generate no output, except error messages. */ if (do_validate) outfp = NULL; DoTranslate(e, tranfile, outfp); } if (do_summ) PrintElemSummary(DocTree); if (do_tree) PrintElemTree(DocTree); if (do_stats) PrintStats(DocTree); if (do_context) PrintContext(DocTree); if (do_idlist) PrintIDList(); } if (out_file && outfp) fclose(outfp); return 0; } /* ______________________________________________________________________ */ /* Initialization stuff done before dealing with args. * Arguments: * Name of program (string). */ static void Initialize1( char *myname ) { time_t tnow; struct tm *nowtm; char *cp, buf[100]; extern int gethostname(char *, int); /* not in a system .h file... */ /* where we try to find data/library files */ if (!(tpt_lib=getenv(TPT_LIB))) tpt_lib = DEF_TPT_LIB; /* set some global variables */ warnings = 1; fold_case = 1; this_prog = myname; /* setup global variable mapping */ Variables = NewMap(IMS_variables); /* set some pre-defined variables */ SetMappingNV(Variables, "user", (cp=getenv("USER")) ? cp : "UnknownUser" ); time(&tnow); nowtm = localtime(&tnow); strftime(buf, 100, "%a %d %b %Y, %R", nowtm); SetMappingNV(Variables, "date", buf); if (gethostname(buf, 100) < 0) strcpy(buf, "unknown-host"); SetMappingNV(Variables, "host", buf); SetMappingNV(Variables, "transpec", tranfile ? tranfile : "??"); } /* Initialization stuff done after dealing with args. */ static void Initialize2() { SetMappingNV(Variables, "transpec", tranfile ? tranfile : "??"); /* If user wants to send output to a file, open the file, and set * the file pointer. Else we send output to standard out. */ if (out_file) { if (!(outfp = fopen(out_file, "w"))) { fprintf(stderr, "Could not open output '%s' file for writing.\n%s", out_file, strerror(errno)); exit(1); } } else outfp = stdout; } /* ______________________________________________________________________ */ /* Set a variable. If it is one of the "known" variables, set the * variable in the C code (this program). * Arguments: * Variable name/value string - separated by an '=' (eg, "myname=Sally"). */ static void CmdLineSetVariable( char *var ) { char *cp, buf[100], **tok; int n; /* Turn '=' into a space, to isolate the name. Then set variable. */ strcpy(buf, var); if ((cp=strchr(buf, '='))) { /* we have "var=value" */ *cp = ' '; n = 2; tok = Split(buf, &n, 0); /* see if variable name matches one of our internal ones */ if (!strcmp(tok[0], "verbose")) verbose = atoi(tok[1]); else if (!strcmp(tok[0], "warnings")) warnings = atoi(tok[1]); else if (!strcmp(tok[0], "foldcase")) fold_case = atoi(tok[1]); else SetMappingNV(Variables, tok[0], tok[1]); } else { fprintf(stderr, "Expected an '=' in variable assignment: %s. Ignored\n", var); } } /* ______________________________________________________________________ */ /* Bounce through arguments, setting variables and flags. * Arguments: * Argc and Argv, as passed to main(). */ static void HandleArgs( int ac, char *av[] ) { int c, errflag=0; extern char *optarg; extern int optind; while ((c=getopt(ac, av, "df:t:vc:s:o:huSxIl:bHVWi:D:Z")) != EOF) { switch (c) { case 't': tranfile = optarg; break; case 'v': do_validate = 1; break; case 's': sdatafile = optarg; break; case 'c': cmapfile = optarg; break; case 'h': do_tree = 1; break; case 'u': do_summ = 1; break; case 'S': do_stats = 1; break; case 'x': do_context = 1; break; case 'I': do_idlist = 1; break; case 'l': tpt_lib = optarg; break; case 'i': start_id = optarg; break; case 'o': out_file = optarg; break; case 'd': do_DATAhack++; break; case 'f': BOFTTextThresh = atoi(optarg); break; case 'b': interactive = 1; break; case 'W': warnings = 0; break; case 'V': verbose = 1; break; case 'Z': slave = 1; break; case 'H': DoHelpMessage(); exit(0); break; case 'D': CmdLineSetVariable(optarg); break; case '?': errflag = 1; break; } if (errflag) { fprintf(stderr, "Try '%s -H' for help.\n", this_prog); exit(1); } } /* input (ESIS) file name */ if (optind < ac) in_file = av[optind]; /* If doing interactive/browsing, we can't take ESIS from stdin. */ if (interactive && !in_file) { fprintf(stderr, "You must specify ESIS file on cmd line for browser mode.\n"); exit(1); } } /* ______________________________________________________________________ */ /* Simply print out a help/usage message. */ static char *help_msg[] = { "", " -t file Print translated output using translation spec in ", " -s file contains a list of SDATA entity mappings", " -c file contains a list of character mappings", " -v Validate using translation spec specified with -t", " -i id Consider only subtree starting at element with ID ", " -b Interactive browser", " -S Print statistics (how often elements occur, etc.)", " -u Print element usage summary (# of children, depth, etc.)", " -x Print context of each element", " -h Print document hierarchy as a tree", " -o file Write output to . Default is standard output.", " -l dir Set library directory to

. (or env. variable TPT_LIB)", " -I List all IDs used in the instance", " -W Do not print warning messages", " -H Print this help message", " -Dvar=val Set variable 'var' to value 'val'", " file Take input from named file. If not specified, assume stdin.", " File should be output from the 'sgmls' program (ESIS).", NULL }; static void DoHelpMessage() { char **s = help_msg; printf("Instant: SGML document processor/translator, Version %s\n", VERSION); printf("usage: %s [option ...] [file]", this_prog); while (*s) puts(*s++); /* printf("\nVersion: %s\n", _HeadVeRsIoN_); */ } /* ______________________________________________________________________ */ /* Remember an external entity for future reference. * Arguments: * Pointer to entity structure to remember. */ static void AddEntity( Entity_t *ent ) { static Entity_t *last_ent; if (!Entities) { Malloc(1, Entities, Entity_t); last_ent = Entities; } else { Malloc(1, last_ent->next, Entity_t); last_ent = last_ent->next; } *last_ent = *ent; } /* Find an entity, given its entity name. * Arguments: * Name of entity to retrieve. */ static Entity_t * FindEntity( char *ename ) { Entity_t *n; for (n=Entities; n; n=n->next) if (StrEq(ename, n->ename)) return n; return 0; } /* Accumulate lines up to the open tag. Attributes, line number, * entity info, notation info, etc., all come before the open tag. */ static Element_t * AccumElemInfo( FILE *fp ) { char buf[LINESIZE+1]; int c; int i, na; char *cp, *atval; Mapping_t a[100]; Element_t *e; Entity_t ent, *ent2; char **tok; static int Index=0; static Element_t *last_e; Calloc(1, e, Element_t); memset(&ent, 0, sizeof ent); /* clean space for entity info */ /* Also, keep a linked list of elements, so we can easily scan through */ if (last_e) last_e->next = e; last_e = e; e->index = Index++; /* just a unique number for identification */ /* in case these are not set for this element in the ESIS */ e->lineno = last_lineno; e->infile = last_file; na = 0; while (1) { if ((c = getc(fp)) == EOF) break; fgets(buf, LINESIZE, fp); stripNL(buf); switch (c) { case EOF: /* End of input */ fprintf(stderr, "Error: Unexpectedly reached end of ESIS.\n"); exit(1); break; case CMD_OPEN: /* (gi */ e->gi = AddElemName(buf); if (na > 0) { Malloc(na, e->atts, Mapping_t); memcpy(e->atts, a, na*sizeof(Mapping_t)); e->natts = na; na = 0; } /* Check if this elem has a notation attr. If yes, and there is no notation specified, recall the previous one. (feature of sgmls - it does not repeat notation stuff if we the same is used twice in a row) */ if (((atval=FindAttValByName(e, "NAME")) || (atval=FindAttValByName(e, "ENTITYREF")) || (atval=FindAttValByName(e, "EXTERNAL"))) && /* HACK */ (ent2=FindEntity(atval))) { e->entity = ent2; } return e; break; case CMD_ATT: /* Aname val */ i = 3; tok = Split(buf, &i, 0); if (!strcmp(tok[1], "IMPLIED")) break; /* skip IMPLIED atts. */ if (!strcmp(tok[1], "CDATA") || !strcmp(tok[1], "TOKEN") || !strcmp(tok[1], "ENTITY") ||!strcmp(tok[1], "NOTATION")) { a[na].name = AddAttName(tok[0]); a[na].sval = AddAttName(tok[2]); na++; } else { fprintf(stderr, "Error: Bad attr line (%d): A%s %s...\n", e->lineno, tok[0], tok[1]); } break; case CMD_LINE: /* Llineno */ /* These lines come in 2 forms: "L123" and "L123 file.sgml". * Filename is given only at 1st occurance. Remember it. */ if ((cp = strchr(buf, ' '))) { cp++; last_file = strdup(cp); } last_lineno = e->lineno = atoi(buf); e->infile = last_file; break; case CMD_DATA: /* -data */ fprintf(stderr, "Error: Data in AccumElemInfo, line %d:\n%c%s\n", e->lineno, c,buf); /*return e;*/ exit(1); break; case CMD_D_ATT: /* Dename name val */ case CMD_NOTATION: /* Nnname */ case CMD_PI: /* ?pi */ /* This should be reworked soon, as it forces all PI's before the first GI to be ignored. -CSS */ break; case CMD_EXT_ENT: /* Eename typ nname */ i = 3; tok = Split(buf, &i, 0); ent.ename = strdup(tok[0]); ent.type = strdup(tok[1]); ent.nname = strdup(tok[2]); AddEntity(&ent); break; case CMD_INT_ENT: /* Iename typ text */ fprintf(stderr, "Error: Got CMD_INT_ENT in AccumElemInfo: %s\n", buf); break; case CMD_SYSID: /* ssysid */ ent.sysid = strdup(buf); break; case CMD_PUBID: /* ppubid */ ent.pubid = strdup(buf); break; case CMD_FILENAME: /* ffilename */ ent.fname = strdup(buf); break; case CMD_CLOSE: /* )gi */ case CMD_SUBDOC: /* Sename */ case CMD_SUBDOC_S: /* {ename */ case CMD_SUBDOC_E: /* }ename */ case CMD_EXT_REF: /* &name */ case CMD_APPINFO: /* #text */ case CMD_CONFORM: /* C */ default: fprintf(stderr, "Error: Unexpected input in AccumElemInfo, %d:\n%c%s\n", e->lineno, c,buf); exit(1); break; } } fprintf(stderr, "Error: End of AccumElemInfo - should not be here: %s\n", (e && e->gi) ? e->gi : "(No element)"); /* return e;*/ exit(1); } /* Read ESIS lines. * Limitation? Max 5000 children per node. (done for efficiency -- * should do some malloc and bookkeeping games later). * * [ANS-db3l] * Changes to process ESIS input quoting/cmap/sdata at this point. Also * pass in parent element to function so it can look up the hierarchy * for parent attributes if necessary (such as for FORMAT). */ static Element_t * ReadESIS( FILE *fp, int depth, Element_t *parent ) { char *buf, *xlatebuf, *dst, *src, *pch, *sdata; int i, c, ncont, inspace, nomap; Element_t *e, *cur_e; Content_t cont[5000]; Malloc( LINESIZE+1, buf, char ); Malloc( LINESIZE+1, xlatebuf, char ); /* Read input stream - the output of "sgmls", called "ESIS". */ e = AccumElemInfo(fp); e->depth = depth; e->parent = parent; ncont = 0; while (1) { if ((c = getc(fp)) == EOF) break; switch (c) { case EOF: /* End of input */ break; case CMD_DATA: /* -data */ fgets(buf, LINESIZE, fp); stripNL(buf); /* [ANS-db3l] Process/sanitize element data */ /* */ /* The new default behavior (unless "-d" - do_DATAhack is */ /* given) is to process inbound translation of ESIS data */ /* elements at the input stage. This handles all quoting */ /* from [n]sgmls, as well as character mapping. Doing it */ /* now avoids a lot of headaches later. OutputString will */ /* still do Transpec mappings but this way character maps */ /* only apply to input data, thus freeing the SDATA and */ /* translation spec from knowing what is in the CMAP. */ /* */ /* After translating quoting and mapping characters, as */ /* long as this attribute doesn't have a defined format of */ /* linespecific (preserve whitespace/line formatting), the */ /* result is further processed to translate all spans of */ /* whitespace into a single space. */ /* */ /* Using "-d" restores the previous do_DATAhack behavior, */ /* while "-d -d" restores original non-translating mode. */ if (!do_DATAhack) { #ifdef DEBUG fprintf(stderr,"Data: Element '%s'\n Input='%s'\n", e->gi,buf); #endif /* Use the secondary buffer to avoid moving things */ /* around too much. Note that unless no further cmap */ /* translation should be performed (nomap==1), *dst */ /* should point to the last character stored and not */ /* one past (it should be one past for no cmap). */ src = buf; dst = xlatebuf; while (*src) { nomap = 0; if (*src == '\\') { src++; switch (*src) { case '\\': /* Quoted backslash */ *dst = *src++; break; case 'n': /* Newline */ *dst = '\n'; src++; break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': /* Octal encoding */ *dst = ((*src-'0') << 6) + ((*(src+1)-'0') << 3) + ((*(src+2)-'0')); src += 3; break; case '#': case '%': /* Decimal internal(#)/document(%) char */ /* XXX: Handle better */ *dst++ = '['; while (*src != ';') { *dst++ = *src++; } *dst++ = ']'; src++; /* XXX: Whimp out - no translation */ nomap = 1; break; case '|': /* SDATA reference */ sdata = ++src; while (*src && *src != '\\' && *(src+1) != '|') { src++; } if (!*src) break; *src = '\0'; /* Terminate SDATA name */ src += 2; /* and skip past */ if (pch = LookupSDATA(sdata)) { strcpy(dst,pch); dst += strlen(pch); } else { /* Output in brackets */ *dst++ = '['; strcpy(dst,sdata); dst += strlen(sdata); *dst++ = ']'; } /* No cmap translation of sdata */ nomap = 1; break; default: fprintf(stderr, "? Warning: Unknown ESIS escape " "sequence in stream: ('%c')\n", *src); *dst++ = *src++; nomap = 1; } } else { *dst = *src++; } /* Handle any character mapping of last character */ if (!nomap) { if (nCharMap) { for (i=0; igi); #endif break; } cur_e = cur_e->parent; } if (!(pch && !(strcmp(pch,"LINESPECIFIC")))) { #ifdef DEBUG fprintf(stderr," D: Compressing whitespace\n"); #endif /* Replace any span of whitespace with a single space */ dst = src = buf; inspace = 0; while (*src) { i = isspace(*src); if (!(inspace && i)) { *dst++ = i ? ' ' : *src; } inspace = i; src++; } *dst = '\0'; } /* if !linespecific */ #ifdef DEBUG fprintf(stderr," D: Output='%s'\n",buf); #endif } /* if !do_DATAhack */ /* Remove any empty elements (not sure you can ever */ /* get this from NSGMLS, but while I'm here...) */ if (*buf == '\0') { /* Nothing left - skip this chunk */ break; } /* Original "do_DATAhack" support. We check explicitly */ /* here for a do_DATAhack value of 1, since using -d */ /* twice on the command line can now restore the older */ /* default behavior of not doing anything. */ if (do_DATAhack==1 && (buf[0] == '\\') && (buf[1] == 'n')) { if ( ! buf[2] ) break; buf[0] = ' '; memcpy(&buf[1], &buf[2], strlen(buf)-1); } cont[ncont].ch.data = strdup(buf); cont[ncont].type = CMD_DATA; ncont++; break; case CMD_PI: /* ?pi */ fgets(buf, LINESIZE, fp); stripNL(buf); cont[ncont].type = CMD_PI; cont[ncont].ch.data = strdup(buf); ncont++; break; case CMD_CLOSE: /* )gi */ fgets(buf, LINESIZE, fp); stripNL(buf); if (ncont) { e->ncont = ncont; Malloc(ncont, e->cont, Content_t); for (i=0; icont[i] = cont[i]; } free(buf); free(xlatebuf); return e; break; case CMD_OPEN: /* (gi */ /*fprintf(stderr, "+++++ OPEN +++\n");*/ /* break;*/ case CMD_ATT: /* Aname val */ case CMD_D_ATT: /* Dename name val */ case CMD_NOTATION: /* Nnname */ case CMD_EXT_ENT: /* Eename typ nname */ case CMD_INT_ENT: /* Iename typ text */ case CMD_SYSID: /* ssysid */ case CMD_PUBID: /* ppubid */ case CMD_FILENAME: /* ffilename */ ungetc(c, fp); cont[ncont].ch.elem = ReadESIS(fp, depth+1,e); cont[ncont].type = CMD_OPEN; cont[ncont].ch.elem->parent = e; ncont++; break; case CMD_LINE: /* Llineno */ fgets(buf, LINESIZE, fp); break; /* ignore these here */ case CMD_SUBDOC: /* Sename */ case CMD_SUBDOC_S: /* {ename */ case CMD_SUBDOC_E: /* }ename */ case CMD_EXT_REF: /* &name */ case CMD_APPINFO: /* #text */ case CMD_CONFORM: /* C */ default: fgets(buf, LINESIZE, fp); fprintf(stderr, "Error: Unexpected input at %d: '%c%s'\n", e->lineno, c, buf); exit(1); break; } } fprintf(stderr, "Error: End of ReadESIS - should not be here: %s\n", e->gi); free(buf); free(xlatebuf); return NULL; } /* ______________________________________________________________________ */ /* Read input stream, creating a tree in memory of the elements and data. * Arguments: * Filename where instance's ESIS is. */ static void ReadInstance( char *filename ) { int i, n; FILE *fp; Element_t *e; char *idatt; if (filename) { /* if we specified input file. else stdin */ if ((fp=fopen(filename, "r")) == NULL) { perror(filename); exit(1); } } else fp = stdin; last_file = filename; DocTree = ReadESIS(fp, 0, NULL); if (filename) fclose(fp); /* Traverse tree, filling in econt and figuring out which child * (ie. what birth order) each element is. */ DocTree->my_eorder = -1; for (e=DocTree; e; e=e->next) { /* count element children */ for (i=0,n=0; incont; i++) if (IsContElem(e,i)) n++; if (n > 0) Calloc(n, e->econt, Element_t *); for (i=0; incont; i++) if (IsContElem(e,i)) e->econt[e->necont++] = ContElem(e,i); /* count data children */ for (i=0,n=0; incont; i++) if (IsContData(e,i)) n++; if (n > 0) Calloc(n, e->dcont, char *); for (i=0; incont; i++) if (IsContData(e,i)) e->dcont[e->ndcont++] = ContData(e,i); /* where in child order order */ for (i=0; inecont; i++) e->econt[i]->my_eorder = i; /* Does this element have an ID? */ for (i=0; inatts; i++) { if ((idatt=FindAttValByName(e, "ID"))) { AddID(e, idatt); /* remember ID value for quick reference */ e->id = idatt; break; } } } return; } /* ______________________________________________________________________ */ docbook-to-man-2.0.0.orig/Instant/masterVersion.c0100644000176100001440000000025306737404357021226 0ustar debacleusers/* version summary file created by makeVersionFile on Fri Jun 14 23:45:42 1996 */ char _HeadVeRsIoN_[] = "$Id: masterVersion.c,v 1.1.1.1 1998/11/13 21:31:59 db3l Exp $"; docbook-to-man-2.0.0.orig/Instant/sgmls.notes0100644000176100001440000000561306737404357020425 0ustar debacleusers# # 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 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # 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. These are what sgmls feeds us (from the sgmls manpage): Commands (the command is the 1st char): (gi start of element gi )gi end of element gi -data data &name ref to external data entity ?pi processing instruction Aname val attr name and value Dename name val same as A, except external entity ename Nnname sysid pubid def notation nname, ass w/ sysid,pubid Eename typ nname filename def external data entity ename Iename text def internal data entity ename Sename filename... def subdoc entity {ename start of SGML subdocument entity }ename end of SGML subdocument entity Llineno [file] set current line number, filename And attributes values can have the form: IMPLIED CDATA data TOKEN token NOTATION nname ENTITY name... ID id IDREF id... docbook-to-man-2.0.0.orig/Instant/tables.c0100644000176100001440000015260206737404357017645 0ustar debacleusers/* * Copyright 1993 Open Software Foundation, Inc., Cambridge, Massachusetts. * All rights reserved. */ /* * 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 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * 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. * * Originally coded for OSF DTD tables, now recoded (fld 3/27/95) * for CALS-type tables (fragment taken from the DocBook DTD). Then, * *really* upgraded to CALS tables by FLD on 5/28/96. * * This module is for handling table markup, printing TeX or tbl * (tbl) markup to the output stream. Also, table markup checking is * done here. Yes, this depends on the DTD, but it makes translation * specs much cleaner (and makes some things possible). * * Incomplete / not implemented / limitations / notes: * vertical alignment (valign attr) * vertical spanning * row separators are for the whole line, not per cell (the prog looks * at rowsep for the 1st cell and applies it to the whole row) * trusts that units in colwidths are acceptable to LaTeX and tbl * "s" is an acceptable shorthand for "span" in model attributes * * A note on use of OutputString(): Strings with backslashes (\) need lots * of backslashes. You have to escape them for the C compiler, and escape * them again for OutputString() itself. * ________________________________________________________________________ */ #ifndef lint static char *RCSid = "$Header: /aolnet/dev/src/CVS/sgml/docbook-to-man/Instant/tables.c,v 1.2 1998/11/16 22:23:51 db3l Exp $"; #endif #include #include #include #include #include #include #include #include #include "general.h" #include "translate.h" /* text width of page, in inches */ #define TEXTWIDTH 5.5 #define MAXCOLS 100 #define SPAN_NOT 0 #define SPAN_START 1 #define SPAN_CONT 2 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/ /*table parameters */ #define TBLMAXCOL 30 /* max number of columns in tbl table */ #define NAMELEN 40 /* max length of a name */ #define BOFTTHRESHOLD 35 /* text length over which to consider * generating a block of filled text */ /* handy declarations */ typedef enum { Left, Right, Center, Justify, Char, Span } tblalign; typedef enum { TGroup, THead, TFoot, TBody } tblsource; /* source of a spec */ /* table line format information structures */ struct tblcolspec { char name[NAMELEN]; /* colspec's name */ short num; /* column number */ tblsource source; /* where defined */ tblalign align; /* column's alignment */ char alignchar; /* character for alignment */ short aligncharoff; /* offset for alignment */ char colwidth[10]; /* width for column */ char colpwidth[10]; /* proportional widths for column */ bool colsep; /* separator to right of column? */ bool rowsep; /* separator to bottom of column? */ short moreRows; /* value for Morerows */ struct tblcolspec * next; /* next colspec */ }; struct tblspanspec { char name[NAMELEN]; /* spanspec's name */ tblsource source; /* where defined */ struct tblcolspec * start; /* start column */ struct tblcolspec * end; /* end column */ tblalign align; /* span's alignment */ char alignchar; /* character for alignment */ short aligncharoff; /* offset for alignment */ bool colsep; /* separator to right of column? */ bool rowsep; /* separator to bottom of column? */ struct tblspanspec * next; /* next spanspec */ }; struct tblformat { short count; /* count of rows matching this spec */ short cols; /* # of columns */ short rowNum; /* row number */ char colformat[TBLMAXCOL]; /* per-column formats */ char colwidth[TBLMAXCOL][10]; /* per-column widths */ char colpwidth[TBLMAXCOL][10]; /* per-column proportional widths */ char font[TBLMAXCOL][3]; /* column fonts (headers) */ bool colsep[TBLMAXCOL]; /* column separators */ bool rowsep[TBLMAXCOL]; /* row separators */ short moreRows[TBLMAXCOL]; /* moreRows indicator */ struct tblformat * next; /* for the next row */ }; /* table state info */ static short tblcols = 0; /* number of columns in the table */ static short tblrow = 0; /* the current row in the table */ static bool tblTGroupSeen = FALSE; /* seen a TGroup in this table yet? */ static char * tblFrame; /* table frame info */ static bool tblgcolsep; /* global colsep (in table) */ static bool tblgrowsep; /* global rowsep (in table) */ static int tblBOFTCount = 0; /* count of bofts that we've created * (per table) */ int BOFTTextThresh = BOFTTHRESHOLD; /* length of text before we * call it a BOFT */ static bool tblboft = FALSE; /* within a block of filled text? */ static bool tblinBOFT = FALSE; /* within a boft now? */ static struct tblformat * formP = 0; /* THead/TBody format lines */ static struct tblcolspec * tblColSpec = 0; /* colspec structure for table */ static struct tblspanspec * tblSpanSpec = 0; /* spanspec structure for table */ /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/ /* these cover the attributes on the Table, TGroup, Colspec elements */ typedef struct { char *cols; char *align, **align_v; char *colwidth, **colwidth_v; char *colsep, **colsep_v; char *rowsep, **rowsep_v; char *frame; char *orient; int pgwide; int n_align, n_model, n_colwidth, n_colsep; int nc; } TableInfo; /* some flags, set when the table tag is processed, used later */ static int rowsep, siderules; static int frametop, framebot, frameall; static char basemodel[128]; /* model for table (in formatting language) */ static int spaninfo[MAXCOLS]; /* 100 columns, max */ static TableInfo TheTab; /* forward references */ void SetTabAtts(Element_t *, TableInfo *, int); void FreeTabAtts(TableInfo *); void ClearTable(TableInfo *); void CheckTable(Element_t *); void TblTStart(Element_t *, FILE *); void TblTEnd(Element_t *, FILE *); void TblTGroup(Element_t *, FILE *); void TblTGroupEnd(Element_t *, FILE *); void TblTFoot(Element_t *, FILE *); void TblBuildFormat(Element_t *, struct tblformat **, tblsource); struct tblformat * TblBuild1Format(Element_t *, bool, tblsource); char TblGetAlign(short, Element_t *, tblsource); char * TblGetWidth(short, Element_t *, bool, tblsource); char * TblGetFont(short, Element_t *, tblsource); bool TblGetColSep(short, Element_t *, tblsource); bool TblGetRowSep(short, Element_t *, tblsource); short TblGetMoreRows(short, Element_t *, tblsource); bool TblColAdv(short, Element_t *, struct tblformat *, tblsource); struct tblcolspec * TblEntryColSpec(short, Element_t *, tblsource); struct tblspanspec * TblEntrySpanSpec(short, Element_t *, tblsource); bool TblFormatMatch(struct tblformat *, struct tblformat *); void TblPrintFormat(FILE *, struct tblformat *); void TblTRowStart(Element_t *, FILE *); void TblTRowEnd(Element_t *, FILE *); void TblTCellStart(Element_t *, FILE *); int TblCountContent(Element_t *); void TblTCellEnd(Element_t *, FILE *); struct tblcolspec * TblDoColSpec(short, Element_t *, struct tblcolspec *, tblsource); struct tblspanspec * TblDoSpanSpec(Element_t *, struct tblspanspec *, tblsource); struct tblcolspec * TblFindColSpec(char *, tblsource); struct tblcolspec * TblFindColNum(short, tblsource); struct tblspanspec * TblFindSpanSpec(char *, tblsource); void TexTable(Element_t *, FILE *); void TexTableCellStart(Element_t *, FILE *); void TexTableCellEnd(Element_t *, FILE *); void TexTableRowStart(Element_t *, FILE *); void TexTableRowEnd(Element_t *, FILE *); void TexTableTop(Element_t *, FILE *); void TexTableBottom(Element_t *, FILE *); /* ______________________________________________________________________ */ /* Hard-coded stuff for CALS-style DTD tables. * Here are the TABLE attributes (for handy reference): * * Table/InformalTable: * Colsep NUMBER separate all columns in table? * Frame (Top|Bottom|Topbot|All|Sides|None) frame style * Orient (Port | Land) orientation * Pgwide NUMBER wide table? * Rowsep NUMBER separate all rows in the table? * Tabstyle NMTOKEN FOSI table style * * TGroup: * Align (Left|Right|Center|Justify|Char) alignment of cols * Char CDATA Alignment specifier * Charoff NUTOKEN "" "" * Cols NUMBER number of columns * Colsep NUMBER separate all columns in tgroup? * Rowsep NUMBER separate all rows in tgroup? * TGroupstyle NMTOKEN FOSI table group style * * Colspec: * Align (Left|Right|Center|Justify|Char) entry align * Char CDATA Alignment specifier * Charoff NUTOKEN "" "" * Colname NMTOKEN Column identifier * Colnum NUMBER number of column * Colsep NUMBER separate this col from next? * Colwidth CDATA width spec * Rowsep NUMBER serarate entry from following row? * * SpanSpec: * Align (Left|Right|Center|Justify|Char) entry align * Char CDATA Alignment specifier * Charoff NUTOKEN "" "" * Colsep NUMBER separate this col from next? * Nameend NMTOKEN name of rightmost col of a span * Namest NMTOKEN name of leftmost col of a span * Rowsep NUMBER serarate entry from following row? * Spanname NMTOKEN name of a horiz. span * * THead/TFoot/TBody: * VAlign (Top | Middle | Bottom) group placement * * Row: * Rowsep NUMBER separate this row from next? * VAlign (Top | Middle | Bottom) row placement * * Entry: * Align (Left|Right|Center|Justify|Char) entry align * Char CDATA Alignment specifier * Charoff NUTOKEN "" "" * Colname NMTOKEN Column identifier * Colsep NUMBER separate this col from next? * Morerows NUMBER number of addn'l rows in vert straddle * Nameend NMTOKEN name of rightmost col of a span * Namest NMTOKEN name of leftmost col of a span * Rotate NUMBER 90 degree rotation counterclockwise to table? * Rowsep NUMBER serarate entry from following row? * Spanname NMTOKEN name of a horiz. span * VAlign (Top | Middle | Bottom) text vert alignment * * ** OBSOLETE OSF DTD FORM (still used for TeX form): ** Usage in transpec: _calstable [tex|check|clear] ['aspect'] ** where 'aspect' is: ** rowstart stuff to do at start of a row (tests for spanning) ** rowend stuff to do at end of a row (eg, rules, etc.) ** cellstart stuff to do at start of a cell (eg, handle actual ** spanning instructions, etc.) ** cellend stuff to do at end of a cell (eg, cell separator) ** top stuff to do at top of the table ** (like whether or not it needs a starting horiz rule) ** bottom stuff to do at bottom of the table ** (like whether or not it needs an ending horiz rule) ** (nothing) the 'cols' param to LaTeX's \begin{tabular}[pos]{cols} ** or 'options' and 'formats' part in tbl * * * New tbl form: * Usage in transpec: _calstable [tbl] ['aspect'] * where 'aspect' is: * tablestart start a table and do style info * tableend end the table and clean up * tablegroup table TGroup (.T& if not 1st, line format info) * tablegroupend end a TGroup * tablefoot TFoot within a TGroup * rowstart start of a row * rowend end of a row * entrystart start of an entry (block of filled text, if * appropriate) * entryend end of a cell (eg, cell separator) */ /* Procedure to * Arguments: * Pointer to element under consideration. * FILE pointer to where to write output. * Vector of args to _osftable * Count of args to _osftable */ void CALStable( Element_t *e, FILE *fp, char **av, int ac ) { /* Check params and dispatch to appropriate routine */ if (!strcmp(av[1], "tbl")) { if (ac > 2) { if (!strcmp(av[2], "tablestart")) TblTStart(e, fp); else if (!strcmp(av[2], "tableend")) TblTEnd(e, fp); else if (!strcmp(av[2], "tablegroup")) TblTGroup(e, fp); else if (!strcmp(av[2], "tablegroupend")) TblTGroupEnd(e, fp); else if (!strcmp(av[2], "tablefoot")) TblTFoot(e, fp); else if (!strcmp(av[2], "rowstart")) TblTRowStart(e, fp); else if (!strcmp(av[2], "rowend")) TblTRowEnd(e, fp); else if (!strcmp(av[2], "entrystart")) TblTCellStart(e, fp); else if (!strcmp(av[2], "entryend")) TblTCellEnd(e, fp); else fprintf(stderr, "Unknown %s table instruction: %s\n", av[1], av[2]); } else { fprintf(stderr, "Incomplete %s table instruction\n"); } } else if (!strcmp(av[1], "tex")) { if (ac > 1 && !strcmp(av[1], "check")) CheckTable(e); else if (ac > 1 && !strcmp(av[1], "clear")) ClearTable(&TheTab); if (ac > 2) { if (!strcmp(av[2], "cellstart")) TexTableCellStart(e, fp); else if (!strcmp(av[2], "cellend")) TexTableCellEnd(e, fp); else if (!strcmp(av[2], "rowstart")) TexTableRowStart(e, fp); else if (!strcmp(av[2], "rowend")) TexTableRowEnd(e, fp); else if (!strcmp(av[2], "top")) TexTableTop(e, fp); else if (!strcmp(av[2], "bottom")) TexTableBottom(e, fp); else fprintf(stderr, "Unknown %s table instruction: %s\n", av[1], av[2]); } else TexTable(e, fp); } else fprintf(stderr, "Unknown table type: %s\n", av[1]); } /* ClearTable -- start a new table process * */ void ClearTable( TableInfo * t ) { memset(t, 0, sizeof(TableInfo)); } /* ______________________________________________________________________ */ /* Set values of the our internal table structure based on the table's * attributes. (This is called for tables, tgroups, colspecs, and rows, * since tables and rows share many of the same attributes.) * Arguments: * Pointer to element under consideration. * Pointer table info structure which will be filled in. * Flag saying whether or not to set global variables based on attrs. */ void SetTabAtts( Element_t *e, TableInfo *t, int set_globals ) { char *at; Element_t * ep; /* remember values of attributes */ if ((at = FindAttValByName(e, "ALIGN"))) t->align = at; if ((at = FindAttValByName(e, "COLWIDTH"))) t->colwidth = at; if ((at = FindAttValByName(e, "COLSEP"))) t->colsep = at; if ((at = FindAttValByName(e, "FRAME"))) t->frame = at; if ((at = FindAttValByName(e, "COLS"))) t->cols = at; /* Set some things for later when processing this table */ if (set_globals) { rowsep = 1; frametop = framebot = 1; /* default style */ /* For now we look at the first number of rowsep - it controls the * horiz rule for then entire row. (not easy to specify lines that * span only some columns in tex or tbl. */ if ((at = FindAttValByName(e, "ROWSEP"))) rowsep = atoi(at); } if (t->frame) { /* Top|Bottom|Topbot|All|Sides|None */ if (!strcmp(t->frame, "NONE") || !strcmp(t->frame, "SIDES")) frametop = framebot = 0; else if (!strcmp(t->frame, "TOP")) framebot = 0; else if (!strcmp(t->frame, "BOTTOM")) frametop = 0; } /* tbl and tex like lower case for units. convert. */ if (t->colwidth) { char *cp; for (cp=t->colwidth; *cp; cp++) if (isupper(*cp)) *cp = tolower(*cp); } /* Now, split (space-separated) strings into vectors. Hopefully, the * number of elements in each vector matches the number of columns. */ t->align_v = Split(t->align, &t->n_align, S_STRDUP|S_ALVEC); t->colwidth_v = Split(t->colwidth, &t->n_colwidth, S_STRDUP|S_ALVEC); t->colsep_v = Split(t->colsep, &t->n_colsep, S_STRDUP|S_ALVEC); /* Determin the _numeric_ number of columns, "nc". MUST be specified * in Cols attribute of TGroup element. */ if (t->cols) t->nc = atoi(t->cols); } /* ______________________________________________________________________ */ /* Free the storage of info use by the table info structure. (not the * structure itself, but the strings its elements point to) * Arguments: * Pointer table info structure to be freed. */ void FreeTabAtts( TableInfo *t ) { if (!t) return; if (t->align_v) free(*t->align_v); if (t->colwidth_v) free(*t->colwidth_v); if (t->colsep_v) free(*t->colsep_v); } /* ______________________________________________________________________ */ /* Check the attributes and children of the table pointed to by e. * Report problems and inconsistencies to stderr. * Arguments: * Pointer to element (table) under consideration. */ void CheckTable( Element_t *e ) { int pr_loc=0; /* flag to say if we printed location */ int i, r, c; Element_t *ep, *ep2; float wt; char *tpref = "Table Check"; /* prefix for err messages */ char *ncolchk = "Table Check: %s ('%s') has wrong number of tokens. Expecting %d.\n"; if (strcmp(e->gi, "TABLE") && strcmp(e->gi, "INFORMALTABLE") && strcmp(e->gi, "TGROUP") && strcmp(e->gi, "COLSPEC") && strcmp(e->gi, "ROW") ) { fprintf(stderr, "%s: Not pointing to a table element(%s)!\n", tpref, e->gi); return; } FreeTabAtts(&TheTab); /* free storage, if allocated earlier */ SetTabAtts(e, &TheTab, 1); /* look at attributes */ #if FALSE /* NCOLS attribute set? */ if (!TheTab.ncols) { pr_loc++; fprintf(stderr, "%s: NCOLS attribute missing. Inferred as %d.\n", tpref, TheTab.nc); } /* ALIGN attribute set? */ if (!TheTab.align) { pr_loc++; fprintf(stderr, "%s: ALIGN attribute missing.\n", tpref); } /* See if the number of cells in each row matches */ for (r=0; rnecont && (ep=e->econt[r]); r++) { /* each TGroup */ for (i=0; inecont && (ep2=ep->econt[i]); i++) { if ( strcmp(ep2->gi, "TBODY") ) /* only TBodys */ continue; for (c=0; cnecont; c++) { if (ep2->econt[c]->necont != TheTab.nc) { pr_loc++; fprintf(stderr, "%s: COLS (%d) differs from actual number of cells (%d) in row %d.\n", tpref, TheTab.nc, ep2->econt[c]->necont, c); } } } } #endif /* Check ALIGN */ if (TheTab.align) { if (TheTab.nc != TheTab.n_align) { /* number of tokens OK? */ pr_loc++; fprintf(stderr, ncolchk, "ALIGN", TheTab.align, TheTab.nc); } else { /* values OK? */ for (i=0; inecont; i++) { } if ((at = FindAttValByName(e, "MODEL"))) { /* Split into tokens, then look at each for the word "span" */ n = TheTab.nc; spans = Split(at, &n, S_STRDUP|S_ALVEC); /* Mark columns as start-of-span, in-span, or not spanned. Remember * in at list, "spaningo". (Span does not make sense in 1st column.) */ for (i=1,inspan=0; iecont[0], &TheTab, 1); /* attrs of TGroup */ /* Figure out the widths, based either on "colwidth". */ if (TheTab.colwidth && TheTab.nc == TheTab.n_colwidth) { widths = TheTab.colwidth_v; } siderules = 1; if (TheTab.frame) if (strcmp(TheTab.frame, "ALL") && strcmp(TheTab.frame, "SIDES")) siderules = 0; if (siderules) OutputString("|", fp, 1); for (i=0; imy_eorder] == SPAN_START) { for (i=e->my_eorder+1,n=1; ; i++) { if (spaninfo[i] == SPAN_CONT) n++; else break; } sprintf(buf, "\\\\multicolumn{%d}{%sc%s}", n, (siderules?"|":""), (siderules?"|":"")); OutputString(buf, fp, 1); } #ifdef New if ((at = FindAttValByName(e->parent, "ALIGN"))) { /* no span, but user wants to change the alignment */ h_v = Split(wbuf, 0, S_ALVEC|S_STRDUP); OutputString("\\\\multicolumn{1}{%sc%s}", n, fp, 1); } #endif if (spaninfo[e->my_eorder] != SPAN_CONT) OutputString("{", fp, 1); } /* * Arguments: * Pointer to element (cell) under consideration. * FILE pointer to where to write output. */ void TexTableCellEnd( Element_t *e, FILE *fp ) { if (spaninfo[e->my_eorder] != SPAN_CONT) OutputString("} ", fp, 1); /* do cell/col separators */ if (e->my_eorder < (TheTab.nc-1)) { if (spaninfo[e->my_eorder] == SPAN_NOT || spaninfo[e->my_eorder+1] != SPAN_CONT) OutputString("& ", fp, 1); } } /* Look at model for spanning. If set, remember it for when doing the cells. * Arguments: * Pointer to element (row) under consideration. * FILE pointer to where to write output. */ void TexTableRowStart( Element_t *e, FILE *fp ) { check_for_spans(e); } /* * Arguments: * Pointer to element (row) under consideration. * FILE pointer to where to write output. */ void TexTableRowEnd( Element_t *e, FILE *fp ) { char *at; /* check this row's attributes */ if ((at = FindAttValByName(e, "ROWSEP"))) { if (at[0] == '1') OutputString("\\\\\\\\[2mm] \\\\hline ", fp, 1); } else if (rowsep) OutputString("\\\\\\\\ ", fp, 1); else OutputString("\\\\\\\\ ", fp, 1); } /* * Arguments: * Pointer to element (table) under consideration. * FILE pointer to where to write output. */ void TexTableTop(Element_t *e, FILE *fp) { if (frametop) OutputString("\\\\hline", fp, 1); } void TexTableBottom(Element_t *e, FILE *fp) { if (framebot) OutputString("\\\\hline", fp, 1); } /* ______________________________________________________________________ */ /* ______________________________________________________________________ */ /* ______________________________________________________________________ */ /* ______________________________________________________________________ */ /* ______________________________________________________________________ */ /* ___________________________| |____________________________ */ /* ___________________________| TBL STUFF |____________________________ */ /* ___________________________| |____________________________ */ /* ___________________________|_____________|____________________________ */ /* ______________________________________________________________________ */ /* ______________________________________________________________________ */ /* ______________________________________________________________________ */ /* ______________________________________________________________________ */ /* TblTStart() -- start a table and do style information * * TO DO: * * do .TS * find global rowsep and colsep */ void TblTStart(Element_t * ep, FILE * fP) { register char * cp; register struct Element_t * ep2; OutputString("^.TS^", fP, 1); tblTGroupSeen = FALSE; tblinBOFT = FALSE; /* within a boft? */ tblBOFTCount = 0; /* count of Blocks of Filled Text that * we've created */ tblgcolsep = (cp = FindAttValByName(ep, "COLSEP")) && !strcmp(cp, "1"); tblgrowsep = (cp = FindAttValByName(ep, "ROWSEP")) && !strcmp(cp, "1"); } /* TblTEnd() -- end a table and do any cleanup * * TO DO: * * do .TE * * deallocate format line info */ void TblTEnd(Element_t * ep, FILE * fP) { register struct tblformat * ffp, * ffp2; if ( tblBOFTCount > 31 ) { fprintf(stderr, "# warning, line %d: created %d blocks of filled text in one table\n", ep->lineno, tblBOFTCount); fprintf(stderr, "#\t\t(31 is the limit in some systems)\n"); } OutputString("^.TE^", fP, 1); for ( ffp=formP; ffp; ffp=ffp2 ) { ffp2 = ffp->next; free(ffp); /* clear entire list */ } formP = 0; } /* TblTTGroup() -- do body work (row format info) * * TO DO: * * set number of columns * * if this is the first TGroup of this table, do style info: * a. alignment * b. defaults: tab * c. box vx allbox * * do format info: * a. generate tableformat structure * b. output it * * prepare structures for colspecs and spanspecs * */ void TblTGroup(Element_t * ep, FILE * fP) { register int i, j, k; register char * cp, * cp2; register Element_t * ep2, ep3; register struct tblcolspec * tcsp, * tcsp2; register struct tblspanspec * tssp, * tssp2; tblColSpec = 0; /* make sure they're clear */ tblSpanSpec = 0; /* set the number of columns */ tblcols = atoi(FindAttValByName(ep, "COLS")); /* do colspecs */ tblColSpec = tcsp = TblDoColSpec(0, ep, 0, TGroup); /* do TGroup first -- it becomes the default */ for ( i=0, k=1; i < ep->necont; i++ ) { if ( !strcmp(ep->econt[i]->gi, "COLSPEC") ) { tcsp2 = TblDoColSpec(k, ep->econt[i], tblColSpec, TGroup); tcsp->next = tcsp2; /* put into list */ tcsp = tcsp2; k = tcsp2->num + 1; /* next column number */ } if ( !strcmp(ep->econt[i]->gi, "THEAD") ) { ep2 = ep->econt[i]; for ( j=0, k=1; j < ep2->necont; j++ ) { if ( !strcmp(ep2->econt[j]->gi, "COLSPEC") ) { tcsp2 = TblDoColSpec(k, ep2->econt[j], tblColSpec, THead); tcsp->next = tcsp2; /* put into list */ tcsp = tcsp2; k = tcsp2->num + 1; /* next column number */ } } } if ( !strcmp(ep->econt[i]->gi, "TFOOT") ) { ep2 = ep->econt[i]; for ( j=0, k=1; j < ep2->necont; j++ ) { if ( !strcmp(ep2->econt[j]->gi, "COLSPEC") ) { tcsp2 = TblDoColSpec(k, ep2->econt[j], tblColSpec, TFoot); tcsp->next = tcsp2; /* put into list */ tcsp = tcsp2; k = tcsp2->num + 1; /* next column number */ } } } if ( !strcmp(ep->econt[i]->gi, "TBODY") ) { ep2 = ep->econt[i]; for ( j=0, k=1; j < ep2->necont; j++ ) { if ( !strcmp(ep2->econt[j]->gi, "COLSPEC") ) { tcsp2 = TblDoColSpec(k, ep2->econt[j], tblColSpec, TBody); tcsp->next = tcsp2; /* put into list */ tcsp = tcsp2; k = tcsp2->num + 1; /* next column number */ } } } } /* do spanspecs */ tblSpanSpec = tssp = TblDoSpanSpec(ep, 0, TGroup); /* do TGroup first -- it becomes the default */ for ( i=0; i < ep->necont; i++ ) { if ( !strcmp(ep->econt[i]->gi, "SPANSPEC") ) { tssp2 = TblDoSpanSpec(ep->econt[i], tblSpanSpec, TGroup); tssp->next = tssp2; /* put into list */ tssp = tssp2; } } /* if this is the first TGroup in this table, do style stuff */ if ( ! tblTGroupSeen ) { OutputString("tab(\007)", fP, 1); ep2 = ep->parent; if ( ! (tblFrame = FindAttValByName(ep2, "FRAME")) ) tblFrame = ""; if ( !strcmp(tblFrame, "ALL") ) { if ( tcsp->colsep && tcsp->rowsep ) OutputString(" allbox", fP, 1); else OutputString(" box", fP, 1); } if ( (cp = FindAttValByName(ep, "ALIGN")) && !strcmp(cp, "CENTER") ) { OutputString(" center", fP, 1); } OutputString(";\n", fP, 1); tblTGroupSeen = TRUE; } /* do format stuff -- step through all THead rows then all TBody * rows. Build a list of tblformats that describe all of them. * then output the resulting list. */ for ( i=0; i < ep->necont; i++ ) { if ( !strcmp(ep->econt[i]->gi, "THEAD") ) { TblBuildFormat(ep->econt[i], &formP, THead); /* add in those rows */ break; } } for ( i=0; i < ep->necont; i++ ) { if ( !strcmp(ep->econt[i]->gi, "TBODY") ) { TblBuildFormat(ep->econt[i], &formP, TBody); /* add in those rows */ break; } } TblPrintFormat(fP, formP); tblrow = 0; /* the current row within this format */ } /* TblTGroupEnd() -- end a TGroup * * TO DO: * * deallocate colspecs and spanspecs * * [ANS-db3l] * I found that if you ended a table with a spanning entry, tbl got * confused and seemed to use the spanning row definition for the default * row entry in the table. So we output a final row adjustment if the * current (last) row format wasn't the same as the tgroup element. The * code is adapted from from the original code in TblTFoot(). */ void TblTGroupEnd(Element_t * ep, FILE * fP) { register struct tblcolspec * tcsp, * tcsp2; register struct tblspanspec * tssp, * tssp2; register struct tblformat * ffp, * ffp2; static struct tblformat * tfp, * tfp2; tfp = TblBuild1Format(ep, FALSE, TGroup);/* gen format for the row */ for ( tfp2=formP; tfp2 && tfp2->next; tfp2=tfp2->next ) ; if (!TblFormatMatch(tfp,tfp2)) { for ( ffp=formP; ffp; ffp=ffp2 ) { ffp2 = ffp->next; free(ffp); /* clear entire list */ } formP = tfp; /* this becomes the prevailing format */ OutputString("^.T&^", fP, 1); TblPrintFormat(fP, formP); } for ( tcsp=tblColSpec; tcsp; tcsp=tcsp2 ) { tcsp2 = tcsp->next; free(tcsp); } for ( tssp=tblSpanSpec; tssp; tssp=tssp2 ) { tssp2 = tssp->next; free(tssp); } } /* TblTTFoot() -- do body foot work (row format info) * * TO DO: * * do format info: * a. generate tableformat structure * i. if it is only 1 line long and matches the * prevailing format, just output rows. * ii. else, output a .T& and the new format specs */ void TblTFoot(Element_t * ep, FILE * fP) { register struct tblformat * ffp, * ffp2; static struct tblformat * tfp, * tfp2; TblBuildFormat(ep, &tfp, TFoot); /* gen format for the foot */ for ( tfp2=formP; tfp2 && tfp2->next; tfp2=tfp2->next ) ; if ( tfp->next || !TblFormatMatch(tfp, tfp2) ) { for ( ffp=formP; ffp; ffp=ffp2 ) { ffp2 = ffp->next; free(ffp); /* clear entire list */ } formP = tfp; /* this becomes the prevailing format */ OutputString("^.T&^", fP, 1); TblPrintFormat(fP, formP); } tblrow = 0; /* the current row within this format */ } /* TblBuildFormat() -- build a format structure out of a set of * rows and columns * */ void TblBuildFormat(Element_t * ep, /* parent of rows.. */ struct tblformat ** fp, /* pointer to head of struct we're * building */ tblsource source) /* type of record */ { register int i; register struct tblformat * lfp; /* "current" format */ register struct tblformat * nfp; /* the next format */ for ( lfp= *fp; lfp && lfp->next; lfp=lfp->next ) ; /* find end of format list */ for ( i=0; i < ep->necont; i++ ) if ( !strcmp(ep->econt[i]->gi, "ROW") ) break; /* find where rows start */ for ( ; i < ep->necont; i++ ) { nfp = TblBuild1Format(ep->econt[i], FALSE, source); /* do one row */ if ( !lfp ) lfp = *fp = nfp; /* first one */ else if ( TblFormatMatch(lfp, nfp) ) lfp->count++; /* matches */ else { lfp->count = 1; /* only 1 so far */ lfp->next = nfp; /* new one */ lfp = nfp; } } } /* TblBuild1Format() -- build one row's worth of format information * * * [ANS-db3l] * Added check for spanning columns, and if they exist, move any width * information to the previous non-spanning column (scanning left) since * that seems to be the way that tbl wants it. E.g., tbl works if you * have "lw(6i) s s" but not with "lw(2i) sw(2i) sw(2i)". * */ struct tblformat * TblBuild1Format(Element_t * rp, /* the row to deal with */ bool addinRowsep, /* insert rowsep into model? */ tblsource source) /* type type of row */ { register int i, j; register bool allProp; float totalProp; register struct tblformat * tfp; register Element_t * ep; /* entry pointer */ Calloc(1, tfp, struct tblformat); tfp->cols = tblcols; ep = (rp->necont) ? rp->econt[0] : 0; /* first entry */ allProp = TRUE; totalProp = 0; for ( i=1; i <= tblcols; i++ ) { tfp->colformat[i] = TblGetAlign(i, ep, source); strcpy(tfp->colwidth[i], TblGetWidth(i, ep, TRUE, source)); strcpy(tfp->colpwidth[i], TblGetWidth(i, ep, FALSE, source)); if ( allProp ) { allProp = tfp->colpwidth[i][0]; totalProp += atof(tfp->colpwidth[i]); } if (i>1 && tfp->colformat[i] == 's') { for (j=i; j>=1; j--) { if (tfp->colformat[j] != 's') { if (tfp->colwidth[i][0]) { sprintf(tfp->colwidth[j],"%fi", atof(tfp->colwidth[j])+ atof(tfp->colwidth[i])); } if (tfp->colpwidth[i][0]) { sprintf(tfp->colpwidth[j],"%fi", atof(tfp->colpwidth[j])+ atof(tfp->colpwidth[i])); } tfp->colwidth[i][0] = '\0'; tfp->colpwidth[i][0] = '\0'; break; } } if (j<1) { fprintf(stderr, "? Warning: missed earlier column to " "add span width to\n"); } } strcpy(tfp->font[i], TblGetFont(i, ep, source)); tfp->colsep[i] = tblgcolsep || TblGetColSep(i, ep, source); if ( addinRowsep ) tfp->rowsep[i] = tblgrowsep || TblGetRowSep(i, ep, source); tfp->moreRows[i] = TblGetMoreRows(i, ep, source); if ( (i < rp->necont) && TblColAdv(i, ep, tfp, source) ) { ep = rp->econt[i]; } } /* turn proportional widths into real widths */ if ( allProp ) { for ( i=1; i <= tblcols; i++ ) { if (tfp->colpwidth[i][0]) sprintf(tfp->colwidth[i], "%fi", (atof(tfp->colpwidth[i]) / totalProp) * TEXTWIDTH); } } return tfp; } /* TblGetAlign() -- get alignment spec for a entry * */ char TblGetAlign(short col, /* column number */ Element_t * entry, /* the entry */ tblsource source) /* context */ { register struct tblcolspec * tcsp; register struct tblspanspec * tssp; register tblalign talign; if ( entry && (tssp = TblEntrySpanSpec(col, entry, source)) ) { talign = tssp->align; free(tssp); } else if ( entry && (tcsp = TblEntryColSpec(col, entry, source)) ) { talign = tcsp->align; free(tcsp); } else { return 'l'; } switch ( talign ) { case Left: return 'l'; case Right: return 'r'; case Center: return 'c'; case Justify: return 'l'; case Char: return 'd'; case Span: return 's'; } } /* TblGetWidth() -- get width spec, if any, for a entry * */ char * TblGetWidth(short col, /* column number */ Element_t * entry, /* the entry */ bool literal, /* literal (or proportional) */ tblsource source) /* context */ { register struct tblcolspec * tcsp; register struct tblspanspec * tssp; static char colWidth[10]; colWidth[0] = 0; if ( entry && (tcsp = TblEntryColSpec(col, entry, source)) && tcsp->colwidth[0] ) { if ( !strstr(tcsp->colwidth, "*") ) { if ( literal ) strcpy(colWidth, tcsp->colwidth); } else { if ( ! literal ) strcpy(colWidth, tcsp->colwidth); } free(tcsp); } return colWidth; } /* TblGetFont() -- get font spec, if any, for a entry * */ char * TblGetFont(short col, /* column number */ Element_t * entry, /* the entry */ tblsource source) /* context */ { register struct tblcolspec * tcsp; register struct tblspanspec * tssp; return ""; } /* TblGetColSep() -- get column separater spec, if any, for a entry * */ bool TblGetColSep(short col, /* column number */ Element_t * entry, /* the entry */ tblsource source) /* context */ { register struct tblcolspec * tcsp; register struct tblspanspec * tssp; register bool colsep; if ( entry && (tssp = TblEntrySpanSpec(col, entry, source)) ) { colsep = tssp->colsep; free(tssp); } else if ( entry && (tcsp = TblEntryColSpec(col, entry, source)) ) { colsep = tcsp->colsep; free(tcsp); } else colsep = FALSE; return colsep; } /* TblGetRowSep() -- get row separater spec, if any, for a entry * */ bool TblGetRowSep(short col, /* column number */ Element_t * entry, /* the entry */ tblsource source) /* context */ { register struct tblcolspec * tcsp; register struct tblspanspec * tssp; register bool rowsep; if ( entry && (tssp = TblEntrySpanSpec(col, entry, source)) ) { rowsep = tssp->rowsep; free(tssp); } else if ( entry && (tcsp = TblEntryColSpec(col, entry, source)) ) { rowsep = tcsp->rowsep; free(tcsp); } else { rowsep = FALSE; } return rowsep; } /* TblGetmoreRows() -- get moreRows value * */ bool TblGetMoreRows(short col, /* column number */ Element_t * entry, /* the entry */ tblsource source) /* context */ { register char * cp; if ( cp = FindAttValByName(entry, "MOREROWS") ) return atoi(cp); else return 0; } /* TblColAdv() -- advance pointer to next entry, if appropriate * */ bool TblColAdv(short col, /* the current column */ Element_t *ep, /* pointer to entry */ struct tblformat * tfp, /* pointer to prevailing format */ tblsource source) /* context */ { register bool bump; register struct tblspanspec * tssp; bump = TRUE; if ( tssp = TblEntrySpanSpec(col, ep, source) ) { bump = tssp->align != Span; free(tssp); } return bump; } /* TblEntryColSpec() -- get a completely localized colspec for an entry * */ struct tblcolspec * TblEntryColSpec(short num, /* column number */ Element_t * ep, /* entry */ tblsource source) /* context */ { register int i; register bool throwAway; register char * cp; register struct tblcolspec * tcsp, * tcsp2; tcsp = tcsp2 = 0; throwAway = FALSE; if ( (cp = FindAttValByName(ep, "COLNAME")) ) { if ( ! (tcsp = TblFindColSpec(cp, source)) ) { fprintf(stderr, "? can't find column name '%s'\n", cp); } } if ( tcsp2 = TblFindColNum(num, source) ) { tcsp = TblDoColSpec(num, ep, tcsp2, source); throwAway = TRUE; } tcsp2 = TblDoColSpec(num, ep, tcsp, source); if ( throwAway ) free(tcsp); return tcsp2; } /* TblEntrySpanSpec() -- get a completely localized spanspec for an entry * */ struct tblspanspec * TblEntrySpanSpec(short num, /* column number */ Element_t * ep, /* entry */ tblsource source) /* context */ { register char * cp, * cp2; register struct tblspanspec * tssp, * tssp2; tssp2 = 0; if ( !(cp = FindAttValByName(ep, "SPANNAME")) || !(tssp2 = TblFindSpanSpec(cp, source)) ) { if ( !FindAttValByName(ep, "NAMEST") ) return 0; } tssp = TblDoSpanSpec(ep, tssp2, source); if ( tssp->start && tssp->end && (tssp->start->num < num) && (tssp->end->num >= num) ) { tssp->align = Span; } return tssp; } /* TblFormatMatch() -- compare two format rows for consistency * */ bool TblFormatMatch(struct tblformat * tf1, /* one row */ struct tblformat * tf2) /* the other */ { register int i; if ( tf1->cols != tf2->cols ) { return FALSE; } for ( i=0; i < tf1->cols; i++ ) { if ( tf1->colformat[i] != tf2->colformat[i] ) { return FALSE; } if ( strcmp(tf1->colwidth[i], tf2->colwidth[i]) ) { return FALSE; } if ( strcmp(tf1->font[i], tf2->font[i]) ) { return FALSE; } if ( tf1->colsep[i] != tf2->colsep[i] ) { return FALSE; } if ( tf1->rowsep[i] != tf2->rowsep[i] ) { return FALSE; } if ( tf1->moreRows[i] || tf2->moreRows[i] ) { return FALSE; } } return TRUE; } /* TblPrintFormat() -- print a tbl format structure * */ void TblPrintFormat(FILE * fP, /* where to print */ struct tblformat * tfp) /* the structure */ { register int i; register struct tblformat * tfp2, * tfp3; static char buf[3] = "\000\000"; for ( tfp2=tfp, tfp3=0; tfp2; tfp2=tfp2->next ) { for ( i=1; i <= tfp->cols; i++ ) { if ( i > 1 ) OutputString(" ", fP, 1); if ( tfp3 && tfp3->moreRows[i] ) OutputString("\\^", fP, 1); else { buf[0] = tfp2->colformat[i]; OutputString(buf, fP, 1); } if ( tfp2->colwidth[i][0] ) { OutputString("w(", fP, 1); OutputString(tfp2->colwidth[i], fP, 1); OutputString(")", fP, 1); } if ( tfp2->font[i][0] ) OutputString(tfp2->font[i], fP, 1); if ( tfp2->colsep[i] ) OutputString("|", fP, 1); } if ( ! tfp2->next ) OutputString(".", fP, 1); OutputString("^", fP, 1); tfp3 = tfp2; } } /* TblTRowStart() -- start a row (not much to do) * * TO DO: * * nothing.. * * [ANS-db3l] * We need to look and see if the upcoming row is going to be any different * than the current row formatting in place, and if so, output a new * row control line and make it the default format. This is adapted from * the existing code in TblTFoot(). * */ void TblTRowStart(Element_t * ep, FILE * fP) { register struct tblformat * ffp, * ffp2; static struct tblformat * tfp, * tfp2; tfp = TblBuild1Format(ep, FALSE, TGroup);/* gen format for the row */ for ( tfp2=formP; tfp2 && tfp2->next; tfp2=tfp2->next ) ; if (!TblFormatMatch(tfp,tfp2)) { for ( ffp=formP; ffp; ffp=ffp2 ) { ffp2 = ffp->next; free(ffp); /* clear entire list */ } formP = tfp; /* this becomes the prevailing format */ OutputString("^.T&^", fP, 1); TblPrintFormat(fP, formP); } tblrow++; /* except note that we're within a new row */ } /* TblTRowEnd() -- end a row * * TO DO: * * output a row end character (newline) * if the current row had a rowsep, then output a "fake" row * with underlines in the proper place(s). */ void TblTRowEnd(Element_t * ep, FILE * fP) { register int i, k; register tblsource source; register bool startedRow, didSep; register struct tblformat * rfp; OutputString("^", fP, 1); /* get the format for this row */ if ( !strcmp(ep->parent->gi, "TFoot") ) source = TFoot; else if ( !strcmp(ep->parent->gi, "THead") ) source = THead; else source = TBody; rfp = TblBuild1Format(ep, TRUE, source); startedRow = FALSE; didSep = FALSE; for ( i=1; i <= formP->cols; i++ ) { if ( rfp->rowsep[i] || (didSep && (rfp->colformat[i] == 's')) ) { if ( ! startedRow ) { OutputString("^", fP, 1); for ( k=1; k < i; k++ ) OutputString("\007", fP, 1); startedRow = TRUE; } OutputString("_\007", fP, 1); didSep = TRUE; } else { if ( startedRow ) OutputString("\007", fP, 1); } didSep = FALSE; } free(rfp); /* clear that row.. */ if ( startedRow ) OutputString("^", fP, 1); } /* TblTEntryStart() -- start an entry (block of filled text if * appropriate) * * TO DO: * * if text length > BOFTTextThresh or there is PI, * then output "T{\n", else do nothing * */ void TblTCellStart(Element_t * ep, FILE * fP) { register int i; register Element_t * ep2; register bool sawPI; for ( i=0, sawPI=FALSE; (i < ep->ncont) && !sawPI; i++ ) if ( ep->cont[i].type == '?' ) sawPI = TRUE; if ( sawPI || (TblCountContent(ep) > BOFTTextThresh) ) { tblBOFTCount++; OutputString("T{^", fP, 1); tblinBOFT = TRUE; /* within a boft now */ } } /* TblCountContent() -- count all content below the given element * * */ int TblCountContent(Element_t * ep) /* the element to look under */ { register int i, count; count = 0; for ( i=0; i < ep->ncont; i++ ) { if ( ep->cont[i].type == '-' ) { count += strlen(ep->cont[i].ch.data); } else if ( ep->cont[i].type == '(' ) { count += TblCountContent(ep->cont[i].ch.elem); } } return count; } /* TblTEntryEnd() -- end an entry * * TO DO: * * if within BOFT, output "T}" * if not last entry, output tab character * */ void TblTCellEnd(Element_t * ep, FILE * fP) { register Element_t * ep2; if ( tblinBOFT ) { OutputString("^T}", fP, 1); tblinBOFT = FALSE; /* back out again */ } for ( ep2=ep->next; ep2; ep2=ep2->next ) { if ( !strcmp(ep2->gi, "ENTRY") || !strcmp(ep2->gi, "ENTRYTBL") ) { OutputString("\007", fP, 1); break; } if ( !strcmp(ep2->gi, "ROW") ) break; } } /* TblDoColSpec() -- process one element to create a new colspec * * */ struct tblcolspec * TblDoColSpec(short number, /* this column number */ Element_t * ep, /* element containing colspec stuff */ struct tblcolspec * pcsp, /* prevailing colspec (with defaults) */ tblsource source) /* precedence level of the resulting spec */ { register char * cp; register struct tblcolspec * tcsp; Calloc(1, tcsp, struct tblcolspec); if ( cp = FindAttValByName(ep, "COLNAME") ) strcpy(tcsp->name, cp); tcsp->num = number; tcsp->source = source; if ( cp = FindAttValByName(ep, "ALIGN") ) { if ( !strcmp(cp, "LEFT") ) tcsp->align = Left; else if ( !strcmp(cp, "RIGHT") ) tcsp->align = Right; else if ( !strcmp(cp, "CENTER") ) tcsp->align = Center; else if ( !strcmp(cp, "JUSTIFY") ) tcsp->align = Justify; else if ( !strcmp(cp, "CHAR") ) tcsp->align = Char; } else tcsp->align = ( pcsp ) ? pcsp->align : Left; if ( cp = FindAttValByName(ep, "CHAR") ) tcsp->alignchar = cp[0]; else tcsp->alignchar = ( pcsp ) ? pcsp->alignchar : 0; if ( cp = FindAttValByName(ep, "CHAROFF") ) tcsp->aligncharoff = atoi(cp); else tcsp->aligncharoff = ( pcsp ) ? pcsp->aligncharoff : 0; if ( cp = FindAttValByName(ep, "COLWIDTH") ) strcpy(tcsp->colwidth, cp); else strcpy(tcsp->colwidth, ( pcsp ) ? pcsp->colwidth : ""); if ( cp = FindAttValByName(ep, "COLSEP") ) tcsp->colsep = !strcmp(cp, "1"); else tcsp->colsep = ( pcsp ) ? pcsp->colsep : FALSE; if ( cp = FindAttValByName(ep, "ROWSEP") ) tcsp->rowsep = !strcmp(cp, "1"); else tcsp->rowsep = ( pcsp ) ? pcsp->rowsep : FALSE; return tcsp; } /* TblDoSpanSpec() -- process one element to create a new spanspec * * Note that there's a hack inside here... NameSt and NameEnd are * supposed to point at colnames, but if no colname is found, this * code will look for a colnum by the same value. */ struct tblspanspec * TblDoSpanSpec(Element_t * ep, /* element containing spanspec stuff */ struct tblspanspec * pssp, /* prevailing spanspec (with defaults) */ tblsource source) /* precedence level of the resulting spec */ { register char * cp; register struct tblspanspec * tssp; register struct tblcolspec * tcsp; Calloc(1, tssp, struct tblspanspec); if ( cp = FindAttValByName(ep, "SPANNAME") ) strcpy(tssp->name, cp); tssp->source = source; if ( cp = FindAttValByName(ep, "NAMEST") ) { if ( (tcsp = TblFindColSpec(cp, source)) || (tcsp = TblFindColNum(atoi(cp), source)) ) { tssp->start = tcsp; } else { fprintf(stderr, "? spanspec namest points to unknown column '%s'\n", cp); tssp->start = 0; } } else { if ( pssp && pssp->start ) { tssp->start = pssp->start; } } if ( cp = FindAttValByName(ep, "NAMEEND") ) { if ( (tcsp = TblFindColSpec(cp, source)) || (tcsp = TblFindColNum(atoi(cp), source)) ) { tssp->end = tcsp; } else { fprintf(stderr, "? spanspec nameend points to unknown column '%s'\n", cp); tssp->end = 0; } } else { if ( pssp && pssp->end ) { tssp->end = pssp->end; } } if ( cp = FindAttValByName(ep, "ALIGN") ) { if ( !strcmp(cp, "LEFT") ) tssp->align = Left; else if ( !strcmp(cp, "RIGHT") ) tssp->align = Right; else if ( !strcmp(cp, "CENTER") ) tssp->align = Center; else if ( !strcmp(cp, "JUSTIFY") ) tssp->align = Justify; else if ( !strcmp(cp, "CHAR") ) tssp->align = Char; } else { if ( pssp ) tssp->align = pssp->align; } if ( cp = FindAttValByName(ep, "CHAR") ) tssp->alignchar = cp[0]; else { if ( pssp ) tssp->alignchar = pssp->alignchar; } if ( cp = FindAttValByName(ep, "CHAROFF") ) tssp->aligncharoff = atoi(cp); else { if ( pssp ) tssp->alignchar = pssp->alignchar; } if ( cp = FindAttValByName(ep, "COLSEP") ) tssp->colsep = !strcmp(cp, "1"); else { if ( pssp ) tssp->colsep = pssp->colsep; } if ( cp = FindAttValByName(ep, "ROWSEP") ) tssp->rowsep = !strcmp(cp, "1"); else { if ( pssp ) tssp->rowsep = pssp->rowsep; } return tssp; } /* TblFindColSpec() -- find a table colspec by name (colname) * */ struct tblcolspec * TblFindColSpec(char * name, /* the name we're looking for */ tblsource source) /* the context in which to find it */ { register struct tblcolspec * tcsp; /* first, try to find the one in the right "source" */ for ( tcsp=tblColSpec; tcsp; tcsp=tcsp->next ) { if ( (tcsp->source == source) && !strcmp(tcsp->name, name) ) return tcsp; } /* else, try to find one from a TGroup.. */ for ( tcsp=tblColSpec; tcsp; tcsp=tcsp->next ) { if ( (tcsp->source == TGroup) && !strcmp(tcsp->name, name) ) return tcsp; } /* else not found.. */ return 0; } /* TblFindColNum() -- find a table colspec by number * */ struct tblcolspec * TblFindColNum(short number, /* the number we're looking for */ tblsource source) /* the context in which to find it */ { register struct tblcolspec * tcsp; /* first, try to find the one in the right "source" */ for ( tcsp=tblColSpec; tcsp; tcsp=tcsp->next ) { if ( (tcsp->num == number) && ((tcsp->source == source) || ((source == THead) && (tcsp->source == TGroup))) ) return tcsp; } /* else, try to find one from a TGroup.. */ for ( tcsp=tblColSpec; tcsp; tcsp=tcsp->next ) { if ( (tcsp->source == TGroup) && (tcsp->num == number) ) return tcsp; } /* else not found.. */ return 0; } /* TblFindSpanSpec() -- find a table spanspec by name (spanname) * */ struct tblspanspec * TblFindSpanSpec(char * name, /* the name we're looking for */ tblsource source) /* the context in which to find it */ { register struct tblspanspec * tssp; /* first, try to find the one in the right "source" */ for ( tssp=tblSpanSpec; tssp; tssp=tssp->next ) { if ( !strcmp(tssp->name, name) && ((tssp->source == source) || ((source == THead) && (tssp->source == TGroup))) ) return tssp; } /* else not found.. */ return 0; } docbook-to-man-2.0.0.orig/Instant/traninit.c0100644000176100001440000003326406737404357020225 0ustar debacleusers/* * Copyright 1993 Open Software Foundation, Inc., Cambridge, Massachusetts. * All rights reserved. */ /* * 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 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * 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: * ReadTransSpec(transfile) read/store translation spec from file * ReadSDATA(sdatafile) read/store SDATA mappings from file * ReadMapping(mapfile) read/store char mappings from file * ________________________________________________________________________ */ #ifndef lint static char *RCSid = "$Header: /aolnet/dev/src/CVS/sgml/docbook-to-man/Instant/traninit.c,v 1.2 1998/11/16 22:38:12 db3l Exp $"; #endif #include #include #include #include #include #include #include #include #include "general.h" #include "translate.h" #ifndef TRUE #define TRUE (1 == 1) #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 ReadTransSpec( char *transfile ) { FILE *fp; char buf[LINESIZE], *cp, *fn, *cp2; int lineno=0, c, i; Trans_t T; if ((fp=OpenFile(transfile)) == NULL) { sprintf(buf,"Can not open translation spec '%s'", transfile); perror(buf); return; } memset(&T, 0, sizeof T); /* initialize/clear structure */ while (fgets(buf, LINESIZE, fp)) /* read line from .ts file */ { lineno++; /* skip comment and blank lines */ if (buf[0] == '#' || buf[0] == NL) continue; /* '-' 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] == '-') { T.lineno = lineno; RememberTransSpec(&T, lineno); memset(&T, 0, sizeof T); continue; } stripNL(buf); /* 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) { c = getc(fp); /* 1st char of next line */ if (IsWhite(c)) { /* space or tab? */ /* keep getting characters until it's a non-whitespace */ c = getc(fp); while (IsWhite(c)) c = getc(fp); ungetc(c, fp); /* put back non-whitespace */ i = strlen(buf); buf[i++] = ' '; fn = buf + i; /* point to end of string in buffer */ fgets(fn, LINESIZE-i, fp); /* read and append to buf */ lineno++; stripNL(buf); } else { ungetc(c, fp); /* put back non-whitespace */ break; } } /* Isolate field value */ if ((cp=strchr(buf, ':'))) { cp++; /* point past colon */ while (*cp && IsWhite(*cp)) cp++; /* point to content */ } else { fprintf(stderr, "Trans spec error, missing colon (skipping line):\n %s\n", fn); continue; } fn = buf; /* fn is name of the field, cp the value. */ /* Check field names in order that they're likely to occur. */ if (!strncmp("GI:", fn, 3)) { /* if we are folding the case of GIs, make all upper (unless it's an internal pseudo-GI name, which starts with '_') */ if (fold_case && cp[0] != '_' && cp[0] != '#') { for (cp2=cp; *cp2; cp2++) if (islower(*cp2)) *cp2 = toupper(*cp2); } T.gi = AddElemName(cp); } else if (!strncmp("StartText:", fn, 10)) T.starttext = strdup(cp); else if (!strncmp("EndText:", fn, 8)) T.endtext = strdup(cp); else if (!strncmp("Relation:", fn, 9)) { if (!T.relations) T.relations = NewMap(IMS_relations); SetMapping(T.relations, cp); } else if (!strncmp("Replace:", fn, 8)) T.replace = strdup(cp); else if (!strncmp("AttValue:", fn, 9)) { if (!T.nattpairs) { Malloc(1, T.attpair, AttPair_t); } else Realloc((T.nattpairs+1), T.attpair, AttPair_t); /* we'll split name/value pairs later */ T.attpair[T.nattpairs].name = strdup(cp); 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 if (!strncmp("Context:", fn, 8)) T.context = strdup(cp); else if (!strncmp("Message:", fn, 8)) T.message = strdup(cp); else if (!strncmp("SpecID:", fn, 7)) T.my_id = atoi(cp); else if (!strncmp("Action:", fn, 7)) T.use_id = atoi(cp); else if (!strncmp("Content:", fn, 8)) T.content = strdup(cp); else if (!strncmp("PAttSet:", fn, 8)) T.pattrset = strdup(cp); else if (!strncmp("Verbatim:", fn, 9)) T.verbatim = TRUE; else if (!strncmp("Ignore:", fn, 7)) { if (!strcmp(cp, "all")) T.ignore = IGN_ALL; else if (!strcmp(cp, "data")) T.ignore = IGN_DATA; else if (!strcmp(cp, "children")) T.ignore = IGN_CHILDREN; else fprintf(stderr, "Bad 'Ignore:' arg in transpec (line %d): %s\n", lineno, cp); } else if (!strncmp("VarValue:", fn, 9)) { char **tok; i = 2; tok = Split(cp, &i, S_STRDUP); T.var_name = tok[0]; T.var_value = tok[1]; } else if (!strncmp("VarREValue:", fn, 11)) { char **tok; i = 2; tok = Split(cp, &i, S_STRDUP); T.var_RE_name = tok[0]; ExpandVariables(tok[1], buf, 0); if (!(T.var_RE_value=tpt_regcomp(buf))) { fprintf(stderr, "Regex error in VarREValue Content: %s\n", tok[1]); } } else if (!strncmp("Set:", fn, 4)) { if (!T.set_var) T.set_var = NewMap(IMS_setvar); SetMapping(T.set_var, cp); } else if (!strncmp("Increment:", fn, 10)) { if (!T.incr_var) T.incr_var = NewMap(IMS_incvar); SetMapping(T.incr_var, cp); } else if (!strncmp("NthChild:", fn, 9)) T.nth_child = atoi(cp); else if (!strncmp("Var:", fn, 4)) SetMapping(Variables, cp); else if (!strncmp("Quit:", fn, 5)) T.quit = strdup(cp); else fprintf(stderr, "Unknown translation spec (skipping it): %s\n", fn); } fclose(fp); } /* ______________________________________________________________________ */ /* Store translation spec 't' in memory. * Arguments: * Pointer to translation spec to remember. * Line number where translation spec ends. */ void RememberTransSpec( Trans_t *t, int lineno ) { char *cp; int i, do_regex; static Trans_t *last_t; 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 '.'). */ for (do_regex=0,cp=t->context; *cp; cp++) { if (!isalnum(*cp) && *cp != '-' && *cp != '.' && *cp != ' ') { do_regex = 1; break; } } if (do_regex) { t->depth = MAX_DEPTH; if (!(t->context_re=tpt_regcomp(t->context))) { fprintf(stderr, "Regex error in Context: %s\n", t->context); } } 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. */ cp = t->context; if (!strchr(cp, ' ')) { t->parent = t->context; t->context = NULL; } else { /* Figure out depth of context string */ t->depth = 0; while (*cp) { if (*cp) t->depth++; while (*cp && !IsWhite(*cp)) cp++; /* find end of gi */ while (*cp && IsWhite(*cp)) cp++; /* skip space */ } } } } /* Compile regular expressions for each attribute */ for (i=0; inattpairs; i++) { /* Initially, name points to "name value". Split them... */ cp = t->attpair[i].name; while (*cp && !IsWhite(*cp)) cp++; /* point past end of name */ if (*cp) { /* value found */ *cp++ = EOS; /* terminate name */ while (*cp && IsWhite(*cp)) cp++; /* point to value */ ExpandVariables(cp, buf, 0); /* expand any variables */ t->attpair[i].val = strdup(buf); } else { /* value not found */ t->attpair[i].val = "."; } if (!(t->attpair[i].rex=tpt_regcomp(t->attpair[i].val))) { fprintf(stderr, "Regex error in AttValue: %s %s\n", t->attpair[i].name, t->attpair[i].val); } } /* Compile regular expression for content */ t->content_re = 0; if (t->content) { ExpandVariables(t->content, buf, 0); if (!(t->content_re=tpt_regcomp(buf))) fprintf(stderr, "Regex error in Content: %s\n", t->content); } /* If multiple GIs, break up into a vector, then remember it. We either * sture the individual, or the list - not both. */ if (t->gi && strchr(t->gi, ' ')) { t->gilist = Split(t->gi, 0, S_ALVEC); t->gi = NULL; } /* Now, store structure in linked list. */ if (!TrSpecs) { Malloc(1, TrSpecs, Trans_t); last_t = TrSpecs; } else { Malloc(1, last_t->next, Trans_t); last_t = last_t->next; } *last_t = *t; } /* ______________________________________________________________________ */ /* Read mapping file, filling in structure slots (just name-value pairs). * Arguments: * Name of character mapping file. */ void ReadCharMap( char *filename ) { FILE *fp; char buf[LINESIZE], *name, *val; int lineno=0; int n_alloc=0; /* number of slots allocated so far */ if ((fp=OpenFile(filename)) == NULL) { sprintf(buf,"Can not open character mapping file file '%s': ", filename); perror(buf); return; } /* We allocate slots in blocks of N, so we don't have to call * malloc so many times. */ n_alloc = 32; Calloc(n_alloc, CharMap, Mapping_t); nCharMap = 0; while (fgets(buf, LINESIZE, fp)) { lineno++; /* skip comment and blank lines */ if (buf[0] == '#' || buf[0] == NL) continue; stripNL(buf); /* Need more slots for mapping structures? */ if (nCharMap >= n_alloc) { n_alloc += 32; Realloc(n_alloc, CharMap, Mapping_t); } name = val = buf; while (*val && !IsWhite(*val)) val++; /* point past end of name */ if (*val) { *val++ = EOS; /* terminate name */ while (*val && IsWhite(*val)) val++; /* point to value */ } if (name) { CharMap[nCharMap].name = strdup(name); if (val) CharMap[nCharMap].sval = strdup(val); if (CharMap[nCharMap].name[0] == '\\') CharMap[nCharMap].name++; nCharMap++; } } fclose(fp); } /* ______________________________________________________________________ */ /* 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 ReadSDATA( char *filename ) { FILE *fp; char buf[LINESIZE], *name, *val; int lineno=0; if ((fp=OpenFile(filename)) == NULL) { sprintf(buf,"Can not open SDATA file '%s': ", filename); perror(buf); return; } if (!SDATAmap) SDATAmap = NewMap(IMS_sdata); while (fgets(buf, LINESIZE, fp)) { lineno++; /* skip comment and blank lines */ if (buf[0] == '#' || buf[0] == NL) continue; stripNL(buf); name = val = buf; while (*val && *val != TAB) val++; /* point past end of name */ if (*val) { *val++ = EOS; /* terminate name */ while (*val && *val == TAB) val++; /* point to value */ } SetMappingNV(SDATAmap, name, val); } fclose(fp); } /* ______________________________________________________________________ */ docbook-to-man-2.0.0.orig/Instant/translate.c0100644000176100001440000006366506737404357020402 0ustar debacleusers/* * Copyright 1993 Open Software Foundation, Inc., Cambridge, Massachusetts. * All rights reserved. */ /* * 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 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * 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 is for "translating" an instance to another form, usually * suitable for a formatting application. * * Entry points for this module: * DoTranslate(elem, transfile, mapfile, fp) * ________________________________________________________________________ */ #ifndef lint static char *RCSid = "$Header: /aolnet/dev/src/CVS/sgml/docbook-to-man/Instant/translate.c,v 1.2 1998/11/16 22:23:51 db3l Exp $"; #endif #include #include #include #include #include #include #include #include #include "general.h" #define STORAGE #include "translate.h" static Trans_t NullTrans; /* an empty one */ /* forward references */ void ProcesOutputSpec(char *, Element_t *, FILE *, int); static void WasProcessed(Element_t *); /* ______________________________________________________________________ */ /* Translate the subtree starting at 'e'. Use 'transfile' for translation * specs. Output goes to 'fp'. This is the entry point for translating * an instance. * Assumes you've read SDATA and CharMap files (optionally). * Arguments: * Pointer to element under consideration. * Pointer to name of translation spec file. * FILE pointer to where to write output. */ void DoTranslate( Element_t *e, char *transfile, FILE *fp ) { Trans_t *t, *tn; if (!transfile) { fprintf(stderr, "Translation spec file not specified. Skipping translation.\n"); return; } ReadTransSpec(transfile); /* Find transpec for each node. */ DescendTree(e, PrepTranspecs, 0, 0, 0); /* Stuff to do at start of processing */ if ((t = FindTransByName("_Start"))) { if (t->starttext) ProcesOutputSpec(t->starttext, 0, fp, 1); if (t->replace) ProcesOutputSpec(t->replace, 0, fp, 1); if (t->message) ProcesOutputSpec(t->message, 0, stderr, 0); if (t->endtext) ProcesOutputSpec(t->endtext, 0, fp, 1); } /* Translate topmost/first element. This is recursive. */ TransElement(e, fp, NULL); /* Stuff to do at end of processing */ if ((t = FindTransByName("_End"))) { if (t->starttext) ProcesOutputSpec(t->starttext, 0, fp, 1); if (t->replace) ProcesOutputSpec(t->replace, 0, fp, 1); if (t->message) ProcesOutputSpec(t->message, 0, stderr, 0); if (t->endtext) ProcesOutputSpec(t->endtext, 0, fp, 1); } /* Warn about unprocessed elements in this doc tree, if verbose mode. */ if (verbose) DescendTree(e, WasProcessed, 0, 0, 0); /* Clean up. This is not yet complete, which is no big deal (since the * program is normally done at this point anyway. */ for (t=TrSpecs; t; ) { tn = t->next; /* free the contents of t here ... */ (void)free((void* )t); t = tn; } TrSpecs = 0; } /* ______________________________________________________________________ */ /* Print warning about unprocessed elements in this doc tree (if they * were not explicitely ignored). * Arguments: * Pointer to element under consideration. */ static void WasProcessed( Element_t *e ) { Trans_t *t; t = e->trans; if (!e->processed && (t && !t->ignore)) { fprintf(stderr, "Warning: element '%s' was not processed:\n", e->gi); PrintLocation(e, stderr); } } /* ______________________________________________________________________ */ /* For each element find transpec. * Arguments: * Pointer to element under consideration. */ void PrepTranspecs( Element_t *e ) { Trans_t *t; t = FindTrans(e, 0); e->trans = t; } /* ______________________________________________________________________ */ /* Copy a buffer/string into another, expanding regular variables and immediate * variables. (Special variables are done later.) * Arguments: * Pointer to string to expand. * Pointer to expanded string. (return) * Pointer to element under consideration. */ void ExpandVariables( char *in, char *out, Element_t *e ) { register int i, j; char *ip, *vp, *op; char *def_val, *s, *atval, *modifier; char vbuf[500]; int lev; ip = in; op = out; while (*ip) { /* start of regular variable? */ if (*ip == '$' && *(ip+1) == L_CURLY && *(ip+2) != '_') { ip++; ip++; /* point at variable name */ vp = vbuf; /* Look for matching (closing) curly. (watch for nesting) * We store the variable content in a tmp buffer, so we don't * clobber the input buffer. */ lev = 0; while (*ip) { if (*ip == L_CURLY) lev++; if (*ip == R_CURLY) { if (lev == 0) { ip++; break; } else lev--; } *vp++ = *ip++; /* copy to variable buffer */ } *vp = EOS; /* vbuf now contains the variable name (stuff between curlys). */ if (lev != 0) { fprintf(stderr, "Botched variable use: %s\n", in); /* copy rest of string if we can't recover ?? */ return; } /* Now, expand variable. */ vp = vbuf; /* Check for immediate variables -- like _special variables but * interpreted right now. These start with a "+" */ if ( *vp == '+' ) { if ( ! strcmp(vp, "+content") ) { for ( i=0; incont; i++ ) { if ( IsContData(e, i) ) { j = strlen(ContData(e,i)); memcpy(op, ContData(e,i), j); op += j; } else { fprintf(stderr, "warning: ${+current} skipped element content\n"); } } } else { fprintf(stderr, "unknown immediate variable: %s\n", vp); } } else { /* See if this variable has a default [ format: ${varname def} ] */ def_val = vp; while (*def_val && *def_val != ' ') def_val++; if (*def_val) *def_val++ = EOS; else def_val = 0; /* def_val now points to default, if it exists, null if not. */ modifier = vp; while (*modifier && *modifier != ':') modifier++; if (*modifier) *modifier++ = EOS; else modifier = 0; /* modifier now points to modifier if it exists, null if not. */ s = 0; /* if attribute of current elem with this name found, use value */ if (e && (atval = FindAttValByName(e, vp))) s = atval; else /* else try for (global) variable with this name */ s = FindMappingVal(Variables, vp); /* If we found a value, copy it to the output buffer. */ if (s) { if ( modifier && *modifier == 'l' ) { while (*s) { *op = tolower(*s); op++, *s++; } } else while (*s) *op++ = *s++; } else if (def_val) { while (*def_val) *op++ = *def_val++; } } continue; } *op++ = *ip++; } *op = EOS; /* terminate string */ } /* ______________________________________________________________________ */ /* Process an "output" translation spec - one of StartText, EndText, * Replace, Message. (These are the ones that produce output.) * Steps done: * Expand attributes and regular varaibles in input string. * Pass thru string, accumulating chars to be sent to output stream. * If we find the start of a special variable, output what we've * accumulated, then find the special variable's "bounds" (ie, the * stuff between the curly brackets), and expand that by passing to * ExpandSpecialVar(). Continue until done the input string. * Arguments: * Input buffer (string) to be expanded and output. * Pointer to element under consideration. * FILE pointer to where to write output. * Flag saying whether to track the character position we're on * (passed to OutputString). */ void ProcesOutputSpec( char *ib, Element_t *e, FILE *fp, int track_pos ) { char obuf[LINESIZE]; char vbuf[LINESIZE]; char *dest, vname[LINESIZE], *cp; int esc; obuf[0] = EOS; /* start with empty output buffer */ ExpandVariables(ib, vbuf, e); /* expand regular variables */ ib = vbuf; dest = obuf; esc = 0; while (*ib) { /* Is esc-$ next? If so, just copy the '$'. */ if (*ib == '\\' && ib[1] == '$') { ib++; /* skip esc */ *dest++ = *ib++; /* copy $ */ continue; } /* If not a $, it's a regular char. Just copy it and go to next. */ if (*ib != '$') { /* look for att/variable marker */ *dest++ = *ib++; /* it's not. just copy character */ continue; } /* We have a $. What we have must be a "special variable" since * regular variables have already been expanded, or just a lone $. */ if (ib[1] != L_CURLY) { /* just a stray dollar sign (no variable) */ *dest++ = *ib++; continue; } ib++; /* point past $ */ /* Output what we have in buffer so far. */ *dest = EOS; /* terminate string */ if (obuf[0]) OutputString(obuf, fp, track_pos); dest = obuf; /* ready for new stuff in buffer */ if (!strchr(ib, R_CURLY)) { fprintf(stderr, "Mismatched braces in TranSpec: %s\n", ib); /* how do we recover from this? */ } ib++; cp = vname; while (*ib && *ib != R_CURLY) *cp++ = *ib++; *cp = EOS; /* terminate att/var name */ ib++; /* point past closing curly */ /* we now have special variable name (stuff in curly {}'s) in vname */ ExpandSpecialVar(&vname[1], e, fp, track_pos); } *dest = EOS; /* terminate string in output buffer */ if (obuf[0]) OutputString(obuf, fp, track_pos); } /* ______________________________________________________________________ */ /* Find the translation spec for the given tag. * Returns pointer to first spec that matches (name, depth, etc., of tag). * Arguments: * e -- Pointer to element under consideration. * specID -- name of specid that we're looking for * Return: * Pointer to translation spec that matches given element's context. */ Trans_t * FindTrans( Element_t *e, int specID ) { char context[LINESIZE], buf[LINESIZE], *cp, **vec, *atval; int i, a, match; Trans_t *t, *tt; /* loop through all transpecs */ for (t=TrSpecs; t; t=t->next) { /* Only one of gi or gilist will be set. */ /* Check if elem name matches */ if (t->gi && !StrEq(t->gi, e->gi) && !specID) continue; /* test if we're looking for a specific specID and then if * this is it.. */ if (specID) if (!t->my_id || (specID != t->my_id)) continue; /* Match one in the list of GIs? */ if (t->gilist) { for (match=0,vec=t->gilist; *vec; vec++) { if (StrEq(*vec, e->gi)) { match = 1; break; } } if (!match) continue; } /* Check context */ /* Special case of context */ if (t->parent) if (!QRelation(e, t->parent, REL_Parent)) continue; if (t->context) { /* no context specified -> a match */ FindContext(e, t->depth, context); /* If reg expr set, do regex compare; else just string compare. */ if (t->context_re) { if (! tpt_regexec(t->context_re, context)) continue; } else { /* Is depth of spec deeper than element's depth? */ if (t->depth > e->depth) continue; /* See if context of element matches "context" of transpec */ match = ( (t->context[0] == context[0]) && !strcmp(t->context, context) ); if (!match) continue; } } /* Check attributes. Loop through list, comparing each. */ if (t->nattpairs) { /* no att specified -> a match */ for (match=1,a=0; anattpairs; a++) { if (!(atval = FindAttValByName(e, t->attpair[a].name))) { match = 0; break; } if (!tpt_regexec(t->attpair[a].rex, atval)) match = 0; } if (!match) continue; } /* Check relationships: child, parent, ancestor, sib, ... */ if (t->relations) { Mapping_t *r; match = 1; for (r=t->relations->maps,i=0; irelations->n_used; i++) { if (!CheckRelation(e, r[i].name, r[i].sval, 0, 0, RA_Current)) { match = 0; break; } } if (!match) continue; } /* check this element's parent's attribute */ if (t->pattrset && e->parent) { char *p, **tok; i = 2; match = 1; tok = Split(t->pattrset, &i, S_STRDUP); if ( i == 2 ) { p = FindAttValByName(e->parent, tok[0]); ExpandVariables(tok[1], buf, 0); if ( !p || strcmp(p, buf) ) match = 0; } else { if (!FindAttValByName(e->parent, t->pattrset)) match = 0; } free(tok[0]); if (!match) continue; } /* check this element's "birth order" */ if (t->nth_child) { /* First one is called "1" by the user. Internally called "0". */ i = t->nth_child; if (i > 0) { /* positive # -- count from beginning */ if (e->my_eorder != (i-1)) continue; } else { /* negative # -- count from end */ i = e->parent->necont - i; if (e->my_eorder != i) continue; } } /* check that variables match */ if (t->var_name) { cp = FindMappingVal(Variables, t->var_name); if (!cp || strcmp(cp, t->var_value)) continue; } /* check for variable regular expression match */ if ( t->var_RE_name ) { cp = FindMappingVal(Variables, t->var_RE_name); if (!cp || !tpt_regexec(t->var_RE_value, cp)) continue; } /* check content */ if (t->content) { /* no att specified -> a match */ for (match=0,i=0; indcont; i++) { if (tpt_regexec(t->content_re, e->dcont[i])) { match = 1; break; } } if (!match) continue; } /* -------- at this point we've passed all criteria -------- */ /* See if we should be using another transpec's actions. */ if (t->use_id) { if (t->use_id < 0) return &NullTrans; /* missing? */ /* see if we have a pointer to that transpec */ if (t->use_trans) return t->use_trans; for (tt=TrSpecs; tt; tt=tt->next) { if (t->use_id == tt->my_id) { /* remember pointer for next time */ t->use_trans = tt; return t->use_trans; } } t->use_id = -1; /* flag it as missing */ fprintf(stderr, "Warning: transpec ID (%d) not found for %s.\n", t->use_id, e->gi); return &NullTrans; } return t; } /* At this point, we have not found a matching spec. See if there * is a wildcard, and if so, use it. (Wildcard GI is named "*".) */ if ((t = FindTransByName("*"))) return t; if (warnings && !specID) fprintf(stderr, "Warning: transpec not found for %s\n", e->gi); /* default spec - pass character data and descend node */ return &NullTrans; } /* ______________________________________________________________________ */ /* Find translation spec by (GI) name. Returns the first one that matches. * Arguments: * Pointer to name of transpec (the "gi" field of the Trans structure). * Return: * Pointer to translation spec that matches name. */ Trans_t * FindTransByName( char *s ) { Trans_t *t; for (t=TrSpecs; t; t=t->next) { /* check if tag name matches (first check 1st char, for efficiency) */ if (t->gi) { if (*(t->gi) != *s) continue; /* check 1st character */ if (!strcmp(t->gi, s)) return t; } } return NULL; } /* Find translation spec by its ID (SpecID). * Arguments: * Spec ID (an int). * Return: * Pointer to translation spec that matches name. */ Trans_t * FindTranByID(int n) { Trans_t *t; for (t=TrSpecs; t; t=t->next) if (n == t->my_id) return t; return NULL; } /* ______________________________________________________________________ */ /* Process a "chunk" of content data of an element. * Arguments: * Pointer to data content to process * FILE pointer to where to write output. * * [ANS-db3l] * No longer perform character mapping here - that's done on the input * side when parsing the ESIS data block for an element. * */ void DoData( char *data, FILE *fp, int verbatim ) { char *cp, buf[LINESIZE], *dp, *sub, prev; int i, mapped; /* Worry about embedded newlines? */ if (!fp) return; /* CLEANUP: this should really all be done in OutputString(). (I think) */ #if 0 /* [ANS-db3l] Moved to input processing of ESIS in main.c */ if (nCharMap) { /* for each character, see if it's mapped to something else */ for (prev=0,cp=data,dp=buf; *cp; cp++) { if (prev == '\\') { *dp++ = *cp; prev = *cp; continue; } for (mapped=0,i=0; !verbatim && (ireplace) ProcesOutputSpec(t->replace, 0, fp, 1); else { if (t->starttext) ProcesOutputSpec(t->starttext, 0, fp, 1); if (t->ignore != IGN_DATA) /* skip data nodes? */ if (n > 1) OutputString(tok[1], fp, 1); if (t->endtext) ProcesOutputSpec(t->endtext, 0, fp, 1); } if (t->message) ProcesOutputSpec(t->message, 0, stderr, 0); } else { /* If not found, just print the PI in square brackets, along * with a warning message. */ fprintf(fp, "[%s]", pi); if (warnings) fprintf(stderr, "Warning: Unrecognized PI: [%s]\n", pi); } } /* ______________________________________________________________________ */ /* Set and increment variables, as appropriate, if the transpec says to. * Arguments: * Pointer to translation spec for current element. */ static void set_and_increment( Trans_t *t, Element_t *e ) { Mapping_t *m; int i, inc, n; char *cp, buf[50]; char ebuf[500]; /* set/reset variables */ if (t->set_var) { for (m=t->set_var->maps,i=0; iset_var->n_used; i++) { ExpandVariables(m[i].sval, ebuf, e); /* do some expansion */ SetMappingNV(Variables, m[i].name, ebuf); } } /* increment counters */ if (t->incr_var) { for (m=t->incr_var->maps,i=0; iincr_var->n_used; i++) { cp = FindMappingVal(Variables, m[i].name); /* if not set at all, set to 1 */ if (!cp) SetMappingNV(Variables, m[i].name, "1"); else { if (isdigit(*cp) || (*cp == '-' && isdigit(cp[1]))) { n = atoi(cp); if (m[i].sval && isdigit(*m[i].sval)) inc = atoi(m[i].sval); else inc = 1; sprintf(buf, "%d", (n + inc)); SetMappingNV(Variables, m[i].name, buf); } else if (!*(cp+1) && isalpha(*cp)) { buf[0] = *cp + 1; buf[1] = 0; SetMappingNV(Variables, m[i].name, buf); } } } } } /* ______________________________________________________________________ */ /* Translate one element. * Arguments: * Pointer to element under consideration. * FILE pointer to where to write output. * Pointer to translation spec for current element, or null. */ void TransElement( Element_t *e, FILE *fp, Trans_t *t ) { int i; if (!t) t = ((e && e->trans) ? e->trans : &NullTrans); /* see if we should quit. */ if (t->quit) { fprintf(stderr, "Quitting at location:\n"); PrintLocation(e, fp); fprintf(stderr, "%s\n", t->quit); exit(1); } /* See if we want to replace subtree (do text, don't descend subtree) */ if (t->replace) { ProcesOutputSpec(t->replace, e, fp, 1); if (t->message) ProcesOutputSpec(t->message, e, stderr, 0); set_and_increment(t, e); /* adjust variables, if appropriate */ return; } if (t->starttext) ProcesOutputSpec(t->starttext, e, fp, 1); if (t->message) ProcesOutputSpec(t->message, e, stderr, 0); /* Process data for this node and descend child elements/nodes. */ if (t->ignore != IGN_ALL) { /* Is there a "generated" node at the front of this one? */ if (e->gen_trans[0]) { Trans_t *tp; if ((tp = FindTranByID(e->gen_trans[0]))) { if (tp->starttext) ProcesOutputSpec(tp->starttext, e, fp, 1); if (tp->message) ProcesOutputSpec(tp->message, e, stderr, 0); if (tp->endtext) ProcesOutputSpec(tp->endtext, e, fp, 1); } } /* Loop thruthe "nodes", whether data, child element, or PI. */ for (i=0; incont; i++) { if (IsContElem(e,i)) { if (t->ignore != IGN_CHILDREN) /* skip child nodes? */ TransElement(ContElem(e,i), fp, NULL); } else if (IsContData(e,i)) { if (t->ignore != IGN_DATA) /* skip data nodes? */ DoData(ContData(e,i), fp, t->verbatim); } else if (IsContPI(e,i)) DoPI(e->cont[i].ch.data, fp); } /* Is there a "generated" node at the end of this one? */ if (e->gen_trans[1]) { Trans_t *tp; if ((tp = FindTranByID(e->gen_trans[1]))) { if (tp->starttext) ProcesOutputSpec(tp->starttext, e, fp, 1); if (tp->message) ProcesOutputSpec(tp->message, e, stderr, 0); if (tp->endtext) ProcesOutputSpec(tp->endtext, e, fp, 1); } } } set_and_increment(t, e); /* adjust variables, if appropriate */ if (t->endtext) ProcesOutputSpec(t->endtext, e, fp, 1); e->processed = 1; } /* ______________________________________________________________________ */ /* Check if element matches specified relationship, and, if it does, perform * action on either current element or matching element (depends on flag). * Arguments: * Pointer to element under consideration. * Pointer to relationship name. * Pointer to related element name (GI). * Pointer to action to take (string - turned into an int). * FILE pointer to where to write output. * Flag saying whether to do action on related element (RA_Related) * or on current element (RA_Current). * Return: * Bool, saying whether (1) or not (0) relationship matches. */ int CheckRelation( Element_t *e, char *relname, /* relationship name */ char *related, /* related element */ char *actname, /* action to take */ FILE *fp, RelAction_t flag ) { Element_t *ep; Relation_t r; if ((r = FindRelByName(relname)) == REL_Unknown) return 0; if (!(ep=QRelation(e, related, r))) return 0; if (!actname) return 1; /* no action - return what we found */ switch (flag) { case RA_Related: TranTByAction(ep, actname, fp); break; case RA_Current: TranTByAction(e, actname, fp); break; } return 1; } /* ______________________________________________________________________ */ /* Perform action given by a SpecID on the given element. * Arguments: * Pointer to element under consideration. * SpecID of action to perform. * FILE pointer to where to write output. * */ void TranByAction( Element_t *e, int n, FILE *fp ) { Trans_t *t; t = FindTranByID(n); if (!t) { fprintf(stderr, "Could not find named action for %d.\n", n); return; } TransElement(e, fp, t); } /* ______________________________________________________________________ */ /* Perhaps perform action given by a SpecID on the given element. * Arguments: * Pointer to element under consideration. * SpecID of action to perform. Unlike TranByAction, this is the argument * as it occurred in the transpec (ASCII) and may end with the letter * "t" which means that the transpec mustpass criteria selection. * FILE pointer to where to write output. */ void TranTByAction( Element_t *e, char *strn, FILE *fp ) { int n; Trans_t *t; n = atoi(strn); if ( strn[strlen(strn)-1] != 't' ) { t = FindTranByID(n); if (!t) { fprintf(stderr, "Could not find named action for %d.\n", n); return; } } else { t = FindTrans(e, n); if ( !t || !t->my_id ) return; } TransElement(e, fp, t); } /* ______________________________________________________________________ */ docbook-to-man-2.0.0.orig/Instant/translate.h0100644000176100001440000001372606737404357020400 0ustar debacleusers/* * Copyright 1993 Open Software Foundation, Inc., Cambridge, Massachusetts. * All rights reserved. */ /* * 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 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * 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. * * These are data definitions for the "translating" portion of the program. * * ________________________________________________________________________ */ #ifdef STORAGE #ifndef lint static char *tr_h_RCSid = "$Header: /aolnet/dev/src/CVS/sgml/docbook-to-man/Instant/translate.h,v 1.1.1.1 1998/11/13 21:31:59 db3l Exp $"; #endif #endif #define L_CURLY '{' #define R_CURLY '}' /* things to ignore when processing an element */ #define IGN_NONE 0 #define IGN_ALL 1 #define IGN_DATA 2 #define IGN_CHILDREN 3 /* for CheckRelation() */ typedef enum { RA_Current, RA_Related } RelAction_t; typedef struct { char *name; /* attribute name string */ char *val; /* attribute value string */ regexp *rex; /* attribute value reg expr (compiled) */ } AttPair_t; typedef struct _Trans { /* criteria */ char *gi; /* element name of tag under consideration */ char **gilist; /* list of element names (multiple gi's) */ char *context; /* context in tree - looking depth levels up */ regexp *context_re; /* tree heirarchy looking depth levels up */ int depth; /* number of levels to look up the tree */ AttPair_t *attpair; /* attr name-value pairs */ int nattpairs; /* number of name-value pairs */ char *parent; /* GI has this element as parent */ int nth_child; /* GI is Nth child of this of parent element */ char *content; /* element has this string in content */ regexp *content_re; /* content reg expr (compiled) */ char *pattrset; /* is this attr set (any value) in parent? */ char *var_name; /* variable name */ char *var_value; /* variable value */ char *var_RE_name; /* variable name (for VarREValue) */ regexp *var_RE_value; /* variable value (compiled, for VarREValue) */ Map_t *relations; /* various relations to check */ /* actions */ char *starttext; /* string to output at the start tag */ char *endtext; /* string to output at the end tag */ char *replace; /* string to replace this subtree with */ char *message; /* message for stderr, if element encountered */ int ignore; /* flag - ignore content or data of element? */ int verbatim; /* flag - pass content verbatim or do cmap? */ char *var_reset; char *increment; /* increment these variables */ Map_t *set_var; /* set these variables */ Map_t *incr_var; /* increment these variables */ char *quit; /* print message and exit */ /* pointers and bookkeeping */ int my_id; /* unique (hopefully) ID of this transpec */ int use_id; /* use transpec whose ID is this */ struct _Trans *use_trans; /* pointer to other transpec */ struct _Trans *next; /* linked list */ int lineno; /* line number of end of transpec */ } Trans_t; #ifdef def #undef def #endif #ifdef STORAGE # define def #else # define def extern #endif def Trans_t *TrSpecs; def Mapping_t *CharMap; def int nCharMap; /* prototypes for things defined in translate.c */ int CheckRelation(Element_t *, char *, char *, char *, FILE*, RelAction_t); Trans_t *FindTrans(Element_t *, int); Trans_t *FindTransByName(char *); Trans_t *FindTransByID(int); void PrepTranspecs(Element_t *); void ProcessOneSpec(char *, Element_t *, FILE *, int); void TransElement(Element_t *, FILE *, Trans_t *); void TranByAction(Element_t *, int, FILE *); void TranTByAction(Element_t *, char *, FILE *); /* prototypes for things defined in tranvar.c */ void ExpandSpecialVar(char *, Element_t *, FILE *, int); /* prototypes for things defined in tables.c */ void OSFtable(Element_t *, FILE *, char **, int); /* ______________________________________________________________________ */ docbook-to-man-2.0.0.orig/Instant/tranvar.c0100644000176100001440000005156606737404357020057 0ustar debacleusers/* * Copyright 1993 Open Software Foundation, Inc., Cambridge, Massachusetts. * All rights reserved. */ /* * 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 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * 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. */ /* ________________________________________________________________________ * * instant - a program to manipulate SGML instances. * * This module is for handling "special variables". These act a lot like * procedure calls * ________________________________________________________________________ */ #ifndef lint static char *RCSid = "$Header: /aolnet/dev/src/CVS/sgml/docbook-to-man/Instant/tranvar.c,v 1.1.1.1 1998/11/13 21:31:59 db3l Exp $"; #endif #include #include #include #include #include #include #include #include #include "general.h" #include "translate.h" static char **idrefs; /* list of IDREF att names to follow */ static char *def_idrefs[] = { "LINKEND", "LINKENDS", "IDREF", 0 }; static char *each_A = 0; /* last seen _eachatt */ static char *each_C = 0; /* last seen _eachcon */ /* forward references */ void ChaseIDRefs(Element_t *, char *, char *, FILE *); void Find(Element_t *, int, char **, FILE *); void GetIDREFnames(); /* ______________________________________________________________________ */ /* Handle "special" variable - read file, run command, do action, etc. * Arguments: * Name of special variable to expand. * Pointer to element under consideration. * FILE pointer to where to write output. * Flag saying whether to track the character position we're on * (passed to OutputString). */ void ExpandSpecialVar( char *name, Element_t *e, FILE *fp, int track_pos ) { FILE *infile; char buf[LINESIZE], *cp, *atval; char **tok; int ntok, n, i, actioni; char *action, *action1; Element_t *ep; Trans_t *t, *tt; /* Run a command. * Format: _! command args ... */ if (*name == '!') { name++; if ((infile = popen(name, "r"))) { while (fgets(buf, LINESIZE, infile)) fputs(buf, fp); pclose(infile); fflush(fp); } else { fprintf(stderr, "Could not start program '%s': %s", name, strerror(errno)); } return; } /* See if caller wants one of the tokens from _eachatt or _eachcon. * If so, output it and return. (Yes, I admit that this is a hack.) */ if (*name == 'A' && name[1] == EOS && each_A) { OutputString(each_A, fp, track_pos); return; } if (*name == 'C' && name[1] == EOS && each_C) { OutputString(each_C, fp, track_pos); return; } ntok = 0; tok = Split(name, &ntok, 0); /* Include another file. * Format: _include filename */ if (StrEq(tok[0], "include")) { name = tok[1]; if (ntok > 1 ) { if ((infile=OpenFile(name)) == NULL) { sprintf(buf, "Can not open included file '%s'", name); perror(buf); return; } while (fgets(buf, LINESIZE, infile)) fputs(buf, fp); fclose(infile); } else fprintf(stderr, "No file name specified for include\n"); return; } /* Print location (nearest title, line no, path). * Format: _location */ else if (StrEq(tok[0], "location")) { PrintLocation(e, fp); } /* Print path to this element. * Format: _path */ else if (StrEq(tok[0], "path")) { (void)FindElementPath(e, buf); OutputString(buf, fp, track_pos); } /* Print name of this element (gi). * Format: _gi [M|L|U] */ else if (StrEq(tok[0], "gi")) { strcpy(buf, e->gi); if (ntok >= 2) { if (*tok[1] == 'L' || *tok[1] == 'l' || *tok[1] == 'M' || *tok[1] == 'm') { for (cp=buf; *cp; cp++) if (isupper(*cp)) *cp = tolower(*cp); } if (*tok[1] == 'M' || *tok[1] == 'm') if (islower(buf[0])) buf[0] = toupper(buf[0]); } OutputString(buf, fp, track_pos); } /* Print filename of this element's associated external entity. * Format: _filename */ else if (StrEq(tok[0], "filename")) { if (!e->entity) { fprintf(stderr, "Expected ext entity (internal error? bug?):\n"); PrintLocation(e, stderr); return; } if (!e->entity->fname) { fprintf(stderr, "Expected filename (internal error? bug?):\n"); PrintLocation(e, stderr); return; } OutputString(e->entity->fname, fp, track_pos); } /* Value of parent's attribute, by attr name. * Format: _pattr attname */ else if (StrEq(tok[0], "pattr")) { ep = e->parent; if (!ep) { fprintf(stderr, "Element does not have a parent:\n"); PrintLocation(ep, stderr); return; } if ((atval = FindAttValByName(ep, tok[1]))) { OutputString(atval, fp, track_pos); } } /* Use an action, given transpec's SID. * Format: _action action */ else if (StrEq(tok[0], "action")) { TranTByAction(e, tok[1], fp); } /* Number of child elements of this element. * Format: _nchild */ else if (StrEq(tok[0], "nchild")) { if (ntok > 1) { for (n=0,i=0; inecont; i++) if (StrEq(e->econt[i]->gi, tok[1])) n++; } else n = e->necont; sprintf(buf, "%d", n); OutputString(buf, fp, track_pos); } /* number of 1st child's child elements (grandchildren from first child). * Format: _n1gchild */ else if (StrEq(tok[0], "n1gchild")) { if (e->necont) { sprintf(buf, "%d", e->econt[0]->necont); OutputString(buf, fp, track_pos); } } /* Chase this element's pointers until we hit the named GI. * Do the action if it matches. * Format: _chasetogi gi action */ else if (StrEq(tok[0], "chasetogi")) { if (ntok < 3) { fprintf(stderr, "Error: Not enough args for _chasetogi.\n"); return; } actioni = atoi(tok[2]); if (actioni) ChaseIDRefs(e, tok[1], tok[2], fp); } /* Follow link to element pointed to, then do action. * Format: _followlink [attname] action. */ else if (StrEq(tok[0], "followlink")) { char **s; if (ntok > 2) { if ((atval = FindAttValByName(e, tok[1]))) { if ((ep = FindElemByID(atval))) { TranTByAction(ep, tok[2], fp); return; } } else fprintf(stderr, "Error: Did not find attr: %s.\n", tok[1]); return; } GetIDREFnames(); for (s=idrefs; *s; s++) { /* is this IDREF attr set? */ if ((atval = FindAttValByName(e, *s))) { ntok = 0; tok = Split(atval, &ntok, S_STRDUP); /* we'll follow the first one... */ if ((ep = FindElemByID(tok[0]))) { TranTByAction(ep, tok[1], fp); return; } else fprintf(stderr, "Error: Can not find elem for ID: %s.\n", tok[0]); } } fprintf(stderr, "Error: Element does not have IDREF attribute set:\n"); PrintLocation(e, stderr); return; } /* Starting at this element, decend tree (in-order), finding GI. * Do the action if it matches. * Format: _find args ... */ else if (StrEq(tok[0], "find")) { Find(e, ntok, tok, fp); } /* Starting at this element's parent, decend tree (in-order), finding GI. * Do the action if it matches. * Format: _pfind args ... */ else if (StrEq(tok[0], "pfind")) { Find(e->parent ? e->parent : e, ntok, tok, fp); } /* Content is supposed to be a list of IDREFs. Follow each, doing action. * If 2 actions are specified, use 1st for the 1st ID, 2nd for the rest. * Format: _namelist action [action2] */ else if (StrEq(tok[0], "namelist")) { int id; action1 = tok[1]; if (ntok > 2) action = tok[2]; else action = action1; for (i=0; indcont; i++) { n = 0; tok = Split(e->dcont[i], &n, S_STRDUP); for (id=0; id 3) action = tok[2]; else action = action1; for (i=0; indcont; i++) { n = 0; tok = Split(e->dcont[i], &n, S_STRDUP|S_ALVEC); for (id=0; id 3) action = tok[3]; else action = action1; if ((atval = FindAttValByName(e, tok[1]))) { n = 0; tok = Split(atval, &n, S_STRDUP|S_ALVEC); for (id=0; id= 4) { if (!CheckRelation(e, tok[1], tok[2], tok[3], fp, RA_Current)) { /* action not done, see if alt action specified */ if (ntok >= 5) TranTByAction(e, tok[4], fp); } } } /* Do action on followed element if element has [relationship] with gi. * Format: _followrel relationship gi action */ else if (StrEq(tok[0], "followrel")) { if (ntok >= 4) (void)CheckRelation(e, tok[1], tok[2], tok[3], fp, RA_Related); } /* Find element with matching ID and do action. If action not specified, * choose the right one appropriate for its context. * Format: _id id [action] */ else if (StrEq(tok[0], "id")) { if ((ep = FindElemByID(tok[1]))) { if (ntok > 2) TranTByAction(ep, tok[2], fp); else { t = FindTrans(ep, 0); TransElement(ep, fp, t); } } } /* Set variable to value. * Format: _set name value */ else if (StrEq(tok[0], "set")) { SetMappingNV(Variables, tok[1], tok[2]); } /* Do action if variable is set, optionally to value. * If not set, do nothing. * Format: _isset varname [value] action */ else if (StrEq(tok[0], "isset")) { if ((cp = FindMappingVal(Variables, tok[1]))) { if (ntok == 3) TranTByAction(e, tok[2], fp); else if (ntok > 3 && !strcmp(cp, tok[2])) TranTByAction(e, tok[3], fp); } } /* Insert a node into the tree at start/end, pointing to action to perform. * Format: _insertnode S|E action */ else if (StrEq(tok[0], "insertnode")) { actioni = atoi(tok[2]); if (*tok[1] == 'S') e->gen_trans[0] = actioni; else if (*tok[1] == 'E') e->gen_trans[1] = actioni; } /* Do an CALS DTD table spec for TeX or troff. Looks through attributes * and determines what to output. "check" means to check consistency, * and print error messages. * This is (hopefully) the only hard-coded part of instant. * * This was originally written for the OSF DTDs and recoded by FLD for * CALS tables (since no one will ever use the OSF tables). Although * TeX was addressed first, it seems that a fresh approach was required, * and so, tbl is the first to be really *fixed*. Once tbl is stable, * and there is a need for TeX again, that part will be recoded. * * *Obsolete* form (viz, for TeX): * Format: _calstable [clear|check|tex] * [cellstart|cellend|rowstart|rowend|top|bottom] * * New, good form: * * Format: _calstable [tbl] * [tablestart|tableend|tablegroup|tablefoot|rowstart| * rowend|entrystart|entryend] */ else if (StrEq(tok[0], "calstable")) { CALStable(e, fp, tok, ntok); } /* Do action if element's attr is set, optionally to value. * If not set, do nothing. * Format: _attval att [value] action */ else if (StrEq(tok[0], "attval")) { if ((atval = FindAttValByName(e, tok[1]))) { if (ntok == 3) TranTByAction(e, tok[2], fp); else if (ntok > 3 && !strcmp(atval, tok[2])) TranTByAction(e, tok[3], fp); } } /* Same thing, but look at parent */ else if (StrEq(tok[0], "pattval")) { if ((atval = FindAttValByName(e->parent, tok[1]))) { if (ntok == 3) { TranTByAction(e, tok[2], fp); } if (ntok > 3 && !strcmp(atval, tok[2])) TranTByAction(e, tok[3], fp); } } /* Print each attribute and value for the current element, hopefully * in a legal sgml form: natts; i++) { if (i != 0) putc(' ', fp); fputs(e->atts[i].name, fp); fputs("=\"", fp); fputs(e->atts[i].sval, fp); putc('"', fp); } } /* Print the element's input filename, and optionally, the line number. * Format: _infile [line] */ else if (StrEq(tok[0], "infile")) { if (e->infile) { if (ntok > 1 && !strcmp(tok[1], "root")) { strcpy(buf, e->infile); if ((cp = strrchr(buf, '.'))) *cp = EOS; fputs(buf, fp); } else { fputs(e->infile, fp); if (ntok > 1 && !strcmp(tok[1], "line")) fprintf(fp, " %d", e->lineno); } return; } else fputs("input-file??", fp); } /* Get value of an environement variable */ else if (StrEq(tok[0], "env")) { if (ntok > 1 && (cp = getenv(tok[1]))) { OutputString(cp, fp, track_pos); } } /* Something unknown */ else { fprintf(stderr, "Unknown special variable: %s\n", tok[0]); tt = e->trans; if (tt && tt->lineno) fprintf(stderr, "Used in transpec, line %d\n", tt->lineno); } return; } /* ______________________________________________________________________ */ /* return the value for the special variables _A (last processed _eachatt) * and _C (last processed _eachcon) */ char * Get_A_C_value(char * name) { if ( !strcmp(name, "each_A") ) { if ( each_A ) { return each_A; } else { fprintf(stderr, "Requested value for unset _A variable\n"); } } else if ( !strcmp(name, "each_C") ) { if ( each_C ) { return each_C; } else { fprintf(stderr, "Requested value for unset _C variable\n"); } } else { fprintf(stderr, "Requested value for unknown special variable '%s'\n", name); } return ""; } /* ______________________________________________________________________ */ /* Chase IDs until we find an element whose GI matches. We also check * child element names, not just the names of elements directly pointed * at (by IDREF attributes). */ void GetIDREFnames() { char *cp; if (!idrefs) { /* did user or transpec set the variable */ if ((cp = FindMappingVal(Variables, "link_atts"))) idrefs = Split(cp, 0, S_STRDUP|S_ALVEC); else idrefs = def_idrefs; } } /* ______________________________________________________________________ */ /* Chase ID references - follow IDREF(s) attributes until we find * a GI named 'gi', then perform given action on that GI. * Arguments: * Pointer to element under consideration. * Name of GI we're looking for. * Spec ID of action to take. * FILE pointer to where to write output. */ void ChaseIDRefs( Element_t *e, char *gi, char * action, FILE *fp ) { int ntok, i, ei; char **tok, **s, *atval; /* First, see if we got what we came for with this element */ if (StrEq(e->gi, gi)) { TranTByAction(e, action, fp); return; } GetIDREFnames(); /* loop for each attribute of type IDREF(s) */ for (s=idrefs; *s; s++) { /* is this IDREF attr set? */ if ((atval = FindAttValByName(e, *s))) { ntok = 0; tok = Split(atval, &ntok, 0); for (i=0; igi, gi)) { /* process using named action */ TranTByAction(e, action, fp); return; } else { /* this elem itself did not match, try its children */ for (ei=0; einecont; ei++) { if (StrEq(e->econt[ei]->gi, gi)) { TranTByAction(e->econt[ei], action, fp); return; } } /* try this elem's IDREF attributes */ ChaseIDRefs(e, gi, action, fp); return; } } else { /* should not happen, since parser checks ID/IDREFs */ fprintf(stderr, "Error: Could not find ID %s\n", atval); return; } } } } /* if the pointers didn't lead to the GI, give error */ if (!s) fprintf(stderr, "Error: Could not find '%s'\n", gi); } /* ______________________________________________________________________ */ /* state to pass to recursive routines - so we don't have to use * global variables. */ typedef struct { char *gi; char *gi2; char action[10]; Element_t *elem; FILE *fp; } Descent_t; static void tr_find_gi( Element_t *e, Descent_t *ds ) { if (StrEq(ds->gi, e->gi)) if (ds->action[0]) TranTByAction(e, ds->action, ds->fp); } static void tr_find_gipar( Element_t *e, Descent_t *ds ) { if (StrEq(ds->gi, e->gi) && e->parent && StrEq(ds->gi2, e->parent->gi)) if (ds->action[0]) TranTByAction(e, ds->action, ds->fp); } static void tr_find_attr( Element_t *e, Descent_t *ds ) { char *atval; if ((atval = FindAttValByName(e, ds->gi)) && StrEq(ds->gi2, atval)) TranTByAction(e, ds->action, ds->fp); } static void tr_find_parent( Element_t *e, Descent_t *ds ) { if (QRelation(e, ds->gi, REL_Parent)) { if (ds->action[0]) TranTByAction(e, ds->action, ds->fp); } } /* ______________________________________________________________________ */ /* Descend tree, finding elements that match criteria, then perform * given action. * Arguments: * Pointer to element under consideration. * Number of tokens in special variable. * Vector of tokens in special variable (eg, "find" "gi" "TITLE") * FILE pointer to where to write output. */ void Find( Element_t *e, int ac, char **av, FILE *fp ) { Descent_t DS; /* state passed to recursive routine */ memset(&DS, 0, sizeof(Descent_t)); DS.elem = e; DS.fp = fp; /* see if we should start at the top of instance tree */ if (StrEq(av[1], "top")) { av++; ac--; e = DocTree; } if (ac < 4) { fprintf(stderr, "Bad '_find' specification - missing args.\n"); return; } /* Find elem whose GI is av[2] */ if (StrEq(av[1], "gi")) { DS.gi = av[2]; strcpy(DS.action, av[3]); DescendTree(e, tr_find_gi, 0, 0, &DS); } /* Find elem whose GI is av[2] and whose parent GI is av[3] */ else if (StrEq(av[1], "gi-parent")) { DS.gi = av[2]; DS.gi2 = av[3]; strcpy(DS.action, av[4]); DescendTree(e, tr_find_gipar, 0, 0, &DS); } /* Find elem whose parent GI is av[2] */ else if (StrEq(av[0], "parent")) { DS.gi = av[2]; strcpy(DS.action, av[3]); DescendTree(e, tr_find_parent, 0, 0, &DS); } /* Find elem whose attribute av[2] has value av[3] */ else if (StrEq(av[0], "attr")) { DS.gi = av[2]; DS.gi2 = av[3]; strcpy(DS.action, av[4]); DescendTree(e, tr_find_attr, 0, 0, &DS); } } /* ______________________________________________________________________ */ docbook-to-man-2.0.0.orig/Instant/util.c0100644000176100001440000007343506737404357017356 0ustar debacleusers/* * Copyright 1993 Open Software Foundation, Inc., Cambridge, Massachusetts. * All rights reserved. */ /* * 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 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * 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. */ /* ________________________________________________________________________ * * General utility functions for 'instant' program. These are used * throughout the rest of the program. * * Entry points for this module: * Split(s, &n, flags) split string into n tokens * NewMap(slot_incr) create a new mapping structure * FindMapping(map, name) find mapping by name; return mapping * FindMappingVal(map, name) find mapping by name; return value * SetMapping(map, s) set mapping based on string * OpenFile(filename) open file, looking in inst path * FindElementPath(elem, s) find path to element * PrintLocation(ele, fp) print location of element in tree * NearestOlderElem(elem, name) find prev elem up tree with name * OutputString(s, fp, track_pos) output string * AddElemName(name) add elem to list of known elements * AddAttName(name) add att name to list of known atts * FindAttByName(elem, name) find an elem's att by name * FindContext(elem, lev, context) find context of elem * QRelation(elem, name, rel_flag) find relation elem has to named elem * DescendTree(elem, enter_f, leave_f, data_f, dp) descend doc tree, * calling functions for each elem/node * ________________________________________________________________________ */ #ifndef lint static char *RCSid = "$Header: /aolnet/dev/src/CVS/sgml/docbook-to-man/Instant/util.c,v 1.4 1999/02/23 22:21:27 db3l Exp $"; #endif #include #include #include #include #include #include #include #include /* CSS don't have it and I don't see where it's used #include */ #include "general.h" #ifdef _AIX /* This should be prototyped in string.h but isn't */ int strcasecmp (char *String1, char *String2); #endif /* ______________________________________________________________________ */ /* "Split" a string into tokens. Given a string that has space-separated * (space/tab) tokens, return a pointer to an array of pointers to the * tokens. Like what the shell does with *argv[]. The array can be is * static or allocated. Space can be allocated for string, or allocated. * Arguments: * Pointer to string to pick apart. * Pointer to max number of tokens to find; actual number found is * returned. If 0 or null pointer, use a 'sane' maximum number (hard- * code). If more tokens than the number specified, make last token be * a single string composed of the rest of the tokens (includes spaces). * Flag. Bit 0 says whether to make a copy of input string (since we'll * clobber parts of it). To free the string, use the pointer to * the first token returned by the function (or *ret_value). * Bit 1 says whether to allocate the vector itself. If not, use * (and return) a static vector. * Return: * Pointer to the provided string (for convenience of caller). */ char ** Split( char *s, /* input string */ int *ntok, /* # of tokens desired (input)/found (return) */ int flag /* dup string? allocate a vector? */ ) { int maxnt, i=0; int n_alloc; char **tokens; static char *local_tokens[100]; /* Figure max number of tokens (maxnt) to find. 0 means find them all. */ if (ntok == NULL) maxnt = 100; else { if (*ntok <= 0 || *ntok > 100) maxnt = 100; /* arbitrary size */ else maxnt = *ntok; *ntok = 0; } if (!s) return 0; /* no string */ /* Point to 1st token (there may be initial space) */ while (*s && IsWhite(*s)) s++; /* skip initial space, if any */ if (*s == EOS) return 0; /* none found? */ /* See if caller wants us to copy the input string. */ if (flag & S_STRDUP) s = strdup(s); /* See if caller wants us to allocate the returned vector. */ if (flag & S_ALVEC) { n_alloc = 20; Malloc(n_alloc, tokens, char *); /* if caller did not specify max tokens to find, set to more than * there will possibly ever be */ if (!ntok || !(*ntok)) maxnt = 10000; } else tokens = local_tokens; i = 0; /* index into vector */ tokens[0] = s; /* s already points to 1st token */ while (i= n_alloc) { n_alloc += 20; Realloc(n_alloc, tokens, char *); } if (i >= maxnt) break; /* is this the last one? */ while (*s && !IsWhite(*s)) s++; /* skip past end of token */ if (*s == EOS) break; /* at end of input string? */ if (*s) *s++ = EOS; /* terminate token string */ while (*s && IsWhite(*s)) s++; /* skip space - to next token */ } if (ntok) *ntok = i; /* return number of tokens found */ tokens[i] = 0; /* null-terminate vector */ return tokens; } /* ______________________________________________________________________ */ /* Mapping routines. These are used for name-value pairs, like attributes, * variables, and counters. A "Map" is an opaque data structure used * internally by these routines. The caller gets one when creating a new * map, then hands it to other routines that need it. A "Mapping" is a * name/value pair. The user has access to this. * Here's some sample usage: * * Map *V; * V = NewMap(20); * SetMappingNV(V, "home", "/users/bowe"); * printf("Home: %s\n", FindMappingVal(V, "home"); */ /* Allocate new map structure. Only done once for each map/variable list. * Arg: * Number of initial slots to allocate space for. This is also the * "chunk size" - how much to allocate when we use up the given space. * Return: * Pointer to the (opaque) map structure. (User passes this to other * mapping routines.) */ Map_t * NewMap( int slot_increment ) { Map_t *M; Calloc(1, M, Map_t); /* should really do the memset's in Calloc/Malloc/Realloc macros, but that will have to wait until time permits -CSS */ memset((char *)M, 0, sizeof(Map_t)); if (!slot_increment) slot_increment = 1; M->slot_incr = slot_increment; return M; } /* Given pointer to a Map and a name, find the mapping. * Arguments: * Pointer to map structure (as returned by NewMap(). * Variable name. * Return: * Pointer to the matching mapping structure, or null if not found. */ Mapping_t * FindMapping( Map_t *M, char *name ) { int i; Mapping_t *m; if (!M || M->n_used == 0) return NULL; for (m=M->maps,i=0; in_used; i++) if (m[i].name[0] == name[0] && !strcmp(m[i].name, name)) return &m[i]; return NULL; } /* Given pointer to a Map and a name, return string value of the mapping. * Arguments: * Pointer to map structure (as returned by NewMap(). * Variable name. * Return: * Pointer to the value (string), or null if not found. */ char * FindMappingVal( Map_t *M, char *name ) { Mapping_t *m; if ( !strcmp(name, "each_A") || !strcmp(name, "each_C") ) { return Get_A_C_value(name); } /* if (!M || M->n_used == 0) return NULL; if ((m = FindMapping(M, name))) return m->sval; return NULL; */ if (!M || M->n_used == 0) { return NULL; } if ((m = FindMapping(M, name))) { return m->sval; } return NULL; } /* Set a mapping/variable in Map M. Input string is a name-value pair where * there is some amount of space after the name. The correct mapping is done. * Arguments: * Pointer to map structure (as returned by NewMap(). * Pointer to variable name (string). * Pointer to variable value (string). */ void SetMappingNV( Map_t *M, char *name, char *value ) { FILE *pp; char buf[LINESIZE], *cp, *s; int i; Mapping_t *m; Mapping_t *xx; /* First, look to see if it's a "well-known" variable. */ if (!strcmp(name, "verbose")) { verbose = atoi(value); return; } if (!strcmp(name, "warnings")) { warnings = atoi(value); return; } if (!strcmp(name, "foldcase")) { fold_case = atoi(value); return; } m = FindMapping(M, name); /* find existing mapping (if set) */ /* OK, we have a string mapping */ if (m) { /* exists - just replace value */ free(m->sval); if (value) m->sval = strdup(value); else m->sval = NULL; } else { if (name) { /* just in case */ /* Need more slots for mapping structures? Allocate in clumps. */ if (M->n_used == 0) { M->n_alloc = M->slot_incr; Malloc(M->n_alloc, M->maps, Mapping_t); } else if (M->n_used >= M->n_alloc) { M->n_alloc += M->slot_incr; Realloc(M->n_alloc, M->maps, Mapping_t); } m = &M->maps[M->n_used]; M->n_used++; m->name = strdup(name); if (value) m->sval = strdup(value); else m->sval = NULL; } } if (value) { /* See if the value is a command to run. If so, run the command * and replace the value with the output. */ s = value; if (*s == '!') { s++; /* point to command */ if ((pp = popen(s, "r"))) { /* run cmd, read its output */ i = 0; cp = buf; while (fgets(cp, LINESIZE-i, pp)) { i += strlen(cp); cp = &buf[i]; if (i >= LINESIZE) { fprintf(stderr, "Prog execution of variable '%s' too long.\n", m->name); break; } } free(m->sval); stripNL(buf); m->sval = strdup(buf); pclose(pp); } else { sprintf(buf, "Could not start program '%s'", s); perror(buf); } } } } /* Separate name and value from input string, then pass to SetMappingNV. * Arguments: * Pointer to map structure (as returned by NewMap(). * Pointer to variable name and value (string), in form "name value". */ void SetMapping( Map_t *M, char *s ) { char buf[LINESIZE]; char *name, *val; if (!M) { fprintf(stderr, "SetMapping: Map not initialized.\n"); return; } strcpy(buf, s); name = val = buf; while (*val && !IsWhite(*val)) val++; /* point past end of name */ if (*val) { *val++ = EOS; /* terminate name */ while (*val && IsWhite(*val)) val++; /* point to value */ } if (name) SetMappingNV(M, name, val); } /* ______________________________________________________________________ */ /* Opens a file for reading. If not found in current directory, try * lib directories (from TPT_LIB env variable, or -l option). * Arguments: * Filename (string). * Return: * FILE pointer to open file, or null if it not found or can't open. */ FILE * OpenFile( char *filename ) { FILE *fp; char buf[LINESIZE]; int i; static char **libdirs; static int nlibdirs = -1; if ((fp=fopen(filename, "r"))) return fp; if (*filename == '/') return NULL; /* full path specified? */ if (nlibdirs < 0) { char *cp, *s; if (tpt_lib) { s = strdup(tpt_lib); for (cp=s; *cp; cp++) if (*cp == ':') *cp = ' '; nlibdirs = 0; libdirs = Split(s, &nlibdirs, S_ALVEC); } else nlibdirs = 0; } for (i=0; iparent) e_path[ep->depth-1] = ep->my_eorder; /* Move down the tree, printing the element names to the string. */ for (cp=s,i=0,ep=DocTree; idepth; ep=ep->econt[e_path[i]],i++) { sprintf(cp, "%s(%d) ", ep->gi, e_path[i]); cp += strlen(cp); } sprintf(cp, "%s", e->gi); return s; } /* ______________________________________________________________________ */ /* Print some location info about a tag. Helps user locate error. * Messages are indented 2 spaces (convention for multi-line messages). * Arguments: * Pointer to element under consideration. * FILE pointer of where to print. */ void PrintLocation( Element_t *e, FILE *fp ) { char *s, buf[LINESIZE]; if (!e || !fp) return; fprintf(fp, " Path: %s\n", FindElementPath(e, buf)); if ((s=NearestOlderElem(e, "TITLE"))) fprintf(fp, " Position hint: TITLE='%s'\n", s); if (e->lineno) { if (e->infile) fprintf(fp, " At or near instance file: %s, line: %d\n", e->infile, e->lineno); else fprintf(fp, " At or near instance line: %d\n", e->lineno); } if (e->id) fprintf(fp, " ID: %s\n", e->id); } /* ______________________________________________________________________ */ /* Finds the data part of the nearest "older" tag (up the tree, and * preceding) whose tag name matches the argument, or "TITLE", if null. * Returns a pointer to the first chunk of character data. * Arguments: * Pointer to element under consideration. * Name (GI) of element we'll return data from. * Return: * Pointer to that element's data content. */ char * NearestOlderElem( Element_t *e, char *name ) { int i; Element_t *ep; if (!e) return 0; if (!name) name = "TITLE"; /* useful default */ for (; e->parent; e=e->parent) /* move up tree */ for (i=0; i<=e->my_eorder; i++) { /* check preceding sibs */ ep = e->parent; if (!strcmp(name, ep->econt[i]->gi)) return ep->econt[i]->ndcont ? ep->econt[i]->dcont[0] : "-empty-"; } return NULL; } /* ______________________________________________________________________ */ /* Expands escaped strings in the input buffer (things like tabs, newlines, * octal characters - using C style escapes) and outputs buffer to specified * fp. The hat/anchor character forces that position to appear at the * beginning of a line. The cursor position is kept track of (optionally) * so that this can be done. * Arguments: * Pointer to element under consideration. * FILE pointer of where to print. * Flag saying whether or not to keep track of our position in the output * stream. (We want to when writing to a file, but not for stderr.) * */ void OutputString( char *s, FILE *fp, int track_pos ) { char c, *sdata, *cp; static int char_pos; /* remembers our character position */ if (!fp) return; if (!s) s = "^"; /* no string - go to start of line */ for ( ; *s; s++) { if (*s == '\\') { s++; if (track_pos) char_pos++; switch (*s) { default: c = *s; break; case 's': c = ' '; break; case 't': c = TAB; break; case 'n': c = NL; char_pos = 0; break; case 'r': c = CR; char_pos = 0; break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': /* for octal numbers (C style) of the form \012 */ c = *s - '0'; for (s++; ((*s >= '0') && (*s <= '7')); s++) c = (c << 3) + (*s - '0'); s--; break; case '|': /* SDATA */ /* [ANS-db3l] In non-"DATAhack" (-d) operation, this is */ /* now normally done while reading the ESIS input, but */ /* I've left it here just in case some existing users of */ /* OutputString need it (don't think so, but...) */ s++; /* point past \| */ sdata = s; /* find matching/closing \| */ cp = s; while (*cp && *cp != '\\' && cp[1] != '|') cp++; if (!*cp) break; *cp = EOS; /* terminate sdata string */ cp++; s = cp; /* s now points to | */ cp = LookupSDATA(sdata); if (cp) OutputString(cp, fp, track_pos); else { /* not found - output sdata thing in brackets */ putc('[', fp); fputs(sdata, fp); putc(']', fp); } c = 0; break; } } else { /* not escaped - just pass the character */ c = *s; /* If caller wants us to track position, see if it's an anchor * (ie, align at a newline). */ if (track_pos) { if (c == ANCHOR) { /* If we're already at the start of a line, don't do * another newline. */ if (char_pos != 0) c = NL; else c = 0; } else char_pos++; if (c == NL) char_pos = 0; } else if (c == ANCHOR) c = NL; } if (c) { if (track_pos) { char_pos = ((c == '\n') ? 0 : char_pos+1); } putc(c, fp); } /* if c */ } } /* ______________________________________________________________________ */ /* Figure out value of SDATA entity. * We rememeber lookup hits in a "cache" (a shorter list), and look in * cache before general list. Typically there will be LOTS of entries * in the general list and only a handful in the hit list. Often, if an * entity is used once, it'll be used again. * Arguments: * Pointer to SDATA entity token in ESIS. * Return: * Mapped value of the SDATA entity. */ char * LookupSDATA( char *s ) { char *v; static Map_t *Hits; /* remember lookup hits */ /* If we have a hit list, check it. */ if (Hits) { if ((v = FindMappingVal(Hits, s))) return v; } v = FindMappingVal(SDATAmap, s); /* If mapping found, remember it, then return it. */ if ((v = FindMappingVal(SDATAmap, s))) { if (!Hits) Hits = NewMap(IMS_sdatacache); SetMappingNV(Hits, s, v); return v; } fprintf(stderr, "Error: Could not find SDATA substitution '%s'.\n", s); return NULL; } /* ______________________________________________________________________ */ /* Add tag 'name' of length 'len' to list of tag names (if not there). * This is a list of null-terminated strings so that we don't have to * keep using the name length. * Arguments: * Pointer to element name (GI) to remember. * Return: * Pointer to the SAVED element name (GI). */ char * AddElemName( char *name ) { int i; static int n_alloc=0; /* number of slots allocated so far */ /* See if it's already in the list. */ for (i=0; i= n_alloc) { n_alloc += IMS_elemnames; Realloc(n_alloc, UsedElem, char *); } UsedElem[nUsedElem] = strdup(name); return UsedElem[nUsedElem++]; } /* ______________________________________________________________________ */ /* Add attrib name to list of attrib names (if not there). * This is a list of null-terminated strings so that we don't have to * keep using the name length. * Arguments: * Pointer to attr name to remember. * Return: * Pointer to the SAVED attr name. */ char * AddAttName( char *name ) { int i; static int n_alloc=0; /* number of slots allocated so far */ /* See if it's already in the list. */ for (i=0; i= n_alloc) { n_alloc += IMS_attnames; Realloc(n_alloc, UsedAtt, char *); } UsedAtt[nUsedAtt] = strdup(name); return UsedAtt[nUsedAtt++]; } /* ______________________________________________________________________ */ /* Find an element's attribute value given element pointer and attr name. * Typical use: * a=FindAttByName("TYPE", t); * do something with a->val; * Arguments: * Pointer to element under consideration. * Pointer to attribute name. * Return: * Pointer to the value of the attribute. */ /* Mapping_t * FindAttByName( Element_t *e, char *name ) { int i; if (!e) return NULL; for (i=0; inatts; i++) if (e->atts[i].name[0] == name[0] && !strcmp(e->atts[i].name, name)) return &(e->atts[i]); return NULL; } */ char * FindAttValByName( Element_t *e, char *name ) { int i; if (!e) return NULL; for (i=0; inatts; i++) if (e->atts[i].name[0] == name[0] && !strcmp(e->atts[i].name, name)) return e->atts[i].sval; return NULL; } /* ______________________________________________________________________ */ /* Find context of a tag, 'levels' levels up the tree. * Space for string is passed by caller. * Arguments: * Pointer to element under consideration. * Number of levels to look up tree. * String to write path into (provided by caller). * Return: * Pointer to the provided string (for convenience of caller). */ char * FindContext( Element_t *e, int levels, char *con ) { char *s; Element_t *ep; int i; if (!e) return NULL; s = con; *s = EOS; for (i=0,ep=e->parent; ep && levels; ep=ep->parent,i++,levels--) { if (i != 0) *s++ = ' '; strcpy(s, ep->gi); s += strlen(s); } return con; } /* ______________________________________________________________________ */ /* Tests relationship (specified by argument/flag) between given element * (structure pointer) and named element. * Returns pointer to matching tag if found, null otherwise. * Arguments: * Pointer to element under consideration. * Pointer to name of elem whose relationsip we are trying to determine. * Relationship we are testing. * Return: * Pointer to the provided string (for convenience of caller). */ Element_t * QRelation( Element_t *e, char *s, Relation_t rel ) { int i; Element_t *ep; if (!e) return 0; /* we'll call e the "given element" */ switch (rel) { case REL_Parent: if (!e->parent || !e->parent->gi) return 0; if (!strcmp(e->parent->gi, s)) return e->parent; break; case REL_Child: for (i=0; inecont; i++) if (!strcmp(s, e->econt[i]->gi)) return e->econt[i]; break; case REL_Ancestor: if (!e->parent || !e->parent->gi) return 0; for (ep=e->parent; ep; ep=ep->parent) if (!strcmp(ep->gi, s)) return ep; break; case REL_Descendant: if (e->necont == 0) return 0; /* check immediate children first */ for (i=0; inecont; i++) if (!strcmp(s, e->econt[i]->gi)) return e->econt[i]; /* then children's children (recursively) */ for (i=0; inecont; i++) if ((ep=QRelation(e->econt[i], s, REL_Descendant))) return ep; break; case REL_Sibling: if (!e->parent) return 0; ep = e->parent; for (i=0; inecont; i++) if (!strcmp(s, ep->econt[i]->gi) && i != e->my_eorder) return ep->econt[i]; break; case REL_Preceding: if (!e->parent || e->my_eorder == 0) return 0; ep = e->parent; for (i=0; imy_eorder; i++) if (!strcmp(s, ep->econt[i]->gi)) return ep->econt[i]; break; case REL_ImmPreceding: if (!e->parent || e->my_eorder == 0) return 0; ep = e->parent->econt[e->my_eorder-1]; if (!strcmp(s, ep->gi)) return ep; break; case REL_Following: if (!e->parent || e->my_eorder == (e->parent->necont-1)) return 0; /* last? */ ep = e->parent; for (i=(e->my_eorder+1); inecont; i++) if (!strcmp(s, ep->econt[i]->gi)) return ep->econt[i]; break; case REL_ImmFollowing: if (!e->parent || e->my_eorder == (e->parent->necont-1)) return 0; /* last? */ ep = e->parent->econt[e->my_eorder+1]; if (!strcmp(s, ep->gi)) return ep; break; case REL_Cousin: if (!e->parent) return 0; /* Now, see if element's parent has that thing as a child. */ return QRelation(e->parent, s, REL_Child); break; case REL_None: case REL_Unknown: fprintf(stderr, "You can not query 'REL_None' or 'REL_Unknown'.\n"); break; } return NULL; } /* Given a relationship name (string), determine enum symbol for it. * Arguments: * Pointer to relationship name. * Return: * Relation_t enum. */ Relation_t FindRelByName( char *relname ) { if (!strcmp(relname, "?")) { fprintf(stderr, "Supported query/relationships %s\n%s.\n", "child, parent, ancestor, descendant,", "sibling, sibling+, sibling+1, sibling-, sibling-1"); return REL_None; } else if (StrEq(relname, "child")) return REL_Child; else if (StrEq(relname, "parent")) return REL_Parent; else if (StrEq(relname, "ancestor")) return REL_Ancestor; else if (StrEq(relname, "descendant")) return REL_Descendant; else if (StrEq(relname, "sibling")) return REL_Sibling; else if (StrEq(relname, "sibling-")) return REL_Preceding; else if (StrEq(relname, "sibling-1")) return REL_ImmPreceding; else if (StrEq(relname, "sibling+")) return REL_Following; else if (StrEq(relname, "sibling+1")) return REL_ImmFollowing; else if (StrEq(relname, "cousin")) return REL_Cousin; else fprintf(stderr, "Unknown relationship: %s\n", relname); return REL_Unknown; } /* ______________________________________________________________________ */ /* This will descend the element tree in-order. (enter_f)() is called * upon entering the node. Then all children (data and child elements) * are operated on, calling either DescendTree() with a pointer to * the child element or (data_f)() for each non-element child node. * Before leaving the node (ascending), (leave_f)() is called. enter_f * and leave_f are passed a pointer to this node and data_f is passed * a pointer to the data/content (which includes the data itself and * type information). dp is an opaque pointer to any data the caller * wants to pass. * Arguments: * Pointer to element under consideration. * Pointer to procedure to call when entering element. * Pointer to procedure to call when leaving element. * Pointer to procedure to call for each "chunk" of content data. * Void data pointer, passed to the avobe 3 procedures. */ void DescendTree( Element_t *e, void (*enter_f)(), void (*leave_f)(), void (*data_f)(), void *dp ) { int i; if (enter_f) (enter_f)(e, dp); for (i=0; incont; i++) { if (e->cont[i].type == CMD_OPEN) DescendTree(e->cont[i].ch.elem, enter_f, leave_f, data_f, dp); else if (data_f) (data_f)(&e->cont[i], dp); } if (leave_f) (leave_f)(e, dp); } /* ______________________________________________________________________ */ /* Add element, 'e', whose ID is 'idval', to a list of IDs. * This makes it easier to find an element by ID later. * Arguments: * Pointer to element under consideration. * Element's ID attribute value (a string). */ void AddID( Element_t *e, char *idval ) { static ID_t *id_last; if (!IDList) { Malloc(1, id_last, ID_t); IDList = id_last; } else { Malloc(1, id_last->next, ID_t); id_last = id_last->next; } id_last->elem = e; id_last->id = idval; } /* ______________________________________________________________________ */ /* Return pointer to element who's ID is given. * Arguments: * Element's ID attribute value (a string). * Return: * Pointer to element whose ID matches. */ Element_t * FindElemByID( char *idval ) { ID_t *id; for (id=IDList; id; id=id->next) if (toupper(id->id[0]) == toupper(idval[0]) && !strcasecmp(id->id, idval)) return id->elem; return 0; } /* ______________________________________________________________________ */ /* [ANS-db3l] Change this to a config'd request for a replacement function */ /* since later Sun systems have this and on other systems not explicitly */ /* checked here (existing code only excluded Linux) such as FreeBSD/BSDI */ /* it would crash on perror() calls. */ #ifdef STRERROR char * strerror(int number) { char buf[100]; sprintf(buf, "error number %d\n", number); perror(buf); } #endif docbook-to-man-2.0.0.orig/Instant/tptregexp/0040755000176100001440000000000007031671612020232 5ustar debacleusersdocbook-to-man-2.0.0.orig/Instant/tptregexp/Imakefile0100644000176100001440000000044606737404357022060 0ustar debacleusers#define DoNormalLib YES #define DoSharedLib NO #define DoDebugLib NO #define DoProfileLib NO #define LibName tptregexp #define LibHeaders NO #define LibInstall NO SRCS = regexp.c regsub.c regerror.c OBJS = regexp.o regsub.o regerror.o INCLUDES = -I. #include DependTarget() docbook-to-man-2.0.0.orig/Instant/tptregexp/Makefile0100644000176100001440000000625606737404357021714 0ustar debacleusers# # 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) 1995 # Dalrymple Consulting # # # $Header: /aolnet/dev/src/CVS/sgml/docbook-to-man/Instant/tptregexp/Makefile,v 1.2 1999/02/23 22:21:27 db3l Exp $ # ROOT = /usr/local MAKE = make SHELL = /bin/sh LIBDIR = $(ROOT)/lib CC = gcc # Things you might want to put in ENV and LENV: # -Dvoid=int compilers that don't do void # -DCHARBITS=0377 compilers that don't do unsigned char # -DSTATIC=extern compilers that don't like "static foo();" as forward decl # -DSTRCSPN library does not have strcspn() # -Dstrchr=index library does not have strchr() # -DERRAVAIL have utzoo-compatible error() function and friends # -DSTRERROR library does not have strerror() [ANS-db3l] #ENV=-Dvoid=int -DCHARBITS=0377 -DSTATIC=extern #LENV=-Dvoid=int -DCHARBITS=0377 # Things you might want to put in TEST: # -DDEBUG debugging hooks # -I. tptregexp.h from current directory, not /usr/include TEST= -I. # Things you might want to put in PROF: # -Dstatic='/* */' make everything global so profiler can see it. # -p profiler PROF= CFLAGS=-O $(ENV) $(TEST) $(PROF) LINTFLAGS=$(LENV) $(TEST) -ha LDFLAGS= OBJ=regexp.o regsub.o regerror.o strerror.o LSRC=regexp.c regsub.c regerror.c strerror.c DTR=README dMakefile regexp.3 tptregexp.h regexp.c regsub.c regerror.c \ regmagic.h try.c timer.c tests all: libtptregexp.a install: libtptregexp.a # @echo "No install of regex lib - install in a lib directory by hand if desired." cp libtptregexp.a $(LIBDIR) try: try.o $(OBJ) $(CC) $(LDFLAGS) try.o $(OBJ) -o try # Making timer will probably require putting stuff in $(PROF) and then # recompiling everything; the following is just the final stage. timer: timer.o $(OBJ) $(CC) $(LDFLAGS) $(PROF) timer.o $(OBJ) -o timer timer.o: timer.c timer.t.h timer.t.h: tests sed 's/ /","/g;s/\\/&&/g;s/.*/{"&"},/' tests >timer.t.h # Regression test. r: try tests @echo 'No news is good news...' try dtr dMakefile: Makefile sed '/^L*ENV=/s/ *-DERRAVAIL//' Makefile >dMakefile lib: libtptregexp.a libtptregexp.a: $(OBJ) ar rcv $@ $(OBJ) if [ -f /usr/bin/ranlib ] ; then ranlib $@ ; else true ; fi docbook-to-man-2.0.0.orig/Instant/tptregexp/README0100644000176100001440000001176006737404360021122 0ustar debacleusers# # 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. # This is a nearly-public-domain reimplementation of the V8 regexp(3) package. It gives C programs the ability to use egrep-style regular expressions, and does it in a much cleaner fashion than the analogous routines in SysV. Copyright (c) 1986 by University of Toronto. Written by Henry Spencer. Not derived from licensed software. Permission is granted to anyone to use this software for any purpose on any computer system, and to redistribute it freely, subject to the following restrictions: 1. The author is not responsible for the consequences of use of this software, no matter how awful, even if they arise from defects in it. 2. The origin of this software must not be misrepresented, either by explicit claim or by omission. 3. Altered versions must be plainly marked as such, and must not be misrepresented as being the original software. Barring a couple of small items in the BUGS list, this implementation is believed 100% compatible with V8. It should even be binary-compatible, sort of, since the only fields in a "struct regexp" that other people have any business touching are declared in exactly the same way at the same location in the struct (the beginning). This implementation is *NOT* AT&T/Bell code, and is not derived from licensed software. Even though U of T is a V8 licensee. This software is based on a V8 manual page sent to me by Dennis Ritchie (the manual page enclosed here is a complete rewrite and hence is not covered by AT&T copyright). The software was nearly complete at the time of arrival of our V8 tape. I haven't even looked at V8 yet, although a friend elsewhere at U of T has been kind enough to run a few test programs using the V8 regexp(3) to resolve a few fine points. I admit to some familiarity with regular-expression implementations of the past, but the only one that this code traces any ancestry to is the one published in Kernighan & Plauger (from which this one draws ideas but not code). Simplistically: put this stuff into a source directory, copy regexp.h into /usr/include, inspect Makefile for compilation options that need changing to suit your local environment, and then do "make r". This compiles the regexp(3) functions, compiles a test program, and runs a large set of regression tests. If there are no complaints, then put regexp.o, regsub.o, and regerror.o into your C library, and regexp.3 into your manual-pages directory. Note that if you don't put regexp.h into /usr/include *before* compiling, you'll have to add "-I." to CFLAGS before compiling. The files are: Makefile instructions to make everything regexp.3 manual page regexp.h header file, for /usr/include regexp.c source for regcomp() and regexec() regsub.c source for regsub() regerror.c source for default regerror() regmagic.h internal header file try.c source for test program timer.c source for timing program tests test list for try and timer This implementation uses nondeterministic automata rather than the deterministic ones found in some other implementations, which makes it simpler, smaller, and faster at compiling regular expressions, but slower at executing them. In theory, anyway. This implementation does employ some special-case optimizations to make the simpler cases (which do make up the bulk of regular expressions actually used) run quickly. In general, if you want blazing speed you're in the wrong place. Replacing the insides of egrep with this stuff is probably a mistake; if you want your own egrep you're going to have to do a lot more work. But if you want to use regular expressions a little bit in something else, you're in luck. Note that many existing text editors use nondeterministic regular-expression implementations, so you're in good company. This stuff should be pretty portable, given appropriate option settings. If your chars have less than 8 bits, you're going to have to change the internal representation of the automaton, although knowledge of the details of this is fairly localized. There are no "reserved" char values except for NUL, and no special significance is attached to the top bit of chars. The string(3) functions are used a fair bit, on the grounds that they are probably faster than coding the operations in line. Some attempts at code tuning have been made, but this is invariably a bit machine-specific. docbook-to-man-2.0.0.orig/Instant/tptregexp/README.osf0100644000176100001440000000250506737404360021705 0ustar debacleusers# # 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. # OSF did not write this code. Changes made: Renamed "regexp.h" to "tptregexp.h" to avoid conflicts with systems that have a /usr/include/regexp.h. Changed the *.c files in the appropriate places. Renamed these routines: regcomp() -> tpt_regcomp() regexec() -> tpt_regexec() regsub() -> tpt_regsub() regerror() -> tpt_regerror() This is to avoid conflicts in the standard C library. In Makefile - wrote "all" and "install" targets. Changed "regexp.h" to "tptregexp.h", as appropriate. In regexp.c - added #include to keep compiler happy. docbook-to-man-2.0.0.orig/Instant/tptregexp/regerror.c0100644000176100001440000000026606737404360022234 0ustar debacleusers#include void tpt_regerror(s) char *s; { #ifdef ERRAVAIL error("tpt_regexp: %s", s); #else fprintf(stderr, "tpt_regexp(3): %s", s); exit(1); #endif /* NOTREACHED */ } docbook-to-man-2.0.0.orig/Instant/tptregexp/regexp.30100644000176100001440000001505006737404360021614 0ustar debacleusers.TH REGEXP 3 local .DA 30 Nov 1985 .SH NAME regcomp, regexec, regsub, regerror \- regular expression handler .SH SYNOPSIS .ft B .nf #include regexp *regcomp(exp) char *exp; int regexec(prog, string) regexp *prog; char *string; regsub(prog, source, dest) regexp *prog; char *source; char *dest; regerror(msg) char *msg; .SH DESCRIPTION These functions implement .IR egrep (1)-style regular expressions and supporting facilities. .PP .I Regcomp compiles a regular expression into a structure of type .IR regexp , and returns a pointer to it. The space has been allocated using .IR malloc (3) and may be released by .IR free . .PP .I Regexec matches a NUL-terminated \fIstring\fR against the compiled regular expression in \fIprog\fR. It returns 1 for success and 0 for failure, and adjusts the contents of \fIprog\fR's \fIstartp\fR and \fIendp\fR (see below) accordingly. .PP The members of a .I regexp structure include at least the following (not necessarily in order): .PP .RS char *startp[NSUBEXP]; .br char *endp[NSUBEXP]; .RE .PP where .I NSUBEXP is defined (as 10) in the header file. Once a successful \fIregexec\fR has been done using the \fIregexp\fR, each \fIstartp\fR-\fIendp\fR pair describes one substring within the \fIstring\fR, with the \fIstartp\fR pointing to the first character of the substring and the \fIendp\fR pointing to the first character following the substring. The 0th substring is the substring of \fIstring\fR that matched the whole regular expression. The others are those substrings that matched parenthesized expressions within the regular expression, with parenthesized expressions numbered in left-to-right order of their opening parentheses. .PP .I Regsub copies \fIsource\fR to \fIdest\fR, making substitutions according to the most recent \fIregexec\fR performed using \fIprog\fR. Each instance of `&' in \fIsource\fR is replaced by the substring indicated by \fIstartp\fR[\fI0\fR] and \fIendp\fR[\fI0\fR]. Each instance of `\e\fIn\fR', where \fIn\fR is a digit, is replaced by the substring indicated by \fIstartp\fR[\fIn\fR] and \fIendp\fR[\fIn\fR]. To get a literal `&' or `\e\fIn\fR' into \fIdest\fR, prefix it with `\e'; to get a literal `\e' preceding `&' or `\e\fIn\fR', prefix it with another `\e'. .PP .I Regerror is called whenever an error is detected in \fIregcomp\fR, \fIregexec\fR, or \fIregsub\fR. The default \fIregerror\fR writes the string \fImsg\fR, with a suitable indicator of origin, on the standard error output and invokes \fIexit\fR(2). .I Regerror can be replaced by the user if other actions are desirable. .SH "REGULAR EXPRESSION SYNTAX" A regular expression is zero or more \fIbranches\fR, separated by `|'. It matches anything that matches one of the branches. .PP A branch is zero or more \fIpieces\fR, concatenated. It matches a match for the first, followed by a match for the second, etc. .PP A piece is an \fIatom\fR possibly followed by `*', `+', or `?'. An atom followed by `*' matches a sequence of 0 or more matches of the atom. An atom followed by `+' matches a sequence of 1 or more matches of the atom. An atom followed by `?' matches a match of the atom, or the null string. .PP An atom is a regular expression in parentheses (matching a match for the regular expression), a \fIrange\fR (see below), `.' (matching any single character), `^' (matching the null string at the beginning of the input string), `$' (matching the null string at the end of the input string), a `\e' followed by a single character (matching that character), or a single character with no other significance (matching that character). .PP A \fIrange\fR is a sequence of characters enclosed in `[]'. It normally matches any single character from the sequence. If the sequence begins with `^', it matches any single character \fInot\fR from the rest of the sequence. If two characters in the sequence are separated by `\-', this is shorthand for the full list of ASCII characters between them (e.g. `[0-9]' matches any decimal digit). To include a literal `]' in the sequence, make it the first character (following a possible `^'). To include a literal `\-', make it the first or last character. .SH AMBIGUITY If a regular expression could match two different parts of the input string, it will match the one which begins earliest. If both begin in the same place but match different lengths, or match the same length in different ways, life gets messier, as follows. .PP In general, the possibilities in a list of branches are considered in left-to-right order, the possibilities for `*', `+', and `?' are considered longest-first, nested constructs are considered from the outermost in, and concatenated constructs are considered leftmost-first. The match that will be chosen is the one that uses the earliest possibility in the first choice that has to be made. If there is more than one choice, the next will be made in the same manner (earliest possibility) subject to the decision on the first choice. And so forth. .PP For example, `(ab|a)b*c' could match `abc' in one of two ways. The first choice is between `ab' and `a'; since `ab' is earlier, and does lead to a successful overall match, it is chosen. Since the `b' is already spoken for, the `b*' must match its last possibility\(emthe empty string\(emsince it must respect the earlier choice. .PP In the particular case where no `|'s are present and there is only one `*', `+', or `?', the net effect is that the longest possible match will be chosen. So `ab*', presented with `xabbbby', will match `abbbb'. Note that if `ab*' is tried against `xabyabbbz', it will match `ab' just after `x', due to the begins-earliest rule. (In effect, the decision on where to start the match is the first choice to be made, hence subsequent choices must respect it even if this leads them to less-preferred alternatives.) .SH SEE ALSO egrep(1), expr(1) .SH DIAGNOSTICS \fIRegcomp\fR returns NULL for a failure (\fIregerror\fR permitting), where failures are syntax errors, exceeding implementation limits, or applying `+' or `*' to a possibly-null operand. .SH HISTORY Both code and manual page were written at U of T. They are intended to be compatible with the Bell V8 \fIregexp\fR(3), but are not derived from Bell code. .SH BUGS Empty branches and empty regular expressions are not portable to V8. .PP The restriction against applying `*' or `+' to a possibly-null operand is an artifact of the simplistic implementation. .PP Does not support \fIegrep\fR's newline-separated branches; neither does the V8 \fIregexp\fR(3), though. .PP Due to emphasis on compactness and simplicity, it's not strikingly fast. It does give special attention to handling simple cases quickly. docbook-to-man-2.0.0.orig/Instant/tptregexp/regexp.c0100644000176100001440000006603406737404360021704 0ustar debacleusers/* * regcomp and regexec -- regsub and regerror are elsewhere * * Copyright (c) 1986 by University of Toronto. * Written by Henry Spencer. Not derived from licensed software. * * Permission is granted to anyone to use this software for any * purpose on any computer system, and to redistribute it freely, * subject to the following restrictions: * * 1. The author is not responsible for the consequences of use of * this software, no matter how awful, even if they arise * from defects in it. * * 2. The origin of this software must not be misrepresented, either * by explicit claim or by omission. * * 3. Altered versions must be plainly marked as such, and must not * be misrepresented as being the original software. * * Beware that some of this code is subtly aware of the way operator * precedence is structured in regular expressions. Serious changes in * regular-expression syntax might require a total rethink. */ #include #include #include #include "regmagic.h" /* * The "internal use only" fields in regexp.h are present to pass info from * compile to execute that permits the execute phase to run lots faster on * simple cases. They are: * * regstart char that must begin a match; '\0' if none obvious * reganch is the match anchored (at beginning-of-line only)? * regmust string (pointer into program) that match must include, or NULL * regmlen length of regmust string * * Regstart and reganch permit very fast decisions on suitable starting points * for a match, cutting down the work a lot. Regmust permits fast rejection * of lines that cannot possibly match. The regmust tests are costly enough * that regcomp() supplies a regmust only if the r.e. contains something * potentially expensive (at present, the only such thing detected is * or + * at the start of the r.e., which can involve a lot of backup). Regmlen is * supplied because the test in regexec() needs it and regcomp() is computing * it anyway. */ /* * Structure for regexp "program". This is essentially a linear encoding * of a nondeterministic finite-state machine (aka syntax charts or * "railroad normal form" in parsing technology). Each node is an opcode * plus a "next" pointer, possibly plus an operand. "Next" pointers of * all nodes except BRANCH implement concatenation; a "next" pointer with * a BRANCH on both ends of it is connecting two alternatives. (Here we * have one of the subtle syntax dependencies: an individual BRANCH (as * opposed to a collection of them) is never concatenated with anything * because of operator precedence.) The operand of some types of node is * a literal string; for others, it is a node leading into a sub-FSM. In * particular, the operand of a BRANCH node is the first node of the branch. * (NB this is *not* a tree structure: the tail of the branch connects * to the thing following the set of BRANCHes.) The opcodes are: */ /* definition number opnd? meaning */ #define END 0 /* no End of program. */ #define BOL 1 /* no Match "" at beginning of line. */ #define EOL 2 /* no Match "" at end of line. */ #define ANY 3 /* no Match any one character. */ #define ANYOF 4 /* str Match any character in this string. */ #define ANYBUT 5 /* str Match any character not in this string. */ #define BRANCH 6 /* node Match this alternative, or the next... */ #define BACK 7 /* no Match "", "next" ptr points backward. */ #define EXACTLY 8 /* str Match this string. */ #define NOTHING 9 /* no Match empty string. */ #define STAR 10 /* node Match this (simple) thing 0 or more times. */ #define PLUS 11 /* node Match this (simple) thing 1 or more times. */ #define OPEN 20 /* no Mark this point in input as start of #n. */ /* OPEN+1 is number 1, etc. */ #define CLOSE 30 /* no Analogous to OPEN. */ /* * Opcode notes: * * BRANCH The set of branches constituting a single choice are hooked * together with their "next" pointers, since precedence prevents * anything being concatenated to any individual branch. The * "next" pointer of the last BRANCH in a choice points to the * thing following the whole choice. This is also where the * final "next" pointer of each individual branch points; each * branch starts with the operand node of a BRANCH node. * * BACK Normal "next" pointers all implicitly point forward; BACK * exists to make loop structures possible. * * STAR,PLUS '?', and complex '*' and '+', are implemented as circular * BRANCH structures using BACK. Simple cases (one character * per match) are implemented with STAR and PLUS for speed * and to minimize recursive plunges. * * OPEN,CLOSE ...are numbered at compile time. */ /* * A node is one char of opcode followed by two chars of "next" pointer. * "Next" pointers are stored as two 8-bit pieces, high order first. The * value is a positive offset from the opcode of the node containing it. * An operand, if any, simply follows the node. (Note that much of the * code generation knows about this implicit relationship.) * * Using two bytes for the "next" pointer is vast overkill for most things, * but allows patterns to get big without disasters. */ #define OP(p) (*(p)) #define NEXT(p) (((*((p)+1)&0377)<<8) + (*((p)+2)&0377)) #define OPERAND(p) ((p) + 3) /* * See regmagic.h for one further detail of program structure. */ /* * Utility definitions. */ #ifndef CHARBITS #define UCHARAT(p) ((int)*(unsigned char *)(p)) #else #define UCHARAT(p) ((int)*(p)&CHARBITS) #endif #define FAIL(m) { tpt_regerror(m); return(NULL); } #define ISMULT(c) ((c) == '*' || (c) == '+' || (c) == '?') #define META "^$.[()|?+*\\" /* * Flags to be passed up and down. */ #define HASWIDTH 01 /* Known never to match null string. */ #define SIMPLE 02 /* Simple enough to be STAR/PLUS operand. */ #define SPSTART 04 /* Starts with * or +. */ #define WORST 0 /* Worst case. */ /* * Global work variables for regcomp(). */ static char *regparse; /* Input-scan pointer. */ static int regnpar; /* () count. */ static char regdummy; static char *regcode; /* Code-emit pointer; ®dummy = don't. */ static long regsize; /* Code size. */ /* * Forward declarations for regcomp()'s friends. */ #ifndef STATIC #define STATIC static #endif STATIC char *reg(); STATIC char *regbranch(); STATIC char *regpiece(); STATIC char *regatom(); STATIC char *regnode(); STATIC char *regnext(); STATIC void regc(); STATIC void reginsert(); STATIC void regtail(); STATIC void regoptail(); #ifdef STRCSPN STATIC int strcspn(); #endif /* - regcomp - compile a regular expression into internal code * * We can't allocate space until we know how big the compiled form will be, * but we can't compile it (and thus know how big it is) until we've got a * place to put the code. So we cheat: we compile it twice, once with code * generation turned off and size counting turned on, and once "for real". * This also means that we don't allocate space until we are sure that the * thing really will compile successfully, and we never have to move the * code and thus invalidate pointers into it. (Note that it has to be in * one piece because free() must be able to free it all.) * * Beware that the optimization-preparation code in here knows about some * of the structure of the compiled regexp. */ regexp * tpt_regcomp(exp) char *exp; { register regexp *r; register char *scan; register char *longest; register int len; int flags; extern char *malloc(); if (exp == NULL) FAIL("NULL argument"); /* First pass: determine size, legality. */ regparse = exp; regnpar = 1; regsize = 0L; regcode = ®dummy; regc(MAGIC); if (reg(0, &flags) == NULL) return(NULL); /* Small enough for pointer-storage convention? */ if (regsize >= 32767L) /* Probably could be 65535L. */ FAIL("regexp too big"); /* Allocate space. */ r = (regexp *)malloc(sizeof(regexp) + (unsigned)regsize); if (r == NULL) FAIL("out of space"); /* Second pass: emit code. */ regparse = exp; regnpar = 1; regcode = r->program; regc(MAGIC); if (reg(0, &flags) == NULL) return(NULL); /* Dig out information for optimizations. */ r->regstart = '\0'; /* Worst-case defaults. */ r->reganch = 0; r->regmust = NULL; r->regmlen = 0; scan = r->program+1; /* First BRANCH. */ if (OP(regnext(scan)) == END) { /* Only one top-level choice. */ scan = OPERAND(scan); /* Starting-point info. */ if (OP(scan) == EXACTLY) r->regstart = *OPERAND(scan); else if (OP(scan) == BOL) r->reganch++; /* * If there's something expensive in the r.e., find the * longest literal string that must appear and make it the * regmust. Resolve ties in favor of later strings, since * the regstart check works with the beginning of the r.e. * and avoiding duplication strengthens checking. Not a * strong reason, but sufficient in the absence of others. */ if (flags&SPSTART) { longest = NULL; len = 0; for (; scan != NULL; scan = regnext(scan)) if (OP(scan) == EXACTLY && strlen(OPERAND(scan)) >= len) { longest = OPERAND(scan); len = strlen(OPERAND(scan)); } r->regmust = longest; r->regmlen = len; } } return(r); } /* - reg - regular expression, i.e. main body or parenthesized thing * * Caller must absorb opening parenthesis. * * Combining parenthesis handling with the base level of regular expression * is a trifle forced, but the need to tie the tails of the branches to what * follows makes it hard to avoid. */ static char * reg(paren, flagp) int paren; /* Parenthesized? */ int *flagp; { register char *ret; register char *br; register char *ender; register int parno; int flags; *flagp = HASWIDTH; /* Tentatively. */ /* Make an OPEN node, if parenthesized. */ if (paren) { if (regnpar >= NSUBEXP) FAIL("too many ()"); parno = regnpar; regnpar++; ret = regnode(OPEN+parno); } else ret = NULL; /* Pick up the branches, linking them together. */ br = regbranch(&flags); if (br == NULL) return(NULL); if (ret != NULL) regtail(ret, br); /* OPEN -> first. */ else ret = br; if (!(flags&HASWIDTH)) *flagp &= ~HASWIDTH; *flagp |= flags&SPSTART; while (*regparse == '|') { regparse++; br = regbranch(&flags); if (br == NULL) return(NULL); regtail(ret, br); /* BRANCH -> BRANCH. */ if (!(flags&HASWIDTH)) *flagp &= ~HASWIDTH; *flagp |= flags&SPSTART; } /* Make a closing node, and hook it on the end. */ ender = regnode((paren) ? CLOSE+parno : END); regtail(ret, ender); /* Hook the tails of the branches to the closing node. */ for (br = ret; br != NULL; br = regnext(br)) regoptail(br, ender); /* Check for proper termination. */ if (paren && *regparse++ != ')') { FAIL("unmatched ()"); } else if (!paren && *regparse != '\0') { if (*regparse == ')') { FAIL("unmatched ()"); } else FAIL("junk on end"); /* "Can't happen". */ /* NOTREACHED */ } return(ret); } /* - regbranch - one alternative of an | operator * * Implements the concatenation operator. */ static char * regbranch(flagp) int *flagp; { register char *ret; register char *chain; register char *latest; int flags; *flagp = WORST; /* Tentatively. */ ret = regnode(BRANCH); chain = NULL; while (*regparse != '\0' && *regparse != '|' && *regparse != ')') { latest = regpiece(&flags); if (latest == NULL) return(NULL); *flagp |= flags&HASWIDTH; if (chain == NULL) /* First piece. */ *flagp |= flags&SPSTART; else regtail(chain, latest); chain = latest; } if (chain == NULL) /* Loop ran zero times. */ (void) regnode(NOTHING); return(ret); } /* - regpiece - something followed by possible [*+?] * * Note that the branching code sequences used for ? and the general cases * of * and + are somewhat optimized: they use the same NOTHING node as * both the endmarker for their branch list and the body of the last branch. * It might seem that this node could be dispensed with entirely, but the * endmarker role is not redundant. */ static char * regpiece(flagp) int *flagp; { register char *ret; register char op; register char *next; int flags; ret = regatom(&flags); if (ret == NULL) return(NULL); op = *regparse; if (!ISMULT(op)) { *flagp = flags; return(ret); } if (!(flags&HASWIDTH) && op != '?') FAIL("*+ operand could be empty"); *flagp = (op != '+') ? (WORST|SPSTART) : (WORST|HASWIDTH); if (op == '*' && (flags&SIMPLE)) reginsert(STAR, ret); else if (op == '*') { /* Emit x* as (x&|), where & means "self". */ reginsert(BRANCH, ret); /* Either x */ regoptail(ret, regnode(BACK)); /* and loop */ regoptail(ret, ret); /* back */ regtail(ret, regnode(BRANCH)); /* or */ regtail(ret, regnode(NOTHING)); /* null. */ } else if (op == '+' && (flags&SIMPLE)) reginsert(PLUS, ret); else if (op == '+') { /* Emit x+ as x(&|), where & means "self". */ next = regnode(BRANCH); /* Either */ regtail(ret, next); regtail(regnode(BACK), ret); /* loop back */ regtail(next, regnode(BRANCH)); /* or */ regtail(ret, regnode(NOTHING)); /* null. */ } else if (op == '?') { /* Emit x? as (x|) */ reginsert(BRANCH, ret); /* Either x */ regtail(ret, regnode(BRANCH)); /* or */ next = regnode(NOTHING); /* null. */ regtail(ret, next); regoptail(ret, next); } regparse++; if (ISMULT(*regparse)) FAIL("nested *?+"); return(ret); } /* - regatom - the lowest level * * Optimization: gobbles an entire sequence of ordinary characters so that * it can turn them into a single node, which is smaller to store and * faster to run. Backslashed characters are exceptions, each becoming a * separate node; the code is simpler that way and it's not worth fixing. */ static char * regatom(flagp) int *flagp; { register char *ret; int flags; *flagp = WORST; /* Tentatively. */ switch (*regparse++) { case '^': ret = regnode(BOL); break; case '$': ret = regnode(EOL); break; case '.': ret = regnode(ANY); *flagp |= HASWIDTH|SIMPLE; break; case '[': { register int class; register int classend; if (*regparse == '^') { /* Complement of range. */ ret = regnode(ANYBUT); regparse++; } else ret = regnode(ANYOF); if (*regparse == ']' || *regparse == '-') regc(*regparse++); while (*regparse != '\0' && *regparse != ']') { if (*regparse == '-') { regparse++; if (*regparse == ']' || *regparse == '\0') regc('-'); else { class = UCHARAT(regparse-2)+1; classend = UCHARAT(regparse); if (class > classend+1) FAIL("invalid [] range"); for (; class <= classend; class++) regc(class); regparse++; } } else regc(*regparse++); } regc('\0'); if (*regparse != ']') FAIL("unmatched []"); regparse++; *flagp |= HASWIDTH|SIMPLE; } break; case '(': ret = reg(1, &flags); if (ret == NULL) return(NULL); *flagp |= flags&(HASWIDTH|SPSTART); break; case '\0': case '|': case ')': FAIL("internal urp"); /* Supposed to be caught earlier. */ break; case '?': case '+': case '*': FAIL("?+* follows nothing"); break; case '\\': if (*regparse == '\0') FAIL("trailing \\"); ret = regnode(EXACTLY); regc(*regparse++); regc('\0'); *flagp |= HASWIDTH|SIMPLE; break; default: { register int len; register char ender; regparse--; len = strcspn(regparse, META); if (len <= 0) FAIL("internal disaster"); ender = *(regparse+len); if (len > 1 && ISMULT(ender)) len--; /* Back off clear of ?+* operand. */ *flagp |= HASWIDTH; if (len == 1) *flagp |= SIMPLE; ret = regnode(EXACTLY); while (len > 0) { regc(*regparse++); len--; } regc('\0'); } break; } return(ret); } /* - regnode - emit a node */ static char * /* Location. */ regnode(op) char op; { register char *ret; register char *ptr; ret = regcode; if (ret == ®dummy) { regsize += 3; return(ret); } ptr = ret; *ptr++ = op; *ptr++ = '\0'; /* Null "next" pointer. */ *ptr++ = '\0'; regcode = ptr; return(ret); } /* - regc - emit (if appropriate) a byte of code */ static void regc(b) char b; { if (regcode != ®dummy) *regcode++ = b; else regsize++; } /* - reginsert - insert an operator in front of already-emitted operand * * Means relocating the operand. */ static void reginsert(op, opnd) char op; char *opnd; { register char *src; register char *dst; register char *place; if (regcode == ®dummy) { regsize += 3; return; } src = regcode; regcode += 3; dst = regcode; while (src > opnd) *--dst = *--src; place = opnd; /* Op node, where operand used to be. */ *place++ = op; *place++ = '\0'; *place++ = '\0'; } /* - regtail - set the next-pointer at the end of a node chain */ static void regtail(p, val) char *p; char *val; { register char *scan; register char *temp; register int offset; if (p == ®dummy) return; /* Find last node. */ scan = p; for (;;) { temp = regnext(scan); if (temp == NULL) break; scan = temp; } if (OP(scan) == BACK) offset = scan - val; else offset = val - scan; *(scan+1) = (offset>>8)&0377; *(scan+2) = offset&0377; } /* - regoptail - regtail on operand of first argument; nop if operandless */ static void regoptail(p, val) char *p; char *val; { /* "Operandless" and "op != BRANCH" are synonymous in practice. */ if (p == NULL || p == ®dummy || OP(p) != BRANCH) return; regtail(OPERAND(p), val); } /* * regexec and friends */ /* * Global work variables for regexec(). */ static char *reginput; /* String-input pointer. */ static char *regbol; /* Beginning of input, for ^ check. */ static char **regstartp; /* Pointer to startp array. */ static char **regendp; /* Ditto for endp. */ /* * Forwards. */ STATIC int regtry(); STATIC int regmatch(); STATIC int regrepeat(); #ifdef DEBUG int regnarrate = 0; void regdump(); STATIC char *regprop(); #endif /* - regexec - match a regexp against a string */ int tpt_regexec(prog, string) register regexp *prog; register char *string; { register char *s; extern char *strchr(); /* Be paranoid... */ if (prog == NULL || string == NULL) { tpt_regerror("NULL parameter"); return(0); } /* Check validity of program. */ if (UCHARAT(prog->program) != MAGIC) { tpt_regerror("corrupted program"); return(0); } /* If there is a "must appear" string, look for it. */ if (prog->regmust != NULL) { s = string; while ((s = strchr(s, prog->regmust[0])) != NULL) { if (strncmp(s, prog->regmust, prog->regmlen) == 0) break; /* Found it. */ s++; } if (s == NULL) /* Not present. */ return(0); } /* Mark beginning of line for ^ . */ regbol = string; /* Simplest case: anchored match need be tried only once. */ if (prog->reganch) return(regtry(prog, string)); /* Messy cases: unanchored match. */ s = string; if (prog->regstart != '\0') /* We know what char it must start with. */ while ((s = strchr(s, prog->regstart)) != NULL) { if (regtry(prog, s)) return(1); s++; } else /* We don't -- general case. */ do { if (regtry(prog, s)) return(1); } while (*s++ != '\0'); /* Failure. */ return(0); } /* - regtry - try match at specific point */ static int /* 0 failure, 1 success */ regtry(prog, string) regexp *prog; char *string; { register int i; register char **sp; register char **ep; reginput = string; regstartp = prog->startp; regendp = prog->endp; sp = prog->startp; ep = prog->endp; for (i = NSUBEXP; i > 0; i--) { *sp++ = NULL; *ep++ = NULL; } if (regmatch(prog->program + 1)) { prog->startp[0] = string; prog->endp[0] = reginput; return(1); } else return(0); } /* - regmatch - main matching routine * * Conceptually the strategy is simple: check to see whether the current * node matches, call self recursively to see whether the rest matches, * and then act accordingly. In practice we make some effort to avoid * recursion, in particular by going through "ordinary" nodes (that don't * need to know whether the rest of the match failed) by a loop instead of * by recursion. */ static int /* 0 failure, 1 success */ regmatch(prog) char *prog; { register char *scan; /* Current node. */ char *next; /* Next node. */ extern char *strchr(); scan = prog; #ifdef DEBUG if (scan != NULL && regnarrate) fprintf(stderr, "%s(\n", regprop(scan)); #endif while (scan != NULL) { #ifdef DEBUG if (regnarrate) fprintf(stderr, "%s...\n", regprop(scan)); #endif next = regnext(scan); switch (OP(scan)) { case BOL: if (reginput != regbol) return(0); break; case EOL: if (*reginput != '\0') return(0); break; case ANY: if (*reginput == '\0') return(0); reginput++; break; case EXACTLY: { register int len; register char *opnd; opnd = OPERAND(scan); /* Inline the first character, for speed. */ if (*opnd != *reginput) return(0); len = strlen(opnd); if (len > 1 && strncmp(opnd, reginput, len) != 0) return(0); reginput += len; } break; case ANYOF: if (*reginput == '\0' || strchr(OPERAND(scan), *reginput) == NULL) return(0); reginput++; break; case ANYBUT: if (*reginput == '\0' || strchr(OPERAND(scan), *reginput) != NULL) return(0); reginput++; break; case NOTHING: break; case BACK: break; case OPEN+1: case OPEN+2: case OPEN+3: case OPEN+4: case OPEN+5: case OPEN+6: case OPEN+7: case OPEN+8: case OPEN+9: { register int no; register char *save; no = OP(scan) - OPEN; save = reginput; if (regmatch(next)) { /* * Don't set startp if some later * invocation of the same parentheses * already has. */ if (regstartp[no] == NULL) regstartp[no] = save; return(1); } else return(0); } break; case CLOSE+1: case CLOSE+2: case CLOSE+3: case CLOSE+4: case CLOSE+5: case CLOSE+6: case CLOSE+7: case CLOSE+8: case CLOSE+9: { register int no; register char *save; no = OP(scan) - CLOSE; save = reginput; if (regmatch(next)) { /* * Don't set endp if some later * invocation of the same parentheses * already has. */ if (regendp[no] == NULL) regendp[no] = save; return(1); } else return(0); } break; case BRANCH: { register char *save; if (OP(next) != BRANCH) /* No choice. */ next = OPERAND(scan); /* Avoid recursion. */ else { do { save = reginput; if (regmatch(OPERAND(scan))) return(1); reginput = save; scan = regnext(scan); } while (scan != NULL && OP(scan) == BRANCH); return(0); /* NOTREACHED */ } } break; case STAR: case PLUS: { register char nextch; register int no; register char *save; register int min; /* * Lookahead to avoid useless match attempts * when we know what character comes next. */ nextch = '\0'; if (OP(next) == EXACTLY) nextch = *OPERAND(next); min = (OP(scan) == STAR) ? 0 : 1; save = reginput; no = regrepeat(OPERAND(scan)); while (no >= min) { /* If it could work, try it. */ if (nextch == '\0' || *reginput == nextch) if (regmatch(next)) return(1); /* Couldn't or didn't -- back up. */ no--; reginput = save + no; } return(0); } break; case END: return(1); /* Success! */ break; default: tpt_regerror("memory corruption"); return(0); break; } scan = next; } /* * We get here only if there's trouble -- normally "case END" is * the terminating point. */ tpt_regerror("corrupted pointers"); return(0); } /* - regrepeat - repeatedly match something simple, report how many */ static int regrepeat(p) char *p; { register int count = 0; register char *scan; register char *opnd; scan = reginput; opnd = OPERAND(p); switch (OP(p)) { case ANY: count = strlen(scan); scan += count; break; case EXACTLY: while (*opnd == *scan) { count++; scan++; } break; case ANYOF: while (*scan != '\0' && strchr(opnd, *scan) != NULL) { count++; scan++; } break; case ANYBUT: while (*scan != '\0' && strchr(opnd, *scan) == NULL) { count++; scan++; } break; default: /* Oh dear. Called inappropriately. */ tpt_regerror("internal foulup"); count = 0; /* Best compromise. */ break; } reginput = scan; return(count); } /* - regnext - dig the "next" pointer out of a node */ static char * regnext(p) register char *p; { register int offset; if (p == ®dummy) return(NULL); offset = NEXT(p); if (offset == 0) return(NULL); if (OP(p) == BACK) return(p-offset); else return(p+offset); } #ifdef DEBUG STATIC char *regprop(); /* - regdump - dump a regexp onto stdout in vaguely comprehensible form */ void regdump(r) regexp *r; { register char *s; register char op = EXACTLY; /* Arbitrary non-END op. */ register char *next; extern char *strchr(); s = r->program + 1; while (op != END) { /* While that wasn't END last time... */ op = OP(s); printf("%2d%s", s-r->program, regprop(s)); /* Where, what. */ next = regnext(s); if (next == NULL) /* Next ptr. */ printf("(0)"); else printf("(%d)", (s-r->program)+(next-s)); s += 3; if (op == ANYOF || op == ANYBUT || op == EXACTLY) { /* Literal string, where present. */ while (*s != '\0') { putchar(*s); s++; } s++; } putchar('\n'); } /* Header fields of interest. */ if (r->regstart != '\0') printf("start `%c' ", r->regstart); if (r->reganch) printf("anchored "); if (r->regmust != NULL) printf("must have \"%s\"", r->regmust); printf("\n"); } /* - regprop - printable representation of opcode */ static char * regprop(op) char *op; { register char *p; static char buf[50]; (void) strcpy(buf, ":"); switch (OP(op)) { case BOL: p = "BOL"; break; case EOL: p = "EOL"; break; case ANY: p = "ANY"; break; case ANYOF: p = "ANYOF"; break; case ANYBUT: p = "ANYBUT"; break; case BRANCH: p = "BRANCH"; break; case EXACTLY: p = "EXACTLY"; break; case NOTHING: p = "NOTHING"; break; case BACK: p = "BACK"; break; case END: p = "END"; break; case OPEN+1: case OPEN+2: case OPEN+3: case OPEN+4: case OPEN+5: case OPEN+6: case OPEN+7: case OPEN+8: case OPEN+9: sprintf(buf+strlen(buf), "OPEN%d", OP(op)-OPEN); p = NULL; break; case CLOSE+1: case CLOSE+2: case CLOSE+3: case CLOSE+4: case CLOSE+5: case CLOSE+6: case CLOSE+7: case CLOSE+8: case CLOSE+9: sprintf(buf+strlen(buf), "CLOSE%d", OP(op)-CLOSE); p = NULL; break; case STAR: p = "STAR"; break; case PLUS: p = "PLUS"; break; default: tpt_regerror("corrupted opcode"); break; } if (p != NULL) (void) strcat(buf, p); return(buf); } #endif /* * The following is provided for those people who do not have strcspn() in * their C libraries. They should get off their butts and do something * about it; at least one public-domain implementation of those (highly * useful) string routines has been published on Usenet. */ #ifdef STRCSPN /* * strcspn - find length of initial segment of s1 consisting entirely * of characters not from s2 */ static int strcspn(s1, s2) char *s1; char *s2; { register char *scan1; register char *scan2; register int count; count = 0; for (scan1 = s1; *scan1 != '\0'; scan1++) { for (scan2 = s2; *scan2 != '\0';) /* ++ moved down. */ if (*scan1 == *scan2++) return(count); count++; } return(count); } #endif docbook-to-man-2.0.0.orig/Instant/tptregexp/regmagic.h0100644000176100001440000000023106737404360022160 0ustar debacleusers/* * The first byte of the regexp internal "program" is actually this magic * number; the start node begins in the second byte. */ #define MAGIC 0234 docbook-to-man-2.0.0.orig/Instant/tptregexp/regsub.c0100644000176100001440000000367106737404360021677 0ustar debacleusers/* * regsub * * Copyright (c) 1986 by University of Toronto. * Written by Henry Spencer. Not derived from licensed software. * * Permission is granted to anyone to use this software for any * purpose on any computer system, and to redistribute it freely, * subject to the following restrictions: * * 1. The author is not responsible for the consequences of use of * this software, no matter how awful, even if they arise * from defects in it. * * 2. The origin of this software must not be misrepresented, either * by explicit claim or by omission. * * 3. Altered versions must be plainly marked as such, and must not * be misrepresented as being the original software. */ #include #include #include "regmagic.h" #ifndef CHARBITS #define UCHARAT(p) ((int)*(unsigned char *)(p)) #else #define UCHARAT(p) ((int)*(p)&CHARBITS) #endif /* - regsub - perform substitutions after a regexp match */ void tpt_regsub(prog, source, dest) regexp *prog; char *source; char *dest; { register char *src; register char *dst; register char c; register int no; register int len; extern char *strncpy(); if (prog == NULL || source == NULL || dest == NULL) { tpt_regerror("NULL parm to regsub"); return; } if (UCHARAT(prog->program) != MAGIC) { tpt_regerror("damaged regexp fed to regsub"); return; } src = source; dst = dest; while ((c = *src++) != '\0') { if (c == '&') no = 0; else if (c == '\\' && '0' <= *src && *src <= '9') no = *src++ - '0'; else no = -1; if (no < 0) { /* Ordinary character. */ if (c == '\\' && (*src == '\\' || *src == '&')) c = *src++; *dst++ = c; } else if (prog->startp[no] != NULL && prog->endp[no] != NULL) { len = prog->endp[no] - prog->startp[no]; (void) strncpy(dst, prog->startp[no], len); dst += len; if (len != 0 && *(dst-1) == '\0') { /* strncpy hit NUL. */ tpt_regerror("damaged match string"); return; } } } *dst++ = '\0'; } docbook-to-man-2.0.0.orig/Instant/tptregexp/strerror.c0100644000176100001440000000061406737404360022264 0ustar debacleusers/* [ANS-db3l] Change this to a config'd request for a replacement function */ /* since later Sun systems have this and on other systems not explicitly */ /* checked here such as FreeBSD/BSDI it would crash on perror() calls. */ #ifdef STRERROR /* standin for strerror(3) which is missing on some systems * (eg, SUN) */ char * strerror(int num) { perror(num); return ""; } #endif docbook-to-man-2.0.0.orig/Instant/tptregexp/tests0100644000176100001440000000535206737404360021327 0ustar debacleusersabc abc y & abc abc xbc n - - abc axc n - - abc abx n - - abc xabcy y & abc abc ababc y & abc ab*c abc y & abc ab*bc abc y & abc ab*bc abbc y & abbc ab*bc abbbbc y & abbbbc ab+bc abbc y & abbc ab+bc abc n - - ab+bc abq n - - ab+bc abbbbc y & abbbbc ab?bc abbc y & abbc ab?bc abc y & abc ab?bc abbbbc n - - ab?c abc y & abc ^abc$ abc y & abc ^abc$ abcc n - - ^abc abcc y & abc ^abc$ aabc n - - abc$ aabc y & abc ^ abc y & $ abc y & a.c abc y & abc a.c axc y & axc a.*c axyzc y & axyzc a.*c axyzd n - - a[bc]d abc n - - a[bc]d abd y & abd a[b-d]e abd n - - a[b-d]e ace y & ace a[b-d] aac y & ac a[-b] a- y & a- a[b-] a- y & a- a[b-a] - c - - a[]b - c - - a[ - c - - a] a] y & a] a[]]b a]b y & a]b a[^bc]d aed y & aed a[^bc]d abd n - - a[^-b]c adc y & adc a[^-b]c a-c n - - a[^]b]c a]c n - - a[^]b]c adc y & adc ab|cd abc y & ab ab|cd abcd y & ab ()ef def y &-\1 ef- ()* - c - - *a - c - - ^* - c - - $* - c - - (*)b - c - - $b b n - - a\ - c - - a\(b a(b y &-\1 a(b- a\(*b ab y & ab a\(*b a((b y & a((b a\\b a\b y & a\b abc) - c - - (abc - c - - ((a)) abc y &-\1-\2 a-a-a (a)b(c) abc y &-\1-\2 abc-a-c a+b+c aabbabc y & abc a** - c - - a*? - c - - (a*)* - c - - (a*)+ - c - - (a|)* - c - - (a*|b)* - c - - (a+|b)* ab y &-\1 ab-b (a+|b)+ ab y &-\1 ab-b (a+|b)? ab y &-\1 a-a [^ab]* cde y & cde (^)* - c - - (ab|)* - c - - )( - c - - abc y & abc n - - a* y & ([abc])*d abbbcd y &-\1 abbbcd-c ([abc])*bcd abcd y &-\1 abcd-a a|b|c|d|e e y & e (a|b|c|d|e)f ef y &-\1 ef-e ((a*|b))* - c - - abcd*efg abcdefg y & abcdefg ab* xabyabbbz y & ab ab* xayabbbz y & a (ab|cd)e abcde y &-\1 cde-cd [abhgefdc]ij hij y & hij ^(ab|cd)e abcde n x\1y xy (abc|)ef abcdef y &-\1 ef- (a|b)c*d abcd y &-\1 bcd-b (ab|ab*)bc abc y &-\1 abc-a a([bc]*)c* abc y &-\1 abc-bc a([bc]*)(c*d) abcd y &-\1-\2 abcd-bc-d a([bc]+)(c*d) abcd y &-\1-\2 abcd-bc-d a([bc]*)(c+d) abcd y &-\1-\2 abcd-b-cd a[bcd]*dcdcde adcdcde y & adcdcde a[bcd]+dcdcde adcdcde n - - (ab|a)b*c abc y &-\1 abc-ab ((a)(b)c)(d) abcd y \1-\2-\3-\4 abc-a-b-d [a-zA-Z_][a-zA-Z0-9_]* alpha y & alpha ^a(bc+|b[eh])g|.h$ abh y &-\1 bh- (bc+d$|ef*g.|h?i(j|k)) effgz y &-\1-\2 effgz-effgz- (bc+d$|ef*g.|h?i(j|k)) ij y &-\1-\2 ij-ij-j (bc+d$|ef*g.|h?i(j|k)) effg n - - (bc+d$|ef*g.|h?i(j|k)) bcdd n - - (bc+d$|ef*g.|h?i(j|k)) reffgz y &-\1-\2 effgz-effgz- ((((((((((a)))))))))) - c - - (((((((((a))))))))) a y & a multiple words of text uh-uh n - - multiple words multiple words, yeah y & multiple words (.*)c(.*) abcde y &-\1-\2 abcde-ab-de \((.*), (.*)\) (a, b) y (\2, \1) (b, a) [k] ab n - - abcd abcd y &-\&-\\& abcd-&-\abcd a(bc)d abcd y \1-\\1-\\\1 bc-\1-\bc [ -~]* abc y & abc [ -~ -~]* abc y & abc [ -~ -~ -~]* abc y & abc [ -~ -~ -~ -~]* abc y & abc [ -~ -~ -~ -~ -~]* abc y & abc [ -~ -~ -~ -~ -~ -~]* abc y & abc [ -~ -~ -~ -~ -~ -~ -~]* abc y & abc docbook-to-man-2.0.0.orig/Instant/tptregexp/timer.c0100644000176100001440000000727606737404360021535 0ustar debacleusers/* * Simple timing program for regcomp(). * * Copyright (c) 1986 by University of Toronto. * Written by Henry Spencer. Not derived from licensed software. * * Permission is granted to anyone to use this software for any * purpose on any computer system, and to redistribute it freely, * subject to the following restrictions: * * 1. The author is not responsible for the consequences of use of * this software, no matter how awful, even if they arise * from defects in it. * * 2. The origin of this software must not be misrepresented, either * by explicit claim or by omission. * * 3. Altered versions must be plainly marked as such, and must not * be misrepresented as being the original software. * * Usage: timer ncomp nexec nsub * or * timer ncomp nexec nsub regexp string [ answer [ sub ] ] * * The second form is for timing repetitions of a single test case. * The first form's test data is a compiled-in copy of the "tests" file. * Ncomp, nexec, nsub are how many times to do each regcomp, regexec, * and regsub. The way to time an operation individually is to do something * like "timer 1 50 1". */ #include struct try { char *re, *str, *ans, *src, *dst; } tests[] = { #include "timer.t.h" { NULL, NULL, NULL, NULL, NULL } }; #include int errreport = 0; /* Report errors via errseen? */ char *errseen = NULL; /* Error message. */ char *progname; /* ARGSUSED */ main(argc, argv) int argc; char *argv[]; { int ncomp, nexec, nsub; struct try one; char dummy[512]; if (argc < 4) { ncomp = 1; nexec = 1; nsub = 1; } else { ncomp = atoi(argv[1]); nexec = atoi(argv[2]); nsub = atoi(argv[3]); } progname = argv[0]; if (argc > 5) { one.re = argv[4]; one.str = argv[5]; if (argc > 6) one.ans = argv[6]; else one.ans = "y"; if (argc > 7) { one.src = argv[7]; one.dst = "xxx"; } else { one.src = "x"; one.dst = "x"; } errreport = 1; try(one, ncomp, nexec, nsub); } else multiple(ncomp, nexec, nsub); exit(0); } void tpt_regerror(s) char *s; { if (errreport) errseen = s; else error(s, ""); } #ifndef ERRAVAIL error(s1, s2) char *s1; char *s2; { fprintf(stderr, "regexp: "); fprintf(stderr, s1, s2); fprintf(stderr, "\n"); exit(1); } #endif int lineno = 0; multiple(ncomp, nexec, nsub) int ncomp, nexec, nsub; { register int i; extern char *strchr(); errreport = 1; for (i = 0; tests[i].re != NULL; i++) { lineno++; try(tests[i], ncomp, nexec, nsub); } } try(fields, ncomp, nexec, nsub) struct try fields; int ncomp, nexec, nsub; { regexp *r; char dbuf[BUFSIZ]; register int i; errseen = NULL; r = tpt_regcomp(fields.re); if (r == NULL) { if (*fields.ans != 'c') complain("tpt_regcomp failure in `%s'", fields.re); return; } if (*fields.ans == 'c') { complain("unexpected tpt_regcomp success in `%s'", fields.re); free((char *)r); return; } for (i = ncomp-1; i > 0; i--) { free((char *)r); r = tpt_regcomp(fields.re); } if (!tpt_regexec(r, fields.str)) { if (*fields.ans != 'n') complain("tpt_regexec failure in `%s'", ""); free((char *)r); return; } if (*fields.ans == 'n') { complain("unexpected tpt_regexec success", ""); free((char *)r); return; } for (i = nexec-1; i > 0; i--) (void) tpt_regexec(r, fields.str); errseen = NULL; for (i = nsub; i > 0; i--) tpt_regsub(r, fields.src, dbuf); if (errseen != NULL) { complain("tpt_regsub complaint", ""); free((char *)r); return; } if (strcmp(dbuf, fields.dst) != 0) complain("tpt_regsub result `%s' wrong", dbuf); free((char *)r); } complain(s1, s2) char *s1; char *s2; { fprintf(stderr, "try: %d: ", lineno); fprintf(stderr, s1, s2); fprintf(stderr, " (%s)\n", (errseen != NULL) ? errseen : ""); } docbook-to-man-2.0.0.orig/Instant/tptregexp/tptregexp.h0100644000176100001440000000111606737404357022435 0ustar debacleusers/* * Definitions etc. for regexp(3) routines. * * Caveat: this is V8 regexp(3) [actually, a reimplementation thereof], * not the System V one. */ #define NSUBEXP 10 typedef struct regexp { char *startp[NSUBEXP]; char *endp[NSUBEXP]; char regstart; /* Internal use only. */ char reganch; /* Internal use only. */ char *regmust; /* Internal use only. */ int regmlen; /* Internal use only. */ char program[1]; /* Unwarranted chumminess with compiler. */ } regexp; extern regexp *tpt_regcomp(); extern int tpt_regexec(); extern void tpt_regsub(); extern void tpt_regerror(); docbook-to-man-2.0.0.orig/Instant/tptregexp/try.c0100644000176100001440000001256006737404360021223 0ustar debacleusers/* * Simple test program for regexp(3) stuff. Knows about debugging hooks. * * Copyright (c) 1986 by University of Toronto. * Written by Henry Spencer. Not derived from licensed software. * * Permission is granted to anyone to use this software for any * purpose on any computer system, and to redistribute it freely, * subject to the following restrictions: * * 1. The author is not responsible for the consequences of use of * this software, no matter how awful, even if they arise * from defects in it. * * 2. The origin of this software must not be misrepresented, either * by explicit claim or by omission. * * 3. Altered versions must be plainly marked as such, and must not * be misrepresented as being the original software. * * Usage: try re [string [output [-]]] * The re is compiled and dumped, regexeced against the string, the result * is applied to output using regsub(). The - triggers a running narrative * from regexec(). Dumping and narrative don't happen unless DEBUG. * * If there are no arguments, stdin is assumed to be a stream of lines with * five fields: a r.e., a string to match it against, a result code, a * source string for regsub, and the proper result. Result codes are 'c' * for compile failure, 'y' for match success, 'n' for match failure. * Field separator is tab. */ #include #include #ifdef ERRAVAIL char *progname; extern char *mkprogname(); #endif #ifdef DEBUG extern int regnarrate; #endif char buf[BUFSIZ]; int errreport = 0; /* Report errors via errseen? */ char *errseen = NULL; /* Error message. */ int status = 0; /* Exit status. */ /* ARGSUSED */ main(argc, argv) int argc; char *argv[]; { regexp *r; int i; #ifdef ERRAVAIL progname = mkprogname(argv[0]); #endif if (argc == 1) { multiple(); exit(status); } r = tpt_regcomp(argv[1]); if (r == NULL) error("tpt_regcomp failure", ""); #ifdef DEBUG regdump(r); if (argc > 4) regnarrate++; #endif if (argc > 2) { i = tpt_regexec(r, argv[2]); printf("%d", i); for (i = 1; i < NSUBEXP; i++) if (r->startp[i] != NULL && r->endp[i] != NULL) printf(" \\%d", i); printf("\n"); } if (argc > 3) { tpt_regsub(r, argv[3], buf); printf("%s\n", buf); } exit(status); } void tpt_regerror(s) char *s; { if (errreport) errseen = s; else error(s, ""); } #ifndef ERRAVAIL error(s1, s2) char *s1; char *s2; { fprintf(stderr, "regexp: "); fprintf(stderr, s1, s2); fprintf(stderr, "\n"); exit(1); } #endif int lineno; regexp badregexp; /* Implicit init to 0. */ multiple() { char rbuf[BUFSIZ]; char *field[5]; char *scan; int i; regexp *r; extern char *strchr(); errreport = 1; lineno = 0; while (fgets(rbuf, sizeof(rbuf), stdin) != NULL) { rbuf[strlen(rbuf)-1] = '\0'; /* Dispense with \n. */ lineno++; scan = rbuf; for (i = 0; i < 5; i++) { field[i] = scan; if (field[i] == NULL) { complain("bad testfile format", ""); exit(1); } scan = strchr(scan, '\t'); if (scan != NULL) *scan++ = '\0'; } try(field); } /* And finish up with some internal testing... */ lineno = 9990; errseen = NULL; if (tpt_regcomp((char *)NULL) != NULL || errseen == NULL) complain("tpt_regcomp(NULL) doesn't complain", ""); lineno = 9991; errseen = NULL; if (tpt_regexec((regexp *)NULL, "foo") || errseen == NULL) complain("tpt_regexec(NULL, ...) doesn't complain", ""); lineno = 9992; r = tpt_regcomp("foo"); if (r == NULL) { complain("tpt_regcomp(\"foo\") fails", ""); return; } lineno = 9993; errseen = NULL; if (tpt_regexec(r, (char *)NULL) || errseen == NULL) complain("tpt_regexec(..., NULL) doesn't complain", ""); lineno = 9994; errseen = NULL; tpt_regsub((regexp *)NULL, "foo", rbuf); if (errseen == NULL) complain("tpt_regsub(NULL, ..., ...) doesn't complain", ""); lineno = 9995; errseen = NULL; tpt_regsub(r, (char *)NULL, rbuf); if (errseen == NULL) complain("tpt_regsub(..., NULL, ...) doesn't complain", ""); lineno = 9996; errseen = NULL; tpt_regsub(r, "foo", (char *)NULL); if (errseen == NULL) complain("tpt_regsub(..., ..., NULL) doesn't complain", ""); lineno = 9997; errseen = NULL; if (tpt_regexec(&badregexp, "foo") || errseen == NULL) complain("tpt_regexec(nonsense, ...) doesn't complain", ""); lineno = 9998; errseen = NULL; tpt_regsub(&badregexp, "foo", rbuf); if (errseen == NULL) complain("tpt_regsub(nonsense, ..., ...) doesn't complain", ""); } try(fields) char **fields; { regexp *r; char dbuf[BUFSIZ]; errseen = NULL; r = tpt_regcomp(fields[0]); if (r == NULL) { if (*fields[2] != 'c') complain("tpt_regcomp failure in `%s'", fields[0]); return; } if (*fields[2] == 'c') { complain("unexpected tpt_regcomp success in `%s'", fields[0]); free((char *)r); return; } if (!tpt_regexec(r, fields[1])) { if (*fields[2] != 'n') complain("tpt_regexec failure in `%s'", ""); free((char *)r); return; } if (*fields[2] == 'n') { complain("unexpected tpt_regexec success", ""); free((char *)r); return; } errseen = NULL; tpt_regsub(r, fields[3], dbuf); if (errseen != NULL) { complain("tpt_regsub complaint", ""); free((char *)r); return; } if (strcmp(dbuf, fields[4]) != 0) complain("tpt_regsub result `%s' wrong", dbuf); free((char *)r); } complain(s1, s2) char *s1; char *s2; { fprintf(stderr, "try: %d: ", lineno); fprintf(stderr, s1, s2); fprintf(stderr, " (%s)\n", (errseen != NULL) ? errseen : ""); status = 1; } docbook-to-man-2.0.0.orig/Transpec/0040755000176100001440000000000007031671612016347 5ustar debacleusersdocbook-to-man-2.0.0.orig/Transpec/Imakefile0100644000176100001440000000026506737404360020166 0ustar debacleusersROOT = /usr/local TPTLIB = $(ROOT)/lib/tpt all:: InstallNonExecFile(docbook-to-man.ts,$(TPTLIB)) InstallNonExecFile(roff.cmap,$(TPTLIB)) InstallNonExecFile(roff.sdata,$(TPTLIB)) docbook-to-man-2.0.0.orig/Transpec/Makefile0100644000176100001440000000402306737404360020011 0ustar debacleusers############################################################################# # # Makefile for docbook-to-man.ts # ############################################################################# # # Copyright (c) 1996 X Consortium # Copyright (c) 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 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # 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. # ############################################################################# # # Written 5/29/96 by Fred Dalrymple # ############################################################################# ROOT = /usr/local TPTLIB = $(ROOT)/share/sgml/transpec MAKE = make SHELL = /bin/sh FILES = docbook-to-man.ts roff.cmap roff.sdata all: install: all if [ ! -d $(TPTLIB) ]; then mkdir $(TPTLIB); fi cd $(TPTLIB); rm -f $(FILES) cp $(FILES) $(TPTLIB) clean: clobber: clean docbook-to-man-2.0.0.orig/Transpec/docbook-to-man.prolog0100644000176100001440000000116706737404360022414 0ustar debacleusers...\" ...\" Prolog for docbook-to-man.ts - macros to push/pop fonts. ...\" $Id: docbook-to-man.prolog,v 1.1 1999/02/23 21:00:18 db3l Exp $ ...\" .de pF .ie \\*(f1 .ds f1 \\n(.f .el .ie \\*(f2 .ds f2 \\n(.f .el .ie \\*(f3 .ds f3 \\n(.f .el .ie \\*(f4 .ds f4 \\n(.f .el .tm ? font overflow .ft \\$1 .. .de fP .ie !\\*(f4 \{\ . ft \\*(f4 . ds f4\" ' br \} .el .ie !\\*(f3 \{\ . ft \\*(f3 . ds f3\" ' br \} .el .ie !\\*(f2 \{\ . ft \\*(f2 . ds f2\" ' br \} .el .ie !\\*(f1 \{\ . ft \\*(f1 . ds f1\" ' br \} .el .tm ? font underflow .. .ds f1\" .ds f2\" .ds f3\" .ds f4\" ...\" ...\" End of prolog ...\" docbook-to-man-2.0.0.orig/Transpec/docbook-to-man.ts0100644000176100001440000007455706737404360021555 0ustar debacleusers############################################################################# # # docbook-to-man.ts # ############################################################################# # # Copyright (c) 1996 X Consortium # Copyright (c) 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 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # 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. # ############################################################################# # # Written 5/29/96 by Fred Dalrymple # ############################################################################# # # $Id: docbook-to-man.ts,v 1.2 1998/11/16 22:23:53 db3l Exp $ # ############################################################################# # # Variables # Var: callout 0 Var: orderlist 0 Var: procstep 0 Var: procsubstep 0 # # # # ############################################################################# # # Hierarchy (and document meta stuff) # # #### ##### ##### ##### ##### ##### #### ##### # GI: REFENTRY StartText: ^'\\" t^${_action 1001} ^.TH "${_followrel descendant REFENTRYTITLE 1000}" "${_followrel descendant MANVOLNUM 1000}"^ EndText: ^...\\" created by instant / docbook-to-man, ${date}^ - # GI: DOCINFO Ignore: all - # GI: TITLE Context: DOCINFO # inside DocInfo, which we're ignoring - # GI: REFMETA Ignore: all - # GI: REFNAMEDIV StartText: ^.SH "NAME"^ - # GI: REFDESCRIPTOR StartText: \\fB EndText: \\fR\s - # GI: REFNAME Relation: sibling- REFDESCRIPTOR # inhibit REFNAMEs when a REFDESCRIPTOR is present Ignore: all - # GI: REFNAME StartText: ${_isset refnameseen xxx 20} EndText: ${_set refnameseen xxx} - # GI: _refname SpecID: 20 StartText: ,\s - # GI: REFPURPOSE StartText: \s\\(em\s EndText: ^ - # GI: REFCLASS StartText: ^.PP^ EndText: ^ - # GI: REFSYNOPSISDIV StartText: ^.SH "SYNOPSIS"^ EndText: ^ - # GI: REFSECT1 StartText: ^.SH "${_followrel child TITLE 1000}"^ EndText: ^ - # GI: REFSECT2 StartText: ^.SS "${_followrel child TITLE 1000}"^ EndText: ^ - # GI: REFSECT3 StartText: ^.SS "${_followrel child TITLE 1000}"^ EndText: ^ - # GI: BRIDGEHEAD StartText: ^.PP^\\fB EndText: \\fP^.PP^ - # GI: TITLE Context: REFSYNOPSISDIV Ignore: all - # GI: TITLE Context: REFSECT1 Ignore: all - # GI: TITLE Context: REFSECT2 Ignore: all - # GI: TITLE Context: REFSECT3 Ignore: all - # GI: LEGALNOTICE # part of the DocInfo structure, which is ignored Ignore: all - # GI: TITLE Context: LEGALNOTICE # part of the DocInfo structure, which is ignored Ignore: all - # GI: REFENTRYTITLE Context: REFMETA # part of the DocInfo structure, which is ignored Ignore: all - # GI: MANVOLNUM Context: REFMETA # part of the DocInfo structure, which is ignored, though this element # if accessed directly by the _followrel call from the REFENTRY element. Ignore: all - # GI: REFMISCINFO # part of the DocInfo structure, which is ignored Ignore: all - # GI: SUBTITLE # part of the DocInfo structure, which is ignored Ignore: all - # GI: AUTHORGROUP # part of the DocInfo structure, which is ignored Ignore: all - # GI: AUTHOR Context: AUTHORGROUP # part of the DocInfo structure, which is ignored Ignore: all - # GI: EDITOR Context: AUTHORGROUP # part of the DocInfo structure, which is ignored Ignore: all - # GI: COLLAB Context: AUTHORGROUP # part of the DocInfo structure, which is ignored Ignore: all - # GI: COLLABNAME Context: COLLAB # part of the DocInfo structure, which is ignored Ignore: all - # GI: CORPAUTHOR Context: AUTHORGROUP # part of the DocInfo structure, which is ignored Ignore: all - # GI: OTHERCREDIT Context: AUTHORGROUP # part of the DocInfo structure, which is ignored Ignore: all - # # ############################################################################# # # (before we get into the branch stuff, we turn off paragraphs in some # contexts where they would break the flow. Generally, this happens # within indented areas, such as within lists. # # #### ##### ##### ##### ##### ##### #### ##### # GI: PARA Context: LISTITEM NthChild: 1 # nothing in this context - # GI: PARA Context: GLOSSDEF NthChild: 1 # nothing in this context - # GI: PARA Context: STEP NthChild: 1 # nothing in this context - # GI: PARA Context: CALLOUT NthChild: 1 # nothing in this context - # GI: PARA Context: MSGTEXT NthChild: 1 # nothing in this context - # # ############################################################################# # # Regular "branch" stuff # # #### ##### ##### ##### ##### ##### #### ##### # GI: FORMALPARA # it's all done in TITLE (FORMALPARA) and PARA - # GI: TITLE Context: FORMALPARA StartText: ^.PP^\\fB EndText: \\fR^ - # GI: PARA Relation: ancestor LISTITEM StartText: ^.IP "" 10^ - # GI: PARA Relation: ancestor STEP StartText: ^.IP "" 10^ - # GI: PARA StartText: ^.PP^ - # GI: SIMPARA StartText: ^.PP^ - # GI: PROGRAMLISTING StartText: ^.PP^.nf^${_action 1001}^\\f(CW EndText: \\fR^.fi^.PP^ Verbatim: - # GI: LITERALLAYOUT StartText: ^.PP^.nf^${_action 1001}^ EndText: ^.fi^ Verbatim: - # GI: BLOCKQUOTE StartText: ^.PP^.RS^ EndText: ^.RE^ - # GI: TITLE Context: BLOCKQUOTE StartText: ^\\fB EndText: \\fR^.PP^ - # GI: EPIGRAPH StartText: ^.PP^.RS^ EndText: ^.RE^ - # GI: ATTRIBUTION StartText: ^\\fI EndText: \\fR^.PP^ - # GI: ABSTRACT Relation: child TITLE - # GI: ABSTRACT StartText: ^.SS "Abstract"^ - # GI: TITLE Context: ABSTRACT StartText: ^.SS " EndText: "^ - # GI: REVHISTORY StartText: ^.SS "Revision History"^ EndText: ^ - # GI: REVISION StartText: ^.PP^\\fBRevision:\\fR\s EndText: ^ - # GI: REVNUMBER StartText: #\s EndText: ;\s - # GI: DATE EndText: ;\s - # GI: AUTHORINITIALS Context: REVISION StartText: \s - # GI: REVREMARK StartText: ;\s\s EndText: ^ - # GI: PROGRAMLISTINGCO # nothing to do specifically in ProgramListingCO -- it falls to # the content of ProgramListing and any callout list - # GI: SCREEN StartText: ^.PP^.nf^${_action 1001}^ EndText: ^.fi^ Verbatim: - # GI: SCREENCO # nothing to do specifically in ScreenCO -- it falls to # the content of Screen and any callout list - # GI: SCREENSHOT # nothing specific to do here -- defer to any ScreenInfo or the # included graphic - # GI: SCREENINFO StartText: ^.PP^\\fI EndText: \\fR^.PP^ - # GI: GRAPHICCO # nothing to do specifically in GraphicCO -- it falls to # the content of Graphic and any callout list - # GI: INFORMALEXAMPLE # nothing special to do here -- it falls to the content. - # GI: EXAMPLE # nothing special to do here -- it falls to the content. - # GI: TITLE Context: EXAMPLE StartText: ^.PP^\\fB EndText: \\fR^ - # GI: FIGURE # nothing special to do here -- it falls to the content. - # GI: TITLE Context: FIGURE StartText: ^.PP^\\fB EndText: \\fR^ - # GI: SIDEBAR Relation: child TITLE StartText: ^.PP^.RS^ EndText: ^.RE^ - # GI: SIDEBAR StartText: ^.PP^.RS^\\fB[ Sidebar ]\\fR^ EndText: ^.RE^ - # GI: TITLE Context: SIDEBAR StartText: ^\\fB[ Sidebar:\s EndText: \s]\\fR^ - # GI: HIGHLIGHTS StartText: ^.SS "Highlights"^ - # GI: AUTHORBLURB # nothing to do specially -- an included title may occur - # GI: TITLE Context: AUTHORBLURB StartText: ^.PP^\\fB EndText: \\fR^ - # # ############################################################################# # # Call-out material # # #### ##### ##### ##### ##### ##### #### ##### # GI: CO # nothing to do for the anchor of a callout - # GI: AREASPEC Ignore: all # not much to do with representing the anchor of callouts in n/troff - # GI: AREA Ignore: all # part of AreaSpec, which is being ignored - # GI: AREASET Ignore: all # part of AreaSpec, which is being ignored - # # ############################################################################# # # Address block # # #### ##### ##### ##### ##### ##### #### ##### # GI: ADDRESS StartText: ^.PP^.nf^${_action 1001}^ EndText: ^.fi^ Verbatim: - # GI: STREET # just the content... - # GI: POB # just the content... - # GI: POSTCODE # just the content... - # GI: CITY EndText: ,\s - # GI: STATE # just the content - # GI: COUNTRY # just the content - # GI: PHONE StartText: ^voice:\s - # GI: FAX StartText: ^fax:\s - # GI: OTHERADDR # just the content.. - # GI: EMAIL Context: ADDRESS # just the content.. - # # ############################################################################# # # Lists # # #### ##### ##### ##### ##### ##### #### ##### # GI: GLOSSLIST Relation: ancestor ITEMIZEDLIST StartText: ^.RS^ EndText: ^.RE^ - # GI: GLOSSLIST Relation: ancestor GLOSSLIST StartText: ^.RS^ EndText: ^.RE^ - # GI: GLOSSLIST Relation: ancestor ORDEREDLIST StartText: ^.RS^ EndText: ^.RE^ - # GI: GLOSSLIST Relation: ancestor SIMPLELIST StartText: ^.RS^ EndText: ^.RE^ - # GI: GLOSSLIST Relation: ancestor VARIABLELIST StartText: ^.RS^ EndText: ^.RE^ - # GI: GLOSSLIST Relation: ancestor SEGMENTEDLIST StartText: ^.RS^ EndText: ^.RE^ - # GI: GLOSSLIST # Nothing to do here.. see glossentry, etc - # GI: GLOSSENTRY # nothing to do.. - # GI: GLOSSTERM Context: GLOSSENTRY StartText: ^.IP " EndText: " 10^ - # GI: GLOSSTERM StartText: \\fB EndText: \\fP - # GI: ACRONYM Context: GLOSSENTRY StartText: (\\fIacronym:\s\\fR EndText: )\s\s - # GI: ABBREV Context: GLOSSENTRY StartText: (\\fIabbreviation:\s\\fR EndText: )\s\s - # GI: GLOSSSEE StartText: ^\\fISee \\fR - # GI: GLOSSDEF # nothing special to do -- just pass the content. - # GI: GLOSSSEEALSO StartText: ^^\\fISee Also \\fR - # GI: ITEMIZEDLIST Relation: ancestor ITEMIZEDLIST StartText: ^.RS^ EndText: ^.RE^ - # GI: ITEMIZEDLIST Relation: ancestor GLOSSLIST StartText: ^.RS^ EndText: ^.RE^ - # GI: ITEMIZEDLIST Relation: ancestor ORDEREDLIST StartText: ^.RS^ EndText: ^.RE^ - # GI: ITEMIZEDLIST Relation: ancestor SIMPLELIST StartText: ^.RS^ EndText: ^.RE^ - # GI: ITEMIZEDLIST Relation: ancestor VARIABLELIST StartText: ^.RS^ EndText: ^.RE^ - # GI: ITEMIZEDLIST Relation: ancestor SEGMENTEDLIST StartText: ^.RS^ EndText: ^.RE^ - # GI: ITEMIZEDLIST # nothing to do.. - # GI: LISTITEM Context: ITEMIZEDLIST StartText: ^.IP "\ \ \ \\(bu" 6^ - # GI: ORDEREDLIST Relation: ancestor ITEMIZEDLIST StartText: ^.RS^ EndText: ^.RE^ - # GI: ORDEREDLIST Relation: ancestor GLOSSLIST StartText: ^.RS^ EndText: ^.RE^ - # GI: ORDEREDLIST Relation: ancestor ORDEREDLIST StartText: ^.RS^ EndText: ^.RE^ - # GI: ORDEREDLIST Relation: ancestor SIMPLELIST StartText: ^.RS^ EndText: ^.RE^ - # GI: ORDEREDLIST Relation: ancestor VARIABLELIST StartText: ^.RS^ EndText: ^.RE^ - # GI: ORDEREDLIST Relation: ancestor SEGMENTEDLIST StartText: ^.RS^ EndText: ^.RE^ - # GI: ORDEREDLIST StartText: ${_set orderlist 1} - # GI: LISTITEM Context: ORDEREDLIST StartText: ^.IP "\ \ \ ${orderlist}." 6^ Increment: orderlist - # GI: SIMPLELIST Relation: ancestor ITEMIZEDLIST StartText: ^.RS^ EndText: ^.RE^ - # GI: SIMPLELIST Relation: ancestor GLOSSLIST StartText: ^.RS^ EndText: ^.RE^ - # GI: SIMPLELIST Relation: ancestor ORDEREDLIST StartText: ^.RS^ EndText: ^.RE^ - # GI: SIMPLELIST Relation: ancestor SIMPLELIST StartText: ^.RS^ EndText: ^.RE^ - # GI: SIMPLELIST Relation: ancestor VARIABLELIST StartText: ^.RS^ EndText: ^.RE^ - # GI: SIMPLELIST Relation: ancestor SEGMENTEDLIST StartText: ^.RS^ EndText: ^.RE^ - # GI: SIMPLELIST # nothing to do here.. - # GI: MEMBER PAttSet: TYPE INLINE NthChild: 1 - # GI: MEMBER PAttSet: TYPE INLINE StartText: ,\s - # GI: MEMBER PAttSet: TYPE HORIZ NthChild: 1 StartText: ^.PP^\t - # GI: MEMBER PAttSet: TYPE HORIZ StartText: \t - # GI: MEMBER PAttSet: TYPE VERT StartText: ^.IP "" 10^ EndText: ^ - # GI: VARIABLELIST Relation: ancestor ITEMIZEDLIST StartText: ^.RS^ EndText: ^.RE^ - # GI: VARIABLELIST Relation: ancestor GLOSSLIST StartText: ^.RS^ EndText: ^.RE^ - # GI: VARIABLELIST Relation: ancestor ORDEREDLIST StartText: ^.RS^ EndText: ^.RE^ - # GI: VARIABLELIST Relation: ancestor SIMPLELIST StartText: ^.RS^ EndText: ^.RE^ - # GI: VARIABLELIST Relation: ancestor VARIABLELIST StartText: ^.RS^ EndText: ^.RE^ - # GI: VARIABLELIST Relation: ancestor SEGMENTEDLIST StartText: ^.RS^ EndText: ^.RE^ - # GI: VARIABLELIST # nothing to do now, see VarListEntry - # GI: VARLISTENTRY # nothing to do now, see Term - # GI: TERM StartText: ^.IP " EndText: " 10^ - # GI: LISTITEM Context: VARLISTENTRY # nothing special to do.. - # GI: SEGMENTEDLIST Relation: ancestor ITEMIZEDLIST StartText: ^.RS^${_followrel child TITLE 400}^.TS^tab();^l l l l l l l l l l l l l l l l l l.^ EndText: ^.TE^.RE^ - # GI: SEGMENTEDLIST Relation: ancestor GLOSSLIST StartText: ^.RS^${_followrel child TITLE 400}^.TS^tab();^l l l l l l l l l l l l l l l l l l.^ EndText: ^.TE^.RE^ - # GI: SEGMENTEDLIST Relation: ancestor ORDETERLIST StartText: ^.RS^${_followrel child TITLE 400}^.TS^tab();^l l l l l l l l l l l l l l l l l l.^ EndText: ^.TE^.RE^ - # GI: SEGMENTEDLIST Relation: ancestor SIMPLELIST StartText: ^.RS^${_followrel child TITLE 400}^.TS^tab();^l l l l l l l l l l l l l l l l l l.^ EndText: ^.TE^.RE^ - # GI: SEGMENTEDLIST Relation: ancestor VARIABLELIST StartText: ^.RS^${_followrel child TITLE 400}^.TS^tab();^l l l l l l l l l l l l l l l l l l.^ EndText: ^.TE^.RE^ - # GI: SEGMENTEDLIST Relation: ancestor SEGMENTEDLIST StartText: ^.RS^${_followrel child TITLE 400}^.TS^tab();^l l l l l l l l l l l l l l l l l l.^ EndText: ^.TE^.RE^ - # GI: SEGMENTEDLIST Relation: child TITLE StartText: ^${_followrel child TITLE 400}^.TS^tab();^l l l l l l l l l l l l l l l l l l.^ EndText: ^.TE^ - # GI: TITLE Context: SEGMENTEDLIST # ignored by default -- must be called by SEGMENTEDLIST gi Ignore: all - # GI: _segmentedlist_title SpecID: 400 StartText: ^.sp 1^\\fB EndText: \\fR^ - # GI: SEGTITLE StartText: \\fB EndText: \\fR - # GI: SEGLISTITEM StartText: ^ EndText: ^ - # GI: SEG EndText:  - # GI: PROCEDURE # defer to the content... StartText: ${_set procstep 1}${_set procsubstep 1} - # GI: TITLE Context: PROCEDURE StartText: ^.PP^\\fB EndText: \\fR^ - # GI: STEP Context: SUBSTEPS StartText: ^.PP^\\fISubstep ${procsubstep}.\s\s EndText: ^ Increment: procsubstep 1 - # GI: STEP StartText: ^.PP^\\fIStep ${procstep}.\s\s EndText: ^ Increment: procstep 1 - # GI: TITLE Context: STEP StartText: ^\\fB EndText: \\fR^.PP^ - # GI: SUBSTEPS StartText: ^.RS^ EndText: ^.RE^ - # GI: CALLOUTLIST StartText: ${_set callout 1} # nothing to do specifically, defer to the content... - # GI: TITLE Context: CALLOUTLIST StartText: ^\\fB EndText: \\fR^.PP^ - # GI: CALLOUT StartText: ^.PP^\\fICallout ${callout}.\s\s\\fR EndText: ^ Increment: callout - # # ############################################################################# # # Messages # # #### ##### ##### ##### ##### ##### #### ##### # GI: MSGSET StartText: ^.SS "Message Set"^ - # GI: MSGENTRY StartText: ^.PP^\\fBMessage Entry\\fR^.RS^ EndText: ^.RE^ - # GI: MSG Relation: child TITLE StartText: ^.PP^ EndText: ^ - # GI: MSG StartText: ^.PP^\\fBMessage:\\fR^.PP^ EndText: ^ - # GI: TITLE Context: MSG StartText: ^.PP^\\fB EndText: \\fR^.PP^ - # GI: MSGINFO # nothing specific -- just groups (MsgLevel | MsgOrig | MsgAud)* - # GI: MSGEXPLAN # nothing special -- defer to content - # GI: TITLE Context: MSGEXPLAN StartText: ^.PP^\\fB EndText: \\fR^ - # GI: MSGMAIN # defer to content - # GI: TITLE Context: MSGMAIN StartText: ^\\fB EndText: \\fR^ - # GI: MSGSUB # defer to content - # GI: TITLE Context: MSGSUB StartText: ^.PP^\\fB EndText: \\fR^ - # GI: MSGREL # defer to content - # GI: TITLE Context: MSGREL StartText: ^.PP^\\fB EndText: \\fR^ - # GI: MSGLEVEL StartText: ^.PP^\\fIMessage level:\s\s\\fR EndText: ^ - # GI: MSGORIG StartText: ^.PP^\\fIMessage origin:\s\s\\fR EndText: ^ - # GI: MSGAUD StartText: ^.PP^\\fIMessage audience:\s\s\\fR EndText: ^ - # GI: MSGTEXT Context: PARA StartText: \\fI EndText: \\fP - # GI: MSGTEXT StartText: \\fR^\\fIMessage text:\\fR\s\s EndText: ^ - # # ############################################################################# # # Admonitions # # #### ##### ##### ##### ##### ##### #### ##### # GI: CAUTION Relation: child TITLE StartText: ^.PP^.RS EndText: ^.RE^ - # GI: CAUTION StartText: ^.PP^.RS^\\fBCaution:\s\s EndText: ^.RE^ - # GI: TITLE Context: CAUTION StartText: ^\\fBCaution:\s\s EndText: \\fR^.PP^ - # GI: IMPORTANT Relation: child TITLE StartText: ^.PP^.RS^ EndText: ^.RE^ - # GI: IMPORTANT StartText: ^.PP^.RS^\\fBImportant:\s\s EndText: ^.RE^ - # GI: TITLE Context: IMPORTANT StartText: ^\\fBImportant:\s\s EndText: \\fR^.PP^ - # GI: NOTE Relation: child TITLE StartText: ^.PP^.RS EndText: ^.RE^ - # GI: NOTE StartText: ^.PP^.RS^\\fBNote:\s\s EndText: ^.RE^ - # GI: TITLE Context: NOTE StartText: ^\\fBNote:\s\s EndText: \\fR^.PP^ - # GI: TIP Relation: child TITLE StartText: ^.PP^.RS EndText: ^.RE^ - # GI: TIP StartText: ^.PP^.RS^\\fBTip:\s\s EndText: ^.RE^ - # GI: TITLE Context: TIP StartText: ^\\fBTip:\s\s EndText: \\fR^.PP^ - # GI: WARNING Relation: child TITLE StartText: ^.PP^.RS EndText: ^.RE^ - # GI: WARNING StartText: ^.PP^.RS^\\fBWarning:\s\s EndText: ^.RE^ - # GI: TITLE Context: WARNING StartText: ^\\fBWarning:\s\s EndText: \\fR^.PP^ - # # ############################################################################# # # Synopses # # #### ##### ##### ##### ##### ##### #### ##### # GI: SYNOPSIS StartText: ^.PP^.nf^${_action 1001}^ EndText: ^.fi^ Verbatim: - # GI: CMDSYNOPSIS StartText: ^.PP^ EndText: ^ - # GI: ARG Context: GROUP NthChild: 1 EndText: ${_attval REP REPEAT 505}\s - # GI: ARG Context: GROUP StartText: \s|\s EndText: ${_attval REP REPEAT 505}\s - # GI: ARG AttValue: CHOICE OPT StartText: \s[ EndText: ${_attval REP REPEAT 505}]\s - # GI: ARG # no special attrs -- just pass content through EndText: ${_attval REP REPEAT 505}\s - # GI: _arg_group SpecID: 505 StartText: \s\\&... Ignore: all - # GI: GROUP AttValue: CHOICE OPT StartText: \s[ EndText: ]\s${_attval REP REPEAT 505} - # GI: GROUP AttValue: CHOICE REQ StartText: \s{ EndText: }\s${_attval REP REPEAT 505} - # GI: GROUP AttValue: CHOICE OPTMULT StartText: \s[[ EndText: ]]\s${_attval REP REPEAT 505} - # GI: GROUP AttValue: CHOICE REQMULT StartText: \s{{ EndText: }}\s${_attval REP REPEAT 505} - # GI: GROUP AttValue: CHOICE PLAIN EndText: ${_attval REP REPEAT 505} - # GI: SBR StartText: ^.br^ - # GI: SYNOPFRAGMENT # nothing special to do here -- just pass through content (Arg | Group)+ - # GI: SYNOPFRAGMENTREF # WHAT TO DO HERE?? pass through the content, but what about the # linkend? (will call it across...) EndText: \s\\fI(refers to: ${_followlink LINKEND 1000})\\fR - # GI: FUNCSYNOPSIS StartText: ^.PP^.nf^${_action 1001}^ EndText: ^.fi^ Verbatim: - # GI: FUNCSYNOPSISINFO StartText: ^ EndText: ^ - # GI: FUNCPROTOTYPE # nothing special -- just pass through content (looks like # a function def StartText: ^.sp 1^ - # GI: FUNCDEF StartText: ^\\fB EndText: \\fR( - # GI: FUNCPARAMS StartText: ^\t\t\t\\fB EndText: \\fR^ - # GI: VOID StartText: \\fBvoid\\fR) - # GI: VARARGS StartText: \\fB\\&...\\fR) - # GI: PARAMDEF Relation: sibling+ PARAMDEF StartText: ^\\fB EndText: \\fR,^ - # GI: PARAMDEF StartText: ^\\fB EndText: \\fR);^ - # # ############################################################################# # # Links # # #### ##### ##### ##### ##### ##### #### ##### # GI: LINK StartText: \\fI EndText: \\fR - # GI: OLINK StartText: \\fI EndText: \s(link to external document ${TargetDocEnt})\s\\fR - # GI: ULINK StartText: \\fI EndText: \s(link to URL ${URL})\s\\fR - # GI: FOOTNOTEREF # just let the footnote ref mark come through - # GI: FOOTNOTE # just let footnote body come through (-man doesn't support footnotes) - # GI: XREF AttValue: ENDTERM StartText: \\fI"${_followlink ENDTERM 1000}"\\fR\s - # GI: XREF StartText: \\fI"${_followlink LINKEND 600}"\\fR\s - # GI: _xref SpecID: 600 StartText: ${_set xreflabel no}${_isset XREFLABEL 601}${_isset xreflabel no 602} Ignore: all - # GI: _xref_label SpecID: 601 StartText: ${_set xreflabel yes}${XREFLABEL} Ignore: all - # GI: _xref_title SpecID: 602 Set: StartText: ${_followrel child TITLE 1000} Ignore: all - # GI: ANCHOR # nothing to do -- this just marks a place.. - # # ############################################################################# # # Graphics and Equations # # #### ##### ##### ##### ##### ##### #### ##### # GI: GRAPHIC AttValue: ENTITYREF StartText: ^.PP^.if t .P! "${_filename}"^ - # GI: INLINEGRAPHIC StartText: ^.if t .P! "${_filename}"^ - # GI: INFORMALEQUATION # nothing special to do -- defer to graphic content.. - # GI: EQUATION # nothing special to do -- defer to graphic content.. - # GI: TITLE Context: EQUATION StartText: ^.PP^\\fB EndText: \\fR^ - # GI: INLINEEQUATION # nothing special to do -- defer to graphic content.. - # # ############################################################################# # # Tables # # #### ##### ##### ##### ##### ##### #### ##### # # GI: INFORMALTABLE StartText: ^${_calstable tbl tablestart}^ EndText: ^${_calstable tbl tableend}^ - # GI: TABLE StartText: ^.PP^\\fB${_followrel child TITLE 1000}\\fR ^${_calstable tbl tablestart}^ EndText: ^${_calstable tbl tableend}^ - # GI: TITLE Context: TABLE # handled in TABLE element Ignore: all - # GI: TGROUP StartText: ^${_calstable tbl tablegroup}^${_followrel child THEAD 700}${_followrel child TBODY 700}${_followrel child TFOOT 701} EndText: ${_calstable tbl tablegroupend} - # GI: COLSPEC Ignore: all - # GI: SPANSPEC Ignore: all - # GI: THEAD TBODY TFOOT # they're called explicitly from TGROUP, but ignored here Ignore: all - # GI: _thead_tbody SpecID: 700 # nothing special to do -- just pass through content - # GI: _tfoot SpecID: 701 StartText: ^${_calstable tbl tablefoot}^ - # GI: ROW StartText: ^${_calstable tbl rowstart} EndText: ${_calstable tbl rowend} - # GI: ENTRY StartText: ${_calstable tbl entrystart} EndText: ${_calstable tbl entryend} - # GI: ENTRYTBL StartText: EndText: Message: ^IMPLEMENT <${_gi} ${_allatts}>^ - # # ############################################################################# # # Index terms # # #### ##### ##### ##### ##### ##### #### ##### # GI: INDEXTERM StartText: ^.iX\s EndText: ^ - # GI: PRIMARY StartText: " EndText: " - # GI: SECONDARY StartText: \s" EndText: " - # GI: TERTIARY StartText: \s" EndText: " - # GI: SEE StartText: \s"See:\s EndText: " - # GI: SEEALSO StartText: \s"SeeAlso:\s EndText: " - # # ############################################################################# # # Author / OtherCredit material # # #### ##### ##### ##### ##### ##### #### ##### # GI: OTHERCREDIT # nothing specific -- defer to content - # GI: HONORIFIC # nothing specific -- defer to content EndText: \s - # GI: FIRSTNAME # nothing specific -- defer to content EndText: \s - # GI: SURNAME # nothing specific -- defer to content EndText: \s - # GI: LINEAGE # nothing specific -- defer to content EndText: \s - # GI: OTHERNAME # nothing specific -- defer to content StartText: ( EndText: )\s - # GI: AFFILIATION # nothing specific -- defer to content EndText: \s - # GI: SHORTAFFIL # nothing specific -- defer to content EndText: \s - # GI: JOBTITLE # nothing specific -- defer to content EndText: \s - # GI: ORGNAME # nothing specific -- defer to content EndText: \s - # GI: ORGDIV # nothing specific -- defer to content EndText: \s - # GI: CONTRIB # nothing specific -- defer to content EndText: \s - # # ############################################################################# # # "Leaf" material # # #### ##### ##### ##### ##### ##### #### ##### # GI: ABBREV # no special presentation - # GI: ACCEL # no special presentation - # GI: ACRONYM # no special presentation - # GI: AUTHORINITIALS # no special presentation - # GI: CITATION StartText: \\fI EndText: \\fP - # GI: CITETITLE AttValue: PUBWORK StartText: \\fI EndText: \\fP (${PUBWORK})\s - # GI: CITETITLE StartText: \\fI EndText: \\fP - # GI: CITEREFENTRY # defer to content.. - # GI: REFENTRYTITLE StartText: \\fB EndText: \\fP - # GI: MANVOLNUM StartText: \\fB( EndText: )\\fP - # GI: COMMENT # docbook says to inhibit this from finished products... Ignore: all - # GI: EMAIL # no special presentation - # GI: EMPHASIS StartText: \\fI EndText: \\fP - # GI: FIRSTTERM StartText: \\fI EndText: \\fR - # GI: FOREIGNPHRASE # no special presentation - # GI: PHRASE # no special presentation - # GI: QUOTE StartText: ``\\fI EndText: \\fP'' - # GI: TRADEMARK EndText: \\u\\s-2TM\\s+2\\d - # GI: WORDASWORD # no special presentation - # GI: ACTION # no special presentation - # GI: APPLICATION StartText: \\fB EndText: \\fP - # GI: CLASSNAME StartText: \\fB EndText: \\fP - # GI: COMMAND StartText: \\fB EndText: \\fP - # GI: COMPUTEROUTPUT StartText: \\f(CW EndText: \\fP - # GI: DATABASE # no special presentation - # GI: ERRORNAME StartText: \\fB EndText: \\fP - # GI: ERRORTYPE # no special presentation - # GI: FILENAME StartText: \\fB EndText: \\fP - # GI: FUNCTION StartText: \\fB EndText: \\fP - # GI: GUIBUTTON StartText: \\fB EndText: \\fP - # GI: GUIICON StartText: \\fB EndText: \\fP - # GI: GUILABEL # no special presentation - # GI: GUIMENU # no special presentation - # GI: GUIMENUITEM # no special presentation - # GI: GUISUBMENU # no special presentation - # GI: HARDWARE # no special presentation - # GI: INTERFACE # no special presentation - # GI: INTERFACEDEFINITION StartText: \\fB EndText: \\fP - # GI: KEYCAP StartText: \\fB< EndText: >\\fP - # GI: KEYCODE # no special presentation - # GI: KEYCOMBO # no special presentation -- defer to the content - # GI: KEYSYM StartText: \\fB< EndText: >\\fP - # GI: LINEANNOTATION StartText: \\fI EndText: \\fP - # GI: LITERAL StartText: \\fB EndText: \\fP - # GI: MARKUP StartText: \\f(CW EndText: \\fP - # GI: MEDIALABEL # no special presentation - # GI: MENUCHOICE # no special presentation - # GI: PROMPT # no special presentation - # GI: SHORTCUT # no special presentation - # GI: MOUSEBUTTON # no special presentation - # GI: OPTION StartText: \\fB EndText: \\fP - # GI: OPTIONAL StartText: [ EndText: ] - # GI: PARAMETER StartText: \\fB EndText: \\fR - # GI: PROPERTY StartText: \\fB EndText: \\fP - # GI: REPLACEABLE StartText: \\fI EndText: \\fP - # GI: RETURNVALUE StartText: \\fB EndText: \\fR - # GI: SGMLTAG AttValue: CLASS ELEMENT StartText: \\fB< EndText: >\\fP - # GI: SGMLTAG StartText: \\fB EndText: \\fP - # GI: STRUCTFIELD StartText: \\fB EndText: \\fR - # GI: STRUCTNAME StartText: \\fB EndText: \\fR - # GI: SYMBOL AttValue: ROLE Variable StartText: \\fI EndText: \\fP - # GI: SYMBOL StartText: \\fI EndText: \\fP - # GI: SYSTEMITEM AttValue: CLASS CONSTANT StartText: \\fB EndText: \\fP - # GI: SYSTEMITEM AttValue: CLASS ENVIRONVAR StartText: \\fB EndText: \\fP - # GI: SYSTEMITEM AttValue: CLASS RESOURCE StartText: \\fB EndText: \\fP - # GI: SYSTEMITEM StartText: \\fB EndText: \\fP - # GI: TOKEN StartText: \\fB EndText: \\fP - # GI: TYPE StartText: \\fB EndText: \\fP - # GI: USERINPUT StartText: \\fB EndText: \\fP - # GI: AUTHOR # no special presentation - defer to content - # GI: CORPAUTHOR # no special presentation - # GI: MODESPEC # nothing to render (this is meta information for Links) - # GI: PRODUCTNAME StartText: \\fB EndText: \\fP - # GI: PRODUCTNUMBER # no special presentation - # GI: SUBSCRIPT StartText: \\d EndText: \\u - # GI: SUPERSCRIPT StartText: \\u EndText: \\d - # # ############################################################################# # # stuff that gets ignored (and doesn't belong elsewhere) # # #### ##### ##### ##### ##### ##### #### ##### # GI: TITLEABBREV # this element is ignored in favor of the real title Ignore: all - # # # ############################################################################# # # handle layout-specific stuff and PIs # # #### ##### ##### ##### ##### ##### #### ##### # GI: BEGINPAGE StartText: ^.br\s EndText: ^ - # GI: _x-break StartText: ^.br\s EndText: ^ - # GI: _sml-break StartText: ^.br\s EndText: ^ - # GI: _sml-need StartText: ^.ne\s EndText: ^ - # GI: _sml-size StartText: ^.ps\s EndText: ^ - # GI: _sml-indent StartText: ^.in\s EndText: ^ - # GI: _sml-space StartText: ^.sp\s EndText: ^ - # GI: _sml-tabset StartText: ^.ta\s EndText: ^ - # # ############################################################################# # # General purpose transpecs # # #### ##### ##### ##### ##### ##### #### ##### # GI: _passthrough SpecID: 1000 - # # Used to reset trap positions, either at start of file or when .nf is # restarted, such as for literal output. Assumes caller is responsible # for line starting characters as appropriate. (it helps the calling # definitions read more logically). # GI: _tabset SpecID: 1001 StartText: .ta 8n 16n 24n 32n 40n 48n 56n 64n 72n Ignore: all - # GI: _doTitle SpecID: 1010 StartText: ^.PP^\\fB EndText: \\fR^.PP^ - # # ############################################################################# # # Catch-all for unknown PIs -- ignore them... # # #### ##### ##### ##### ##### ##### #### ##### # GI: _* Ignore: data - # # ############################################################################# # # Catch-all for unknown elements -- just output their content.. # # #### ##### ##### ##### ##### ##### #### ##### # #GI: * #- # docbook-to-man-2.0.0.orig/Transpec/docbook-to-man.ts-PUSHPOP0100644000176100001440000010050106737404360022664 0ustar debacleusers############################################################################# # # docbook-to-man.ts # ############################################################################# # # Copyright (c) 1996 X Consortium # Copyright (c) 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 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # 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. # ############################################################################# # # Written 5/29/96 by Fred Dalrymple # ############################################################################# # # $Id: docbook-to-man.ts-PUSHPOP,v 1.5 1999/02/23 20:31:38 db3l Exp $ # ############################################################################# # # Variables # Var: callout 0 Var: orderlist 0 Var: procstep 0 Var: procsubstep 0 # # # # ############################################################################# # # Hierarchy (and document meta stuff) # # #### ##### ##### ##### ##### ##### #### ##### # GI: REFENTRY StartText: ^'\\" t^.TH "${_followrel descendant REFENTRYTITLE 1000}" "${_followrel descendant MANVOLNUM 1000}" "${date}" ^${_action 1002}^${_action 1001}^ EndText: ^...\\" created by instant / docbook-to-man, ${date}^ - # GI: DOCINFO Ignore: all - # GI: TITLE Context: DOCINFO # inside DocInfo, which we're ignoring - # GI: REFMETA Ignore: all - # GI: REFNAMEDIV StartText: ^.SH "NAME"^ - # GI: REFDESCRIPTOR StartText: \\fB EndText: \\fR\s - # GI: REFNAME Relation: sibling- REFDESCRIPTOR # inhibit REFNAMEs when a REFDESCRIPTOR is present Ignore: all - # GI: REFNAME StartText: ${_isset refnameseen xxx 20} EndText: ${_set refnameseen xxx} - # GI: _refname SpecID: 20 StartText: ,\s - # GI: REFPURPOSE StartText: \s\\(em\s EndText: ^ - # GI: REFCLASS StartText: ^.PP^ EndText: ^ - # GI: REFSYNOPSISDIV StartText: ^.SH "SYNOPSIS"^ EndText: ^ - # GI: REFSECT1 StartText: ^.SH "${_followrel child TITLE 1000}"^ EndText: ^ - # GI: REFSECT2 StartText: ^.SS "${_followrel child TITLE 1000}"^ EndText: ^ - # GI: REFSECT3 StartText: ^.SS "${_followrel child TITLE 1000}"^ EndText: ^ - # GI: BRIDGEHEAD StartText: ^.PP^.pF B^ EndText: ^.fP^.PP^ - # GI: TITLE Context: REFSYNOPSISDIV Ignore: all - # GI: TITLE Context: REFSECT1 Ignore: all - # GI: TITLE Context: REFSECT2 Ignore: all - # GI: TITLE Context: REFSECT3 Ignore: all - # GI: LEGALNOTICE # part of the DocInfo structure, which is ignored Ignore: all - # GI: TITLE Context: LEGALNOTICE # part of the DocInfo structure, which is ignored Ignore: all - # GI: REFENTRYTITLE Context: REFMETA # part of the DocInfo structure, which is ignored Ignore: all - # GI: MANVOLNUM Context: REFMETA # part of the DocInfo structure, which is ignored, though this element # if accessed directly by the _followrel call from the REFENTRY element. Ignore: all - # GI: REFMISCINFO # part of the DocInfo structure, which is ignored Ignore: all - # GI: SUBTITLE # part of the DocInfo structure, which is ignored Ignore: all - # GI: AUTHORGROUP # part of the DocInfo structure, which is ignored Ignore: all - # GI: AUTHOR Context: AUTHORGROUP # part of the DocInfo structure, which is ignored Ignore: all - # GI: EDITOR Context: AUTHORGROUP # part of the DocInfo structure, which is ignored Ignore: all - # GI: COLLAB Context: AUTHORGROUP # part of the DocInfo structure, which is ignored Ignore: all - # GI: COLLABNAME Context: COLLAB # part of the DocInfo structure, which is ignored Ignore: all - # GI: CORPAUTHOR Context: AUTHORGROUP # part of the DocInfo structure, which is ignored Ignore: all - # GI: OTHERCREDIT Context: AUTHORGROUP # part of the DocInfo structure, which is ignored Ignore: all - # # ############################################################################# # # (before we get into the branch stuff, we turn off paragraphs in some # contexts where they would break the flow. Generally, this happens # within indented areas, such as within lists. # # #### ##### ##### ##### ##### ##### #### ##### # GI: PARA Context: LISTITEM NthChild: 1 # nothing in this context - # GI: PARA Context: GLOSSDEF NthChild: 1 # nothing in this context - # GI: PARA Context: STEP NthChild: 1 # nothing in this context - # GI: PARA Context: CALLOUT NthChild: 1 # nothing in this context - # GI: PARA Context: MSGTEXT NthChild: 1 # nothing in this context - # # ############################################################################# # # Regular "branch" stuff # # #### ##### ##### ##### ##### ##### #### ##### # GI: FORMALPARA # it's all done in TITLE (FORMALPARA) and PARA - # GI: TITLE Context: FORMALPARA StartText: ^.PP^.pF B^ EndText: ^.fR^ - # GI: PARA Context: LISTITEM StartText: ^.IP "" 10^ - # GI: PARA StartText: ^.PP^ - # GI: SIMPARA StartText: ^.PP^ - # GI: PROGRAMLISTING StartText: ^.PP^.nf^${_action 1001}^\\f(CW EndText: \\fR^.fi^.PP^ - # GI: LITERALLAYOUT StartText: ^.PP^.nf^${_action 1001}^ EndText: ^.fi^ - # GI: BLOCKQUOTE StartText: ^.PP^.RS^ EndText: ^.RE^ - # GI: TITLE Context: BLOCKQUOTE StartText: ^.pF B^ EndText: ^.fR^.PP^ - # GI: EPIGRAPH StartText: ^.PP^.RS^ EndText: ^.RE^ - # GI: ATTRIBUTION StartText: ^\\fI EndText: \\fR^.PP^ - # GI: ABSTRACT Relation: child TITLE - # GI: ABSTRACT StartText: ^.SS "Abstract"^ - # GI: TITLE Context: ABSTRACT StartText: ^.SS " EndText: "^ - # GI: REVHISTORY StartText: ^.SS "Revision History"^ EndText: ^ - # GI: REVISION StartText: ^.PP^\\fBRevision:\\fR\s EndText: ^ - # GI: REVNUMBER StartText: #\s EndText: ;\s - # GI: DATE EndText: ;\s - # GI: AUTHORINITIALS Context: REVISION StartText: \s - # GI: REVREMARK StartText: ;\s\s EndText: ^ - # GI: PROGRAMLISTINGCO # nothing to do specifically in ProgramListingCO -- it falls to # the content of ProgramListing and any callout list - # GI: SCREEN StartText: ^.PP^.nf^${_action 1001}^ EndText: ^.fi^ - # GI: SCREENCO # nothing to do specifically in ScreenCO -- it falls to # the content of Screen and any callout list - # GI: SCREENSHOT # nothing specific to do here -- defer to any ScreenInfo or the # included graphic - # GI: SCREENINFO StartText: ^.PP^\\fI EndText: \\fR^.PP^ - # GI: GRAPHICCO # nothing to do specifically in GraphicCO -- it falls to # the content of Graphic and any callout list - # GI: INFORMALEXAMPLE # nothing special to do here -- it falls to the content. - # GI: EXAMPLE # nothing special to do here -- it falls to the content. - # GI: TITLE Context: EXAMPLE StartText: ^.PP^.pF B^ EndText: ^.fR^ - # GI: FIGURE # nothing special to do here -- it falls to the content. - # GI: TITLE Context: FIGURE StartText: ^.PP^.pF B^ EndText: ^.fR^ - # GI: SIDEBAR Relation: child TITLE StartText: ^.PP^.RS^ EndText: ^.RE^ - # GI: SIDEBAR StartText: ^.PP^.RS^\\fB[ Sidebar ]\\fR^ EndText: ^.RE^ - # GI: TITLE Context: SIDEBAR StartText: ^\\fB^[ Sidebar:\s EndText: \s\\fB]\\fR^ - # GI: HIGHLIGHTS StartText: ^.SS "Highlights"^ - # GI: AUTHORBLURB # nothing to do specially -- an included title may occur - # GI: TITLE Context: AUTHORBLURB StartText: ^.PP^.pF B^ EndText: ^.fP^ - # # ############################################################################# # # Call-out material # # #### ##### ##### ##### ##### ##### #### ##### # GI: CO # nothing to do for the anchor of a callout - # GI: AREASPEC Ignore: all # not much to do with representing the anchor of callouts in n/troff - # GI: AREA Ignore: all # part of AreaSpec, which is being ignored - # GI: AREASET Ignore: all # part of AreaSpec, which is being ignored - # # ############################################################################# # # Address block # # #### ##### ##### ##### ##### ##### #### ##### # GI: ADDRESS StartText: ^.PP^.nf^${_action 1001}^ EndText: ^.fi^ - # GI: STREET # just the content... - # GI: POB # just the content... - # GI: POSTCODE # just the content... - # GI: CITY EndText: ,\s - # GI: STATE # just the content - # GI: COUNTRY # just the content - # GI: PHONE StartText: ^voice:\s - # GI: FAX StartText: ^fax:\s - # GI: OTHERADDR # just the content.. - # GI: EMAIL Context: ADDRESS # just the content.. - # # ############################################################################# # # Lists # # #### ##### ##### ##### ##### ##### #### ##### # GI: GLOSSLIST Relation: ancestor ITEMIZEDLIST StartText: ^.RS^ EndText: ^.RE^ - # GI: GLOSSLIST Relation: ancestor GLOSSLIST StartText: ^.RS^ EndText: ^.RE^ - # GI: GLOSSLIST Relation: ancestor ORDEREDLIST StartText: ^.RS^ EndText: ^.RE^ - # GI: GLOSSLIST Relation: ancestor SIMPLELIST StartText: ^.RS^ EndText: ^.RE^ - # GI: GLOSSLIST Relation: ancestor VARIABLELIST StartText: ^.RS^ EndText: ^.RE^ - # GI: GLOSSLIST Relation: ancestor SEGMENTEDLIST StartText: ^.RS^ EndText: ^.RE^ - # GI: GLOSSLIST # Nothing to do here.. see glossentry, etc - # GI: GLOSSENTRY # nothing to do.. - # GI: GLOSSTERM Context: GLOSSENTRY StartText: ^.IP " EndText: " 10^ - # GI: GLOSSTERM Relation: ancestor PARA Action: 900 - # GI: GLOSSTERM Action: 910 - # GI: ACRONYM Context: GLOSSENTRY StartText: (\\fIacronym:\s\\fR EndText: )\s\s - # GI: ABBREV Context: GLOSSENTRY StartText: (\\fIabbreviation:\s\\fR EndText: )\s\s - # GI: GLOSSSEE StartText: ^\\fISee \\fR - # GI: GLOSSDEF # nothing special to do -- just pass the content. - # GI: GLOSSSEEALSO StartText: ^^\\fISee Also \\fR - # GI: ITEMIZEDLIST Relation: ancestor ITEMIZEDLIST StartText: ^.RS^ EndText: ^.RE^ - # GI: ITEMIZEDLIST Relation: ancestor GLOSSLIST StartText: ^.RS^ EndText: ^.RE^ - # GI: ITEMIZEDLIST Relation: ancestor ORDEREDLIST StartText: ^.RS^ EndText: ^.RE^ - # GI: ITEMIZEDLIST Relation: ancestor SIMPLELIST StartText: ^.RS^ EndText: ^.RE^ - # GI: ITEMIZEDLIST Relation: ancestor VARIABLELIST StartText: ^.RS^ EndText: ^.RE^ - # GI: ITEMIZEDLIST Relation: ancestor SEGMENTEDLIST StartText: ^.RS^ EndText: ^.RE^ - # GI: ITEMIZEDLIST # nothing to do.. - # GI: LISTITEM Context: ITEMIZEDLIST StartText: ^.IP "\ \ \ \\(bu" 6^ - # GI: ORDEREDLIST Relation: ancestor ITEMIZEDLIST StartText: ^.RS^ EndText: ^.RE^ - # GI: ORDEREDLIST Relation: ancestor GLOSSLIST StartText: ^.RS^ EndText: ^.RE^ - # GI: ORDEREDLIST Relation: ancestor ORDEREDLIST StartText: ^.RS^ EndText: ^.RE^ - # GI: ORDEREDLIST Relation: ancestor SIMPLELIST StartText: ^.RS^ EndText: ^.RE^ - # GI: ORDEREDLIST Relation: ancestor VARIABLELIST StartText: ^.RS^ EndText: ^.RE^ - # GI: ORDEREDLIST Relation: ancestor SEGMENTEDLIST StartText: ^.RS^ EndText: ^.RE^ - # GI: ORDEREDLIST StartText: ${_set orderlist 1} - # GI: LISTITEM Context: ORDEREDLIST StartText: ^.IP "\ \ \ ${orderlist}." 6^ Increment: orderlist - # GI: SIMPLELIST Relation: ancestor ITEMIZEDLIST StartText: ^.RS^ EndText: ^.RE^ - # GI: SIMPLELIST Relation: ancestor GLOSSLIST StartText: ^.RS^ EndText: ^.RE^ - # GI: SIMPLELIST Relation: ancestor ORDEREDLIST StartText: ^.RS^ EndText: ^.RE^ - # GI: SIMPLELIST Relation: ancestor SIMPLELIST StartText: ^.RS^ EndText: ^.RE^ - # GI: SIMPLELIST Relation: ancestor VARIABLELIST StartText: ^.RS^ EndText: ^.RE^ - # GI: SIMPLELIST Relation: ancestor SEGMENTEDLIST StartText: ^.RS^ EndText: ^.RE^ - # GI: SIMPLELIST # nothing to do here.. - # GI: MEMBER PAttSet: TYPE INLINE NthChild: 1 - # GI: MEMBER PAttSet: TYPE INLINE StartText: ,\s - # GI: MEMBER PAttSet: TYPE HORIZ NthChild: 1 StartText: ^.PP^\t - # GI: MEMBER PAttSet: TYPE HORIZ StartText: \t - # GI: MEMBER PAttSet: TYPE VERT StartText: ^.IP "" 10^ EndText: ^ - # GI: VARIABLELIST Relation: ancestor ITEMIZEDLIST StartText: ^.RS^ EndText: ^.RE^ - # GI: VARIABLELIST Relation: ancestor GLOSSLIST StartText: ^.RS^ EndText: ^.RE^ - # GI: VARIABLELIST Relation: ancestor ORDEREDLIST StartText: ^.RS^ EndText: ^.RE^ - # GI: VARIABLELIST Relation: ancestor SIMPLELIST StartText: ^.RS^ EndText: ^.RE^ - # GI: VARIABLELIST Relation: ancestor VARIABLELIST StartText: ^.RS^ EndText: ^.RE^ - # GI: VARIABLELIST Relation: ancestor SEGMENTEDLIST StartText: ^.RS^ EndText: ^.RE^ - # GI: VARIABLELIST # nothing to do now, see VarListEntry - # GI: VARLISTENTRY # nothing to do now, see Term - # GI: TERM StartText: ^.IP " EndText: " 10^ - # GI: LISTITEM Context: VARLISTENTRY # nothing special to do.. - # GI: SEGMENTEDLIST Relation: ancestor ITEMIZEDLIST StartText: ^.RS^${_followrel child TITLE 400}^.TS^tab();^l l l l l l l l l l l l l l l l l l.^ EndText: ^.TE^.RE^ - # GI: SEGMENTEDLIST Relation: ancestor GLOSSLIST StartText: ^.RS^${_followrel child TITLE 400}^.TS^tab();^l l l l l l l l l l l l l l l l l l.^ EndText: ^.TE^.RE^ - # GI: SEGMENTEDLIST Relation: ancestor ORDETERLIST StartText: ^.RS^${_followrel child TITLE 400}^.TS^tab();^l l l l l l l l l l l l l l l l l l.^ EndText: ^.TE^.RE^ - # GI: SEGMENTEDLIST Relation: ancestor SIMPLELIST StartText: ^.RS^${_followrel child TITLE 400}^.TS^tab();^l l l l l l l l l l l l l l l l l l.^ EndText: ^.TE^.RE^ - # GI: SEGMENTEDLIST Relation: ancestor VARIABLELIST StartText: ^.RS^${_followrel child TITLE 400}^.TS^tab();^l l l l l l l l l l l l l l l l l l.^ EndText: ^.TE^.RE^ - # GI: SEGMENTEDLIST Relation: ancestor SEGMENTEDLIST StartText: ^.RS^${_followrel child TITLE 400}^.TS^tab();^l l l l l l l l l l l l l l l l l l.^ EndText: ^.TE^.RE^ - # GI: SEGMENTEDLIST Relation: child TITLE StartText: ^${_followrel child TITLE 400}^.TS^tab();^l l l l l l l l l l l l l l l l l l.^ EndText: ^.TE^ - # GI: TITLE Context: SEGMENTEDLIST # ignored by default -- must be called by SEGMENTEDLIST gi Ignore: all - # GI: _segmentedlist_title SpecID: 400 StartText: ^.sp 1^.pF B^ EndText: ^.fP^ - # GI: SEGTITLE StartText: \\fB EndText: \\fR - # GI: SEGLISTITEM StartText: ^ EndText: ^ - # GI: SEG EndText:  - # GI: PROCEDURE # defer to the content... StartText: ${_set procstep 1}${_set procsubstep 1} - # GI: TITLE Context: PROCEDURE StartText: ^.PP^.pF B^ EndText: ^.fP^ - # GI: STEP StartText: ^.PP^\\fIStep ${procstep}.\s\s EndText: ^ Increment: procstep 1 - # GI: TITLE Context: STEP StartText: ^.pF B^ EndText: ^.fP^.PP^ - # GI: SUBSTEPS StartText: ^.RS^ EndText: ^.RE^ - # GI: STEP Context: SUBSTEPS StartText: ^.PP^\\fISubstep ${procsubstep}.\s\s EndText: ^ Increment: procsubstep 1 - # GI: CALLOUTLIST StartText: ${_set callout 1} # nothing to do specifically, defer to the content... - # GI: TITLE Context: CALLOUTLIST StartText: ^.pF B^ EndText: ^.fP^.PP^ - # GI: CALLOUT StartText: ^.PP^\\fICallout ${callout}.\s\s\\fR EndText: ^ Increment: callout - # # ############################################################################# # # Messages # # #### ##### ##### ##### ##### ##### #### ##### # GI: MSGSET StartText: ^.SS "Message Set"^ - # GI: MSGENTRY StartText: ^.PP^\\fBMessage Entry\\fR EndText: ^ - # GI: MSG Relation: child TITLE StartText: ^.RS^ EndText: ^.RE^ - # GI: MSG StartText: ^.RS^.PP^\\fIMessage\s\\fB EndText: :\s\s\\fR^.RE^ - # GI: TITLE Context: MSG StartText: ^.PP^.pF B^ EndText: ^.fP^ - # GI: MSGINFO # nothing specific -- just groups (MsgLevel | MsgOrig | MsgAud)* - # GI: MSGEXPLAN # nothing special -- defer to content - # GI: TITLE Context: MSGEXPLAN StartText: ^.PP^.pF B^ EndText: ^.fP^ - # GI: MSGMAIN # defer to content - # GI: TITLE Context: MSGMAIN StartText: ^.PP^.pF B^ EndText: ^.fP^ - # GI: MSGSUB # defer to content - # GI: TITLE Context: MSGSUB StartText: ^.PP^.pF B^ EndText: ^.fP^ - # GI: MSGREL # defer to content - # GI: TITLE Context: MSGREL StartText: ^.PP^.pF B^ EndText: ^.fP^ - # GI: MSGLEVEL StartText: ^\\fIMessage level:\s\s\\fR EndText: ^ - # GI: MSGORIG StartText: ^\\fIMessage origin:\s\s\\fR EndText: ^ - # GI: MSGAUD StartText: ^\\fIMessage audience:\s\s\\fR EndText: ^ - # GI: MSGTEXT StartText: \\fR^\\fIMessage text:\\fR EndText: ^ - # # ############################################################################# # # Admonitions # # #### ##### ##### ##### ##### ##### #### ##### # GI: CAUTION Relation: child TITLE StartText: ^.PP^.RS EndText: ^.RE^ - # GI: CAUTION StartText: ^.PP^.RS^\\fBCaution:\s\s EndText: ^.RE^ - # GI: TITLE Context: CAUTION StartText: ^\\fBCaution:\s\s EndText: \\fR^.PP^ - # GI: IMPORTANT Relation: child TITLE StartText: ^.PP^.RS^ EndText: ^.RE^ - # GI: IMPORTANT StartText: ^.PP^.RS^\\fBImportant:\s\s EndText: ^.RE^ - # GI: TITLE Context: IMPORTANT StartText: ^\\fBImportant:\s\s EndText: \\fR^.PP^ - # GI: NOTE Relation: child TITLE StartText: ^.PP^.RS EndText: ^.RE^ - # GI: NOTE StartText: ^.PP^.RS^\\fBNote:\s\s EndText: ^.RE^ - # GI: TITLE Context: NOTE StartText: ^\\fBNote:\s\s EndText: \\fR^.PP^ - # GI: TIP Relation: child TITLE StartText: ^.PP^.RS EndText: ^.RE^ - # GI: TIP StartText: ^.PP^.RS^\\fBTip:\s\s EndText: ^.RE^ - # GI: TITLE Context: TIP StartText: ^\\fBTip:\s\s EndText: \\fR^.PP^ - # GI: WARNING Relation: child TITLE StartText: ^.PP^.RS EndText: ^.RE^ - # GI: WARNING StartText: ^.PP^.RS^\\fBWarning:\s\s EndText: ^.RE^ - # GI: TITLE Context: WARNING StartText: ^\\fBWarning:\s\s EndText: \\fR^.PP^ - # # ############################################################################# # # Synopses # # #### ##### ##### ##### ##### ##### #### ##### # GI: SYNOPSIS StartText: ^.PP^ EndText: ^ - # GI: CMDSYNOPSIS StartText: ^.PP^ EndText: ^ - # GI: ARG Context: GROUP NthChild: 1 EndText: ${_attval REP REPEAT 505} - # GI: ARG Context: GROUP StartText: \s|\s EndText: ${_attval REP REPEAT 505} - # GI: ARG AttValue: CHOICE OPT StartText: \s[ EndText: ]${_attval REP REPEAT 505}\s - # GI: ARG # no special attrs -- just pass content through EndText: ${_attval REP REPEAT 505} - # GI: _arg_group SpecID: 505 StartText: \s\\&...\s Ignore: all - # GI: GROUP AttValue: CHOICE OPT StartText: \s[ EndText: ]\s${_attval REPEAT REPEAT 505} - # GI: GROUP AttValue: CHOICE REQ StartText: \s{ EndText: }\s${_attval REPEAT REPEAT 505} - # GI: GROUP AttValue: CHOICE OPTMULT StartText: \s[[ EndText: ]]\s${_attval REPEAT REPEAT 505} - # GI: GROUP AttValue: CHOICE REQMULT StartText: \s{{ EndText: }}\s${_attval REPEAT REPEAT 505} - # GI: GROUP AttValue: CHOICE PLAIN EndText: ${_attval REPEAT REPEAT 505} - # GI: SBR StartText: ^.br^ - # GI: SYNOPFRAGMENT # nothing special to do here -- just pass through content (Arg | Group)+ - # GI: SYNOPFRAGMENTREF # WHAT TO DO HERE?? pass through the content, but what about the # linkend? (will call it across...) EndText: \s\\fI(refers to: ${_followlink LINKEND 1000})\\fR - # GI: FUNCSYNOPSIS StartText: ^.PP^.nf^${_action 1001}^ EndText: ^.fi^ - # GI: FUNCSYNOPSISINFO StartText: ^ EndText: ^ - # GI: FUNCPROTOTYPE # nothing special -- just pass through content (looks like # a function def StartText: ^.sp 1^ - # GI: FUNCDEF StartText: ^\\fB EndText: \\fR(^ - # GI: FUNCPARAMS StartText: \\fB EndText: \\fR^ - # GI: VOID StartText: \t\\fBvoid\\fR) - # GI: VARARGS StartText: \t\\fB\\&...\\fR) - # GI: PARAMDEF Relation: sibling+ PARAMDEF StartText: \\fB EndText: \\fR,^ - # GI: PARAMDEF StartText: \\fB EndText: \\fR);^ - # # ############################################################################# # # Links # # #### ##### ##### ##### ##### ##### #### ##### # GI: LINK StartText: \\fI EndText: \\fR - # GI: OLINK StartText: \\fI EndText: \s(link to external document ${TargetDocEnt})\s\\fR - # GI: ULINK StartText: \\fI EndText: \s(link to URL ${URL})\s\\fR - # GI: FOOTNOTEREF # just let the footnote ref mark come through - # GI: FOOTNOTE # just let footnote body come through (-man doesn't support footnotes) - # GI: XREF AttValue: ENDTERM StartText: \\fI"${_followlink ENDTERM 1000}"\\fR\s - # GI: XREF StartText: \\fI"${_followlink LINKEND 600}"\\fR\s - # GI: _xref SpecID: 600 StartText: ${_set xreflabel no}${_isset XREFLABEL 601}${_isset xreflabel no 602} Ignore: all - # GI: _xref_label SpecID: 601 StartText: ${_set xreflabel yes}${XREFLABEL} Ignore: all - # GI: _xref_title SpecID: 602 Set: StartText: ${_followrel child TITLE 1000} Ignore: all - # GI: ANCHOR # nothing to do -- this just marks a place.. - # # ############################################################################# # # Graphics and Equations # # #### ##### ##### ##### ##### ##### #### ##### # GI: GRAPHIC AttValue: ENTITYREF StartText: ^.PP^.P! "${_filename}"^ - # GI: INLINEGRAPHIC StartText: ^.P! "${_filename}"^ - # GI: INFORMALEQUATION # nothing special to do -- defer to graphic content.. - # GI: EQUATION # nothing special to do -- defer to graphic content.. - # GI: TITLE Context: EQUATION StartText: ^.PP^.pF B^ EndText: ^.fP^ - # GI: INLINEEQUATION # nothing special to do -- defer to graphic content.. - # # ############################################################################# # # Tables # # #### ##### ##### ##### ##### ##### #### ##### # # GI: INFORMALTABLE StartText: ^${_calstable tbl tablestart}^ EndText: ^${_calstable tbl tableend}^ - # GI: TABLE StartText: ^.PP^\\fB${_followrel child TITLE 1000}\\fR ^${_calstable tbl tablestart}^ EndText: ^${_calstable tbl tableend}^ - # GI: TITLE Context: TABLE # handled in TABLE element Ignore: all - # GI: TGROUP StartText: ^${_calstable tbl tablegroup}^${_followrel child THEAD 700}${_followrel child TBODY 700}${_followrel child TFOOT 701} EndText: ${_calstable tbl tablegroupend} - # GI: COLSPEC Ignore: all - # GI: SPANSPEC Ignore: all - # GI: THEAD TBODY TFOOT # they're called explicitly from TGROUP, but ignored here Ignore: all - # GI: _thead_tbody SpecID: 700 # nothing special to do -- just pass through content - # GI: _tfoot SpecID: 701 StartText: ^${_calstable tbl tablefoot}^ - # GI: ROW StartText: ^${_calstable tbl rowstart} EndText: ${_calstable tbl rowend}^ - # GI: ENTRY StartText: ${_calstable tbl entrystart} EndText: ${_calstable tbl entryend} - # GI: ENTRYTBL StartText: EndText: Message: ^IMPLEMENT <${_gi} ${_allatts}>^ - # # ############################################################################# # # Index terms # # #### ##### ##### ##### ##### ##### #### ##### # GI: INDEXTERM StartText: ^.iX\s EndText: ^ - # GI: PRIMARY StartText: " EndText: " - # GI: SECONDARY StartText: \s" EndText: " - # GI: TERTIARY StartText: \s" EndText: " - # GI: SEE StartText: \s"See:\s EndText: " - # GI: SEEALSO StartText: \s"SeeAlso:\s EndText: " - # # ############################################################################# # # Author / OtherCredit material # # #### ##### ##### ##### ##### ##### #### ##### # GI: OTHERCREDIT # nothing specific -- defer to content - # GI: HONORIFIC # nothing specific -- defer to content EndText: \s - # GI: FIRSTNAME # nothing specific -- defer to content EndText: \s - # GI: SURNAME # nothing specific -- defer to content EndText: \s - # GI: LINEAGE # nothing specific -- defer to content EndText: \s - # GI: OTHERNAME # nothing specific -- defer to content StartText: ( EndText: )\s - # GI: AFFILIATION # nothing specific -- defer to content EndText: \s - # GI: SHORTAFFIL # nothing specific -- defer to content EndText: \s - # GI: JOBTITLE # nothing specific -- defer to content EndText: \s - # GI: ORGNAME # nothing specific -- defer to content EndText: \s - # GI: ORGDIV # nothing specific -- defer to content EndText: \s - # GI: CONTRIB # nothing specific -- defer to content EndText: \s - # # ############################################################################# # # "Leaf" material # # #### ##### ##### ##### ##### ##### #### ##### # GI: ABBREV # no special presentation - # GI: ACCEL # no special presentation - # GI: ACRONYM # no special presentation - # GI: AUTHORINITIALS # no special presentation - # GI: CITATION Relation: ancestor PARA Action: 900 - # GI: CITATION Action: 910 - # GI: CITETITLE AttValue: PUBWORK Relation: ancestor PARA StartText: \\c^.pF I^ EndText: ^.fP^(${PUBWORK})\s - # GI: CITETITLE Relation: ancestor PARA Action: 920 - # GI: CITETITLE AttValue: PUBWORK StartText: \\fI EndText: \\fP (${PUBWORK})\s - # GI: CITETITLE StartText: \\fI EndText: \\fP - # GI: CITEREFENTRY # defer to content.. - # GI: REFENTRYTITLE Relation: ancestor PARA Action: 900 - # GI: REFENTRYTITLE Action: 910 - # GI: MANVOLNUM Relation: ancestor PARA StartText: \\c^.pF B^(\\c EndText: )\\c^.fP^ - # GI: MANVOLNUM StartText: \\fB( EndText: )\\fP - # GI: COMMENT # docbook says to inhibit this from finished products... Ignore: all - # GI: EMAIL # no special presentation - # GI: EMPHASIS Relation: ancestor PARA Action: 920 - # GI: EMPHASIS Action: 930 - # GI: FIRSTTERM Relation: ancestor PARA Action: 920 - # GI: FIRSTTERM Action: 930 - # GI: FOREIGNPHRASE # no special presentation - # GI: PHRASE # no special presentation - # GI: QUOTE StartText: ``\\fI EndText: \\fR'' - # GI: TRADEMARK EndText: \\u\\s-2TM\\s+2\\d - # GI: WORDASWORD # no special presentation - # GI: ACTION # no special presentation - # GI: APPLICATION Relation: ancestor PARA Action: 900 - # GI: APPLICATION Action: 910 - # GI: CLASSNAME Relation: ancestor PARA Action: 900 - # GI: CLASSNAME Action: 910 - # GI: COMMAND Relation: ancestor PARA Action: 900 - # GI: COMMAND StartText: ${_action 910}\s Ignore: all - # GI: COMPUTEROUTPUT Relation: ancestor PARA StartText: \\c^.pF CW^ EndText: ^.fP^ - # GI: COMPUTEROUTPUT StartText: \\f(CW EndText: \\fP - # GI: DATABASE # no special presentation - # GI: ERRORNAME Relation: ancestor PARA Action: 900 - # GI: ERRORNAME Action: 910 - # GI: ERRORTYPE # no special presentation - # GI: FILENAME Relation: ancestor PARA Action: 900 - # GI: FILENAME Action: 910 - # GI: FUNCTION Relation: ancestor PARA Action: 900 - # GI: FUNCTION Action: 910 - # GI: GUIBUTTON Relation: ancestor PARA Action: 900 - # GI: GUIBUTTON Action: 910 - # GI: GUIICON Relation: ancestor PARA Action: 900 - # GI: GUIICON Action: 910 - # GI: GUILABEL # no special presentation - # GI: GUIMENU # no special presentation - # GI: GUIMENUITEM # no special presentation - # GI: GUISUBMENU # no special presentation - # GI: HARDWARE # no special presentation - # GI: INTERFACE # no special presentation - # GI: INTERFACEDEFINITION Relation: ancestor PARA Action: 900 - # GI: INTERFACEDEFINITION Action: 910 - # GI: KEYCAP Relation: ancestor PARA StartText: \\c^.pF B^<\\c EndText: >\\c^.fP^ - # GI: KEYCAP StartText: \\fB< EndText: >\\fP - # GI: KEYCODE # no special presentation - # GI: KEYCOMBO # no special presentation -- defer to the content - # GI: KEYSYM Relation: ancestor PARA StartText: \\c^.pF B^<\\c EndText: >\\c^.fP^ - # GI: KEYSYM Relation: ancestor PARA StartText: \\c^.pF B^<\\c EndText: >\\c^.fP^ - # GI: KEYSYM StartText: \\fB< EndText: >\\fP - # GI: LINEANNOTATION Action: 920 - # GI: LITERAL Relation: ancestor PARA Action: 900 - # GI: LITERAL Action: 910 - # GI: MARKUP Relation: ancestor PARA Action: 940 - # GI: MARKUP Action: 950 - # GI: MEDIALABEL # no special presentation - # GI: MENUCHOICE # no special presentation - # GI: PROMPT # no special presentation - # GI: SHORTCUT # no special presentation - # GI: MOUSEBUTTON # no special presentation - # GI: OPTION Relation: ancestor PARA Action: 900 - # GI: OPTION Action: 910 - # GI: OPTIONAL StartText: [ EndText: ] - # GI: PARAMETER Relation: ancestor PARA Action: 900 - # GI: PARAMETER Action: 910 - # GI: PROPERTY Relation: ancestor PARA Action: 900 - # GI: PROPERTY Action: 910 - # GI: REPLACEABLE Relation: ancestor PARA Action: 920 - # GI: REPLACEABLE Action: 930 - # GI: RETURNVALUE Relation: ancestor PARA Action: 900 - # GI: RETURNVALUE Action: 910 - # GI: SGMLTAG AttValue: CLASS ELEMENT StartText: \\fB< EndText: >\\fP - # GI: SGMLTAG Relation: ancestor PARA Action: 900 - # GI: SGMLTAG Action: 910 - # GI: STRUCTFIELD Relation: ancestor PARA Action: 900 - # GI: STRUCTFIELD Action: 910 - # GI: STRUCTNAME Relation: ancestor PARA Action: 900 - # GI: STRUCTNAME Action: 910 - # GI: SYMBOL Relation: ancestor PARA Action: 920 - # GI: SYMBOL Action: 930 - # GI: SYSTEMITEM Relation: ancestor PARA Action: 900 - # GI: SYSTEMITEM Action: 910 - # GI: TOKEN Relation: ancestor PARA Action: 900 - # GI: TOKEN Action: 910 - # GI: TYPE Relation: ancestor PARA Action: 900 - # GI: TYPE Action: 910 - # GI: USERINPUT Relation: ancestor PARA Action: 900 - # GI: USERINPUT Action: 910 - # GI: AUTHOR # no special presentation - defer to content - # GI: CORPAUTHOR # no special presentation - # GI: MODESPEC # nothing to render (this is meta information for Links) - # GI: PRODUCTNAME Relation: ancestor PARA Action: 900 - # GI: PRODUCTNAME Action: 910 - # GI: PRODUCTNUMBER # no special presentation - # GI: SUBSCRIPT StartText: \\d EndText: \\u - # GI: SUPERSCRIPT StartText: \\u EndText: \\d - # # ############################################################################# # # stuff that gets ignored (and doesn't belong elsewhere) # # #### ##### ##### ##### ##### ##### #### ##### # GI: TITLEABBREV # this element is ignored in favor of the real title Ignore: all - # # # ############################################################################# # # handle layout-specific stuff and PIs # # #### ##### ##### ##### ##### ##### #### ##### # GI: BEGINPAGE StartText: ^.br - # GI: _x-break StartText: ^.br - # GI: _sml-break StartText: ^.br - # GI: _sml-need StartText: ^.ne\s EndText: ^ - # GI: _sml-size StartText: ^.ps\s EndText: ^ - # GI: _sml-indent StartText: ^.in\s EndText: ^ - # GI: _sml-space StartText: ^.sp\s EndText: ^ - # GI: _sml-tabset StartText: ^.ta\s EndText: ^ - # # ############################################################################# # # General purpose transpecs # # #### ##### ##### ##### ##### ##### #### ##### # # GI: _macro_bold SpecID: 900 StartText: \\c^.pF B^ EndText: \\c^.fP^ - # GI: _inline_bold SpecID: 910 StartText: \\fB EndText: \\fP - # GI: _macro_italiac SpecID: 920 StartText: \\c^.pF I^ EndText: \\c^.fP^ - # GI: _inline_italiac SpecID: 930 StartText: \\fI EndText: \\fP - # GI: _macro_cw SpecID: 940 StartText: \\c^.pF CW^ EndText: \\c^.fP^ - # GI: _macro_cw SpecID: 950 StartText: \\f(CW EndText: \\fP - # GI: _passthrough SpecID: 1000 - # # Used to reset trap positions, either at start of file or when .nf is # restarted, such as for literal output. Assumes caller is responsible # for line starting characters as appropriate. (it helps the calling # definitions read more logically). # GI: _tabset SpecID: 1001 StartText: .ta 8n 16n 24n 32n 40n 48n 56n 64n 72n Ignore: all - # # Sets up macros for push/pop of fonts to better handle nested cases. # Moved reference into this file rather than assuming the wrapper script # will add it, since it's tightly coupled with this file anyway. # GI: _fontmac SpecID: 1002 StartText: ^${_include docbook-to-man.prolog}^ Ignore: all - # GI: _doTitle SpecID: 1010 StartText: ^.PP^\\fB EndText: \\fR^.PP^ - # # ############################################################################# # # Catch-all for unknown PIs -- ignore them... # # #### ##### ##### ##### ##### ##### #### ##### # GI: _* Ignore: all - # # ############################################################################# # # Catch-all for unknown elements -- just output their content.. # # #### ##### ##### ##### ##### ##### #### ##### # #GI: * #- # docbook-to-man-2.0.0.orig/Transpec/roff.cmap0100644000176100001440000000437106737404360020155 0ustar debacleusers# # # 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) 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 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # 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. # # # Character strings to map for troff/nroff. # # # $Id: roff.cmap,v 1.2 1998/11/16 22:23:54 db3l Exp $ # # # From To \\ \\e ^ \^ . \\&. ' \\&' docbook-to-man-2.0.0.orig/Transpec/roff.sdata0100644000176100001440000003677706737404360020350 0ustar debacleusers# # 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) 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 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # 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. # # # SDATA entity mappings to TeX instructions. # sgmls outputs sdata references in the form: \\|[mdash ]\\| # # J.Bowe, 1993 # # Numeric and Special Graphic ________________________________ # # # $Id: roff.sdata,v 1.2 1998/11/16 22:23:55 db3l Exp $ # [half ] \\(12 [frac12] \\(12 [frac14] \\(14 [frac34] \\(34 [frac18] 1/8 [frac38] 3/8 [frac58] 5/8 [frac78] 7/8 [sup1 ] \\u1\\l [sup2 ] \\u2\\l [sup3 ] \\u3\\l [plus ] \\(pl [plusmn] \\(+- [lt ] < [equals] = [gt ] > [divide] \\(di [times ] \\(ti # [curren] =general currency sign [pound ] # [dollar] $ [cent ] \\(ct [yen ] yen [num ] # [percnt] % [amp ] & [ast ] * [commat] @ [lsqb ] [ [bsol ] \\e [rsqb ] ] [lcub ] { /lbrace O: =left curly bracket # [horbar] horizontal bar [horbar] _ [verbar] \\(or [rcub ] } [micro ] \\(*m [ohm ] \\(*W [deg ] \\(de # [ordm ] =ordinal indicator, masculine # [ordf ] =ordinal indicator, feminine [sect ] \\(sc # [para ] =pilcrow (paragraph sign) # [middot] /centerdot B: =middle dot [larr ] \\(<- [rarr ] \\(-> [uarr ] \\(ua [darr ] \\(da [copy ] \\(co [reg ] \\(rg #[trade ] trademark [trade ] \\(tm # [brvbar] =broken (vertical) bar [brvbar] | [not ] \\(no # [sung ] =music note (sung text sign) [excl ] ! # [iexcl ] =inverted exclamation mark [quot ] " [apos ] \\&' [lpar ] ( [rpar ] ) [comma ] , [lowbar] _ [hyphen] \\- [period] . [sol ] / [colon ] : [semi ] ; [quest ] ? # [iquest] =inverted question mark # [laquo ] =angle quotation mark, left [laquo ] << # [raquo ] =angle quotation mark, right [raquo ] >> [lsquo ] ` [rsquo ] \\&' [ldquo ] " [rdquo ] " [nbsp ] \\ [shy ] \\% # # Publishing ________________________________ # # trailing space here [emsp ] \\ \\ [ensp ] \\ [emsp3 ] \\ [emsp4 ] \\ [numsp ] \\0 [puncsp] \\| [thinsp] \\! [hairsp] \\\^ [mdash ] \\(em [ndash ] - [dash ] - [blank ] \\ [hellip] \\&... [nldr ] \\&.. [frac13] 1/3 [frac23] 2/3 [frac15] 1/5 [frac25] 2/5 [frac35] 3/5 [frac45] 4/5 [frac16] 1/6 [frac56] 5/6 # [incare] =in-care-of symbol # [block ] =full block # [uhblk ] =upper half block # [lhblk ] =lower half block # [blk14 ] =25% shaded block # [blk12 ] =50% shaded block # [blk34 ] =75% shaded block # [marker] =histogram marker [cir ] \\(ci [squ ] \\(sq # [rect ] =rectangle, open # [utri ] /triangle =up triangle, open # [dtri ] /triangledown =down triangle, open [star ] \\(** =star, open [bull ] \\(bu # [squf ] /blacksquare =sq bullet, filled # [utrif ] /blacktriangle =up tri, filled # [dtrif ] /blacktriangledown =dn tri, filled # [ltrif ] /blacktriangleleft R: =l tri, filled # [rtrif ] /blacktriangleright R: =r tri, filled # [clubs ] /clubsuit =club suit symbol # [diams ] /diamondsuit =diamond suit symbol # [hearts] /heartsuit =heart suit symbol # [spades] /spadesuit =spades suit symbol # [malt ] /maltese =maltese cross [dagger] \\(dg [Dagger] \\(dd # [check ] /checkmark =tick, check mark # [ballot] =ballot cross # [sharp ] /sharp =musical sharp # [flat ] /flat =musical flat # [male ] =male symbol # [female] =female symbol # [phone ] =telephone symbol # [telrec] =telephone recorder symbol # [copysr] =sound recording copyright sign [caret ] \^ [lsquor] ` [ldquor] `` [fflig ] \\(ff [filig ] \\(fi # [fjlig ] small fj ligature [ffilig] \\(Fi [ffllig] \\(Fl [fllig ] \\(fl # [mldr ] em leader [rdquor] \\&'' [rsquor] \\&' # Vertical ellipsis - cheat for now and treat like horizontal [vellip] \\&... # [hybull] rectangle, filled (hyphen bullet) # [loz ] /lozenge - lozenge or total mark # [lozf ] /blacklozenge - lozenge, filled # [ltri ] /triangleleft B: l triangle, open # [rtri ] /triangleright B: r triangle, open # [starf ] /bigstar - star, filled # [natur ] /natural - music natural # [rx ] pharmaceutical prescription (Rx) # [sext ] sextile (6-pointed star) # [target] register mark or target # [dlcrop] downward left crop mark # [drcrop] downward right crop mark # [ulcrop] upward left crop mark # [urcrop] upward right crop mark # # Added Latin 1 ________________________________ # [aacute] \\(a' [Aacute] \\(A' [acirc ] \\(a^ [Acirc ] \\(A^ [agrave] \\(a` [Agrave] \\(A` # [aring ] =small a, ring # [Aring ] =capital A, ring # [atilde] =small a, tilde # [Atilde] =capital A, tilde [auml ] \\(a: # [Auml ] =capital A, dieresis or umlaut mark [aelig ] \\(ae [AElig ] \\(AE # [ccedil] =small c, cedilla # [Ccedil] =capital C, cedilla # [eth ] =small eth, Icelandic # [ETH ] =capital Eth, Icelandic [eacute] \\(e' [Eacute] \\(E' # [ecirc ] =small e, circumflex accent # [Ecirc ] =capital E, circumflex accent [egrave] \\(e` [Egrave] \\(E` # [euml ] =small e, dieresis or umlaut mark # [Euml ] =capital E, dieresis or umlaut mark [iacute] \\(i' [Iacute] \\(I' # [icirc ] =small i, circumflex accent # [Icirc ] =capital I, circumflex accent [igrave] \\(i` [Igrave] \\(I` # [iuml ] =small i, dieresis or umlaut mark # [Iuml ] =capital I, dieresis or umlaut mark [ntilde] \\(n~ [Ntilde] \\(N~ [oacute] \\(o' [Oacute] \\(O' # [ocirc ] =small o, circumflex accent # [Ocirc ] =capital O, circumflex accent [ograve] \\(o` [Ograve] \\(O` [oslash] \\(o/ [Oslash] \\(O/ # [otilde] =small o, tilde # [Otilde] =capital O, tilde # [ouml ] =small o, dieresis or umlaut mark # [Ouml ] =capital O, dieresis or umlaut mark [szlig ] \\(ss [thorn ] \\(th # [THORN ] =capital THORN, Icelandic [uacute] \\(u' [Uacute] \\(U' # [ucirc ] =small u, circumflex accent # [Ucirc ] =capital U, circumflex accent [ugrave] \\(u` [Ugrave] \\(U` # [uuml ] =small u, dieresis or umlaut mark # [Uuml ] =capital U, dieresis or umlaut mark # [yacute] =small y, acute accent # [Yacute] =capital Y, acute accent # [yuml ] =small y, dieresis or umlaut mark # # Added Latin 2 ________________________________ # # [abreve] =small a, breve # [Abreve] =capital A, breve # [amacr ] =small a, macron # [Amacr ] =capital A, macron [aogon ] \\(ao # [Aogon ] =capital A, ogonek # [cacute] =small c, acute accent # [Cacute] =capital C, acute accent # [ccaron] =small c, caron # [Ccaron] =capital C, caron # [ccirc ] =small c, circumflex accent # [Ccirc ] =capital C, circumflex accent # [cdot ] =small c, dot above # [Cdot ] =capital C, dot above # [dcaron] =small d, caron # [Dcaron] =capital D, caron # [dstrok] =small d, stroke # [Dstrok] =capital D, stroke # [ecaron] =small e, caron # [Ecaron] =capital E, caron # [edot ] =small e, dot above # [Edot ] =capital E, dot above # [emacr ] =small e, macron # [Emacr ] =capital E, macron # [eogon ] =small e, ogonek # [Eogon ] =capital E, ogonek # [gacute] =small g, acute accent # [gbreve] =small g, breve # [Gbreve] =capital G, breve # [Gcedil] =capital G, cedilla # [gcirc ] =small g, circumflex accent # [Gcirc ] =capital G, circumflex accent # [gdot ] =small g, dot above # [Gdot ] =capital G, dot above # [hcirc ] =small h, circumflex accent # [Hcirc ] =capital H, circumflex accent # [hstrok] =small h, stroke # [Hstrok] =capital H, stroke # [Idot ] =capital I, dot above # [Imacr ] =capital I, macron # [imacr ] =small i, macron # [ijlig ] =small ij ligature # [IJlig ] =capital IJ ligature # [inodot] =small i without dot # [iogon ] =small i, ogonek # [Iogon ] =capital I, ogonek # [itilde] =small i, tilde # [Itilde] =capital I, tilde # [jcirc ] =small j, circumflex accent # [Jcirc ] =capital J, circumflex accent # [kcedil] =small k, cedilla # [Kcedil] =capital K, cedilla # [kgreen] =small k, Greenlandic # [lacute] =small l, acute accent # [Lacute] =capital L, acute accent # [lcaron] =small l, caron # [Lcaron] =capital L, caron # [lcedil] =small l, cedilla # [Lcedil] =capital L, cedilla # [lmidot] =small l, middle dot # [Lmidot] =capital L, middle dot # [lstrok] =small l, stroke # [Lstrok] =capital L, stroke # [nacute] =small n, acute accent # [Nacute] =capital N, acute accent # [eng ] =small eng, Lapp # [ENG ] =capital ENG, Lapp # [napos ] =small n, apostrophe # [ncaron] =small n, caron # [Ncaron] =capital N, caron # [ncedil] =small n, cedilla # [Ncedil] =capital N, cedilla # [odblac] =small o, double acute accent # [Odblac] =capital O, double acute accent # [Omacr ] =capital O, macron # [omacr ] =small o, macron # [oelig ] =small oe ligature # [OElig ] =capital OE ligature # [racute] =small r, acute accent # [Racute] =capital R, acute accent # [rcaron] =small r, caron # [Rcaron] =capital R, caron # [rcedil] =small r, cedilla # [Rcedil] =capital R, cedilla # [sacute] =small s, acute accent # [Sacute] =capital S, acute accent # [scaron] =small s, caron # [Scaron] =capital S, caron # [scedil] =small s, cedilla # [Scedil] =capital S, cedilla # [scirc ] =small s, circumflex accent # [Scirc ] =capital S, circumflex accent # [tcaron] =small t, caron # [Tcaron] =capital T, caron # [tcedil] =small t, cedilla # [Tcedil] =capital T, cedilla # [tstrok] =small t, stroke # [Tstrok] =capital T, stroke # [ubreve] =small u, breve # [Ubreve] =capital U, breve # [udblac] =small u, double acute accent # [Udblac] =capital U, double acute accent # [umacr ] =small u, macron # [Umacr ] =capital U, macron # [uogon ] =small u, ogonek # [Uogon ] =capital U, ogonek # [uring ] =small u, ring # [Uring ] =capital U, ring # [utilde] =small u, tilde # [Utilde] =capital U, tilde # [wcirc ] =small w, circumflex accent # [Wcirc ] =capital W, circumflex accent # [ycirc ] =small y, circumflex accent # [Ycirc ] =capital Y, circumflex accent # [Yuml ] =capital Y, dieresis or umlaut mark # [zacute] =small z, acute accent # [Zacute] =capital Z, acute accent # [zcaron] =small z, caron # [Zcaron] =capital Z, caron # [zdot ] =small z, dot above # [Zdot ] =capital Z, dot above # # Greek Letters ________________________________ # [agr ] \\(*a [Agr ] \\(*A [bgr ] \\(*b [Bgr ] \\(*B [ggr ] \\(*g [Ggr ] \\(*G [dgr ] \\(*d [Dgr ] \\(*D [egr ] \\(*e [Egr ] \\(*E [zgr ] \\(*z [Zgr ] \\(*Z [eegr ] \\(*y [EEgr ] \\(*Y [thgr ] \\(*h [THgr ] \\(*H [igr ] \\(*i [Igr ] \\(*I [kgr ] \\(*k [Kgr ] \\(*K [lgr ] \\(*l [Lgr ] \\(*L [mgr ] \\(*m [Mgr ] \\(*M [ngr ] \\(*n [Ngr ] \\(*N [xgr ] \\(*c [Xgr ] \\(*C [ogr ] \\(*o [Ogr ] \\(*O [pgr ] \\(*p [Pgr ] \\(*P [rgr ] \\(*r [Rgr ] \\(*R [sgr ] \\(*s [Sgr ] \\(*S [sfgr ] \\(ts [tgr ] \\(*t [Tgr ] \\(*T [ugr ] \\(*u [Ugr ] \\(*U [phgr ] \\(*f [PHgr ] \\(*F [khgr ] \\(*x [KHgr ] \\(*X [psgr ] \\(*q [PSgr ] \\(*Q [ohgr ] \\(*w [OHgr ] \\(*W # # Greek Symbols ________________________________ # [alpha ] \\(*a [beta ] \\(*b [gamma ] \\(*g [Gamma ] \\(*G # [gammad] /digamma [delta ] \\(*d [Delta ] \\(*D [epsi ] \\(*e # [epsiv ] /varepsilon [epsis ] \\(*e [zeta ] \\(*z [eta ] \\(*y [thetas] \\(*h [Theta ] \\(*H # [thetav] /vartheta - curly or open theta [iota ] \\(*i [kappa ] \\(*k # [kappav] /varkappa [lambda] \\(*l [Lambda] \\(*L [mu ] \\(*m [nu ] \\(*n [xi ] \\(*c [Xi ] \\(*C [pi ] \\(*p # [piv ] /varpi [Pi ] \\(*P [rho ] \\(*r # [rhov ] /varrho [sigma ] \\(*s [Sigma ] \\(*S # [sigmav] /varsigma [tau ] \\(*t [upsi ] \\(*u [Upsi ] \\(*U [phis ] \\(*f [Phi ] \\(*F # [phiv ] /varphi - curly or open phi [chi ] \\(*x [psi ] \\(*q [Psi ] \\(*X [omega ] \\(*w [Omega ] \\(*W # # General Technical ________________________________ # # [aleph ] /aleph =aleph, Hebrew # [and ] /wedge /land B: =logical and # [ang90 ] =right (90 degree) angle # [angsph] /sphericalangle =angle-spherical [ap ] \\(ap # [becaus] /because R: =because # [bottom] /bot B: =perpendicular # [cap ] /cap B: =intersection # [cong ] /cong R: =congruent with # [conint] /oint L: =contour integral operator # [cup ] /cup B: =union or logical sum [equiv ] \\(== # [exist ] /exists =at least one exists # [forall] /forall =for all # [fnof ] =function of (italic small f) [ge ] \\(>= # [iff ] /iff =if and only if [infin ] \\(if # [int ] /int L: =integral operator [isin ] \\(sb # [lang ] /langle O: =left angle bracket # [lArr ] /Leftarrow A: =is implied by [le ] \\(<= [minus ] \\(mi # [mnplus] /mp B: =minus-or-plus sign # [nabla ] /nabla =del, Hamilton operator [ne ] \\(!= # [ni ] /ni /owns R: =contains # [or ] /vee /lor B: =logical or # [par ] /parallel R: =parallel # [part ] /partial =partial differential # [permil] =per thousand # [perp ] /perp R: =perpendicular # [prime ] /prime =prime or minute # [Prime ] =double prime or second [prop ] \\(pt # [radic ] /surd =radical # [rang ] /rangle C: =right angle bracket # [rArr ] /Rightarrow A: =implies # [sim ] /sim R: =similar # [sime ] /simeq R: =similar, equals [square] \\(sq [sub ] \\(sb [sube ] \\(ib [sup ] \\(sp [supe ] \\(ip # [there4] /therefore R: =therefore # [Verbar] /Vert =dbl vertical bar # [angst ] Angstrom =capital A, ring # [bernou] Bernoulli function (script capital B) # [compfn] B: composite function (small circle) # [Dot ] =dieresis or umlaut mark # [DotDot] four dots above # [hamilt] Hamiltonian (script capital H) # [lagran] Lagrangian (script capital L) # [lowast] low asterisk # [notin ] N: negated set membership # [order ] order of (script small o) # [phmmat] physics M-matrix (script capital M) # [tdot ] three dots above # [tprime] triple prime # [wedgeq] R: corresponds to (wedge, equals) # # Diacritical Marks ________________________________ # [acute ] \\&' [breve ] \\(be [caron ] \\(hc [cedil ] \\(cd # [circ ] =circumflex accent # [dblac ] =double acute accent # [die ] =dieresis [dot ] \\(dt [grave ] ` [macr ] \\(ma [ogon ] \\(og [ring ] \\(ri [tilde ] ~ [uml ] \\(.. # docbook-to-man-2.0.0.orig/cmd/0040755000176100001440000000000007031671612015333 5ustar debacleusersdocbook-to-man-2.0.0.orig/cmd/Imakefile0100644000176100001440000000015406737404356017154 0ustar debacleusersROOT = /usr/local BINDIR = $(ROOT)/bin all:: InstallNamedProg(docbook-to-man.sh,docbook-to-man,$(BINDIR)) docbook-to-man-2.0.0.orig/cmd/Makefile0100644000176100001440000000361206737404357017006 0ustar debacleusers############################################################################# # # Makefile for docbook-to-man.sh # ############################################################################# # # Copyright (c) 1996 X Consortium # Copyright (c) 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 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # 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. # ############################################################################# # # Written 5/29/96 by Fred Dalrymple # ############################################################################# ROOT = /usr/local BIN = $(ROOT)/bin all: docbook-to-man install: all cp docbook-to-man $(BIN) clean: clobber: clean rm -f docbook-to-man docbook-to-man-2.0.0.orig/cmd/docbook-to-man.sh0100644000176100001440000001053706737404357020517 0ustar debacleusers#!/bin/sh ############################################################################# # # docbook-to-man.sh # ############################################################################# # # Copyright (c) 1996 X Consortium # Copyright (c) 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 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # 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. # ############################################################################# # # Written 5/29/96 by Fred Dalrymple # ############################################################################# # ***** change the following paths if your installation of nsgmls and / or # ***** DocBook isn't into the default places. ROOT=/usr/local SGMLS=$ROOT/lib/sgml DOCBOOK=$SGMLS/Davenport/dtd # ***** modify the following line (to "=false") if you're not using the # ***** Elan Documentor's Workbench doElanPSInclude=true # Everything below this line should be pretty standard and not require # modification. #ulimit -c unlimited PARSER=nsgmls INSTANT=instant INSTANT_OPT=-d CATALOG=$DOCBOOK/docbook.cat DECL=$DOCBOOK/docbook.dcl #PROLOG=$DOCBOOK/docbook.prolog error=false if [ $# -eq 1 ] then INSTANCE=$1 else error=true fi if `$error` then echo "usage: docbook-to-man docbook-instance" exit 1 fi if `$doElanPSInclude` then cat > /tmp/dtm.$$.psinc <<\! ...\" $Header: /aolnet/dev/src/CVS/sgml/docbook-to-man/cmd/docbook-to-man.sh,v 1.1.1.1 1998/11/13 21:31:59 db3l Exp $ ...\" ...\" transcript compatibility for postscript use. ...\" ...\" synopsis: .P! ...\" .de P! \\&. .fl \" force out current output buffer \\!%PB \\!/showpage{}def ...\" the following is from Ken Flowers -- it prevents dictionary overflows \\!/tempdict 200 dict def tempdict begin .fl \" prolog .sy cat \\$1\" bring in postscript file ...\" the following line matches the tempdict above \\!end % tempdict % \\!PE \\!. .sp \\$2u \" move below the image .. ! else cat > /tmp/dtm.$$.psinc <<\! ...\" $Header: /aolnet/dev/src/CVS/sgml/docbook-to-man/cmd/docbook-to-man.sh,v 1.1.1.1 1998/11/13 21:31:59 db3l Exp $ ...\" ...\" transcript compatibility for postscript use. ...\" ...\" synopsis: .P! ...\" .de P! .fl \!!1 setgray .fl \\&.\" .fl \!!0 setgray .fl \" force out current output buffer \!!save /psv exch def currentpoint translate 0 0 moveto \!!/showpage{}def .fl \" prolog .sy sed -e 's/^/!/' \\$1\" bring in postscript file \!!psv restore . ! fi cat >> /tmp/dtm.$$.psinc <<\! .de pF .ie \\*(f1 .ds f1 \\n(.f .el .ie \\*(f2 .ds f2 \\n(.f .el .ie \\*(f3 .ds f3 \\n(.f .el .ie \\*(f4 .ds f4 \\n(.f .el .tm ? font overflow .ft \\$1 .. .de fP .ie !\\*(f4 \{\ . ft \\*(f4 . ds f4\" ' br \} .el .ie !\\*(f3 \{\ . ft \\*(f3 . ds f3\" ' br \} .el .ie !\\*(f2 \{\ . ft \\*(f2 . ds f2\" ' br \} .el .ie !\\*(f1 \{\ . ft \\*(f1 . ds f1\" ' br \} .el .tm ? font underflow .. .ds f1\" .ds f2\" .ds f3\" .ds f4\" ! #if [ ! -f $PROLOG ] #then cat > $PROLOG < #]> #! #fi (cat /tmp/dtm.$$.psinc; $PARSER -gl -m$CATALOG $DECL $INSTANCE | $INSTANT $INSTANT_OPT -croff.cmap -sroff.sdata -tdocbook-to-man.ts) rm -f /tmp/dtm.$$.psinc