.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "btparse::doc::bt_macros 3" .TH btparse::doc::bt_macros 3 "2023-01-30" "btparse, version 0.89" "btparse" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" bt_macros \- accessing and manipulating the btparse macro table .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 6 \& void bt_add_macro_value (AST * assignment, \& btshort options); \& void bt_add_macro_text (char * macro, \& char * text, \& char * filename, \& int line); \& \& void bt_delete_macro (char * macro); \& void bt_delete_all_macros (void); \& \& int bt_macro_length (char *macro); \& char * bt_macro_text (char * macro, \& char * filename, \& int line); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fBbtparse\fR maintains a single table of all macros (abbreviations) encountered while parsing BibTeX entries. It updates this table whenever it encounters a \*(L"macro definition\*(R" (\f(CW@string\fR) entry, and refers to it whenever a macro is used in an entry and needs to be expanded. (Macros are not necessarily expanded on input, although this is the default. See bt_postprocess.) Macro definitions are only cleared when \fBbtparse\fR's global cleanup function, \f(CW\*(C`bt_cleanup()\*(C'\fR, is called. Thus, unless you explicitly call \f(CW\*(C`bt_delete_macro()\*(C'\fR or \&\f(CW\*(C`bt_delete_all_macros()\*(C'\fR, macro definitions persist for as long as you use the library\-\-\-usually, the lifetime of your process. .SH "FUNCTIONS" .IX Header "FUNCTIONS" You can use the following functions to add macros, delete them, and query their values\-\-\-thus interfering with \fBbtparse\fR's normal operation on the fly. .IP "bt_add_macro_text ()" 4 .IX Item "bt_add_macro_text ()" .Vb 4 \& void bt_add_macro_text (char * macro, \& char * text, \& char * filename, \& int line); .Ve .Sp Defines a new macro, or redefines an old one. \f(CW\*(C`macro\*(C'\fR is the name of the macro, and \f(CW\*(C`text\*(C'\fR is the text it should expand to. \f(CW\*(C`filename\*(C'\fR and \&\f(CW\*(C`line\*(C'\fR are just used to generate any warnings about the macro definition; if they don't apply, specify \f(CW\*(C`NULL\*(C'\fR for \f(CW\*(C`filename\*(C'\fR and \&\f(CW0\fR for \f(CW\*(C`line\*(C'\fR. The only such warning occurs when you redefine an old macro: its value is overridden, and \f(CW\*(C`bt_add_macro_text()\*(C'\fR issues a warning saying so. .Sp For instance, when parsing this macro definition entry: .Sp .Vb 1 \& @string{fubar = "Fouled Up Beyond All Recognition"} .Ve .Sp the library (in particular, the post-processing code called after an entry is successfully parsed) will ultimately do this: .Sp .Vb 2 \& bt_add_macro_text ("fubar", "Fouled Up Beyond All Recognition", \& filename, line); .Ve .Sp This in turn will cause the macro \f(CW\*(C`fubar\*(C'\fR to be expanded appropriately whenever the post-processing code sees it in any future entries. .IP "bt_add_macro_value ()" 4 .IX Item "bt_add_macro_value ()" .Vb 2 \& void bt_add_macro_value (AST * assignment, \& btshort options); .Ve .Sp This function is mainly for internal use by the library, but it's available to you if you ever find yourself with a little bit of \s-1AST\s0 representing a macro definition, and you want to set the macro yourself (rather than letting the library's post-processing code take care of it for you). \f(CW\*(C`assignment\*(C'\fR must be an \s-1AST\s0 node as returned by \&\f(CW\*(C`bt_next_field()\*(C'\fR. Unlike most other \fBbtparse\fR functions that take an \&\f(CW\*(C`options\*(C'\fR argument, \f(CW\*(C`options\*(C'\fR here tells how the value in \&\f(CW\*(C`assignment\*(C'\fR was post-processed. This is needed because macro values have to be processed in a special way to be valid in future expansions; if this one wasn't processed like that, \f(CW\*(C`bt_add_macro_value()\*(C'\fR will do it for you. If you don't know how the value was post-processed, just supply \f(CW0\fR for \f(CW\*(C`options\*(C'\fR\-\-\-that's guaranteed to describe something different from \*(L"the right way\*(R" for macros, so the post-processing will be done correctly. .Sp The processing done to macro values is mainly to ensure that we can get away with storing just a string in the macro table: macros invoked by the macro are themselves expanded, and all sub-strings are concatenated. For instance, if \fBbtparse\fR parses these entries: .Sp .Vb 2 \& @string{and = " and "} \& @string{jim_n_bob = "James Smith" # and # "Bob Jones"} .Ve .Sp then the value stored for \f(CW\*(C`jim_n_bob\*(C'\fR should obviously be the string \&\f(CW"James Smith and Bob Jones"\fR. To ensure this, \fBbtparse\fR has to process the value of \f(CW\*(C`and\*(C'\fR differently from most BibTeX strings: in particular, whitespace is \fInot\fR collapsed before the string is stored. That way, the correct value, \f(CW" and "\fR, is interpolated into the value of \f(CW\*(C`jim_n_bob\*(C'\fR. Thus, all macro values have sub-macros expanded and strings concatenated before they are stored, but whitespace is not collapsed until the macro is used in a regular entry. .Sp This function calls \f(CW\*(C`bt_add_macro_text()\*(C'\fR, so the same proviso about redefining old macros applies\-\-\-a warning will be issued, and the old value lost. .IP "bt_delete_macro ()" 4 .IX Item "bt_delete_macro ()" .Vb 1 \& void bt_delete_macro (char * macro); .Ve .Sp Deletes a macro from the macro table. If \f(CW\*(C`macro\*(C'\fR isn't defined, takes no action. .IP "bt_delete_all_macros ()" 4 .IX Item "bt_delete_all_macros ()" .Vb 1 \& void bt_delete_all_macros (void); .Ve .Sp Deletes all macros from the macro table. .IP "bt_macro_length ()" 4 .IX Item "bt_macro_length ()" .Vb 1 \& int bt_macro_length (char *macro); .Ve .Sp Returns the length of a macro's expansion text. If the macro is undefined, returns 0; no warning is issued. .IP "bt_macro_text ()" 4 .IX Item "bt_macro_text ()" .Vb 3 \& char * bt_macro_text (char * macro, \& char * filename, \& int line); .Ve .Sp Returns the expansion text of a macro. If the macro is not defined, issues a warning and returns \f(CW\*(C`NULL\*(C'\fR. \f(CW\*(C`filename\*(C'\fR and \f(CW\*(C`line\*(C'\fR are used for generating this warning; if they don't apply (i.e. you're not expanding the macro as a result of finding it in some file), supply \&\f(CW\*(C`NULL\*(C'\fR for \f(CW\*(C`filename\*(C'\fR and \f(CW0\fR for \f(CW\*(C`line\*(C'\fR. .SH "SEE ALSO" .IX Header "SEE ALSO" btparse .SH "AUTHOR" .IX Header "AUTHOR" Greg Ward