eletrotupi / tcc/ monografia/abnt.bstc941890054e469bdf624c967e653c5c48b4fb80f
29.4 KB | 1374 lines Raw
1
%==============================================================================
2
% abnt.bst
3
% Estilo BibTeX de formatação de referências bibliográficas no padrão ABNT
4
%
5
% UFRGS TeX Users Group
6
% Informatics Institute --- UFRGS
7
% Porto Alegre, Brazil
8
% http://www.inf.ufrgs.br/utug
9
% Discussion list: utug-l@inf.ufrgs.br
10
%
11
% $Id: abnt.bst,v 5.6 2003/03/03 00:17:46 avila Exp $
12
%
13
% Copyright (C) 2001-2002 UFRGS TeX Users Group
14
%
15
% This program is free software; you can redistribute it and/or modify
16
% it under the terms of the GNU General Public License as published by
17
% the Free Software Foundation; either version 2 of the License, or
18
% (at your option) any later version.
19
%
20
% This program is distributed in the hope that it will be useful,
21
% but WITHOUT ANY WARRANTY; without even the implied warranty of
22
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
% GNU General Public License for more details.
24
%
25
% You should have received a copy of the GNU General Public License
26
% along with this program; if not, write to the Free Software
27
% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
28
%==============================================================================
29

30
%==============================================================================
31
% Definição dos campos das entradas
32
%==============================================================================
33
ENTRY
34
{ 
35
  author
36
  editor
37
  title
38
  booktitle
39
  chapter
40
  pages
41
  address
42
  publisher
43
  year
44
  journal
45
  month
46
  number
47
  edition
48
  howpublished
49
  institution
50
  key
51
  note
52
  organization
53
  school
54
  series
55
  type
56
  volume
57
    url
58
    urldate
59
}
60
{}
61
{
62
  label
63
  year.char
64
}
65

66
INTEGERS {i j n}
67
STRINGS {s t last.label last.year.char current.letter names new.pages}
68

69
%==============================================================================
70
% Definicao dos nomes dos meses
71
%==============================================================================
72
MACRO {jan} {"Jan."}
73
MACRO {feb} {"Feb."}
74
MACRO {mar} {"Mar."}
75
MACRO {apr} {"Apr."}
76
MACRO {may} {"May"}
77
MACRO {jun} {"June"}
78
MACRO {jul} {"July"}
79
MACRO {aug} {"Aug."}
80
MACRO {sep} {"Sept."}
81
MACRO {oct} {"Oct."}
82
MACRO {nov} {"Nov."}
83
MACRO {dec} {"Dec."}
84

85
%==============================================================================
86
% Definicao de strings usados na elaboracao das referencias
87
%==============================================================================
88
FUNCTION {str:mastersthesis} {"Disserta{\c{c}}{\~a}o (Mestrado em Ci{\^e}ncia da Computa{\c{c}}{\~a}o)"}
89
FUNCTION {str:phdthesis} {"Tese (Doutorado em Ci{\^e}ncia da Computa{\c{c}}{\~a}o)"}
90
FUNCTION {str:chapter} {"Cap."}
91

92
%==============================================================================
93
% Definicao das abreviaturas padrao
94
%==============================================================================
95
MACRO {acmcs} {"ACM Computing Surveys"}
96
MACRO {acta} {"Acta Informatica"}
97
MACRO {cacm} {"Communications of the ACM"}
98
MACRO {ibmjrd} {"IBM Journal of Research and Development"}
99
MACRO {ibmsj} {"IBM Systems Journal"}
100
MACRO {ieeese} {"IEEE Transactions on Software Engineering"}
101
MACRO {ieeetc} {"IEEE Transactions on Computers"}
102
MACRO {ieeetcad}
103
  {"IEEE Transactions on Computer-Aided Design of Integrated Circuits"}
104
MACRO {ipl} {"Information Processing Letters"}
105
MACRO {jacm} {"Journal of the ACM"}
106
MACRO {jcss} {"Journal of Computer and System Sciences"}
107
MACRO {scp} {"Science of Computer Programming"}
108
MACRO {sicomp} {"SIAM Journal on Computing"}
109
MACRO {tocs} {"ACM Transactions on Computer Systems"}
110
MACRO {tods} {"ACM Transactions on Database Systems"}
111
MACRO {tog} {"ACM Transactions on Graphics"}
112
MACRO {toms} {"ACM Transactions on Mathematical Software"}
113
MACRO {toois} {"ACM Transactions on Office Information Systems"}
114
MACRO {toplas} {"ACM Transactions on Programming Languages and Systems"}
115
MACRO {tcs} {"Theoretical Computer Science"}
116

117
%==============================================================================
118
% Exibe warning quando um campo ``required'' esta' faltando. Recebe na pilha o
119
% tipo do campo.
120
%==============================================================================
121
FUNCTION {show.missing.field.warning}
122
{
123
  "Falta o campo " swap$ " em " cite$ * * * warning$
124
}
125

