Bug 106067 - man:groff(7) cannot show the request names
Summary: man:groff(7) cannot show the request names
Status: RESOLVED FIXED
Alias: None
Product: kio
Classification: Frameworks and Libraries
Component: man (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Unassigned bugs mailing-list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-05-21 16:06 UTC by Nicolas Goutte
Modified: 2011-01-07 22:05 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nicolas Goutte 2005-05-21 16:06:22 UTC
Version:            (using KDE Devel)
Installed from:    Compiled sources
Compiler:          gcc 3.3.1 -march=pentium2
OS:                Linux

groff(7) uses macro to define new requests. With one of those new requests, it display the name of the groff requests in the list explaining what requests groff(1) supports. It displays @tmp@ instead.

It seems that man2html needs a little more knowledge about macros.
Comment 1 Nicolas Goutte 2005-05-21 17:37:13 UTC
SVN commit 416452 by goutte:

First step of supporting string variables with long names (long > 2 chars)
(For now, it just put in red, when the page wants such a variable.)
CCBUG:106067


 M  +55 -13    trunk/KDE/kdebase/kioslave/man/man2html.cpp  
Comment 2 Nicolas Goutte 2005-05-24 23:41:22 UTC
SVN commit 417884 by goutte:

Start working on long names and on unifying string and macro definitions:
- create one class and a QMap to store string and macro definitions.
- port strings to this new class and QMap
- allow strings with long names

CCBUG:106067
It fixes bug 106067 when taken to the letter. However there is still plenty
to do for displaying groff(7) correctly, for example macros with long names.

(Note: this breaks -DSIMPLE_MAN2HTML (temporarily))


 M  +171 -108  man2html.cpp  
Comment 3 Nicolas Goutte 2005-05-25 01:14:55 UTC
SVN commit 417923 by goutte:

- Define macros in the same QMap than strings
- Macros can have long names now
I have no idea if it is in the right direction or not, as groff(7) looks
even worser than before.
CCBUG:106067


 M  +96 -116   man2html.cpp  
Comment 4 Nicolas Goutte 2005-05-25 13:45:09 UTC
SVN commit 418050 by goutte:

Fix the bug when calling macros
(The first line was not preceed by a line feed, so the first request was
ignored.)
(groff(7) looks now again better)
CCBUG:106067


 M  +42 -28    man2html.cpp  
Comment 5 Nicolas Goutte 2005-05-26 00:20:38 UTC
SVN commit 418213 by goutte:

Improve the groff basic support:
- make troff/nroff switchable by the requests .troff and .nroff
  (The mode is therefore not compilable anymore by a #define)
- put the strings declared by man(7) and mdoc(7) as strings and
  not as special character anymore
  (It was a mismatch that I had unfortunately introduced.)
- add the missing strings declared by mdoc(7)
- allow strings to be called by \* in its three modes: single letter,
  two letters, long name
- do not put the string name in red when it is not found, groff(7) tells
  that an undefined string is empty.
- support for $0 (the name of the macro)
- allow parameters to be called by \$ in its three modes: single digit,
  two digits, any number of digits. (But we are still limited in the
  numbers of arguments that we can process.)
- define .als ("ALias String"), however temporarily not as hard link
  but as simple copy.
  (As Qt4 has other classes than Qt3, it is better to postpone it.)
- fix .rn ("ReName string"), as the second parameter was not parsed.
CCBUG:106067

 M  +288 -109  man2html.cpp  
Comment 6 Nicolas Goutte 2005-05-27 00:35:26 UTC
SVN commit 418559 by goutte:

Improve the groff basic support:
- use a QMap to define number registers
- add a predefined string \*[.KDE_VERSION_STRING] giving the KDE version
- new predefined number registers \n[year] \n(yr \n(mo \n(dy \n(dw
  (year Y2K, year non-Y2K, month, day, day of week)
- replace argument list by a QValueList<char*>
- add support for \$* and \$@ ("all arguments")
- add read-only number registers, like \n[.$] or the 3 components of the
  KDE version.
- try to read all variants of \n including long names and auto-increments
  indicated after \n( or after \n[
- fix .nr to allow normal increments
  (Note: \R is still missing)
- define .rr and .rnn  (remove and rename number registers)
- define .aln ("ALias Number register"), however temporarily not as hard link
  but as simple copy.
  (As Qt4 has other classes than Qt3, it is better to postpone it.)
- define .shift (to shift arguments)
- be careful that the code allows a word list longer than 20
  (even if probably no macro has so much parameters)
- fix a few small details

CCBUG:106067
(The document looks again worser; what is really missing now is the request
.while)

 M  +414 -68   man2html.cpp   [POSSIBLY UNSAFE: scanf]
Comment 7 Nicolas Goutte 2005-05-27 13:07:45 UTC
SVN commit 418672 by goutte:

Improve the groff basic support:
- add support for the request .while (yes, finally!)
- allow more characters for an indentifier (nearly whole printable ASCII)
- be more careful when parsing an identifier as parameter of a request
  (There was an off-by-one error, which could make that the next line
  was skipped, because the right end of line was already passed.)
- no need to parse the first \n when calling a macro
  (This too is an off-by-one-error. The first \n is needed for parsing
  the next character, we do not need to parse it itself.)
- do not use puts in KDE mode for the request .ab
- a few kdDebugs less
- use the function skip_till_newline whne needed to avoid off-by-one errors
- for the request .shift, be careful when parsing the argument not to pass
  the end of line (again off-by-one error).
- remove function that was under #if 0
- add my copyright (as I have now modified quite much)
- fix a few small details

CCBUG:106067
(The document looks much much better.)


 M  +165 -150  man2html.cpp  
Comment 8 Nicolas Goutte 2005-05-28 01:17:14 UTC
SVN commit 418902 by goutte:

Improve the groff basic support:
- define characters by a QMap too (nearly like strings)
  (The predefined one are still loaded from the old structure.)
- use QCString where possible, especially to avoid static char* buffers
  to pass strings between functions
- allow long name characters with \[name] and \C'name'
- allow the long name of characters or strings is defined by a string
- make a versionof scan_expression that does not call out_html but that
  returns the string as QCString

CCBUG:106067
(Only small progress this time.)

 M  +327 -163  man2html.cpp  
Comment 9 Nicolas Goutte 2005-05-28 16:44:55 UTC
SVN commit 419104 by goutte:

Improve the groff basic support:
- fix a few of the special characters (by looking into Unicode list)
- change the way of setting fonts, always as HTML <span>
  (The new implementation has the drawback not to have any font number anymore.
  So may be we need to go back a little in future, assuming needing \n[.f] )
  (We do not use/abuse the KDE CSS classes as fonts anymore.)
- as we do not know .ftr (font translation) offer a few other fonts too
  (The main ones of the ps output of groff)
  (Sorry, still no Japanese fonts, as I have no idea how to test. But Qt
  might be smarter anyway.)
- fix the off-by-one easy-to-do error in scan_escape_direct and friends
- fix single letter string variables and number registers.
- new code for the font setting escape \f (including long names now)
- fix \\ for getting a backspace
- use HTML <small> for the corresponding requests .SM and .SB
- a few other minor details

CCBUG:106067
(It looks rather good this time, except the .while condition problem,
which still polutes the text with >=2 here and there.)


 M  +292 -147  man2html.cpp  
Comment 10 Nicolas Goutte 2005-06-02 10:40:19 UTC
SVN commit 421114 by goutte:

A few basic groff improvements:
- do not assign a char directly to QCString
  (Doing so is asking for trouble, as it does not work correctly)
- fix font name handling
  (The logic of the code for checking if it is a number or a name was wrong.)
- &grave; does not exist in HTML
- use cerr as kdDebug replacement in SIMPLE_MAN2HTML mode
- remove the #if 0-ed definition of what were probably (planned to be)
  internal number registers
- try to allow a &nbsp; in a man link
  (not finished, as I found the major problem of QCString before being
  able to finishe this part of code; for bug #85753).
- little detail change the <meta> from "Mandoc-Type" to "ROFF-Type"
  (It would be nice if one day the man kioslave could do other ROFF types
  than man(7) or mdoc(7) pages
  
CCBUG:106067
(With font changing working now, this looks even better. The major problem
is still the .while condition.)


 M  +48 -35    man2html.cpp  
Comment 11 Nicolas Goutte 2005-06-02 20:57:24 UTC
SVN commit 421319 by goutte:

Fix the scanning of conditions to allow a space if the condition is
between parentheses

CCBUG:106067
This fixes the .while condition problem.
The remain big problen is the generated HTML... do not know how to do it
ith the current code. :-(


 M  +11 -4     man2html.cpp  


--- trunk/KDE/kdebase/kioslave/man/man2html.cpp #421318:421319
@@ -2303,7 +2303,7 @@
     return c;
 }
 
-static char *scan_expression(char *c, int *result)
+static char *scan_expression( char *c, int *result, const unsigned int numLoop )
 {
     int value=0,value2,sign=1,opex=0;
     char oper='c';
@@ -2350,11 +2350,11 @@
 	if (tcmp) c=c+3;
 	c++;
     } else {
-	while (*c && !isspace(*c) && *c!=')' && opex >= 0) {
+        while (*c && ( !isspace(*c) || ( numLoop > 0 ) ) && *c!=')' && opex >= 0) {
 	    opex=0;
 	    switch (*c) {
 	    case '(':
-		c=scan_expression(c+1, &value2);
+                c = scan_expression( c + 1, &value2, numLoop + 1 );
 		value2=sign*value2;
 		opex=1;
 		break;
@@ -2446,6 +2446,11 @@
     return c;
 }
 
+static char *scan_expression(char *c, int *result)
+{
+    return scan_expression( c, result, 0 );
+}
+
 static void trans_char(char *c, char s, char t)
 {
     char *sl=c;
@@ -2745,8 +2750,10 @@
     {
         // Unlike for a normal macro, we have the condition at start, so we do not need to prepend extra bytes
         char* liveloop = qstrdup( macro.data() );
-            kdDebug(7107) << "Scanning .while condition" << endl;
+        kdDebug(7107) << "Scanning .while condition" << endl;
+        kdDebug(7101) << "Loop macro " << liveloop << endl;
         char* end_expression = scan_expression( liveloop, &result );
+        kdDebug(7101) << "After " << end_expression << endl;
         if ( result )
         {
             kdDebug(7107) << "New .while iteration" << endl;
Comment 12 Martin Koller 2011-01-07 19:14:11 UTC
SVN commit 1212624 by mkoller:

CCBUG: 238534
CCBUG: 105765
BUG: 106067
BUG: 195241
BUG: 247012

Fix a lot of HTML-generation bugs by implementing some additional macros,
escape sequences, etc, etc.
Also start to make the code more readable and introduce more Qt/C++
while eliminating old C code, which is horrible to maintain.
The request keywords are now looked up by a gperf hash function.
The generated gperf file is committed, so that noone has to rely on the
existence of gperf on the build machine.

If I broke the rendering of some man pages, please inform me.


 M  +1 -1      CMakeLists.txt  
 M  +586 -614  man2html.cpp  
 A             request_gperf.c   [License: GENERATED FILE]
 A             request_hash.cpp   [License: UNKNOWN]
 A             request_hash.h   [License: UNKNOWN]
 A             requests.gperf  
 M  +4 -1      tests/CMakeLists.txt  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1212624
Comment 13 Martin Koller 2011-01-07 22:05:36 UTC
SVN commit 1212666 by mkoller:

Backport from trunk:

CCBUG: 238534
CCBUG: 105765
CCBUG: 106067
CCBUG: 195241
CCBUG: 247012

Fix a lot of HTML-generation bugs by implementing some additional macros,
escape sequences, etc, etc.
Also start to make the code more readable and introduce more Qt/C++
while eliminating old C code, which is horrible to maintain.
The request keywords are now looked up by a gperf hash function.
The generated gperf file is committed, so that noone has to rely on the
existence of gperf on the build machine.

If I broke the rendering of some man pages, please inform me.



 M  +1 -1      CMakeLists.txt  
 M  +586 -614  man2html.cpp  
 A             request_gperf.c   [License: GENERATED FILE]
 A             request_hash.cpp   [License: LGPL (v2+)]
 A             request_hash.h   [License: LGPL (v2+)]
 A             requests.gperf  
 M  +4 -1      tests/CMakeLists.txt  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1212666