[PATCH] man2hlp breaks links in help file



Hi all,

src/man2hlp.c utility sometimes replaces spaces in the link target with newlines.
There is a workaround code in src/help.c:141, which handles that case.

But it doesn't always help. If the link is used inside the indented
block (made by .TP tag), man2hlp will insert additional spaces inside the link. For example, the link "Directory tree" will become "Directory\n Tree".
This will result to a broken link.

Currently, in Russian help file there are two such broken links
(one in "Listing Mode..." section, and the other one in "Options/Virtual FS" section). The result of trying to follow such broken link is displayed at this screenshot:
http://img227.imageshack.us/img227/179/mcbrokenlinkmo3.png

It is lucky that there are no such broken links in English help,
but they can appear in the future.

So I made a patch for the man2hlp utility, to make man2hlp never insert
newline and spaces inside the link target.
Only the link target (the invisible part of the link) is affected by the patch.
The link name itself (that is visible in the Help Viewer) can always
be wrapped to another line, and it never causes problems.


Regards,
 Grigory Trenin.

--

Grigory Trenin  <gtrenin gmail com>
       * src/man2hlp.c (print_string): Don't insert spaces or newlines
         in link target.


--- src/man2hlp.c.orig  2005-10-12 01:56:49.000000000 +0400
+++ src/man2hlp.c       2006-11-20 15:34:05.000000000 +0300
@@ -252,8 +252,11 @@
           if (*(buffer)) {
               len = string_len (buffer);
               /* Change the line if about to break the right margin */
-               if (col + len >= HELP_TEXT_WIDTH)
-                   newline ();
+ /* But avoid inserting newlines and spaces inside the link */
+                if (len && (strchr(buffer, CHAR_LINK_POINTER) != NULL ||
+                           strchr(buffer, CHAR_LINK_END) == NULL))
+                   if (col + len >= HELP_TEXT_WIDTH)
+                       newline ();
               /* Words are separated by spaces */
               if (col > 0) {
                   fputc (' ', f_out);




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]