126
%==============================================================================
127
% Funcoes logicas
128
%==============================================================================
129
FUNCTION {not}
130
{
131
    { #0 }
132
    { #1 }
133
  if$
134
}
135

136
FUNCTION {and}
137
{
138
    'skip$
139
    { pop$ #0 }
140
  if$
141
}
142

143
FUNCTION {or}
144
{
145
    { pop$ #1 }
146
    'skip$
147
  if$
148
}
149

150
FUNCTION {is.numeric.char}
151
{
152
  #1 #1 substring$
153
  duplicate$ "" =
154
    {pop$ #0}
155
    {
156
      duplicate$ chr.to.int$ #47 >
157
      swap$ chr.to.int$ #58 <
158
      and
159
    }
160
  if$
161
}
162

163
FUNCTION {is.uppercase.char}
164
{
165
  #1 #1 substring$
166
  duplicate$ "" =
167
    {pop$ #0}
168
    {
169
      duplicate$ chr.to.int$ #64 >
170
      swap$ chr.to.int$ #91 <
171
      and
172
    }
173
  if$
174
}
175

176
%==============================================================================
177
% Escreve no arquivo o comando que gera o item
178
%
179
% Parm:
180
%  um string com a formatacao do item
181
%==============================================================================
182
FUNCTION {write.item}
183
{
184
  "\bibitem[" label * "]{" * cite$ * "} " *
185
  swap$ *
186
  write$ newline$ newline$
187
}
188

189
%==============================================================================
190
% Separa o titulo em titulo e sub-titulo, empilhando o sub-titulo e o titulo,
191
% nessa ordem
192
%
193
% Parm:
194
%  o titulo
195
%==============================================================================
196
FUNCTION {extract.subtitle}
197
{
198
  #1 'i :=
199

200
  duplicate$
201
  i #1 substring$
202
  {
203
    duplicate$ ":" = not
204
    swap$ "" = not
205
    and
206
  }
207
  {
208
    #1 i + 'i :=
209
    duplicate$
210
    i #1 substring$
211
  } while$
212

213
  duplicate$ i #999 substring$
214
  swap$
215
  #1 i #1 - substring$
216
}
217

218
%==============================================================================
219
% Separa a primeira palavra do texto, empilhando o resto e a palavra, nessa
220
% ordem
221
%
222
% Parm:
223
%  o texto
224
%==============================================================================
225
FUNCTION {extract.first.word}
226
{
227
  #1 'i :=
228

229
  duplicate$
230
  i #1 substring$
231
  {
232
    duplicate$ " " = not
233
    swap$ "" = not
234
    and
235
  }
236
  {
237
    #1 i + 'i :=
238
    duplicate$
239
    i #1 substring$
240
  } while$
241

242
  duplicate$ i #999 substring$
243
  swap$
244
  #1 i #1 - substring$
245
}
246

247
%==============================================================================
248
% Enfatiza um string
249
%
250
% Parm:
251
%  o string
252
%==============================================================================
253
FUNCTION {emphasize}
254
{
255
  "\textbf{" swap$ * "}" *
256
}
257

258
%==============================================================================
259
% Adiciona um texto (se nao-empty$) ja' formatado ao item, separando-o por
260
% ponto.
261
% Ex.: NOME. Titulo. data. ano.
262
%
263
% Parm:
264
%  um string representando o item (pode ser vazio, para iniciar o item)
265
%  o texto a ser adicionado
266
%==============================================================================
267
FUNCTION {add.to.item}
268
{
269
  duplicate$ empty$
270
    'pop$
271
    {
272
      swap$
273
      duplicate$ empty$
274
        'skip$
275
        {" " *}
276
      if$
277
      swap$ add.period$ *
278
    }
279
  if$
280
}
281

282
%==============================================================================
283
% Adiciona um item (se nao-empty$) a uma lista do tipo "a, b, c, ..."
284
%
285
% Parm:
286
%  um string representando a lista (pode ser vazio, para criar uma lista)
287
%  o item a ser adicionado
288
%==============================================================================
289
FUNCTION {add.to.list}
290
{
291
  duplicate$ empty$
292
    'pop$
293
    {
294
      swap$
295
      duplicate$ empty$
296
        'skip$
297
        {", " *}
298
      if$
299
      swap$ *
300
    }
301
  if$
302
}
303

304
%==============================================================================
305
% Adiciona um nome a uma lista de nomes (separados por ponto-e-virgula)
306
%
307
% Parm:
308
%  um string representando a lista (pode ser vazio, para criar uma lista)
309
%  o nome a ser adicionado
310
%==============================================================================
311
FUNCTION {add.to.namelist}
312
{
313
  swap$
314
  duplicate$ empty$
315
    'skip$
316
    {"; " *}
317
  if$
318
  swap$ *
319
}
320

321
%==============================================================================
322
% Formata uma lista de nomes.
323
%
324
% Parm:
325
%  os nomes a serem formatados
326
%==============================================================================
327
FUNCTION {format.names}
328
{
329
  duplicate$ num.names$ 'n :=
330
  #1 'i :=
331
  "" 'names :=
332

333
  {i n #1 + <}
334
  {
335
    duplicate$ duplicate$ i "{ll}{~jj}" format.name$
336
    duplicate$ "others" =
337
        n #4 >
338
        i #2 =
339
        and
340
        or
341
    {
342
      pop$ pop$ names " et~al." *
343
      n 'i :=
344
    }{
345
      "u" change.case$ swap$
346
      i "{, ff}{~vv}" format.name$ *
347
      names swap$ add.to.namelist
348
    } if$ 'names :=
349
    #1 i + 'i :=
350
  } while$
351
  pop$
352
  names
353
  duplicate$ #-1 #1 substring$ "." = {
354
    #-2 global.max$ substring$
355
    "\@." *
356
  }
357
    'skip$
358
  if$
359
}
360

361
%==============================================================================
362
% Formata uma lista de sobrenomes.
363
%
364
% Parm:
365
%  os nomes a serem formatados
366
%==============================================================================
367
FUNCTION {format.family.names}
368
{
369
  duplicate$ num.names$ 'n :=
370
  #1 'i :=
371
  "" 'names :=
372

373
  {i n #1 + <}
374
  {
375
    duplicate$ i "{ll}{~jj}" format.name$
376
    duplicate$ "others" =
377
    n #3 >
378
    i #2 =
379
    and
380
    or
381
    {
382
      pop$ names " et~al." *
383
      n 'i :=
384
    }{
385
      "u" change.case$
386
      names swap$ add.to.namelist
387
    } if$ 'names :=
388
    #1 i + 'i :=
389
  } while$
390
  pop$
391
  names
392
}
393

394
%==============================================================================
395
% Formata uma lista de sobrenomes com todos os autores.
396
%
397
% Parm:
398
%  os nomes a serem formatados
399
%==============================================================================
400
FUNCTION {format.family.names.all}
401
{
402
  duplicate$ num.names$ 'n :=
403
  #1 'i :=
404
  "" 'names :=
405

406
  {i n #1 + <}
407
  {
408
    duplicate$ i "{ll}{~jj}" format.name$
409
    duplicate$ "others" =
410
    {
411
      pop$ names " et~al." *
412
      n 'i :=
413
    }{
414
      "u" change.case$
415
      names swap$ add.to.namelist
416
    } if$ 'names :=
417
    #1 i + 'i :=
418
  } while$
419
  pop$
420
  names
421
}
422

423
%==============================================================================
424
% Formata um titulo (pode ser `title' ou `booktitle')
425
%
426
% Parm:
427
%  um valor (0 ou 1) que indica se a formatacao deve ser enfatizada ou nao
428
%  um string com o titulo a ser formatado
429
%==============================================================================
430
FUNCTION {format.title}
431
{
432
  swap$ {
433
    extract.subtitle emphasize swap$ *
434
  }{
435
    skip$
436
  } if$
437
}
438

439
%==============================================================================
440
% Retorna a indicacao de paginas ajustada para ter dois tracos (`--') se a
441
% entrada so' tiver um.
442
%==============================================================================
443
FUNCTION {get.adjusted.pages}
444
{
445
  #1 'i :=
446
  "" 'new.pages :=
447
  pages #1 #1 substring$
448
  {duplicate$ "" = not}
449
  {
450
    duplicate$ "-" =
451
    pages i #1 - #1 substring$ "-" = not
452
    and
453
    pages i #1 + #1 substring$ "-" = not
454
    and
455
      {"-" *}
456
      'skip$
457
    if$
458
    new.pages swap$ * 'new.pages :=
459
    #1 i + 'i :=
460
    pages i #1 substring$
461
  } while$
462
  pop$
463
  new.pages
464
}
465

466
%==============================================================================
467
% Coloca a primeira palavra do titulo em letras maiusculas e o resto em
468
% minusculas. Esta funcao e' usada para gerar referencias cuja entrada e' pelo
469
% titulo.
470
%==============================================================================
471
FUNCTION {format.entrytitle}
472
{
473
  #0 title format.title
474
  extract.first.word "u" change.case$
475
  swap$ * 
476
}
477

478
%==============================================================================
479
% Converte a edicao literal ("First", "Second", etc., que é o padrão indicado
480
% no manual do BibTeX) para o algarismo correspondente. Recebe na pilha o
481
% string e devolve o numero.
482
%==============================================================================
483
FUNCTION {convert.to.number}
484
{
485
  duplicate$ "First" =
486
  {pop$ "1"}
487
  {duplicate$ "Second" =
488
  {pop$ "2"}
489
  {duplicate$ "Third" =
490
  {pop$ "3"}
491
  {duplicate$ "Fourth" =
492
  {pop$ "4"}
493
  {duplicate$ "Fifth" =
494
  {pop$ "5"}
495
  {duplicate$ "Sixth" =
496
  {pop$ "6"}
497
  {duplicate$ "Seventh" =
498
  {pop$ "7"}
499
  {duplicate$ "Eighth" =
500
  {pop$ "8"}
501
  {duplicate$ "Ninth" =
502
  {pop$ "9"}
503
  {duplicate$ "Tenth" =
504
  {pop$ "10"}
505
  {skip$
506
  } if$
507
  } if$
508
  } if$
509
  } if$
510
  } if$
511
  } if$
512
  } if$
513
  } if$
514
  } if$
515
  } if$
516
}
517

518
%=========================================================================
519
% Formatacao dos campos. Se o campo nao existir a funcao devolve um string
520
% vazio.
521
%==============================================================================
522
FUNCTION {format.author}
523
{
524
  author empty$
525
    {""}
526
    {author format.names}
527
  if$
528
}
529

530
FUNCTION {format.editor}
531
{
532
  editor empty$
533
    {""}
534
    {editor format.names "~(Ed.)" *}
535
  if$
536
}
537

538
FUNCTION {format.edition}
539
{
540
  edition empty$
541
    {""}
542
    {edition convert.to.number ".ed." *}
543
  if$
544
}
545

546
FUNCTION {format.volume}
547
{
548
  volume empty$
549
    {""}
550
    {"v." volume *}
551
  if$
552
}
553

554
FUNCTION {format.number}
555
{
556
  number empty$
557
    {""}
558
    {"n." number *}
559
  if$
560
}
561

562
FUNCTION {format.month}
563
{
564
  month empty$
565
    {""}
566
    {month}
567
  if$
568
}
569

570
FUNCTION {format.address}
571
{
572
  address empty$
573
    {""}
574
    {address}
575
  if$
576
}
577

578
FUNCTION {format.publisher}
579
{
580
  type$ "mastersthesis" =
581
  type$ "phdthesis" =
582
  or
583
  {
584
    school empty$
585
      {""}
586
      {school}
587
    if$
588
  }{
589
  type$ "techreport" =
590
  {
591
    institution empty$
592
      {""}
593
      {institution}
594
    if$
595
  }{
596
    publisher empty$
597
      {""}
598
      {publisher}
599
    if$
600
  } if$
601
  } if$
602
}
603

604
FUNCTION {format.year}
605
{
606
  year empty$
607
    {""}
608
    {year}
609
  if$
610
}
611

612
FUNCTION {format.chapter}
613
{
614
  chapter empty$
615
    {""}
616
    {
617
      type empty$
618
        {str:chapter}
619
        {type "~" *}
620
      if$
621
      chapter *
622
    }
623
  if$
624
}
625

626
FUNCTION {format.pages}
627
{
628
  pages empty$
629
    {""}
630
    {"p." get.adjusted.pages *}
631
  if$
632
}
633

634
FUNCTION {format.totalpages}
635
{
636
  pages empty$
637
    {""}
638
    {pages "p." *}
639
  if$
640
}
641

642
FUNCTION {format.note}
643
{
644
  note empty$
645
    {""}
646
    {note}
647
  if$
648
}
649

650
FUNCTION {format.month.year}
651
{
652
  month empty$
653
    {year}
654
    {month "~" * year *}
655
  if$
656
}
657

658
FUNCTION {format.type}
659
{
660
  type empty$
661
    'skip$
662
    {pop$ type}
663
  if$
664
}
665

666
FUNCTION {format.howpublished}
667
{
668
  howpublished empty$
669
    {""}
670
    {howpublished}
671
  if$
672
}
673

674
FUNCTION {format.series}
675
{
676
  series empty$
677
    {""}
678
    {series}
679
  if$
680
}
681

682
FUNCTION {format.parenthised.number}
683
{
684
  number empty$ {
685
    ""
686
  }{
687
    "(" number * ")" *
688
  } if$
689
}
690

691
%==============================================================================
692
% As seguintes funcoes adicionam um item a uma lista passada na pilha.
693
%==============================================================================
694
FUNCTION {add.address} {format.address add.to.list}
695
FUNCTION {add.publisher} {format.publisher add.to.list}
696
FUNCTION {add.year} {format.year add.to.list}
697
FUNCTION {add.chapter} {format.chapter add.to.list}
698
FUNCTION {add.edition} {format.edition add.to.list}
699
FUNCTION {add.volume} {format.volume add.to.list}
700
FUNCTION {add.number} {format.number add.to.list}
701
FUNCTION {add.month} {format.month add.to.list}
702
FUNCTION {add.totalpages} {format.totalpages add.to.list}
703
FUNCTION {add.pages} {format.pages add.to.list}
704
FUNCTION {add.note} {format.note add.to.list}
705
FUNCTION {add.month.year} {format.month.year add.to.list}
706
FUNCTION {add.howpublished} {format.howpublished add.to.list}
707

708
FUNCTION {format.urldate} {
709
  urldate empty$
710
      {""}
711
    {"Acesso em: " urldate *}
712
    if$
713
}
714

715
FUNCTION {format.url} {
716
  url empty$
717
      {""}
718
        {"Dispon{\'\i}vel em: <" url * ">" *}
719
  if$
720
}
721

722

723
%==============================================================================
724
% Converte virgula para dois-pontos; usado na formatacao do publisher de
725
% proceedings e inproceedings, que normalmente levam tambem o local de publi-
726
% cao; no padrao ABNT essa separacao deve ser por dois-pontos.
727
% Recebe o string original e devolve o novo.
728
%==============================================================================
729
FUNCTION {comma.to.colon}
730
{
731
  's :=
732
  "" 't :=
733
  #1 'i :=
734
  {s i #1 substring$ "" = not}
735
  {
736
    s i #1 substring$ duplicate$ "," =
737
      {pop$ t ":" * 't :=}
738
      {t swap$ * 't :=}
739
    if$
740
    i #1 + 'i :=
741
  } while$
742
  t
743
}
744

745
%
746
% localiza a posicao do primeiro caractere maiusculo
747
% recebe o string, devolve a posicao
748
%
749
FUNCTION {find.first.uppercase.char}
750
{
751
  's :=
752
  #1 'j :=
753
  #1 'i :=
754
  {
755
    s i #1 substring$ 't :=
756
    t "" = not
757
    t is.uppercase.char not
758
    and
759
  }
760
  {
761
    i #1 + 'i :=
762
    t "\" = not
763
    t "{" = not
764
    and
765
    t "}" = not
766
    and
767
      {i 'j :=}
768
      'skip$
769
    if$
770
  } while$
771
  t "" =
772
    {#1}
773
    {j}
774
  if$
775
}
776

777
%
778
% extrai o primeiro numero que aparece no string passado na pilha,
779
% retornando-o; se nao ha' numero, retorna ""
780
%
781
FUNCTION {extract.first.number}
782
{
783
  's :=
784
  "" 't :=
785
  #1 'i :=
786
  {
787
    s i #1 substring$
788
    duplicate$ is.numeric.char not
789
    swap$ "" = not
790
    and
791
  }
792
  {
793
    i #1 + 'i :=
794
  } while$
795
  {s i #1 substring$ is.numeric.char}
796
  {
797
    t s i #1 substring$ * 't :=
798
    i #1 + 'i :=
799
  } while$
800
  t
801
}
802

803
%
804
% divide um string em dois
805
% recebe o string e a posicao
806
% devolve a primeira e a segunda parte
807
FUNCTION {split.string}
808
{
809
  swap$ 's :=
810
  duplicate$
811
  s swap$ #1 swap$ #1 - substring$
812
  swap$ s swap$ global.max$ substring$
813
}
814

815
%
816
% recebe o titulo original e devolve, na ordem, o tipo de proceedings e o
817
% restante do titulo
818
%
819
FUNCTION {extract.proceedings.type}
820
{
821
  's :=
822
  type empty$ not
823
    {type s}
824
    {"dummy"
825
  pop$ s #1 #11 substring$ duplicate$ "Proceedings" =
826
    {s #12 global.max$ substring$}{
827
  pop$ s #1 #5 substring$ duplicate$ "Proc." =
828
    {pop$ "Proceedings" s #6 global.max$ substring$}{
829
  pop$ s #1 #22 substring$ duplicate$ "Conference Proceedings" =
830
    {pop$ "Proceedings" s #23 global.max$ substring$}{
831
  pop$ s #1 #6 substring$ duplicate$ "Annals" =
832
    {s #7 global.max$ substring$}{
833
  pop$ s #1 #5 substring$ duplicate$ "Actas" =
834
    {s #6 global.max$ substring$}{
835
  pop$ s #1 #5 substring$ duplicate$ "Anais" =
836
    {s #6 global.max$ substring$}{
837
  pop$ s #1 #6 substring$ duplicate$ "Anales" =
838
    {s #7 global.max$ substring$}{
839
  pop$ s #1 #8 substring$ duplicate$ "Memorias" =
840
    {s #9 global.max$ substring$}{
841
  pop$ s #1 #22 substring$ duplicate$ "Trabajos Seleccionados" =
842
    {s #23 global.max$ substring$}{
843
  pop$ s #1 #11 substring$ duplicate$ "Tagungsband" =
844
    {s #12 global.max$ substring$}
845
    {pop$ "Proceedings" s} if$
846
  } if$
847
  } if$
848
  } if$
849
  } if$
850
  } if$
851
  } if$
852
  } if$
853
  } if$
854
  } if$
855
  } if$
856
}
857

858
%==============================================================================
859
% Converte um booktitle do tipo "Proc. of XXX" no padrao ABNT
860
% Recebe na pilha o titulo original
861
% Devolve na pilha, na ordem:
862
% - o tipo de publicacao
863
% - o titulo ja' formatado (em maiusculas e com a edicao)
864
%==============================================================================
865
FUNCTION {process.proceedings.booktitle}
866
{
867
  extract.proceedings.type
868
  duplicate$ find.first.uppercase.char split.string "u" change.case$
869
  swap$ extract.first.number
870
  duplicate$ empty$
871
    'pop$
872
    {", " swap$ * * "." *}
873
  if$
874
}
875

876
%==============================================================================
877
% Estas funcoes formatam partes comuns a varios tipos de referencia.
878
%==============================================================================
879
FUNCTION {format.publication}
880
{
881
  ""
882
  address empty$
883
    {
884
      "[S.l."
885
      format.publisher empty$
886
        {":~s.n.]" *}
887
        {"]: " format.publisher * *}
888
      if$ add.year add.to.item
889
    }
890
    {
891
      format.address
892
      format.publisher empty$
893
        {": [s.n.]" *}
894
        {": " format.publisher * *}
895
      if$ add.year add.to.item
896
    }
897
  if$
898
}
899

900
FUNCTION {format.proceedings.publication}
901
{
902
  publisher empty$
903
    {"[S.l.:~s.n.]"}
904
    {publisher comma.to.colon}
905
  if$ add.year
906
}
907

908
FUNCTION {format.misc.publication}
909
{
910
  address empty$
911
  publisher empty$
912
  and
913
    {""}
914
    {format.publication}
915
  if$
916
}
917

918
FUNCTION {format.series.info}
919
{
920
  "(" format.series *
921
  add.volume ")" *
922
}
923

924
FUNCTION {format.complementary.data.with.totalpages}
925
{
926
  "" format.totalpages add.to.item
927
  ""
928
  series empty$
929
    {add.volume add.number add.to.item}
930
    {add.number add.to.item format.series.info add.to.item}
931
  if$
932
}
933

934
FUNCTION {format.complementary.data.with.page.range}
935
{
936
  ""
937
  series empty$
938
    {add.volume add.number add.pages}
939
    {"" add.number add.pages add.to.item format.series.info add.to.item}
940
  if$
941
}
942

943
%
944
% esta funcao recebe o titulo a ser formatado
945
%
946
FUNCTION {format.proceedings.booktitle}
947
{
948
  process.proceedings.booktitle "" swap$ add.year add.address add.to.item
949
  swap$ "{\ldots}" * emphasize " " swap$ * *
950
}
951

952
%==============================================================================
953
% Formatacao das entradas
954
%==============================================================================
955
FUNCTION {article}
956
{
957
  ""
958
  format.author add.to.item
959
  #0 title format.title add.to.item
960
  journal emphasize
961
    address empty$ {
962
      "[S.l.]" add.to.list
963
    }{
964
      add.address
965
    } if$
966
    add.volume add.number add.pages add.month.year add.to.item
967
  format.note add.to.item
968

969
  write.item
970
}
971

972
FUNCTION {book}
973
{
974
  ""
975
  editor empty$
976
    {format.author}
977
    {format.editor}
978
  if$ add.to.item
979
  #1 title format.title add.to.item
980
  format.edition add.to.item
981
  format.publication add.to.item
982
  format.complementary.data.with.totalpages add.to.item
983
  format.note add.to.item
984

985
  write.item
986
}
987

988
FUNCTION {inbook}
989
{
990
  ""
991
  editor empty$
992
    {format.author}
993
    {format.editor}
994
  if$ add.to.item
995
  #1 title format.title add.to.item
996
  format.edition add.to.item
997
  format.publication add.to.item
998
  format.complementary.data.with.page.range add.to.item
999
  format.note add.to.item
1000

1001
  write.item
1002
}
1003

1004
FUNCTION {incollection}
1005
{
1006
  ""
1007
  format.author add.to.item
1008
  #0 title format.title add.to.item
1009
  "In:"
1010
    editor empty$
1011
      'skip$
1012
      {format.editor add.to.item}
1013
    if$ 
1014
    #1 booktitle format.title add.to.item add.to.item
1015
  format.edition add.to.item
1016
  format.publication add.to.item
1017
  format.complementary.data.with.page.range add.to.item
1018
  format.note add.to.item
1019

1020
  write.item
1021
}
1022

1023
FUNCTION {inproceedings}
1024
{
1025
  ""
1026
  format.author add.to.item
1027
  #0 title format.title add.to.item
1028
  " In: " booktitle format.proceedings.booktitle * *
1029
  format.proceedings.publication add.to.item
1030
  format.complementary.data.with.page.range add.to.item
1031
  format.note add.to.item
1032

1033
  write.item
1034
}
1035

1036
FUNCTION {manual}
1037
{
1038
  ""
1039
  author empty$
1040
    {format.entrytitle add.to.item}
1041
    {
1042
      format.author add.to.item
1043
      #1 title format.title add.to.item
1044
    }
1045
  if$
1046

1047
  format.edition add.to.item
1048
  format.publication add.to.item
1049
  format.complementary.data.with.totalpages add.to.item
1050
  format.note add.to.item
1051

1052
  write.item
1053
}
1054

1055
FUNCTION {mastersthesis}
1056
{
1057
  ""
1058
  format.author add.to.item
1059
  #1 title format.title add.to.item
1060
  format.year add.to.item
1061
  format.totalpages add.to.item
1062
  str:mastersthesis format.type " --- " * format.publisher *
1063
    add.address add.to.item
1064
  format.note add.to.item
1065
  format.parenthised.number add.to.item
1066

1067
  write.item
1068
}
1069

1070
FUNCTION {misc}
1071
{
1072
  ""
1073
  author empty$
1074
    {
1075
      title empty$
1076
        'skip$
1077
        {format.entrytitle add.to.item}
1078
      if$
1079
    }
1080
    {
1081
      format.author add.to.item
1082
      title empty$
1083
        'skip$
1084
        {#1 title format.title add.to.item}
1085
      if$
1086
    }
1087
  if$
1088
    
1089
  format.misc.publication add.to.item
1090
  format.complementary.data.with.totalpages add.to.item
1091
  format.note add.howpublished add.to.item
1092

1093
    format.url add.to.item
1094
    format.urldate add.to.item
1095
        
1096
  write.item
1097
}
1098

1099
FUNCTION {phdthesis}
1100
{
1101
  ""
1102
  format.author add.to.item
1103
  #1 title format.title add.to.item
1104
  format.year add.to.item
1105
  format.totalpages add.to.item
1106
  str:phdthesis format.type " --- " * format.publisher *
1107
    add.address add.to.item
1108
  format.note add.to.item
1109
  format.parenthised.number add.to.item
1110

1111
  write.item
1112
}
1113

1114
FUNCTION {proceedings}
1115
{
1116
  ""
1117
  title format.proceedings.booktitle *
1118
  format.proceedings.publication add.to.item
1119
  format.complementary.data.with.page.range add.to.item
1120
  format.note add.to.item
1121

1122
  write.item
1123
}
1124

1125
FUNCTION {techreport}
1126
{
1127
  ""
1128
  format.author add.to.item
1129
  #1 title format.title add.to.item
1130
  format.publication add.to.item
1131
  type empty$
1132
    {""}
1133
    {type}
1134
  if$ add.note add.to.item
1135
  format.parenthised.number add.to.item
1136

1137
  write.item
1138
}
1139

1140
FUNCTION {booklet} {misc}
1141
FUNCTION {unpublished} {misc}
1142
FUNCTION {default.type} {misc}
1143

1144
%==============================================================================
1145
% Inicializa algumas variaveis globais
1146
%==============================================================================
1147
FUNCTION {init}
1148
{
1149
  "" 'last.label :=
1150
  "b" 'current.letter :=
1151
}
1152

1153
%==============================================================================
1154
% Retorna na pilha o string a ser usado para a ordenacao das entradas.
1155
%==============================================================================
1156
FUNCTION {get.sortstring}
1157
{
1158
  author empty$ not {format.author " AAA" *}{
1159
  editor empty$ not {format.editor " AAA" *}{
1160
  title empty$ not {title}{
1161
  note empty$ not {note}{
1162
  key empty$ not {key}{
1163
  "???"
1164
  } if$
1165
  } if$
1166
  } if$
1167
  } if$
1168
  } if$
1169

1170
  type$ "inbook" =
1171
  booktitle empty$ not
1172
  and
1173
    {
1174
      booktitle title = not
1175
        {pop$ title}
1176
        'skip$
1177
      if$
1178
    }
1179
    'skip$
1180
  if$
1181

1182
  type$ "proceedings" = {
1183
    pop$
1184
    title process.proceedings.booktitle
1185
    swap$ pop$
1186
  }
1187
    'skip$
1188
  if$
1189
  purify$ "l" change.case$
1190
}
1191

1192
%==============================================================================
1193
% Define as ``keys'' para ordenacao
1194
%==============================================================================
1195
FUNCTION {set.sortkeys}
1196
{
1197
  get.sortstring
1198
  format.year *
1199
  #1 entry.max$ substring$
1200
  #1 global.max$ substring$
1201
  'sort.key$ :=
1202
}
1203

1204
%==============================================================================
1205
% Ajusta os labels, adicionando letras minusculas aos labels de mesmo autor e
1206
% ano
1207
%==============================================================================
1208
FUNCTION {adjust.label}
1209
{
1210
        last.label
1211
        label 'last.label :=
1212
        label = {
1213
                current.letter 'year.char :=
1214
                current.letter chr.to.int$
1215
                #1 + int.to.chr$
1216
                'current.letter :=
1217
        }{
1218
    "" 'year.char :=
1219
                "b" 'current.letter :=
1220
  } if$
1221
}
1222
FUNCTION {reverse.adjust.label}
1223
{
1224
        last.year.char "b" = {
1225
    "a" 'year.char :=
1226
  }
1227
    'skip$
1228
  if$
1229
        year.char 'last.year.char :=
1230
}
1231

1232
%==============================================================================
1233
% Retorna na pilha o string a ser usado para a construcao do label. Quase sempre
1234
% sera' o sobrenome do primeiro autor, mas para alguns tipos de referencia pode
1235
% ser o editor, a entidade ou o titulo
1236
%==============================================================================
1237
FUNCTION {get.labelstring}
1238
{
1239
  author empty$ not
1240
    {author format.family.names}
1241
    {
1242
      editor empty$ not
1243
        {editor format.family.names}
1244
        {
1245
          title empty$ not
1246
            {title "u" change.case$}
1247
            {
1248
              key empty$ not
1249
                {key}
1250
                {"???"}
1251
              if$
1252
            }
1253
          if$
1254
        }
1255
      if$
1256
    }
1257
  if$
1258

1259
  type$ "inbook" =
1260
  booktitle empty$ not
1261
  and
1262
    {
1263
      booktitle title = not
1264
        {pop$ title "u" change.case$}
1265
        'skip$
1266
      if$
1267
    }
1268
    'skip$
1269
  if$
1270
}
1271

1272
%==============================================================================
1273
% Retorna na pilha o string a ser usado para a construcao do label. Quase sempre
1274
% sera' o sobrenome do primeiro autor, mas para alguns tipos de referencia pode
1275
% ser o editor, a entidade ou o titulo
1276
%
1277
% esta versao retorna os nomes completos
1278
%==============================================================================
1279
FUNCTION {get.labelstring.all}
1280
{
1281
  author empty$ not
1282
    {author format.family.names.all}
1283
    {
1284
      editor empty$ not
1285
        {editor format.family.names.all}
1286
        {
1287
          title empty$ not
1288
            {title "u" change.case$}
1289
            {
1290
              key empty$ not
1291
                {key}
1292
                {"???"}
1293
              if$
1294
            }
1295
          if$
1296
        }
1297
      if$
1298
    }
1299
  if$
1300

1301
  type$ "inbook" =
1302
  booktitle empty$ not
1303
  and
1304
    {
1305
      booktitle title = not
1306
        {pop$ title "u" change.case$}
1307
        'skip$
1308
      if$
1309
    }
1310
    'skip$
1311
  if$
1312
}
1313

1314
%==============================================================================
1315
% Construção dos labels
1316
%==============================================================================
1317
FUNCTION {prepare.label.sorting}
1318
{
1319
  get.labelstring.all format.year *
1320
  duplicate$ 'label := 'sort.key$ :=
1321
}
1322
FUNCTION {make.label}
1323
{
1324
  get.labelstring
1325
  "(" *
1326
  year empty$ {
1327
    "????"
1328
  }{
1329
    year year.char *
1330
  } if$ *
1331
  ")" *
1332
  get.labelstring.all *
1333
  #1 entry.max$ substring$
1334
  #1 global.max$ substring$
1335
  'label :=
1336
}
1337

1338
%==============================================================================
1339
% Inicia a definicao das referencias
1340
%==============================================================================
1341
FUNCTION {begin.bib}
1342
{
1343
  preamble$ empty$
1344
    'skip$
1345
    {preamble$ write$ newline$ newline$}
1346
  if$
1347
  "\begin{thebibliography}{\hspace{\parindent}}" write$ newline$
1348
  newline$
1349
}
1350

1351
%==============================================================================
1352
% Termina a definicao das referencias
1353
%==============================================================================
1354
FUNCTION {end.bib}
1355
{
1356
  "\end{thebibliography}" write$ newline$
1357
}
1358

1359
%==============================================================================
1360
% main()
1361
%==============================================================================
1362
READ
1363
EXECUTE {init}
1364
ITERATE {prepare.label.sorting}
1365
SORT
1366
ITERATE {adjust.label}
1367
REVERSE {reverse.adjust.label}
1368
ITERATE {make.label}
1369
ITERATE {set.sortkeys}
1370
SORT
1371
EXECUTE {begin.bib}
1372
ITERATE {call.type$}
1373
EXECUTE {end.bib}
1374