Re: [patch] fix natbib conversion

Juergen Spitzmueller <[email protected]> Mon, 30 Jul 2007 10:41:09 +0200
Newsgroups gmane.comp.tex.latex.latex2rtf.devel
Message-ID <[email protected]>
--nextPart3816507.luzr7CCOWR
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Tyler Smith wrote:
> Hi Jurgen,
>=20
> I applied your patch to 1.9.16a, and then merged that into the current
> version (svn revision 570). I only did a very cursory test of the
> patch, but it does now appear to work as it should.

Thanks, Tyler. Glad to see the work on latex2rtf continues.

Please find attached an updated patch (against current svn) that fixes is=
sue
#1635471 (citet with multiple years) for me. I've not only fixed citet, b=
ut
all natbib styles with multiple years.

Regards,
J=C3=BCrgen

> Thanks,
>=20
> Tyler


--nextPart3816507.luzr7CCOWR
Content-Type: text/x-diff; name="xref.diff"
Content-Disposition: attachment; filename="xref.diff"
Content-Transfer-Encoding: quoted-printable

Index: xref.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- xref.c	(Revision 570)
+++ xref.c	(Arbeitskopie)
@@ -810,7 +810,11 @@
             if (strcmp(v, g_last_author_cited) =3D=3D 0)
                 author_repeated =3D TRUE;
=20
+	    if (strncmp(year, g_last_year_cited, 4) =3D=3D 0)   /* over simplis=
tic test * ... */
+		year_repeated =3D TRUE;
+
             if (!first && !author_repeated) {
+		ConvertString(g_bibpunct_close);
             	ConvertString(g_bibpunct_cite_sep);
                 fprintRTF(" ");
             }
@@ -832,32 +836,44 @@
                 author_repeated =3D TRUE;
=20
             if (!first && !author_repeated) {
+		ConvertString(g_bibpunct_close);
             	ConvertString(g_bibpunct_cite_sep);
                 fprintRTF(" ");
             }
=20
-            if (!author_repeated) { /* suppress repeated names */
+	    if (!author_repeated) { /* suppress repeated names */
                 ConvertString(v);
                 strcpy(g_last_author_cited, v);
                 strcpy(g_last_year_cited, year);
-            }
-
-			if (g_bibpunct_style =3D=3D BIB_STYLE_ALPHA){
+		if (g_bibpunct_style =3D=3D BIB_STYLE_ALPHA) {
+			fprintRTF(" ");
+			ConvertString(g_bibpunct_open);
+			if (pre) {
+				ConvertString(pre);
 				fprintRTF(" ");
-				ConvertString(g_bibpunct_open);
-			=09
-				if (pre) {
-					ConvertString(pre);
-					fprintRTF(" ");=20
-				}
-
-				ConvertString(year);
-				if (last && post && !isEmptyName(post)) {
-					ConvertString(g_bibpunct_postnote_sep);
-					ConvertString(post);
-				}
-				ConvertString(g_bibpunct_close);
+			}
+			ConvertString(year);
+		}
+	    } else if (g_bibpunct_style =3D=3D BIB_STYLE_ALPHA) {
+		if (!year_repeated) {
+			ConvertString(g_bibpunct_numbers_sep);
+			fprintRTF(" ");
+			ConvertString(year);
+                } else {
+			char *s =3D strdup(year + 4);
+			ConvertString(g_bibpunct_numbers_sep);
+			ConvertString(s);
+			free(s);
+                }
             }
+	    if (g_bibpunct_style =3D=3D BIB_STYLE_ALPHA) {
+		if (last && post && !isEmptyName(post)) {
+			ConvertString(g_bibpunct_postnote_sep);
+			ConvertString(post);
+		}
+		if (last)
+			ConvertString(g_bibpunct_close);
+            }
             break;
=20
         case CITE_ALT:
@@ -868,6 +884,9 @@
             if (strcmp(v, g_last_author_cited) =3D=3D 0)
                 author_repeated =3D TRUE;
=20
+	    if (strncmp(year, g_last_year_cited, 4) =3D=3D 0)   /* over simplis=
tic test * ... */
+                year_repeated =3D TRUE;
+
             if (!first && !author_repeated) {
             	ConvertString(g_bibpunct_cite_sep);
                 fprintRTF(" ");
@@ -877,17 +896,24 @@
                 ConvertString(v);
                 strcpy(g_last_author_cited, v);
                 strcpy(g_last_year_cited, year);
-            }
-
+		fprintRTF(" ");
+		if (pre) {
+			ConvertString(pre);
 			fprintRTF(" ");
-		=09
-			if (pre) {
-				ConvertString(pre);
-				fprintRTF(" ");
-			}
-
+		}
+		ConvertString(year);
+	    } else {
+		if (!year_repeated) {
+			ConvertString(g_bibpunct_numbers_sep);
+			fprintRTF(" ");
 			ConvertString(year);
-
+		} else {
+			char *s =3D strdup(year + 4);
+			ConvertString(g_bibpunct_numbers_sep);
+			ConvertString(s);
+			free(s);
+		}
+	    }
 			if (last && post && !isEmptyName(post)) {
 			        ConvertString(g_bibpunct_postnote_sep);
 				ConvertString(post);
@@ -901,6 +927,9 @@
             if (strcmp(v, g_last_author_cited) =3D=3D 0)
                 author_repeated =3D TRUE;
=20
+            if (strncmp(year, g_last_year_cited, 4) =3D=3D 0)   /* over =
simplistic test * ... */
+                year_repeated =3D TRUE;
+
             if (!first && !author_repeated) {
             	ConvertString(g_bibpunct_cite_sep);
                 fprintRTF(" ");
@@ -972,8 +1001,7 @@
                     ConvertString(year);
                 } else {
                     char *s =3D strdup(year + 4);
-
-                    fprintRTF(",");
+                    ConvertString(g_bibpunct_numbers_sep);
                     ConvertString(s);
                     free(s);
                 }


--nextPart3816507.luzr7CCOWR
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
--nextPart3816507.luzr7CCOWR
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Latex2rtf-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/latex2rtf-developers

--nextPart3816507.luzr7CCOWR--