Shortened page ranges
[latex-mlastyle.git] / mlastyle.bst
index fb0778a5d1b1b3177b361ef0f5b9c49ba8cd2dfc..83f4b76b6161947f6c09657cb2d6e230279bb0ae 100644 (file)
@@ -1,4 +1,4 @@
-% $Id: mlastyle.bst,v 1.12 2003-11-22 05:54:34 tpope Exp $
+% $Id: mlastyle.bst,v 1.13 2003-11-22 19:15:11 tpope Exp $
 % BibTeX bibliography style `mlastyle'
 % Based on BibTeX standard bibliography style `plain'
        % version 0.99a for BibTeX versions 0.99a or later, LaTeX version 2.09.
@@ -589,11 +589,53 @@ FUNCTION {multi.page.check}
 FUNCTION {format.pages}
 { pages empty$
     { "" }
-    { %pages multi.page.check
-%      { "pages" pages n.dashify tie.or.space.connect }
-%      { "page" pages tie.or.space.connect }
-%      if$
-    pages n.dashify
+    {
+% j is positive if pages contains a comma
+% (not fully implemented)
+      #0 'j :=
+      pages n.dashify 't :=
+      ""
+       { t empty$ not }
+       { t #1 #2 substring$ "--" =
+           { t #3 global.max$ substring$ 't :=
+             duplicate$ num.chars 'i :=
+             "--" *
+             i t num.chars =
+               {   { i #2 > }
+                   { duplicate$ #1 i #2 - substring$
+                     t #1 i #2 - substring$ =
+                       { t i #1 - global.max$ substring$ * "" 't :=  #2 'i := }
+                       { i #1 - 'i := }
+                     if$
+                   }
+                 while$
+               }
+               'skip$
+             if$
+           }
+           { t #1 #1 substring$ *
+             t #2 global.max$ substring$ 't :=
+           }
+         if$
+       }
+      while$
+    }
+  if$
+}
+
+FUNCTION {format.year}
+{ year empty$
+    { "" }
+    { year n.dashify
+      duplicate$ duplicate$ num.chars #10 =
+      swap$ #5 #2 substring$ "--" = and
+       { duplicate$ duplicate$ #1 #2 substring$ swap$ #7 #2 substring$ =
+           { duplicate$ #1 #6 substring$ swap$ #8 #2 substring$ * }
+           {}
+         if$
+       }
+       {}
+      if$
     }
   if$
 }