Fixed the sum range variable subscipts.
[binaryfield.git] / IEEEtran.bst
1 %%
2 %% IEEEtran.bst
3 %% BibTeX Bibliography Style file for IEEE Journals and Conferences (unsorted)
4 %% Version 1.13 (2008/09/30)
5 %% 
6 %% Copyright (c) 2003-2008 Michael Shell
7 %% 
8 %% Original starting code base and algorithms obtained from the output of
9 %% Patrick W. Daly's makebst package as well as from prior versions of
10 %% IEEE BibTeX styles:
11 %% 
12 %% 1. Howard Trickey and Oren Patashnik's ieeetr.bst  (1985/1988)
13 %% 2. Silvano Balemi and Richard H. Roy's IEEEbib.bst (1993)
14 %% 
15 %% Support sites:
16 %% http://www.michaelshell.org/tex/ieeetran/
17 %% http://www.ctan.org/tex-archive/macros/latex/contrib/IEEEtran/
18 %% and/or
19 %% http://www.ieee.org/
20 %% 
21 %% For use with BibTeX version 0.99a or later
22 %%
23 %% This is a numerical citation style.
24 %% 
25 %%*************************************************************************
26 %% Legal Notice:
27 %% This code is offered as-is without any warranty either expressed or
28 %% implied; without even the implied warranty of MERCHANTABILITY or
29 %% FITNESS FOR A PARTICULAR PURPOSE! 
30 %% User assumes all risk.
31 %% In no event shall IEEE or any contributor to this code be liable for
32 %% any damages or losses, including, but not limited to, incidental,
33 %% consequential, or any other damages, resulting from the use or misuse
34 %% of any information contained here.
35 %%
36 %% All comments are the opinions of their respective authors and are not
37 %% necessarily endorsed by the IEEE.
38 %%
39 %% This work is distributed under the LaTeX Project Public License (LPPL)
40 %% ( http://www.latex-project.org/ ) version 1.3, and may be freely used,
41 %% distributed and modified. A copy of the LPPL, version 1.3, is included
42 %% in the base LaTeX documentation of all distributions of LaTeX released
43 %% 2003/12/01 or later.
44 %% Retain all contribution notices and credits.
45 %% ** Modified files should be clearly indicated as such, including  **
46 %% ** renaming them and changing author support contact information. **
47 %%
48 %% File list of work: IEEEabrv.bib, IEEEfull.bib, IEEEexample.bib,
49 %%                    IEEEtran.bst, IEEEtranS.bst, IEEEtranSA.bst,
50 %%                    IEEEtranN.bst, IEEEtranSN.bst, IEEEtran_bst_HOWTO.pdf
51 %%*************************************************************************
52 %
53 %
54 % Changelog:
55 %
56 % 1.00 (2002/08/13) Initial release
57 %
58 % 1.10 (2002/09/27)
59 %  1. Corrected minor bug for improperly formed warning message when a
60 %     book was not given a title. Thanks to Ming Kin Lai for reporting this.
61 %  2. Added support for CTLname_format_string and CTLname_latex_cmd fields
62 %     in the BST control entry type.
63 %
64 % 1.11 (2003/04/02)
65 %  1. Fixed bug with URLs containing underscores when using url.sty. Thanks
66 %     to Ming Kin Lai for reporting this.
67 %
68 % 1.12 (2007/01/11)
69 %  1. Fixed bug with unwanted comma before "et al." when an entry contained
70 %     more than two author names. Thanks to Pallav Gupta for reporting this.
71 %  2. Fixed bug with anomalous closing quote in tech reports that have a
72 %     type, but without a number or address. Thanks to Mehrdad Mirreza for
73 %     reporting this.
74 %  3. Use braces in \providecommand in begin.bib to better support
75 %     latex2html. TeX style length assignments OK with recent versions
76 %     of latex2html - 1.71 (2002/2/1) or later is strongly recommended.
77 %     Use of the language field still causes trouble with latex2html.
78 %     Thanks to Federico Beffa for reporting this.
79 %  4. Added IEEEtran.bst ID and version comment string to .bbl output.
80 %  5. Provide a \BIBdecl hook that allows the user to execute commands
81 %     just prior to the first entry.
82 %  6. Use default urlstyle (is using url.sty) of "same" rather than rm to
83 %     better work with a wider variety of bibliography styles.
84 %  7. Changed month abbreviations from Sept., July and June to Sep., Jul.,
85 %     and Jun., respectively, as IEEE now does. Thanks to Moritz Borgmann
86 %     for reporting this.
87 %  8. Control entry types should not be considered when calculating longest
88 %     label width.
89 %  9. Added alias www for electronic/online.
90 % 10. Added CTLname_url_prefix control entry type.
91 %
92 % 1.13 (2008/09/30)
93 %  1. Fixed bug with edition number to ordinal conversion. Thanks to
94 %     Michael Roland for reporting this and correcting the algorithm.
95
96
97 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
98 %% DEFAULTS FOR THE CONTROLS OF THE BST STYLE %%
99 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
100
101 % These are the defaults for the user adjustable controls. The values used
102 % here can be overridden by the user via IEEEtranBSTCTL entry type.
103
104 % NOTE: The recommended LaTeX command to invoke a control entry type is:
105
106 %\makeatletter
107 %\def\bstctlcite{\@ifnextchar[{\@bstctlcite}{\@bstctlcite[@auxout]}}
108 %\def\@bstctlcite[#1]#2{\@bsphack
109 %  \@for\@citeb:=#2\do{%
110 %    \edef\@citeb{\expandafter\@firstofone\@citeb}%
111 %    \if@filesw\immediate\write\csname #1\endcsname{\string\citation{\@citeb}}\fi}%
112 %  \@esphack}
113 %\makeatother
114 %
115 % It is called at the start of the document, before the first \cite, like:
116 % \bstctlcite{IEEEexample:BSTcontrol}
117 %
118 % IEEEtran.cls V1.6 and later does provide this command.
119
120
121
122 % #0 turns off the display of the number for articles.
123 % #1 enables
124 FUNCTION {default.is.use.number.for.article} { #1 }
125
126
127 % #0 turns off the display of the paper and type fields in @inproceedings.
128 % #1 enables
129 FUNCTION {default.is.use.paper} { #1 }
130
131
132 % #0 turns off the forced use of "et al."
133 % #1 enables
134 FUNCTION {default.is.forced.et.al} { #0 }
135
136 % The maximum number of names that can be present beyond which an "et al."
137 % usage is forced. Be sure that num.names.shown.with.forced.et.al (below)
138 % is not greater than this value!
139 % Note: There are many instances of references in IEEE journals which have
140 % a very large number of authors as well as instances in which "et al." is
141 % used profusely.
142 FUNCTION {default.max.num.names.before.forced.et.al} { #10 }
143
144 % The number of names that will be shown with a forced "et al.".
145 % Must be less than or equal to max.num.names.before.forced.et.al
146 FUNCTION {default.num.names.shown.with.forced.et.al} { #1 }
147
148
149 % #0 turns off the alternate interword spacing for entries with URLs.
150 % #1 enables
151 FUNCTION {default.is.use.alt.interword.spacing} { #1 }
152
153 % If alternate interword spacing for entries with URLs is enabled, this is
154 % the interword spacing stretch factor that will be used. For example, the
155 % default "4" here means that the interword spacing in entries with URLs can
156 % stretch to four times normal. Does not have to be an integer. Note that
157 % the value specified here can be overridden by the user in their LaTeX
158 % code via a command such as: 
159 % "\providecommand\BIBentryALTinterwordstretchfactor{1.5}" in addition to
160 % that via the IEEEtranBSTCTL entry type.
161 FUNCTION {default.ALTinterwordstretchfactor} { "4" }
162
163
164 % #0 turns off the "dashification" of repeated (i.e., identical to those
165 % of the previous entry) names. IEEE normally does this.
166 % #1 enables
167 FUNCTION {default.is.dash.repeated.names} { #1 }
168
169
170 % The default name format control string.
171 FUNCTION {default.name.format.string}{ "{f.~}{vv~}{ll}{, jj}" }
172
173
174 % The default LaTeX font command for the names.
175 FUNCTION {default.name.latex.cmd}{ "" }
176
177
178 % The default URL prefix.
179 FUNCTION {default.name.url.prefix}{ "[Online]. Available:" }
180
181
182 % Other controls that cannot be accessed via IEEEtranBSTCTL entry type.
183
184 % #0 turns off the terminal startup banner/completed message so as to
185 % operate more quietly.
186 % #1 enables
187 FUNCTION {is.print.banners.to.terminal} { #1 }
188
189
190
191
192 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
193 %% FILE VERSION AND BANNER %%
194 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
195
196 FUNCTION{bst.file.version} { "1.13" }
197 FUNCTION{bst.file.date} { "2008/09/30" }
198 FUNCTION{bst.file.website} { "http://www.michaelshell.org/tex/ieeetran/bibtex/" }
199
200 FUNCTION {banner.message}
201 { is.print.banners.to.terminal
202      { "-- IEEEtran.bst version" " " * bst.file.version *
203        " (" * bst.file.date * ") " * "by Michael Shell." *
204        top$
205        "-- " bst.file.website *
206        top$
207        "-- See the " quote$ * "IEEEtran_bst_HOWTO.pdf" * quote$ * " manual for usage information." *
208        top$
209      }
210      { skip$ }
211    if$
212 }
213
214 FUNCTION {completed.message}
215 { is.print.banners.to.terminal
216      { ""
217        top$
218        "Done."
219        top$
220      }
221      { skip$ }
222    if$
223 }
224
225
226
227
228 %%%%%%%%%%%%%%%%%%%%%%
229 %% STRING CONSTANTS %%
230 %%%%%%%%%%%%%%%%%%%%%%
231
232 FUNCTION {bbl.and}{ "and" }
233 FUNCTION {bbl.etal}{ "et~al." }
234 FUNCTION {bbl.editors}{ "eds." }
235 FUNCTION {bbl.editor}{ "ed." }
236 FUNCTION {bbl.edition}{ "ed." }
237 FUNCTION {bbl.volume}{ "vol." }
238 FUNCTION {bbl.of}{ "of" }
239 FUNCTION {bbl.number}{ "no." }
240 FUNCTION {bbl.in}{ "in" }
241 FUNCTION {bbl.pages}{ "pp." }
242 FUNCTION {bbl.page}{ "p." }
243 FUNCTION {bbl.chapter}{ "ch." }
244 FUNCTION {bbl.paper}{ "paper" }
245 FUNCTION {bbl.part}{ "pt." }
246 FUNCTION {bbl.patent}{ "Patent" }
247 FUNCTION {bbl.patentUS}{ "U.S." }
248 FUNCTION {bbl.revision}{ "Rev." }
249 FUNCTION {bbl.series}{ "ser." }
250 FUNCTION {bbl.standard}{ "Std." }
251 FUNCTION {bbl.techrep}{ "Tech. Rep." }
252 FUNCTION {bbl.mthesis}{ "Master's thesis" }
253 FUNCTION {bbl.phdthesis}{ "Ph.D. dissertation" }
254 FUNCTION {bbl.st}{ "st" }
255 FUNCTION {bbl.nd}{ "nd" }
256 FUNCTION {bbl.rd}{ "rd" }
257 FUNCTION {bbl.th}{ "th" }
258
259
260 % This is the LaTeX spacer that is used when a larger than normal space
261 % is called for (such as just before the address:publisher).
262 FUNCTION {large.space} { "\hskip 1em plus 0.5em minus 0.4em\relax " }
263
264 % The LaTeX code for dashes that are used to represent repeated names.
265 % Note: Some older IEEE journals used something like
266 % "\rule{0.275in}{0.5pt}\," which is fairly thick and runs right along
267 % the baseline. However, IEEE now uses a thinner, above baseline,
268 % six dash long sequence.
269 FUNCTION {repeated.name.dashes} { "------" }
270
271
272
273 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
274 %% PREDEFINED STRING MACROS %%
275 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
276
277 MACRO {jan} {"Jan."}
278 MACRO {feb} {"Feb."}
279 MACRO {mar} {"Mar."}
280 MACRO {apr} {"Apr."}
281 MACRO {may} {"May"}
282 MACRO {jun} {"Jun."}
283 MACRO {jul} {"Jul."}
284 MACRO {aug} {"Aug."}
285 MACRO {sep} {"Sep."}
286 MACRO {oct} {"Oct."}
287 MACRO {nov} {"Nov."}
288 MACRO {dec} {"Dec."}
289
290
291
292 %%%%%%%%%%%%%%%%%%
293 %% ENTRY FIELDS %%
294 %%%%%%%%%%%%%%%%%%
295
296 ENTRY
297   { address
298     assignee
299     author
300     booktitle
301     chapter
302     day
303     dayfiled
304     edition
305     editor
306     howpublished
307     institution
308     intype
309     journal
310     key
311     language
312     month
313     monthfiled
314     nationality
315     note
316     number
317     organization
318     pages
319     paper
320     publisher
321     school
322     series
323     revision
324     title
325     type
326     url
327     volume
328     year
329     yearfiled
330     CTLuse_article_number
331     CTLuse_paper
332     CTLuse_forced_etal
333     CTLmax_names_forced_etal
334     CTLnames_show_etal
335     CTLuse_alt_spacing
336     CTLalt_stretch_factor
337     CTLdash_repeated_names
338     CTLname_format_string
339     CTLname_latex_cmd
340     CTLname_url_prefix
341   }
342   {}
343   { label }
344
345
346
347
348 %%%%%%%%%%%%%%%%%%%%%%%
349 %% INTEGER VARIABLES %%
350 %%%%%%%%%%%%%%%%%%%%%%%
351
352 INTEGERS { prev.status.punct this.status.punct punct.std
353            punct.no punct.comma punct.period 
354            prev.status.space this.status.space space.std
355            space.no space.normal space.large
356            prev.status.quote this.status.quote quote.std
357            quote.no quote.close
358            prev.status.nline this.status.nline nline.std
359            nline.no nline.newblock 
360            status.cap cap.std
361            cap.no cap.yes}
362
363 INTEGERS { longest.label.width multiresult nameptr namesleft number.label numnames }
364
365 INTEGERS { is.use.number.for.article
366            is.use.paper
367            is.forced.et.al
368            max.num.names.before.forced.et.al
369            num.names.shown.with.forced.et.al
370            is.use.alt.interword.spacing
371            is.dash.repeated.names}
372
373
374 %%%%%%%%%%%%%%%%%%%%%%
375 %% STRING VARIABLES %%
376 %%%%%%%%%%%%%%%%%%%%%%
377
378 STRINGS { bibinfo
379           longest.label
380           oldname
381           s
382           t
383           ALTinterwordstretchfactor
384           name.format.string
385           name.latex.cmd
386           name.url.prefix}
387
388
389
390
391 %%%%%%%%%%%%%%%%%%%%%%%%%
392 %% LOW LEVEL FUNCTIONS %%
393 %%%%%%%%%%%%%%%%%%%%%%%%%
394
395 FUNCTION {initialize.controls}
396 { default.is.use.number.for.article 'is.use.number.for.article :=
397   default.is.use.paper 'is.use.paper :=
398   default.is.forced.et.al 'is.forced.et.al :=
399   default.max.num.names.before.forced.et.al 'max.num.names.before.forced.et.al :=
400   default.num.names.shown.with.forced.et.al 'num.names.shown.with.forced.et.al :=
401   default.is.use.alt.interword.spacing 'is.use.alt.interword.spacing :=
402   default.is.dash.repeated.names 'is.dash.repeated.names :=
403   default.ALTinterwordstretchfactor 'ALTinterwordstretchfactor :=
404   default.name.format.string 'name.format.string :=
405   default.name.latex.cmd 'name.latex.cmd :=
406   default.name.url.prefix 'name.url.prefix :=
407 }
408
409
410 % This IEEEtran.bst features a very powerful and flexible mechanism for
411 % controlling the capitalization, punctuation, spacing, quotation, and
412 % newlines of the formatted entry fields. (Note: IEEEtran.bst does not need
413 % or use the newline/newblock feature, but it has been implemented for
414 % possible future use.) The output states of IEEEtran.bst consist of
415 % multiple independent attributes and, as such, can be thought of as being
416 % vectors, rather than the simple scalar values ("before.all", 
417 % "mid.sentence", etc.) used in most other .bst files.
418
419 % The more flexible and complex design used here was motivated in part by
420 % IEEE's rather unusual bibliography style. For example, IEEE ends the
421 % previous field item with a period and large space prior to the publisher
422 % address; the @electronic entry types use periods as inter-item punctuation
423 % rather than the commas used by the other entry types; and URLs are never
424 % followed by periods even though they are the last item in the entry.
425 % Although it is possible to accommodate these features with the conventional
426 % output state system, the seemingly endless exceptions make for convoluted,
427 % unreliable and difficult to maintain code.
428 %
429 % IEEEtran.bst's output state system can be easily understood via a simple
430 % illustration of two most recently formatted entry fields (on the stack):
431 %
432 %               CURRENT_ITEM
433 %               "PREVIOUS_ITEM
434 %
435 % which, in this example, is to eventually appear in the bibliography as:
436
437 %               "PREVIOUS_ITEM," CURRENT_ITEM
438 %
439 % It is the job of the output routine to take the previous item off of the
440 % stack (while leaving the current item at the top of the stack), apply its
441 % trailing punctuation (including closing quote marks) and spacing, and then
442 % to write the result to BibTeX's output buffer:
443
444 %               "PREVIOUS_ITEM," 
445
446 % Punctuation (and spacing) between items is often determined by both of the
447 % items rather than just the first one. The presence of quotation marks
448 % further complicates the situation because, in standard English, trailing
449 % punctuation marks are supposed to be contained within the quotes.
450
451 % IEEEtran.bst maintains two output state (aka "status") vectors which
452 % correspond to the previous and current (aka "this") items. Each vector
453 % consists of several independent attributes which track punctuation,
454 % spacing, quotation, and newlines. Capitalization status is handled by a
455 % separate scalar because the format routines, not the output routine,
456 % handle capitalization and, therefore, there is no need to maintain the
457 % capitalization attribute for both the "previous" and "this" items.
458
459 % When a format routine adds a new item, it copies the current output status
460 % vector to the previous output status vector and (usually) resets the
461 % current (this) output status vector to a "standard status" vector. Using a
462 % "standard status" vector in this way allows us to redefine what we mean by
463 % "standard status" at the start of each entry handler and reuse the same
464 % format routines under the various inter-item separation schemes. For
465 % example, the standard status vector for the @book entry type may use
466 % commas for item separators, while the @electronic type may use periods,
467 % yet both entry handlers exploit many of the exact same format routines.
468
469 % Because format routines have write access to the output status vector of
470 % the previous item, they can override the punctuation choices of the
471 % previous format routine! Therefore, it becomes trivial to implement rules
472 % such as "Always use a period and a large space before the publisher." By
473 % pushing the generation of the closing quote mark to the output routine, we
474 % avoid all the problems caused by having to close a quote before having all
475 % the information required to determine what the punctuation should be.
476 %
477 % The IEEEtran.bst output state system can easily be expanded if needed.
478 % For instance, it is easy to add a "space.tie" attribute value if the
479 % bibliography rules mandate that two items have to be joined with an
480 % unbreakable space. 
481
482 FUNCTION {initialize.status.constants}
483 { #0 'punct.no :=
484   #1 'punct.comma :=
485   #2 'punct.period :=
486   #0 'space.no := 
487   #1 'space.normal :=
488   #2 'space.large :=
489   #0 'quote.no :=
490   #1 'quote.close :=
491   #0 'cap.no :=
492   #1 'cap.yes :=
493   #0 'nline.no :=
494   #1 'nline.newblock :=
495 }
496
497 FUNCTION {std.status.using.comma}
498 { punct.comma 'punct.std :=
499   space.normal 'space.std :=
500   quote.no 'quote.std :=
501   nline.no 'nline.std :=
502   cap.no 'cap.std :=
503 }
504
505 FUNCTION {std.status.using.period}
506 { punct.period 'punct.std :=
507   space.normal 'space.std :=
508   quote.no 'quote.std :=
509   nline.no 'nline.std :=
510   cap.yes 'cap.std :=
511 }
512
513 FUNCTION {initialize.prev.this.status}
514 { punct.no 'prev.status.punct :=
515   space.no 'prev.status.space :=
516   quote.no 'prev.status.quote :=
517   nline.no 'prev.status.nline :=
518   punct.no 'this.status.punct :=
519   space.no 'this.status.space :=
520   quote.no 'this.status.quote :=
521   nline.no 'this.status.nline :=
522   cap.yes 'status.cap :=
523 }
524
525 FUNCTION {this.status.std}
526 { punct.std 'this.status.punct :=
527   space.std 'this.status.space :=
528   quote.std 'this.status.quote :=
529   nline.std 'this.status.nline :=
530 }
531
532 FUNCTION {cap.status.std}{ cap.std 'status.cap := }
533
534 FUNCTION {this.to.prev.status}
535 { this.status.punct 'prev.status.punct :=
536   this.status.space 'prev.status.space :=
537   this.status.quote 'prev.status.quote :=
538   this.status.nline 'prev.status.nline :=
539 }
540
541
542 FUNCTION {not}
543 {   { #0 }
544     { #1 }
545   if$
546 }
547
548 FUNCTION {and}
549 {   { skip$ }
550     { pop$ #0 }
551   if$
552 }
553
554 FUNCTION {or}
555 {   { pop$ #1 }
556     { skip$ }
557   if$
558 }
559
560
561 % convert the strings "yes" or "no" to #1 or #0 respectively
562 FUNCTION {yes.no.to.int}
563 { "l" change.case$ duplicate$
564     "yes" =
565     { pop$  #1 }
566     { duplicate$ "no" =
567         { pop$ #0 }
568         { "unknown boolean " quote$ * swap$ * quote$ *
569           " in " * cite$ * warning$
570           #0
571         }
572       if$
573     }
574   if$
575 }
576
577
578 % pushes true if the single char string on the stack is in the
579 % range of "0" to "9"
580 FUNCTION {is.num}
581 { chr.to.int$
582   duplicate$ "0" chr.to.int$ < not
583   swap$ "9" chr.to.int$ > not and
584 }
585
586 % multiplies the integer on the stack by a factor of 10
587 FUNCTION {bump.int.mag}
588 { #0 'multiresult :=
589     { duplicate$ #0 > }
590     { #1 -
591       multiresult #10 +
592       'multiresult :=
593     }
594   while$
595 pop$
596 multiresult
597 }
598
599 % converts a single character string on the stack to an integer
600 FUNCTION {char.to.integer}
601 { duplicate$ 
602   is.num
603     { chr.to.int$ "0" chr.to.int$ - }
604     {"noninteger character " quote$ * swap$ * quote$ *
605           " in integer field of " * cite$ * warning$
606     #0
607     }
608   if$
609 }
610
611 % converts a string on the stack to an integer
612 FUNCTION {string.to.integer}
613 { duplicate$ text.length$ 'namesleft :=
614   #1 'nameptr :=
615   #0 'numnames :=
616     { nameptr namesleft > not }
617     { duplicate$ nameptr #1 substring$
618       char.to.integer numnames bump.int.mag +
619       'numnames :=
620       nameptr #1 +
621       'nameptr :=
622     }
623   while$
624 pop$
625 numnames
626 }
627
628
629
630
631 % The output routines write out the *next* to the top (previous) item on the
632 % stack, adding punctuation and such as needed. Since IEEEtran.bst maintains
633 % the output status for the top two items on the stack, these output
634 % routines have to consider the previous output status (which corresponds to
635 % the item that is being output). Full independent control of punctuation,
636 % closing quote marks, spacing, and newblock is provided.
637
638 % "output.nonnull" does not check for the presence of a previous empty
639 % item.
640
641 % "output" does check for the presence of a previous empty item and will
642 % remove an empty item rather than outputing it.
643
644 % "output.warn" is like "output", but will issue a warning if it detects
645 % an empty item.
646
647 FUNCTION {output.nonnull}
648 { swap$
649   prev.status.punct punct.comma =
650      { "," * }
651      { skip$ }
652    if$
653   prev.status.punct punct.period =
654      { add.period$ }
655      { skip$ }
656    if$ 
657   prev.status.quote quote.close =
658      { "''" * }
659      { skip$ }
660    if$
661   prev.status.space space.normal =
662      { " " * }
663      { skip$ }
664    if$
665   prev.status.space space.large =
666      { large.space * }
667      { skip$ }
668    if$
669   write$
670   prev.status.nline nline.newblock =
671      { newline$ "\newblock " write$ }
672      { skip$ }
673    if$
674 }
675
676 FUNCTION {output}
677 { duplicate$ empty$
678     'pop$
679     'output.nonnull
680   if$
681 }
682
683 FUNCTION {output.warn}
684 { 't :=
685   duplicate$ empty$
686     { pop$ "empty " t * " in " * cite$ * warning$ }
687     'output.nonnull
688   if$
689 }
690
691 % "fin.entry" is the output routine that handles the last item of the entry
692 % (which will be on the top of the stack when "fin.entry" is called).
693
694 FUNCTION {fin.entry}
695 { this.status.punct punct.no =
696      { skip$ }
697      { add.period$ }
698    if$
699    this.status.quote quote.close =
700      { "''" * }
701      { skip$ }
702    if$
703 write$
704 newline$
705 }
706
707
708 FUNCTION {is.last.char.not.punct}
709 { duplicate$
710    "}" * add.period$
711    #-1 #1 substring$ "." =
712 }
713
714 FUNCTION {is.multiple.pages}
715 { 't :=
716   #0 'multiresult :=
717     { multiresult not
718       t empty$ not
719       and
720     }
721     { t #1 #1 substring$
722       duplicate$ "-" =
723       swap$ duplicate$ "," =
724       swap$ "+" =
725       or or
726         { #1 'multiresult := }
727         { t #2 global.max$ substring$ 't := }
728       if$
729     }
730   while$
731   multiresult
732 }
733
734 FUNCTION {capitalize}{ "u" change.case$ "t" change.case$ }
735
736 FUNCTION {emphasize}
737 { duplicate$ empty$
738     { pop$ "" }
739     { "\emph{" swap$ * "}" * }
740   if$
741 }
742
743 FUNCTION {do.name.latex.cmd}
744 { name.latex.cmd
745   empty$
746     { skip$ }
747     { name.latex.cmd "{" * swap$ * "}" * }
748   if$
749 }
750
751 % IEEEtran.bst uses its own \BIBforeignlanguage command which directly
752 % invokes the TeX hyphenation patterns without the need of the Babel
753 % package. Babel does a lot more than switch hyphenation patterns and
754 % its loading can cause unintended effects in many class files (such as
755 % IEEEtran.cls).
756 FUNCTION {select.language}
757 { duplicate$ empty$ 'pop$
758     { language empty$ 'skip$
759         { "\BIBforeignlanguage{" language * "}{" * swap$ * "}" * }
760       if$
761     }
762   if$
763 }
764
765 FUNCTION {tie.or.space.prefix}
766 { duplicate$ text.length$ #3 <
767     { "~" }
768     { " " }
769   if$
770   swap$
771 }
772
773 FUNCTION {get.bbl.editor}
774 { editor num.names$ #1 > 'bbl.editors 'bbl.editor if$ }
775
776 FUNCTION {space.word}{ " " swap$ * " " * }
777
778
779 % Field Conditioners, Converters, Checkers and External Interfaces
780
781 FUNCTION {empty.field.to.null.string}
782 { duplicate$ empty$
783     { pop$ "" }
784     { skip$ }
785   if$
786 }
787
788 FUNCTION {either.or.check}
789 { empty$
790     { pop$ }
791     { "can't use both " swap$ * " fields in " * cite$ * warning$ }
792   if$
793 }
794
795 FUNCTION {empty.entry.warn}
796 { author empty$ title empty$ howpublished empty$
797   month empty$ year empty$ note empty$ url empty$
798   and and and and and and
799     { "all relevant fields are empty in " cite$ * warning$ }
800     'skip$
801   if$
802 }
803
804
805 % The bibinfo system provides a way for the electronic parsing/acquisition
806 % of a bibliography's contents as is done by ReVTeX. For example, a field
807 % could be entered into the bibliography as:
808 % \bibinfo{volume}{2}
809 % Only the "2" would show up in the document, but the LaTeX \bibinfo command
810 % could do additional things with the information. IEEEtran.bst does provide
811 % a \bibinfo command via "\providecommand{\bibinfo}[2]{#2}". However, it is
812 % currently not used as the bogus bibinfo functions defined here output the
813 % entry values directly without the \bibinfo wrapper. The bibinfo functions
814 % themselves (and the calls to them) are retained for possible future use.
815
816 % bibinfo.check avoids acting on missing fields while bibinfo.warn will
817 % issue a warning message if a missing field is detected. Prior to calling
818 % the bibinfo functions, the user should push the field value and then its
819 % name string, in that order.
820
821 FUNCTION {bibinfo.check}
822 { swap$ duplicate$ missing$
823     { pop$ pop$ "" }
824     { duplicate$ empty$
825         { swap$ pop$ }
826         { swap$ pop$ }
827       if$
828     }
829   if$
830 }
831
832 FUNCTION {bibinfo.warn}
833 { swap$ duplicate$ missing$
834     { swap$ "missing " swap$ * " in " * cite$ * warning$ pop$ "" }
835     { duplicate$ empty$
836         { swap$ "empty " swap$ * " in " * cite$ * warning$ }
837         { swap$ pop$ }
838       if$
839     }
840   if$
841 }
842
843
844 % IEEE separates large numbers with more than 4 digits into groups of
845 % three. IEEE uses a small space to separate these number groups. 
846 % Typical applications include patent and page numbers.
847
848 % number of consecutive digits required to trigger the group separation.
849 FUNCTION {large.number.trigger}{ #5 }
850
851 % For numbers longer than the trigger, this is the blocksize of the groups.
852 % The blocksize must be less than the trigger threshold, and 2 * blocksize
853 % must be greater than the trigger threshold (can't do more than one
854 % separation on the initial trigger).
855 FUNCTION {large.number.blocksize}{ #3 }
856
857 % What is actually inserted between the number groups.
858 FUNCTION {large.number.separator}{ "\," }
859
860 % So as to save on integer variables by reusing existing ones, numnames
861 % holds the current number of consecutive digits read and nameptr holds
862 % the number that will trigger an inserted space.
863 FUNCTION {large.number.separate}
864 { 't :=
865   ""
866   #0 'numnames :=
867   large.number.trigger 'nameptr :=
868   { t empty$ not }
869   { t #-1 #1 substring$ is.num
870       { numnames #1 + 'numnames := }
871       { #0 'numnames := 
872         large.number.trigger 'nameptr :=
873       }
874     if$
875     t #-1 #1 substring$ swap$ *
876     t #-2 global.max$ substring$ 't :=
877     numnames nameptr =
878       { duplicate$ #1 nameptr large.number.blocksize - substring$ swap$
879         nameptr large.number.blocksize - #1 + global.max$ substring$
880         large.number.separator swap$ * *
881         nameptr large.number.blocksize - 'numnames :=
882         large.number.blocksize #1 + 'nameptr :=
883       }
884       { skip$ }
885     if$
886   }
887   while$
888 }
889
890 % Converts all single dashes "-" to double dashes "--".
891 FUNCTION {n.dashify}
892 { large.number.separate
893   't :=
894   ""
895     { t empty$ not }
896     { t #1 #1 substring$ "-" =
897         { t #1 #2 substring$ "--" = not
898             { "--" *
899               t #2 global.max$ substring$ 't :=
900             }
901             {   { t #1 #1 substring$ "-" = }
902                 { "-" *
903                   t #2 global.max$ substring$ 't :=
904                 }
905               while$
906             }
907           if$
908         }
909         { t #1 #1 substring$ *
910           t #2 global.max$ substring$ 't :=
911         }
912       if$
913     }
914   while$
915 }
916
917
918 % This function detects entries with names that are identical to that of
919 % the previous entry and replaces the repeated names with dashes (if the
920 % "is.dash.repeated.names" user control is nonzero).
921 FUNCTION {name.or.dash}
922 { 's :=
923    oldname empty$
924      { s 'oldname := s }
925      { s oldname =
926          { is.dash.repeated.names
927               { repeated.name.dashes }
928               { s 'oldname := s }
929             if$
930          }
931          { s 'oldname := s }
932        if$
933      }
934    if$
935 }
936
937 % Converts the number string on the top of the stack to
938 % "numerical ordinal form" (e.g., "7" to "7th"). There is
939 % no artificial limit to the upper bound of the numbers as the
940 % two least significant digits determine the ordinal form.
941 FUNCTION {num.to.ordinal}
942 { duplicate$ #-2 #1 substring$ "1" =
943       { bbl.th * }
944       { duplicate$ #-1 #1 substring$ "1" =
945           { bbl.st * }
946           { duplicate$ #-1 #1 substring$ "2" =
947               { bbl.nd * }
948               { duplicate$ #-1 #1 substring$ "3" =
949                   { bbl.rd * }
950                   { bbl.th * }
951                 if$
952               }
953             if$
954           }
955         if$
956       }
957     if$
958 }
959
960 % If the string on the top of the stack begins with a number,
961 % (e.g., 11th) then replace the string with the leading number
962 % it contains. Otherwise retain the string as-is. s holds the
963 % extracted number, t holds the part of the string that remains
964 % to be scanned.
965 FUNCTION {extract.num}
966 { duplicate$ 't :=
967   "" 's :=
968   { t empty$ not }
969   { t #1 #1 substring$
970     t #2 global.max$ substring$ 't :=
971     duplicate$ is.num
972       { s swap$ * 's := }
973       { pop$ "" 't := }
974     if$
975   }
976   while$
977   s empty$
978     'skip$
979     { pop$ s }
980   if$
981 }
982
983 % Converts the word number string on the top of the stack to
984 % Arabic string form. Will be successful up to "tenth".
985 FUNCTION {word.to.num}
986 { duplicate$ "l" change.case$ 's :=
987   s "first" =
988     { pop$ "1" }
989     { skip$ }
990   if$
991   s "second" =
992     { pop$ "2" }
993     { skip$ }
994   if$
995   s "third" =
996     { pop$ "3" }
997     { skip$ }
998   if$
999   s "fourth" =
1000     { pop$ "4" }
1001     { skip$ }
1002   if$
1003   s "fifth" =
1004     { pop$ "5" }
1005     { skip$ }
1006   if$
1007   s "sixth" =
1008     { pop$ "6" }
1009     { skip$ }
1010   if$
1011   s "seventh" =
1012     { pop$ "7" }
1013     { skip$ }
1014   if$
1015   s "eighth" =
1016     { pop$ "8" }
1017     { skip$ }
1018   if$
1019   s "ninth" =
1020     { pop$ "9" }
1021     { skip$ }
1022   if$
1023   s "tenth" =
1024     { pop$ "10" }
1025     { skip$ }
1026   if$
1027 }
1028
1029
1030 % Converts the string on the top of the stack to numerical
1031 % ordinal (e.g., "11th") form.
1032 FUNCTION {convert.edition}
1033 { duplicate$ empty$ 'skip$
1034     { duplicate$ #1 #1 substring$ is.num
1035         { extract.num
1036           num.to.ordinal
1037         }
1038         { word.to.num
1039           duplicate$ #1 #1 substring$ is.num
1040             { num.to.ordinal }
1041             { "edition ordinal word " quote$ * edition * quote$ *
1042               " may be too high (or improper) for conversion" * " in " * cite$ * warning$
1043             }
1044           if$
1045         }
1046       if$
1047     }
1048   if$
1049 }
1050
1051
1052
1053
1054 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1055 %% LATEX BIBLIOGRAPHY CODE %%
1056 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1057
1058 FUNCTION {start.entry}
1059 { newline$
1060   "\bibitem{" write$
1061   cite$ write$
1062   "}" write$
1063   newline$
1064   ""
1065   initialize.prev.this.status
1066 }
1067
1068 % Here we write out all the LaTeX code that we will need. The most involved
1069 % code sequences are those that control the alternate interword spacing and
1070 % foreign language hyphenation patterns. The heavy use of \providecommand
1071 % gives users a way to override the defaults. Special thanks to Javier Bezos,
1072 % Johannes Braams, Robin Fairbairns, Heiko Oberdiek, Donald Arseneau and all
1073 % the other gurus on comp.text.tex for their help and advice on the topic of
1074 % \selectlanguage, Babel and BibTeX.
1075 FUNCTION {begin.bib}
1076 { "% Generated by IEEEtran.bst, version: " bst.file.version * " (" * bst.file.date * ")" *
1077   write$ newline$
1078   preamble$ empty$ 'skip$
1079     { preamble$ write$ newline$ }
1080   if$
1081   "\begin{thebibliography}{"  longest.label  * "}" *
1082   write$ newline$
1083   "\providecommand{\url}[1]{#1}"
1084   write$ newline$
1085   "\csname url@samestyle\endcsname"
1086   write$ newline$
1087   "\providecommand{\newblock}{\relax}"
1088   write$ newline$
1089   "\providecommand{\bibinfo}[2]{#2}"
1090   write$ newline$
1091   "\providecommand{\BIBentrySTDinterwordspacing}{\spaceskip=0pt\relax}"
1092   write$ newline$
1093   "\providecommand{\BIBentryALTinterwordstretchfactor}{"
1094   ALTinterwordstretchfactor * "}" *
1095   write$ newline$
1096   "\providecommand{\BIBentryALTinterwordspacing}{\spaceskip=\fontdimen2\font plus "
1097   write$ newline$
1098   "\BIBentryALTinterwordstretchfactor\fontdimen3\font minus \fontdimen4\font\relax}"
1099   write$ newline$
1100   "\providecommand{\BIBforeignlanguage}[2]{{%"
1101   write$ newline$
1102   "\expandafter\ifx\csname l@#1\endcsname\relax"
1103   write$ newline$
1104   "\typeout{** WARNING: IEEEtran.bst: No hyphenation pattern has been}%"
1105   write$ newline$
1106   "\typeout{** loaded for the language `#1'. Using the pattern for}%"
1107   write$ newline$
1108   "\typeout{** the default language instead.}%"
1109   write$ newline$
1110   "\else"
1111   write$ newline$
1112   "\language=\csname l@#1\endcsname"
1113   write$ newline$
1114   "\fi"
1115   write$ newline$
1116   "#2}}"
1117   write$ newline$
1118   "\providecommand{\BIBdecl}{\relax}"
1119   write$ newline$
1120   "\BIBdecl"
1121   write$ newline$
1122 }
1123
1124 FUNCTION {end.bib}
1125 { newline$ "\end{thebibliography}" write$ newline$ }
1126
1127 FUNCTION {if.url.alt.interword.spacing}
1128 { is.use.alt.interword.spacing 
1129      {url empty$ 'skip$ {"\BIBentryALTinterwordspacing" write$ newline$} if$}
1130      { skip$ }
1131    if$
1132 }
1133
1134 FUNCTION {if.url.std.interword.spacing}
1135 { is.use.alt.interword.spacing 
1136      {url empty$ 'skip$ {"\BIBentrySTDinterwordspacing" write$ newline$} if$}
1137      { skip$ }
1138    if$
1139 }
1140
1141
1142
1143
1144 %%%%%%%%%%%%%%%%%%%%%%%%
1145 %% LONGEST LABEL PASS %%
1146 %%%%%%%%%%%%%%%%%%%%%%%%
1147
1148 FUNCTION {initialize.longest.label}
1149 { "" 'longest.label :=
1150   #1 'number.label :=
1151   #0 'longest.label.width :=
1152 }
1153
1154 FUNCTION {longest.label.pass}
1155 { type$ "ieeetranbstctl" =
1156     { skip$ }
1157     { number.label int.to.str$ 'label :=
1158       number.label #1 + 'number.label :=
1159       label width$ longest.label.width >
1160         { label 'longest.label :=
1161           label width$ 'longest.label.width :=
1162         }
1163         { skip$ }
1164       if$
1165     }
1166   if$
1167 }
1168
1169
1170
1171
1172 %%%%%%%%%%%%%%%%%%%%%
1173 %% FORMAT HANDLERS %%
1174 %%%%%%%%%%%%%%%%%%%%%
1175
1176 %% Lower Level Formats (used by higher level formats)
1177
1178 FUNCTION {format.address.org.or.pub.date}
1179 { 't :=
1180   ""
1181   year empty$
1182     { "empty year in " cite$ * warning$ }
1183     { skip$ }
1184   if$
1185   address empty$ t empty$ and
1186   year empty$ and month empty$ and
1187     { skip$ }
1188     { this.to.prev.status
1189       this.status.std
1190       cap.status.std
1191       address "address" bibinfo.check *
1192       t empty$
1193         { skip$ }
1194         { punct.period 'prev.status.punct :=
1195           space.large 'prev.status.space :=
1196           address empty$
1197             { skip$ }
1198             { ": " * }
1199           if$
1200           t *
1201         }
1202       if$
1203       year empty$ month empty$ and
1204         { skip$ }
1205         { t empty$ address empty$ and
1206             { skip$ }
1207             { ", " * }
1208           if$
1209           month empty$
1210             { year empty$
1211                 { skip$ }
1212                 { year "year" bibinfo.check * }
1213               if$
1214             }
1215             { month "month" bibinfo.check *
1216               year empty$
1217                  { skip$ }
1218                  { " " * year "year" bibinfo.check * }
1219               if$
1220             }
1221           if$
1222         }
1223       if$
1224     }
1225   if$
1226 }
1227
1228
1229 FUNCTION {format.names}
1230 { 'bibinfo :=
1231   duplicate$ empty$ 'skip$ {
1232   this.to.prev.status
1233   this.status.std
1234   's :=
1235   "" 't :=
1236   #1 'nameptr :=
1237   s num.names$ 'numnames :=
1238   numnames 'namesleft :=
1239     { namesleft #0 > }
1240     { s nameptr
1241       name.format.string
1242       format.name$
1243       bibinfo bibinfo.check
1244       't :=
1245       nameptr #1 >
1246         { nameptr num.names.shown.with.forced.et.al #1 + =
1247           numnames max.num.names.before.forced.et.al >
1248           is.forced.et.al and and
1249             { "others" 't :=
1250               #1 'namesleft :=
1251             }
1252             { skip$ }
1253           if$
1254           namesleft #1 >
1255             { ", " * t do.name.latex.cmd * }
1256             { s nameptr "{ll}" format.name$ duplicate$ "others" =
1257                 { 't := }
1258                 { pop$ }
1259               if$
1260               t "others" =
1261                 { " " * bbl.etal emphasize * }
1262                 { numnames #2 >
1263                     { "," * }
1264                     { skip$ }
1265                   if$
1266                   bbl.and
1267                   space.word * t do.name.latex.cmd *
1268                 }
1269               if$
1270             }
1271           if$
1272         }
1273         { t do.name.latex.cmd }
1274       if$
1275       nameptr #1 + 'nameptr :=
1276       namesleft #1 - 'namesleft :=
1277     }
1278   while$
1279   cap.status.std
1280   } if$
1281 }
1282
1283
1284
1285
1286 %% Higher Level Formats
1287
1288 %% addresses/locations
1289
1290 FUNCTION {format.address}
1291 { address duplicate$ empty$ 'skip$
1292     { this.to.prev.status
1293       this.status.std
1294       cap.status.std
1295     }
1296   if$
1297 }
1298
1299
1300
1301 %% author/editor names
1302
1303 FUNCTION {format.authors}{ author "author" format.names }
1304
1305 FUNCTION {format.editors}
1306 { editor "editor" format.names duplicate$ empty$ 'skip$
1307     { ", " *
1308       get.bbl.editor
1309       capitalize
1310       *
1311     }
1312   if$
1313 }
1314
1315
1316
1317 %% date
1318
1319 FUNCTION {format.date}
1320 {
1321   month "month" bibinfo.check duplicate$ empty$
1322   year  "year" bibinfo.check duplicate$ empty$
1323     { swap$ 'skip$
1324         { this.to.prev.status
1325           this.status.std
1326           cap.status.std
1327          "there's a month but no year in " cite$ * warning$ }
1328       if$
1329       *
1330     }
1331     { this.to.prev.status
1332       this.status.std
1333       cap.status.std
1334       swap$ 'skip$
1335         {
1336           swap$
1337           " " * swap$
1338         }
1339       if$
1340       *
1341     }
1342   if$
1343 }
1344
1345 FUNCTION {format.date.electronic}
1346 { month "month" bibinfo.check duplicate$ empty$
1347   year  "year" bibinfo.check duplicate$ empty$
1348     { swap$ 
1349         { pop$ }
1350         { "there's a month but no year in " cite$ * warning$
1351         pop$ ")" * "(" swap$ *
1352         this.to.prev.status
1353         punct.no 'this.status.punct :=
1354         space.normal 'this.status.space :=
1355         quote.no 'this.status.quote :=
1356         cap.yes  'status.cap :=
1357         }
1358       if$
1359     }
1360     { swap$ 
1361         { swap$ pop$ ")" * "(" swap$ * }
1362         { "(" swap$ * ", " * swap$ * ")" * }
1363       if$
1364     this.to.prev.status
1365     punct.no 'this.status.punct :=
1366     space.normal 'this.status.space :=
1367     quote.no 'this.status.quote :=
1368     cap.yes  'status.cap :=
1369     }
1370   if$
1371 }
1372
1373
1374
1375 %% edition/title
1376
1377 % Note: IEEE considers the edition to be closely associated with
1378 % the title of a book. So, in IEEEtran.bst the edition is normally handled 
1379 % within the formatting of the title. The format.edition function is 
1380 % retained here for possible future use.
1381 FUNCTION {format.edition}
1382 { edition duplicate$ empty$ 'skip$
1383     { this.to.prev.status
1384       this.status.std
1385       convert.edition
1386       status.cap
1387         { "t" }
1388         { "l" }
1389       if$ change.case$
1390       "edition" bibinfo.check
1391       "~" * bbl.edition *
1392       cap.status.std
1393     }
1394   if$
1395 }
1396
1397 % This is used to format the booktitle of a conference proceedings.
1398 % Here we use the "intype" field to provide the user a way to 
1399 % override the word "in" (e.g., with things like "presented at")
1400 % Use of intype stops the emphasis of the booktitle to indicate that
1401 % we no longer mean the written conference proceedings, but the
1402 % conference itself.
1403 FUNCTION {format.in.booktitle}
1404 { booktitle "booktitle" bibinfo.check duplicate$ empty$ 'skip$
1405     { this.to.prev.status
1406       this.status.std
1407       select.language
1408       intype missing$
1409         { emphasize
1410           bbl.in " " *
1411         }
1412         { intype " " * }
1413       if$
1414       swap$ *
1415       cap.status.std
1416     }
1417   if$
1418 }
1419
1420 % This is used to format the booktitle of collection.
1421 % Here the "intype" field is not supported, but "edition" is.
1422 FUNCTION {format.in.booktitle.edition}
1423 { booktitle "booktitle" bibinfo.check duplicate$ empty$ 'skip$
1424     { this.to.prev.status
1425       this.status.std
1426       select.language
1427       emphasize
1428       edition empty$ 'skip$
1429         { ", " *
1430           edition
1431           convert.edition
1432           "l" change.case$
1433           * "~" * bbl.edition *
1434         }
1435       if$
1436       bbl.in " " * swap$ *
1437       cap.status.std
1438     }
1439   if$
1440 }
1441
1442 FUNCTION {format.article.title}
1443 { title duplicate$ empty$ 'skip$
1444     { this.to.prev.status
1445       this.status.std
1446       "t" change.case$
1447     }
1448   if$
1449   "title" bibinfo.check
1450   duplicate$ empty$ 'skip$
1451     { quote.close 'this.status.quote :=
1452       is.last.char.not.punct
1453         { punct.std 'this.status.punct := }
1454         { punct.no 'this.status.punct := }
1455       if$
1456       select.language
1457       "``" swap$ *
1458       cap.status.std
1459     }
1460   if$
1461 }
1462
1463 FUNCTION {format.article.title.electronic}
1464 { title duplicate$ empty$ 'skip$
1465     { this.to.prev.status
1466       this.status.std
1467       cap.status.std
1468       "t" change.case$ 
1469     }
1470   if$
1471   "title" bibinfo.check
1472   duplicate$ empty$ 
1473     { skip$ } 
1474     { select.language }
1475   if$
1476 }
1477
1478 FUNCTION {format.book.title.edition}
1479 { title "title" bibinfo.check
1480   duplicate$ empty$
1481     { "empty title in " cite$ * warning$ }
1482     { this.to.prev.status
1483       this.status.std
1484       select.language
1485       emphasize
1486       edition empty$ 'skip$
1487         { ", " *
1488           edition
1489           convert.edition
1490           status.cap
1491             { "t" }
1492             { "l" }
1493           if$
1494           change.case$
1495           * "~" * bbl.edition *
1496         }
1497       if$
1498       cap.status.std
1499     }
1500   if$
1501 }
1502
1503 FUNCTION {format.book.title}
1504 { title "title" bibinfo.check
1505   duplicate$ empty$ 'skip$
1506     { this.to.prev.status
1507       this.status.std
1508       cap.status.std
1509       select.language
1510       emphasize
1511     }
1512   if$
1513 }
1514
1515
1516
1517 %% journal
1518
1519 FUNCTION {format.journal}
1520 { journal duplicate$ empty$ 'skip$
1521     { this.to.prev.status
1522       this.status.std
1523       cap.status.std
1524       select.language
1525       emphasize
1526     }
1527   if$
1528 }
1529
1530
1531
1532 %% how published
1533
1534 FUNCTION {format.howpublished}
1535 { howpublished duplicate$ empty$ 'skip$
1536     { this.to.prev.status
1537       this.status.std
1538       cap.status.std
1539     }
1540   if$
1541 }
1542
1543
1544
1545 %% institutions/organization/publishers/school
1546
1547 FUNCTION {format.institution}
1548 { institution duplicate$ empty$ 'skip$
1549     { this.to.prev.status
1550       this.status.std
1551       cap.status.std
1552     }
1553   if$
1554 }
1555
1556 FUNCTION {format.organization}
1557 { organization duplicate$ empty$ 'skip$
1558     { this.to.prev.status
1559       this.status.std
1560       cap.status.std
1561     }
1562   if$
1563 }
1564
1565 FUNCTION {format.address.publisher.date}
1566 { publisher "publisher" bibinfo.warn format.address.org.or.pub.date }
1567
1568 FUNCTION {format.address.publisher.date.nowarn}
1569 { publisher "publisher" bibinfo.check format.address.org.or.pub.date }
1570
1571 FUNCTION {format.address.organization.date}
1572 { organization "organization" bibinfo.check format.address.org.or.pub.date }
1573
1574 FUNCTION {format.school}
1575 { school duplicate$ empty$ 'skip$
1576     { this.to.prev.status
1577       this.status.std
1578       cap.status.std
1579     }
1580   if$
1581 }
1582
1583
1584
1585 %% volume/number/series/chapter/pages
1586
1587 FUNCTION {format.volume}
1588 { volume empty.field.to.null.string
1589   duplicate$ empty$ 'skip$
1590     { this.to.prev.status
1591       this.status.std
1592       bbl.volume 
1593       status.cap
1594         { capitalize }
1595         { skip$ }
1596       if$
1597       swap$ tie.or.space.prefix
1598       "volume" bibinfo.check
1599       * *
1600       cap.status.std
1601     }
1602   if$
1603 }
1604
1605 FUNCTION {format.number}
1606 { number empty.field.to.null.string
1607   duplicate$ empty$ 'skip$
1608     { this.to.prev.status
1609       this.status.std
1610       status.cap
1611          { bbl.number capitalize }
1612          { bbl.number }
1613        if$
1614       swap$ tie.or.space.prefix
1615       "number" bibinfo.check
1616       * *
1617       cap.status.std
1618     }
1619   if$
1620 }
1621
1622 FUNCTION {format.number.if.use.for.article}
1623 { is.use.number.for.article 
1624      { format.number }
1625      { "" }
1626    if$
1627 }
1628
1629 % IEEE does not seem to tie the series so closely with the volume
1630 % and number as is done in other bibliography styles. Instead the
1631 % series is treated somewhat like an extension of the title.
1632 FUNCTION {format.series}
1633 { series empty$ 
1634    { "" }
1635    { this.to.prev.status
1636      this.status.std
1637      bbl.series " " *
1638      series "series" bibinfo.check *
1639      cap.status.std
1640    }
1641  if$
1642 }
1643
1644
1645 FUNCTION {format.chapter}
1646 { chapter empty$
1647     { "" }
1648     { this.to.prev.status
1649       this.status.std
1650       type empty$
1651         { bbl.chapter }
1652         { type "l" change.case$
1653           "type" bibinfo.check
1654         }
1655       if$
1656       chapter tie.or.space.prefix
1657       "chapter" bibinfo.check
1658       * *
1659       cap.status.std
1660     }
1661   if$
1662 }
1663
1664
1665 % The intended use of format.paper is for paper numbers of inproceedings.
1666 % The paper type can be overridden via the type field.
1667 % We allow the type to be displayed even if the paper number is absent
1668 % for things like "postdeadline paper"
1669 FUNCTION {format.paper}
1670 { is.use.paper
1671      { paper empty$
1672         { type empty$
1673             { "" }
1674             { this.to.prev.status
1675               this.status.std
1676               type "type" bibinfo.check
1677               cap.status.std
1678             }
1679           if$
1680         }
1681         { this.to.prev.status
1682           this.status.std
1683           type empty$
1684             { bbl.paper }
1685             { type "type" bibinfo.check }
1686           if$
1687           " " * paper
1688           "paper" bibinfo.check
1689           *
1690           cap.status.std
1691         }
1692       if$
1693      }
1694      { "" } 
1695    if$
1696 }
1697
1698
1699 FUNCTION {format.pages}
1700 { pages duplicate$ empty$ 'skip$
1701     { this.to.prev.status
1702       this.status.std
1703       duplicate$ is.multiple.pages
1704         {
1705           bbl.pages swap$
1706           n.dashify
1707         }
1708         {
1709           bbl.page swap$
1710         }
1711       if$
1712       tie.or.space.prefix
1713       "pages" bibinfo.check
1714       * *
1715       cap.status.std
1716     }
1717   if$
1718 }
1719
1720
1721
1722 %% technical report number
1723
1724 FUNCTION {format.tech.report.number}
1725 { number "number" bibinfo.check
1726   this.to.prev.status
1727   this.status.std
1728   cap.status.std
1729   type duplicate$ empty$
1730     { pop$ 
1731       bbl.techrep
1732     }
1733     { skip$ }
1734   if$
1735   "type" bibinfo.check 
1736   swap$ duplicate$ empty$
1737     { pop$ }
1738     { tie.or.space.prefix * * }
1739   if$
1740 }
1741
1742
1743
1744 %% note
1745
1746 FUNCTION {format.note}
1747 { note empty$
1748     { "" }
1749     { this.to.prev.status
1750       this.status.std
1751       punct.period 'this.status.punct :=
1752       note #1 #1 substring$
1753       duplicate$ "{" =
1754         { skip$ }
1755         { status.cap
1756           { "u" }
1757           { "l" }
1758         if$
1759         change.case$
1760         }
1761       if$
1762       note #2 global.max$ substring$ * "note" bibinfo.check
1763       cap.yes  'status.cap :=
1764     }
1765   if$
1766 }
1767
1768
1769
1770 %% patent
1771
1772 FUNCTION {format.patent.date}
1773 { this.to.prev.status
1774   this.status.std
1775   year empty$
1776     { monthfiled duplicate$ empty$
1777         { "monthfiled" bibinfo.check pop$ "" }
1778         { "monthfiled" bibinfo.check }
1779       if$
1780       dayfiled duplicate$ empty$
1781         { "dayfiled" bibinfo.check pop$ "" * }
1782         { "dayfiled" bibinfo.check 
1783           monthfiled empty$ 
1784              { "dayfiled without a monthfiled in " cite$ * warning$
1785                * 
1786              }
1787              { " " swap$ * * }
1788            if$
1789         }
1790       if$
1791       yearfiled empty$
1792         { "no year or yearfiled in " cite$ * warning$ }
1793         { yearfiled "yearfiled" bibinfo.check 
1794           swap$
1795           duplicate$ empty$
1796              { pop$ }
1797              { ", " * swap$ * }
1798            if$
1799         }
1800       if$
1801     }
1802     { month duplicate$ empty$
1803         { "month" bibinfo.check pop$ "" }
1804         { "month" bibinfo.check }
1805       if$
1806       day duplicate$ empty$
1807         { "day" bibinfo.check pop$ "" * }
1808         { "day" bibinfo.check 
1809           month empty$ 
1810              { "day without a month in " cite$ * warning$
1811                * 
1812              }
1813              { " " swap$ * * }
1814            if$
1815         }
1816       if$
1817       year "year" bibinfo.check 
1818       swap$
1819       duplicate$ empty$
1820         { pop$ }
1821         { ", " * swap$ * }
1822       if$
1823     }
1824   if$
1825   cap.status.std
1826 }
1827
1828 FUNCTION {format.patent.nationality.type.number}
1829 { this.to.prev.status
1830   this.status.std
1831   nationality duplicate$ empty$
1832     { "nationality" bibinfo.warn pop$ "" }
1833     { "nationality" bibinfo.check
1834       duplicate$ "l" change.case$ "united states" =
1835         { pop$ bbl.patentUS }
1836         { skip$ }
1837       if$
1838       " " *
1839     }
1840   if$
1841   type empty$
1842     { bbl.patent "type" bibinfo.check }
1843     { type "type" bibinfo.check }
1844   if$  
1845   *
1846   number duplicate$ empty$
1847     { "number" bibinfo.warn pop$ }
1848     { "number" bibinfo.check
1849       large.number.separate
1850       swap$ " " * swap$ *
1851     }
1852   if$ 
1853   cap.status.std
1854 }
1855
1856
1857
1858 %% standard
1859
1860 FUNCTION {format.organization.institution.standard.type.number}
1861 { this.to.prev.status
1862   this.status.std
1863   organization duplicate$ empty$
1864     { pop$ 
1865       institution duplicate$ empty$
1866         { "institution" bibinfo.warn }
1867         { "institution" bibinfo.warn " " * }
1868       if$
1869     }
1870     { "organization" bibinfo.warn " " * }
1871   if$
1872   type empty$
1873     { bbl.standard "type" bibinfo.check }
1874     { type "type" bibinfo.check }
1875   if$  
1876   *
1877   number duplicate$ empty$
1878     { "number" bibinfo.check pop$ }
1879     { "number" bibinfo.check
1880       large.number.separate
1881       swap$ " " * swap$ *
1882     }
1883   if$ 
1884   cap.status.std
1885 }
1886
1887 FUNCTION {format.revision}
1888 { revision empty$
1889     { "" }
1890     { this.to.prev.status
1891       this.status.std
1892       bbl.revision
1893       revision tie.or.space.prefix
1894       "revision" bibinfo.check
1895       * *
1896       cap.status.std
1897     }
1898   if$
1899 }
1900
1901
1902 %% thesis
1903
1904 FUNCTION {format.master.thesis.type}
1905 { this.to.prev.status
1906   this.status.std
1907   type empty$
1908     {
1909       bbl.mthesis
1910     }
1911     { 
1912       type "type" bibinfo.check
1913     }
1914   if$
1915 cap.status.std
1916 }
1917
1918 FUNCTION {format.phd.thesis.type}
1919 { this.to.prev.status
1920   this.status.std
1921   type empty$
1922     {
1923       bbl.phdthesis
1924     }
1925     { 
1926       type "type" bibinfo.check
1927     }
1928   if$
1929 cap.status.std
1930 }
1931
1932
1933
1934 %% URL
1935
1936 FUNCTION {format.url}
1937 { url empty$
1938     { "" }
1939     { this.to.prev.status
1940       this.status.std
1941       cap.yes 'status.cap :=
1942       name.url.prefix " " *
1943       "\url{" * url * "}" *
1944       punct.no 'this.status.punct :=
1945       punct.period 'prev.status.punct :=
1946       space.normal 'this.status.space :=
1947       space.normal 'prev.status.space :=
1948       quote.no 'this.status.quote :=
1949     }
1950   if$
1951 }
1952
1953
1954
1955
1956 %%%%%%%%%%%%%%%%%%%%
1957 %% ENTRY HANDLERS %%
1958 %%%%%%%%%%%%%%%%%%%%
1959
1960
1961 % Note: In many journals, IEEE (or the authors) tend not to show the number
1962 % for articles, so the display of the number is controlled here by the
1963 % switch "is.use.number.for.article"
1964 FUNCTION {article}
1965 { std.status.using.comma
1966   start.entry
1967   if.url.alt.interword.spacing
1968   format.authors "author" output.warn
1969   name.or.dash
1970   format.article.title "title" output.warn
1971   format.journal "journal" bibinfo.check "journal" output.warn
1972   format.volume output
1973   format.number.if.use.for.article output
1974   format.pages output
1975   format.date "year" output.warn
1976   format.note output
1977   format.url output
1978   fin.entry
1979   if.url.std.interword.spacing
1980 }
1981
1982 FUNCTION {book}
1983 { std.status.using.comma
1984   start.entry
1985   if.url.alt.interword.spacing
1986   author empty$
1987     { format.editors "author and editor" output.warn }
1988     { format.authors output.nonnull }
1989   if$
1990   name.or.dash
1991   format.book.title.edition output
1992   format.series output
1993   author empty$
1994     { skip$ }
1995     { format.editors output }
1996   if$
1997   format.address.publisher.date output
1998   format.volume output
1999   format.number output
2000   format.note output
2001   format.url output
2002   fin.entry
2003   if.url.std.interword.spacing
2004 }
2005
2006 FUNCTION {booklet}
2007 { std.status.using.comma
2008   start.entry
2009   if.url.alt.interword.spacing
2010   format.authors output
2011   name.or.dash
2012   format.article.title "title" output.warn
2013   format.howpublished "howpublished" bibinfo.check output
2014   format.organization "organization" bibinfo.check output
2015   format.address "address" bibinfo.check output
2016   format.date output
2017   format.note output
2018   format.url output
2019   fin.entry
2020   if.url.std.interword.spacing
2021 }
2022
2023 FUNCTION {electronic}
2024 { std.status.using.period
2025   start.entry
2026   if.url.alt.interword.spacing
2027   format.authors output
2028   name.or.dash
2029   format.date.electronic output
2030   format.article.title.electronic output
2031   format.howpublished "howpublished" bibinfo.check output
2032   format.organization "organization" bibinfo.check output
2033   format.address "address" bibinfo.check output
2034   format.note output
2035   format.url output
2036   fin.entry
2037   empty.entry.warn
2038   if.url.std.interword.spacing
2039 }
2040
2041 FUNCTION {inbook}
2042 { std.status.using.comma
2043   start.entry
2044   if.url.alt.interword.spacing
2045   author empty$
2046     { format.editors "author and editor" output.warn }
2047     { format.authors output.nonnull }
2048   if$
2049   name.or.dash
2050   format.book.title.edition output
2051   format.series output
2052   format.address.publisher.date output
2053   format.volume output
2054   format.number output
2055   format.chapter output
2056   format.pages output
2057   format.note output
2058   format.url output
2059   fin.entry
2060   if.url.std.interword.spacing
2061 }
2062
2063 FUNCTION {incollection}
2064 { std.status.using.comma
2065   start.entry
2066   if.url.alt.interword.spacing
2067   format.authors "author" output.warn
2068   name.or.dash
2069   format.article.title "title" output.warn
2070   format.in.booktitle.edition "booktitle" output.warn
2071   format.series output
2072   format.editors output
2073   format.address.publisher.date.nowarn output
2074   format.volume output
2075   format.number output
2076   format.chapter output
2077   format.pages output
2078   format.note output
2079   format.url output
2080   fin.entry
2081   if.url.std.interword.spacing
2082 }
2083
2084 FUNCTION {inproceedings}
2085 { std.status.using.comma
2086   start.entry
2087   if.url.alt.interword.spacing
2088   format.authors "author" output.warn
2089   name.or.dash
2090   format.article.title "title" output.warn
2091   format.in.booktitle "booktitle" output.warn
2092   format.series output
2093   format.editors output
2094   format.volume output
2095   format.number output
2096   publisher empty$
2097     { format.address.organization.date output }
2098     { format.organization "organization" bibinfo.check output
2099       format.address.publisher.date output
2100     }
2101   if$
2102   format.paper output
2103   format.pages output
2104   format.note output
2105   format.url output
2106   fin.entry
2107   if.url.std.interword.spacing
2108 }
2109
2110 FUNCTION {manual}
2111 { std.status.using.comma
2112   start.entry
2113   if.url.alt.interword.spacing
2114   format.authors output
2115   name.or.dash
2116   format.book.title.edition "title" output.warn
2117   format.howpublished "howpublished" bibinfo.check output 
2118   format.organization "organization" bibinfo.check output
2119   format.address "address" bibinfo.check output
2120   format.date output
2121   format.note output
2122   format.url output
2123   fin.entry
2124   if.url.std.interword.spacing
2125 }
2126
2127 FUNCTION {mastersthesis}
2128 { std.status.using.comma
2129   start.entry
2130   if.url.alt.interword.spacing
2131   format.authors "author" output.warn
2132   name.or.dash
2133   format.article.title "title" output.warn
2134   format.master.thesis.type output.nonnull
2135   format.school "school" bibinfo.warn output
2136   format.address "address" bibinfo.check output
2137   format.date "year" output.warn
2138   format.note output
2139   format.url output
2140   fin.entry
2141   if.url.std.interword.spacing
2142 }
2143
2144 FUNCTION {misc}
2145 { std.status.using.comma
2146   start.entry
2147   if.url.alt.interword.spacing
2148   format.authors output
2149   name.or.dash
2150   format.article.title output
2151   format.howpublished "howpublished" bibinfo.check output 
2152   format.organization "organization" bibinfo.check output
2153   format.address "address" bibinfo.check output
2154   format.pages output
2155   format.date output
2156   format.note output
2157   format.url output
2158   fin.entry
2159   empty.entry.warn
2160   if.url.std.interword.spacing
2161 }
2162
2163 FUNCTION {patent}
2164 { std.status.using.comma
2165   start.entry
2166   if.url.alt.interword.spacing
2167   format.authors output
2168   name.or.dash
2169   format.article.title output
2170   format.patent.nationality.type.number output
2171   format.patent.date output
2172   format.note output
2173   format.url output
2174   fin.entry
2175   empty.entry.warn
2176   if.url.std.interword.spacing
2177 }
2178
2179 FUNCTION {periodical}
2180 { std.status.using.comma
2181   start.entry
2182   if.url.alt.interword.spacing
2183   format.editors output
2184   name.or.dash
2185   format.book.title "title" output.warn
2186   format.series output
2187   format.volume output
2188   format.number output
2189   format.organization "organization" bibinfo.check output
2190   format.date "year" output.warn
2191   format.note output
2192   format.url output
2193   fin.entry
2194   if.url.std.interword.spacing
2195 }
2196
2197 FUNCTION {phdthesis}
2198 { std.status.using.comma
2199   start.entry
2200   if.url.alt.interword.spacing
2201   format.authors "author" output.warn
2202   name.or.dash
2203   format.article.title "title" output.warn
2204   format.phd.thesis.type output.nonnull
2205   format.school "school" bibinfo.warn output
2206   format.address "address" bibinfo.check output
2207   format.date "year" output.warn
2208   format.note output
2209   format.url output
2210   fin.entry
2211   if.url.std.interword.spacing
2212 }
2213
2214 FUNCTION {proceedings}
2215 { std.status.using.comma
2216   start.entry
2217   if.url.alt.interword.spacing
2218   format.editors output
2219   name.or.dash
2220   format.book.title "title" output.warn
2221   format.series output
2222   format.volume output
2223   format.number output
2224   publisher empty$
2225     { format.address.organization.date output }
2226     { format.organization "organization" bibinfo.check output
2227       format.address.publisher.date output
2228     }
2229   if$
2230   format.note output
2231   format.url output
2232   fin.entry
2233   if.url.std.interword.spacing
2234 }
2235
2236 FUNCTION {standard}
2237 { std.status.using.comma
2238   start.entry
2239   if.url.alt.interword.spacing
2240   format.authors output
2241   name.or.dash
2242   format.book.title "title" output.warn
2243   format.howpublished "howpublished" bibinfo.check output 
2244   format.organization.institution.standard.type.number output
2245   format.revision output
2246   format.date output
2247   format.note output
2248   format.url output
2249   fin.entry
2250   if.url.std.interword.spacing
2251 }
2252
2253 FUNCTION {techreport}
2254 { std.status.using.comma
2255   start.entry
2256   if.url.alt.interword.spacing
2257   format.authors "author" output.warn
2258   name.or.dash
2259   format.article.title "title" output.warn
2260   format.howpublished "howpublished" bibinfo.check output 
2261   format.institution "institution" bibinfo.warn output
2262   format.address "address" bibinfo.check output
2263   format.tech.report.number output.nonnull
2264   format.date "year" output.warn
2265   format.note output
2266   format.url output
2267   fin.entry
2268   if.url.std.interword.spacing
2269 }
2270
2271 FUNCTION {unpublished}
2272 { std.status.using.comma
2273   start.entry
2274   if.url.alt.interword.spacing
2275   format.authors "author" output.warn
2276   name.or.dash
2277   format.article.title "title" output.warn
2278   format.date output
2279   format.note "note" output.warn
2280   format.url output
2281   fin.entry
2282   if.url.std.interword.spacing
2283 }
2284
2285
2286 % The special entry type which provides the user interface to the
2287 % BST controls
2288 FUNCTION {IEEEtranBSTCTL}
2289 { is.print.banners.to.terminal
2290     { "** IEEEtran BST control entry " quote$ * cite$ * quote$ * " detected." *
2291       top$
2292     }
2293     { skip$ }
2294   if$
2295   CTLuse_article_number
2296   empty$
2297     { skip$ }
2298     { CTLuse_article_number
2299       yes.no.to.int
2300       'is.use.number.for.article :=
2301     }
2302   if$
2303   CTLuse_paper
2304   empty$
2305     { skip$ }
2306     { CTLuse_paper
2307       yes.no.to.int
2308       'is.use.paper :=
2309     }
2310   if$
2311   CTLuse_forced_etal
2312   empty$
2313     { skip$ }
2314     { CTLuse_forced_etal
2315       yes.no.to.int
2316       'is.forced.et.al :=
2317     }
2318   if$
2319   CTLmax_names_forced_etal
2320   empty$
2321     { skip$ }
2322     { CTLmax_names_forced_etal
2323       string.to.integer
2324       'max.num.names.before.forced.et.al :=
2325     }
2326   if$
2327   CTLnames_show_etal
2328   empty$
2329     { skip$ }
2330     { CTLnames_show_etal
2331       string.to.integer
2332       'num.names.shown.with.forced.et.al :=
2333     }
2334   if$
2335   CTLuse_alt_spacing
2336   empty$
2337     { skip$ }
2338     { CTLuse_alt_spacing
2339       yes.no.to.int
2340       'is.use.alt.interword.spacing :=
2341     }
2342   if$
2343   CTLalt_stretch_factor
2344   empty$
2345     { skip$ }
2346     { CTLalt_stretch_factor
2347       'ALTinterwordstretchfactor :=
2348       "\renewcommand{\BIBentryALTinterwordstretchfactor}{"
2349       ALTinterwordstretchfactor * "}" *
2350       write$ newline$
2351     }
2352   if$
2353   CTLdash_repeated_names
2354   empty$
2355     { skip$ }
2356     { CTLdash_repeated_names
2357       yes.no.to.int
2358       'is.dash.repeated.names :=
2359     }
2360   if$
2361   CTLname_format_string
2362   empty$
2363     { skip$ }
2364     { CTLname_format_string
2365       'name.format.string :=
2366     }
2367   if$
2368   CTLname_latex_cmd
2369   empty$
2370     { skip$ }
2371     { CTLname_latex_cmd
2372       'name.latex.cmd :=
2373     }
2374   if$
2375   CTLname_url_prefix
2376   missing$
2377     { skip$ }
2378     { CTLname_url_prefix
2379       'name.url.prefix :=
2380     }
2381   if$
2382
2383
2384   num.names.shown.with.forced.et.al max.num.names.before.forced.et.al >
2385     { "CTLnames_show_etal cannot be greater than CTLmax_names_forced_etal in " cite$ * warning$ 
2386       max.num.names.before.forced.et.al 'num.names.shown.with.forced.et.al :=
2387     }
2388     { skip$ }
2389   if$
2390 }
2391
2392
2393 %%%%%%%%%%%%%%%%%%%
2394 %% ENTRY ALIASES %%
2395 %%%%%%%%%%%%%%%%%%%
2396 FUNCTION {conference}{inproceedings}
2397 FUNCTION {online}{electronic}
2398 FUNCTION {internet}{electronic}
2399 FUNCTION {webpage}{electronic}
2400 FUNCTION {www}{electronic}
2401 FUNCTION {default.type}{misc}
2402
2403
2404
2405 %%%%%%%%%%%%%%%%%%
2406 %% MAIN PROGRAM %%
2407 %%%%%%%%%%%%%%%%%%
2408
2409 READ
2410
2411 EXECUTE {initialize.controls}
2412 EXECUTE {initialize.status.constants}
2413 EXECUTE {banner.message}
2414
2415 EXECUTE {initialize.longest.label}
2416 ITERATE {longest.label.pass}
2417
2418 EXECUTE {begin.bib}
2419 ITERATE {call.type$}
2420 EXECUTE {end.bib}
2421
2422 EXECUTE{completed.message}
2423
2424
2425 %% That's all folks, mds.