From d2b63746183fe9a91992b7327fcc262fef67f088 Mon Sep 17 00:00:00 2001 From: dkf Date: Fri, 26 Oct 2007 14:32:15 +0000 Subject: Working towards better nroff scraping... --- ChangeLog | 32 ++++++++++++++++------------ tools/man2help.tcl | 5 +++-- tools/man2help2.tcl | 61 +++++++++++++++++++++++++++++++++++++++++------------ tools/man2tcl.c | 30 ++++++++++++++++++++++++-- 4 files changed, 97 insertions(+), 31 deletions(-) diff --git a/ChangeLog b/ChangeLog index cf8568e..9ed5822 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,9 +1,15 @@ +2007-10-26 Donal K. Fellows + + * tools/man2help2.tcl, tools/man2tcl.c: Made some of the tooling code + to do man->other formats work better with current manpage set. Long + way still to go. + 2007-10-25 Zoran Vasiljevic * generic/tclThread.c: Added TclpMasterLock/Unlock arround calls to - ForgetSyncObject in Tcl_MutexFinalize and Tcl_ConditionFinalize - to prevent from garbling the internal lists that track sync objects. - (Tcl Bug #1726873) + ForgetSyncObject in Tcl_MutexFinalize and Tcl_ConditionFinalize to + prevent from garbling the internal lists that track sync objects. [Bug + 1726873] 2007-10-24 Donal K. Fellows @@ -22,8 +28,8 @@ 2007-10-18 David Gravereaux - * tools/mkdepend.tcl: sort the dep list for a more humanly - readable output. + * tools/mkdepend.tcl: sort the dep list for a more humanly readable + output. 2007-10-18 Don Porter @@ -31,14 +37,14 @@ values get pulled out of the dictionary, even if they are integer valued. - * generic/tclCompCmds.c (TclCompileReturnCmd): Added code to - more optimally compile [return -level 0 $x] to "push $x". [RFE 1794073] + * generic/tclCompCmds.c (TclCompileReturnCmd): Added code to more + optimally compile [return -level 0 $x] to "push $x". [RFE 1794073] * compat/tmpnam.c (removed): The routine tmpnam() is no longer - * unix/Makefile.in: called by Tcl source code. Remove autogoo - * unix/configure.in: the supplied a replacement version on - * win/tcl.dsp: systems where the routine was not available. - [RFE 1811848]. + * unix/Makefile.in: called by Tcl source code. Remove autogoo the + * unix/configure.in: supplied a replacement version on systems + * win/tcl.dsp: where the routine was not available. [RFE + 1811848] * unix/configure: autoconf-2.59 @@ -46,8 +52,8 @@ 2007-10-17 David Gravereaux - * tools/mkdepend.tcl: Improved defense from malformed object - list infile. + * tools/mkdepend.tcl: Improved defense from malformed object list + infile. 2007-10-17 Donal K. Fellows diff --git a/tools/man2help.tcl b/tools/man2help.tcl index 91fcb89..c61085b 100644 --- a/tools/man2help.tcl +++ b/tools/man2help.tcl @@ -6,14 +6,15 @@ # # Copyright (c) 1996 by Sun Microsystems, Inc. # -# RCS: @(#) $Id: man2help.tcl,v 1.14 2003/06/04 23:40:18 mistachkin Exp $ +# RCS: @(#) $Id: man2help.tcl,v 1.15 2007/10/26 14:32:16 dkf Exp $ # # # PASS 1 # -set man2tclprog [file join [file dirname [info script]] man2tcl.exe] +set man2tclprog [file join [file dirname [info script]] \ + man2tcl[file extension [info nameofexecutable]]] proc generateContents {basename version files} { global curID topics diff --git a/tools/man2help2.tcl b/tools/man2help2.tcl index 62b5b2e..7cd020c 100644 --- a/tools/man2help2.tcl +++ b/tools/man2help2.tcl @@ -9,7 +9,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: man2help2.tcl,v 1.15 2004/07/07 12:08:43 dkf Exp $ +# RCS: @(#) $Id: man2help2.tcl,v 1.16 2007/10/26 14:32:16 dkf Exp $ # # Global variables used by these scripts: @@ -425,6 +425,21 @@ proc macro {name args} { } VE {} VS {} + QW { + formattedText "``[lindex $args 0]''[lindex $args 1] " + } + MT { + text "``'' " + } + PQ { + formattedText \ + "(``[lindex $args 0]''[lindex $args 1])[lindex $args 2] " + } + QR { + formattedText "``[lindex $args 0]" + dash + formattedText "[lindex $args 1]''[lindex $args 2] " + } default { puts stderr "Unknown macro: .$name [join $args " "]" } @@ -516,13 +531,12 @@ proc formattedText {text} { dash set text [string range $text [expr {$index+2}] end] } - | { + & - | { set text [string range $text [expr {$index+2}] end] } - o { - text "\\'" - regexp {'([^']*)'(.*)} $text all ch text - text $chars($ch) + ( { + char [string range $text $index [expr {$index+3}]] + set text [string range $text [expr {$index+4}] end] } default { puts stderr "Unknown sequence: \\$c" @@ -665,32 +679,51 @@ proc char {name} { global file state switch -exact $name { - \\o { + {\o} { set state(intl) 1 } - \\\ { + {\ } { textSetup puts -nonewline $file " " } - \\0 { + {\0} { textSetup puts -nonewline $file " \\emspace " } - \\\\ { + {\\} - {\e} { textSetup puts -nonewline $file "\\\\" } - \\(+- { + {\(+-} { textSetup puts -nonewline $file "\\'b1 " } - \\% - - \\| { + {\%} - {\|} { } - \\(bu { + {\(->} { + textSetup + puts -nonewline $file "->" + } + {\(bu} { textSetup puts -nonewline $file "\\bullet " } + {\(co} { + textSetup + puts -nonewline $file "\\'a9 " + } + {\(mu} { + textSetup + puts -nonewline $file "\\'d7 " + } + {\(em} { + textSetup + puts -nonewline $file "-" + } + {\(fm} { + textSetup + puts -nonewline $file "\\'27 " + } default { puts stderr "Unknown character: $name" } diff --git a/tools/man2tcl.c b/tools/man2tcl.c index a90b729..8ddeb20 100644 --- a/tools/man2tcl.c +++ b/tools/man2tcl.c @@ -15,7 +15,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: man2tcl.c,v 1.11 2007/01/19 08:17:35 mistachkin Exp $ + * RCS: @(#) $Id: man2tcl.c,v 1.12 2007/10/26 14:32:16 dkf Exp $ */ static char sccsid[] = "@(#) man2tcl.c 1.3 95/08/12 17:34:08"; @@ -329,6 +329,9 @@ DoText( p++; } else if (*p == '&') { p++; + } else if (*p == '0') { + PRINT(("text { }\n")); + p++; } else if (*p == '(') { if ((p[1] == 0) || (p[2] == 0)) { fprintf(stderr, "Bad \\( sequence on line %d.\n", @@ -338,6 +341,13 @@ DoText( PRINT(("char {\\(%c%c}\n", p[1], p[2])); p += 3; } + } else if (*p == 'N' && *(p+1) == '\'') { + int ch; + + p += 2; + sscanf(p,"%d",&ch); + PRINT(("text \\u%04x", ch)); + while(*p&&*p!='\'') p++; } else if (*p != 0) { PRINT(("char {\\%c}\n", *p)); p++; @@ -377,7 +387,23 @@ QuoteText( } for ( ; count > 0; string++, count--) { switch (*string) { - case '$': case '[': case '{': case ' ': case ';': case '\\': + case '\\': + if (*(string+1) == 'N' && *(string+2) == '\'') { + int ch; + + string += 3; + count -= 3; + sscanf(string,"%d",&ch); + PRINT(("\\u%04x", ch)); + while(count>0&&*string!='\'') {string++;count--;} + continue; + } else if (*(string+1) == '0') { + PRINT(("\\ ")); + string++; + count--; + continue; + } + case '$': case '[': case '{': case ' ': case ';': case '"': case '\t': PRINTC('\\'); default: -- cgit v0.12