Fix for broken {names}

"Paul Jungwirth" <[email protected]> Fri, 24 Mar 2006 16:27:43 -0500
Newsgroups gmane.comp.tex.bibtex.jurabib.devel
Message-ID <[email protected]>
Hello,

I noticed that jurabib v0.6 fails on names that shouldn't be
rearranged, like this:

"{Gregory the Theologian}"

The problem is in capitalize.von.part, which assumes that all braces
are special characters. It doesn't account for closing braces returned
by text.prefix$ (e.g. "{G}").

I wrote a fix for jox.bst. Here is a diff:

Index: jox.bst
===================================================================
--- jox.bst	(revision 447)
+++ jox.bst	(revision 452)
@@ -2054,29 +2054,51 @@
 }

 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-INTEGERS { nextchar-ptr }                % points just past 1st "text" char
+INTEGERS { first-char-pos }

-FUNCTION {get.nextchar.ptr}              % set nextchar-ptr to be just past
-{ #1 'nextchar-ptr :=                    % the first "text" char---this will
-    { duplicate$                         % be not quite trivial if
-      nextchar-ptr #1 substring$         % the first "text" char is a
-      "" = not                           % special characters like {\'E}
-    }
-    { nextchar-ptr #1 + 'nextchar-ptr := }
-  while$
+% Returns true if passed an alphanumeric, hyphen, tilde, or space,
+% false otherwise.
+FUNCTION {is.a.char}
+{
+  duplicate$ "-" =
+  { #1 }
+  {
+    duplicate$ "~" =
+	{ #1 }
+	{
+	  duplicate$ purify$ =
+	} if$
+  } if$
+}
+
+FUNCTION {find.first.char}
+{
+  #1 'first-char-pos :=
+
+  % Loop while the current char is not a char:
+  {
+    duplicate$ first-char-pos #1 substring$
+	duplicate$ is.a.char not
+	swap$ "" = not and			% Stop looping at the string's end
+  }
+  {
+    first-char-pos #1 + 'first-char-pos :=
+  } while$
+
   pop$
-  nextchar-ptr
+  first-char-pos
 }

-STRINGS { first-char }                   % the to-be-capitalized character
+FUNCTION {capitalize.von.part}
+{
+  % Find the first character:
+  duplicate$ find.first.char 'first-char-pos :=

-FUNCTION {capitalize.von.part}           % capitalize 1st character of string
-{ duplicate$ #1 text.prefix$             % get 1st character
-  duplicate$ get.nextchar.ptr
-  swap$ "u" change.case$                 % capitalize it
-  'first-char :=
-  global.max$ substring$                 % get rest of string
-  first-char swap$ *                     % append the two
+  % Make the first character be uppercase:
+  duplicate$ #1 first-char-pos substring$ "u" change.case$
+
+  % Append the rest of the name:
+  swap$ first-char-pos #1 + global.max$ substring$ *
 }
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

If anyone has the same problem, I hope this helps!

Paul
--
_________________________________
Pulchritudo splendor veritatis.


 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/jurabib-developer/

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/