[patch] fix natbib conversion
Juergen Spitzmueller <[email protected]> Thu, 04 Jan 2007 19:31:33 +0100
| Newsgroups | gmane.comp.tex.latex.latex2rtf.devel |
|---|---|
| Message-ID | <[email protected]> |
--nextPart2658145.gmgorcnYXc
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Hi,
I've fixed some issues with natbib conversion in latex2rtf-1.9.16a:
- \bibpunct parsing was broken (as soon as you chose the optional argumen=
t,
everything was messed up).
- the optional argument of \bibpunct was not read in correctly
- the parsing of natbibs (unusual) optional arguments was wrong
- the positioning of the first and second argument (which depends on the
actual cite command as well as from whether there are multiple keys)
differed from the dvi output.
The output (including first and second argument and bibpunct) is now exac=
tly
the same as in the dvi.
Please find attached a diff against 1.9.16a.
Regards,
J=C3=BCrgen
--nextPart2658145.gmgorcnYXc
Content-Type: text/x-diff; name="xref.diff"
Content-Disposition: attachment; filename="xref.diff"
Content-Transfer-Encoding: quoted-printable
--- xref.c 2007-01-04 19:14:32.000000000 +0100
+++ latex2rtf-1.9.16a/xref.c 2007-01-04 19:20:20.000000000 +0100
@@ -645,7 +645,7 @@
return 0;
}
=20
-static void ConvertNatbib(char *s, int code, char *pre, char *post, int =
first)
+static void ConvertNatbib(char *s, int code, char *pre, char *post, int =
first, int last)
{
char *n, *year, *abbv, *full, *v;
int author_repeated, year_repeated;
@@ -723,12 +723,13 @@
fprintRTF(" ");
ConvertString(g_bibpunct_open);
=09
- ConvertString(year);
if (pre) {
- ConvertString(g_bibpunct_postnote_sep);
ConvertString(pre);
+ fprintRTF(" ");
}
- if (post) {
+
+ ConvertString(year);
+ if (last && post && !isEmptyName(post)) {
ConvertString(g_bibpunct_postnote_sep);
ConvertString(post);
}
@@ -755,20 +756,15 @@
}
=20
fprintRTF(" ");
- =09
- if (pre && post) {
+
+ if (pre) {
ConvertString(pre);
fprintRTF(" ");
}
-
+ =09
ConvertString(year);
=20
- if (pre && !post) {
- fprintRTF(", ");
- ConvertString(pre);
- }
-
- if (post) {
+ if (last && post && !isEmptyName(post)) {
ConvertString(g_bibpunct_postnote_sep);
ConvertString(post);
}
@@ -785,10 +781,10 @@
fprintRTF(" ");
}
=20
- if (pre && post && first) {
- ConvertString(pre);
- fprintRTF(" ");
- }
+ if (pre && g_current_cite_item =3D=3D 1) {
+ ConvertString(pre);
+ fprintRTF(" ");
+ }
=20
if (!author_repeated) { /* suppress repeated names */
ConvertString(v);
@@ -800,12 +796,7 @@
=09
ConvertString(year);
=20
- if (pre && !post) {
- fprintRTF(", ");
- ConvertString(pre);
- }
-
- if (post && *post !=3D '\0') {
+ if (last && post && !isEmptyName(post)) {
ConvertString(g_bibpunct_postnote_sep);
ConvertString(post);
}
@@ -828,11 +819,9 @@
if (strncmp(year, g_last_year_cited, 4) =3D=3D 0) /* over =
simplistic test * ... */
year_repeated =3D TRUE;
=20
- if (pre && post!=3DNULL && g_current_cite_item =3D=3D 1) {
- if (*pre) {
- ConvertString(pre);
+ if (pre && g_current_cite_item =3D=3D 1) {
+ ConvertString(pre);
fprintRTF(" ");
- }
}
if (!first && !author_repeated) {
ConvertString(g_bibpunct_cite_sep);
@@ -860,15 +849,9 @@
}
}
=20
- if (pre && post=3D=3DNULL) {
- ConvertString(g_bibpunct_postnote_sep);
- ConvertString(pre);
- fprintRTF(" ");
- }
- if (post && *post !=3D '\0') {
+ if (last && post && !isEmptyName(post)) {
ConvertString(g_bibpunct_postnote_sep);
ConvertString(post);
- fprintRTF(" ");
}
break;
=20
@@ -885,7 +868,13 @@
if (CITE_AUTHOR_STAR =3D=3D code)
if (!isEmptyName(full))
v =3D full;
+
ConvertString(v);
+
+ if (last && post && !isEmptyName(post)) {
+ ConvertString(g_bibpunct_postnote_sep);
+ ConvertString(post);
+ }
break;
=20
case CITE_YEAR:
@@ -895,21 +884,15 @@
fprintRTF(" ");
}
=20
- if (CITE_YEAR !=3D code && pre && !isEmptyName(post) && g_cu=
rrent_cite_item =3D=3D 1) {
+ if (CITE_YEAR !=3D code && pre && g_current_cite_item =3D=3D=
1) {
ConvertString(pre);
fprintRTF(" ");
}
ConvertString(year);
=20
- if (pre && isEmptyName(post)) {
- ConvertString(g_bibpunct_postnote_sep);
- ConvertString(pre);
- fprintRTF(" ");
- }
- if (post && *post !=3D '\0') {
+ if (last && post && !isEmptyName(post)) {
ConvertString(g_bibpunct_postnote_sep);
ConvertString(post);
- fprintRTF(" ");
}
break;
}
@@ -1001,7 +984,8 @@
if (s) {
if (g_bibpunct_postnote_sep)
free(g_bibpunct_postnote_sep);
- g_bibpunct_postnote_sep=3DgetBraceParam();
+ g_bibpunct_postnote_sep =3D strdup(s);
+ free(s);
}
=09
free(g_bibpunct_open);
@@ -1285,6 +1269,7 @@
char *option =3D NULL;
char *pretext =3D NULL;
int first_key =3D TRUE;
+ int last_key =3D FALSE;
=20
/* Setup punctuation and read options before citation */
g_current_cite_paren =3D TRUE;
@@ -1298,6 +1283,10 @@
=09
pretext =3D getBracketParam();
option =3D getBracketParam();
+ if (!option) {
+ option =3D pretext;
+ pretext =3D '\0';
+ }
if (code !=3D CITE_P && code !=3D CITE_P_STAR && code !=3D CITE_YEAR_P)
g_current_cite_paren =3D FALSE;
=20
@@ -1362,7 +1351,7 @@
diagnostics(3, "natbib key=3D[%s] <%s> ", key, s);
if (s) {
g_current_cite_seen =3D citation_used(key);
- ConvertNatbib(s, code, pretext, option, first_key);
+ ConvertNatbib(s, code, pretext, option, first_key, last_key);
} else {
if (!first_key) {
ConvertString(g_bibpunct_cite_sep);
@@ -1376,6 +1365,7 @@
=20
key =3D next_keys;
next_keys =3D popCommaName(key);
+ last_key =3D !next_keys;
}
=20
if (g_current_cite_paren)
--nextPart2658145.gmgorcnYXc
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
--nextPart2658145.gmgorcnYXc
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
--nextPart2658145.gmgorcnYXc--