[sword-devel] another OSIS weirdness: headers in LEB

Karl Kleinpaste karl at kleinpaste.org
Thu Mar 25 04:51:15 MST 2010


So the new LEB from Logos came out, and there's a new module in the
CrossWire repo.  I picked it up, and I turned on footnotes and headings.

Before I turned on headings, display looked pretty normal, though I
could question excess line breaks in Matt 1:23.  Turning on headings, I
get this psychotically overwrought whitespace nightmare, and I've got no
actual headings.

Screenshots are too big to send to the list, so look here:
http://karl.kleinpaste.org/.../LEB-Mat1-noHeadings.png
http://karl.kleinpaste.org/.../LEB-Mat1-Headings.png

The lack of real headings concerned me pretty seriously, considering
that I had looked at the OSIS source and could see them there, so I
started up gdb and breakpointed Xiphos to see what it was doing with
headers.  This heading analysis works in every other OSIS module.

	sprintf(heading, "%d", x);
	while ((preverse = be->get_entry_attribute("Heading", "Preverse",
							heading)) != NULL) {
		preverse2 = mod.RenderText(preverse);
		text = g_strdup_printf("<br><b>%s</b><br><br>",
				       (((ops->strongs || ops->lemmas) ||
					ops->morphs)
					? block_render(preverse2)
					: preverse2));
		CleanupContent(text, ops, mod.Name());

		cVerse.AppendHeader(text);
		g_free((gchar *)text);
		g_free((gchar *)preverse);
		++x;
		sprintf(heading, "%d", x);
	}

"be" is our backend object, accessing the engine.  We get the heading,
we render it according to the module's needs, and then we wrap it in a
bit of extra HTML markup before we append it to the total.

Here's a copy/paste of using gdb to watch this happen, for Matt 2:1,
which has a heading, "Wise Men Visit Jesus."

| (gdb) s
| CacheHeader (cVerse=..., mod=..., ops=0x51c3fa0, be=0xbb4860) at ../src/main/display.cc:773
| 773		int x = 0;
| (gdb) n
| 778		cVerse.SetHeader("");
| (gdb) 
| 780		sprintf(heading, "%d", x);
| (gdb) p cVerse
| $4 = (ModuleCache::CacheVerse &) @0x2137048: {_text = 
|     0x51e0ec0 "Now <i>after</i><a href=\"passagestudy.jsp?action=showNote&type=n&value=1&module=LEB&passage=Matthew+2%3A1\"><small><sup>*n</sup></small></a> Jesus was born in Bethlehem of Judea in the days of Herod th"..., _header = 0x50bcc10 "", _flags = 11269}
| (gdb) n
| 781		while ((preverse = be->get_entry_attribute("Heading", "Preverse",
| (gdb) 
| 783			preverse2 = mod.RenderText(preverse);
| (gdb) p preverse
| $5 = (const gchar *) 
|     0x51dfff0 "<div sID=\"gen43\" type=\"section\"/> <title>Wise Men Visit Jesus</title> <div sID=\"gen44\" type=\"paragraph\"/>"
| (gdb) n
| 788						: preverse2));
| (gdb) p preverse2
| $6 = (const gchar *) 0x3b9c9c0 " <b></b><br /> <!P><br />"
| (gdb) n
| 789			CleanupContent(text, ops, mod.Name());
| (gdb) p text
| $7 = (gchar *) 0x51bfa80 "<br><b> <b></b><br /> <!P><br /></b><br><br>"
| (gdb) n
| 791			cVerse.AppendHeader(text);

Please note, at $5 we had a normal OSIS heading, but just one line of
code execution later, at $6 what has come back from RenderText()
is...total nonsense.  A space, an empty bold sequence (where "Wise Men
Visit Jesus" should have appeared), a line break, a paragraph break, and
a line break?  No wonder it looks psychotic.

I don't know what to say about it.  I can't very well go looking for
what's happening inside Xiphos, because this works fine for KJV and beta
NASB and every other OSIS module.  But on LEB, RenderText() is simply
freaked out for some reason.  Encoding problem?  osis2mod problem?

I'm using Sword at -r2507.



More information about the sword-devel mailing list