From e8f173cde0932b62c68e8fe08ae7ff1094ea94dd Mon Sep 17 00:00:00 2001 From: Lutz Kettner Date: Fri, 9 May 1997 17:25:55 +0000 Subject: [PATCH] Bug fixes in conjunction with the new test suite on ../format/test.tex . --- Packages/Manual_tools/src/cc_extract_html.C | 192 +++++++++++++------- Packages/Manual_tools/src/cc_manual_to_html | 6 +- Packages/Manual_tools/src/html_lex.yy | 25 +-- Packages/Manual_tools/src/html_syntax.y | 4 +- 4 files changed, 145 insertions(+), 82 deletions(-) diff --git a/Packages/Manual_tools/src/cc_extract_html.C b/Packages/Manual_tools/src/cc_extract_html.C index a3f63c4aa30..4e1376e15d9 100644 --- a/Packages/Manual_tools/src/cc_extract_html.C +++ b/Packages/Manual_tools/src/cc_extract_html.C @@ -64,18 +64,19 @@ typedef char Switch; #define MINUS_SWITCH 1 #define PLUS_SWITCH 2 -Switch trace_switch = NO_SWITCH; -Switch line_switch = NO_SWITCH; +Switch trace_switch = NO_SWITCH; +Switch line_switch = NO_SWITCH; -Switch config_switch = NO_SWITCH; -Switch warn_switch = NO_SWITCH; -Switch macro_switch = NO_SWITCH; +Switch config_switch = NO_SWITCH; +Switch warn_switch = NO_SWITCH; +Switch macro_switch = NO_SWITCH; -Switch noheader_switch = NO_SWITCH; +Switch noheader_switch = NO_SWITCH; Switch onlyheader_switch = NO_SWITCH; -char* cgal_lib_dir = NULL; - +char* cgal_lib_dir = NULL; +char* pre_main_filename = NULL; +ostream* pre_stream = NULL; /* An object storing the current font */ /* ================================== */ @@ -823,7 +824,10 @@ void filter_config_file( istream& in, ostream& out) { break; case 'u': if ( main_stream != &cout) - out << main_filename; + if ( main_stream != pre_stream) + out << main_filename; + else + out << pre_main_filename; break; case 'd': if ( manual_date ) @@ -992,6 +996,8 @@ const char* html_multi_character( char c) { } void print_ascii_to_html( ostream& out, const char* txt) { + if (txt == NULL) + return; while( *txt) { if ( *txt == '\\' && isupper(txt[1]) && txt[2] == '\\') { out << new_remember_font( txt[1]); @@ -1005,6 +1011,8 @@ void print_ascii_to_html( ostream& out, const char* txt) { } void print_ascii_len_to_html( ostream& out, const char* txt, int n) { + if (txt == NULL) + return; while( n) { if ( *txt == '\\' && isupper(txt[1]) && txt[2] == '\\') { out << new_remember_font( txt[1]); @@ -1020,6 +1028,8 @@ void print_ascii_len_to_html( ostream& out, const char* txt, int n) { // This version eliminates multiple spaces. void print_ascii_to_html_spc( ostream& out, const char* txt) { + if (txt == NULL) + return; while( *txt) { if ( *txt == '\\' && isupper(txt[1]) && txt[2] == '\\') { out << new_remember_font( txt[1]); @@ -1034,6 +1044,8 @@ void print_ascii_to_html_spc( ostream& out, const char* txt) { } int strlen_ascii_to_html( const char* txt) { + if (txt == NULL) + return 0; int len = 0; while( *txt) { if ( *txt == '\\' && isupper(txt[1]) && txt[2] == '\\') { @@ -1087,9 +1099,9 @@ char* convert_C_to_html( const char* txt) { return formatted; } -// A scope operator is also appended +// No longer is a scope operator appended. char* convert_ascii_to_scrambled_html( const char* txt) { - char* s = new char[ strlen_ascii_to_html( txt) + 3 + char* s = new char[ strlen_ascii_to_html( txt) + 1 + strlen( index_scramble)]; char* p = s; bool tag = true; @@ -1113,19 +1125,19 @@ char* convert_ascii_to_scrambled_html( const char* txt) { tag = false; } } - *p++ = ':'; - *p++ = ':'; *p = '\0'; return s; } -char* convert_C_to_scrambled_html( const char* txt) { +// A scope operator is also appended. +char* convert_C_to_scrambled_scope_html( const char* txt) { current_font = it_font; char* tmp = convert_ascii_to_scrambled_html( txt); const char* end_font = new_font_tags( it_font); - char* formatted = new char[ strlen( tmp) + strlen( end_font) + 8]; + char* formatted = new char[ strlen( tmp) + strlen( end_font) + 10]; strcpy( formatted, ""); strcat( formatted, tmp); + strcat( formatted, "::"); strcat( formatted, end_font); strcat( formatted, ""); delete[] tmp; @@ -2126,7 +2138,11 @@ void format_function( bool method, const char* signature, const Text& T) { if ( conversion_operator) { print_ascii_to_html_spc( *current_stream, op_symbols); *current_stream << " ( "; - print_ascii_to_html_spc( *current_stream, creationvariable); + if ( creationvariable == NULL) { + printErrorMessage( VariableUsedError); + *current_stream << "*this"; + } else + print_ascii_to_html_spc( *current_stream, creationvariable); *current_stream << ")"; } else { double dd_width = table_width * ( 1.0 - table_first_col / 100.0); @@ -2138,7 +2154,11 @@ void format_function( bool method, const char* signature, const Text& T) { *current_stream << get_remember_font() << indNewline; } if ( method) { - print_ascii_to_html_spc( *current_stream, creationvariable); + if ( creationvariable == NULL) { + printErrorMessage( VariableUsedError); + *current_stream << "*this"; + } else + print_ascii_to_html_spc(*current_stream, creationvariable); *current_stream << '.'; } if ( scope) @@ -2217,14 +2237,12 @@ void format_variable( const char* signature, // generate a substitution rule for hyperlinking *anchor_stream << "[a-zA-Z0-9_]\"" << formatted_var << "\" { ECHO; }" << endl; - *anchor_stream << "\"" << formatted_var - << "\"[a-zA-Z0-9_] { ECHO; }" << endl; *anchor_stream << '"' << formatted_var - << "\" { fputs( \"" << formatted_var << "\", stdout); }" + << "\"/{noCCchar} { fputs( \"" << formatted_var << "\", stdout); }" << endl; // index @@ -2243,15 +2261,16 @@ void format_variable( const char* signature, filter_for_index_comment( *index_stream, variable_name); *index_stream << "!>" << endl; delete[] scrambled_var; } *current_stream << "" << endl; + << (is_typedef ? "Typedef_" : "Var_" ); + filter_for_index_anchor( *current_stream, variable_name); + *current_stream << "\">" << endl; // end index if ( return_value) @@ -2442,12 +2461,11 @@ void format_enum( const char* signature, const Text& T) { // generate a substitution rule for hyperlinking *anchor_stream << "[a-zA-Z0-9_]\"" << formatted_enum << "\" { ECHO; }" << endl; - *anchor_stream << "\"" << formatted_enum - << "\"[a-zA-Z0-9_] { ECHO; }" << endl; *anchor_stream << '"' << formatted_enum - << "\" { fputs( \"" - << formatted_enum << "\", stdout); }" + << "\"/{noCCchar} { fputs( \"" << formatted_enum << "\", stdout); }" << endl; // index @@ -2463,12 +2481,15 @@ void format_enum( const char* signature, const Text& T) { *index_stream << "::"; filter_for_index_comment( *index_stream, enum_name); *index_stream << "!>" << endl; delete[] scrambled_enum; } - *current_stream << "" << endl; + *current_stream << "" << endl; // end index // first, estimate size @@ -2538,12 +2559,11 @@ void format_enum( const char* signature, const Text& T) { char *tmp_param = convert_ascii_to_html( p); *anchor_stream << "[a-zA-Z0-9_]\"" << tmp_param << "\" { ECHO; }" << endl; - *anchor_stream << "\"" << tmp_param - << "\"[a-zA-Z0-9_] { ECHO; }" << endl; *anchor_stream << '"' << tmp_param - << "\" { fputs( \"" + << "\"/{noCCchar} { fputs( \"" << tmp_param << "\", stdout); }" << endl; delete[] tmp_param; @@ -2561,8 +2581,9 @@ void format_enum( const char* signature, const Text& T) { *index_stream << "::"; filter_for_index_comment( *index_stream, p); *index_stream << "!>" << endl; delete[] scrambled_tag; } @@ -2618,12 +2639,11 @@ void format_struct( const char* signature, const Text& T) { // generate a substitution rule for hyperlinking *anchor_stream << "[a-zA-Z0-9_]\"" << formatted_struct << "\" { ECHO; }" << endl; - *anchor_stream << "\"" << formatted_struct - << "\"[a-zA-Z0-9_] { ECHO; }" << endl; *anchor_stream << '"' << formatted_struct - << "\" { fputs( \"" << formatted_struct << "\", stdout); }" + << "\"/{noCCchar} { fputs( \"" << formatted_struct << "\", stdout); }" << endl; // index *index_stream << sort_key_struct << '1'; @@ -2638,12 +2658,15 @@ void format_struct( const char* signature, const Text& T) { *index_stream << "::"; filter_for_index_comment( *index_stream, struct_name); *index_stream << "!>" << endl; delete[] scrambled_struct; } - *current_stream << "" << endl; + *current_stream << "" << endl; // end index // first, estimate size @@ -2769,7 +2792,7 @@ void handleChapter( const Text& T) { chapter_title = text_block_to_string( T); footnotes = &main_footnotes; footnote_counter = &main_footnote_counter; - if ( main_stream != &cout) { + if ( main_stream != &cout && main_stream != pre_stream) { printFootnotes( *main_stream); // navigation footer *main_stream << "
Next chapter: " << tmp_name << "\", stdout); }" << endl; if ( tmpl_class) { *anchor_stream << '"' << tmp_name - << "\"[ ]*\"<\" {\n" + << "\"{ws}\"<\"{ws}{CCidfier}{ws}\">\" {\n" << " fputs( \"\", stdout);\n" - << " nesting = 1;\n" - << " yymore();\n" - << " BEGIN( PARAMMODE); }\n" + << " ECHO;\n" + << " fputs( \"\", stdout); }\n" << endl; +// *anchor_stream << '"' << tmp_name +// << "\"[ ]*\"<\" {\n" +// << " fputs( \"\", stdout);\n" +// << " nesting = 1;\n" +// << " yymore();\n" +// << " BEGIN( PARAMMODE); }\n" +// << endl; } delete[] tmp_name; @@ -3069,7 +3098,7 @@ void handleClasses( const char* classname, const char* template_cls) { formatted_template_class_name = convert_C_to_html( template_class_name); scrambled_template_class_name = - convert_C_to_scrambled_html( template_class_name); + convert_C_to_scrambled_scope_html( template_class_name); class_name = newstr( classname); creationvariable = newstr( "*this"); formatted_creationvariable = newstr( "*this"); @@ -3352,6 +3381,16 @@ main( int argc, char **argv) { nParameters = ErrParameters; } endDetect(); + detectSwitch( dummy_switch, "main"); + i++; + if ( i < argc) { + pre_main_filename = argv[i]; + } else { + cerr << "error: option -main needs an additional parameter" + << endl; + nParameters = ErrParameters; + } + endDetect(); detectSwitch( warn_switch, "warn"); endDetect(); detectSwitch( macro_switch, "macro"); @@ -3399,6 +3438,8 @@ main( int argc, char **argv) { "output files." << endl; cerr << " -cgal_dir set the path to the CGAL " "header files." << endl; + cerr << " -main main filename for the part before" + " any chapter" << endl; cerr << " -warn warn about unknown macros" << endl; cerr << " -macro trace macro definitions" << endl; cerr << " -noheader no header for contents.html and " @@ -3445,6 +3486,13 @@ main( int argc, char **argv) { index_stream = open_file_with_path_for_write( tmp_path, index_filename); if ( ! noheader_switch) write_headers_to_index( *index_stream); + + if ( pre_main_filename) { + pre_stream = open_file_with_path_for_write(tmp_path,pre_main_filename); + current_stream = pre_stream; + current_filename = pre_main_filename; + open_html( *pre_stream); + } for ( i = 0; i < nParameters; i++) { FILE* in; @@ -3456,9 +3504,16 @@ main( int argc, char **argv) { } in_filename = parameters[i]; - main_stream = &cout; - current_stream = main_stream; - current_filename = main_filename; + if ( pre_main_filename) { + main_stream = pre_stream; + main_filename = pre_main_filename; + current_stream = main_stream; + current_filename = pre_main_filename; + } else { + main_stream = &cout; + current_stream = main_stream; + current_filename = main_filename; + } init_scanner( in); yyparse(); @@ -3474,7 +3529,7 @@ main( int argc, char **argv) { class_filename = 0; } assert_file_write( *main_stream, main_filename); - if ( main_stream != &cout) { + if ( main_stream != &cout && main_stream != pre_stream) { footnotes = &main_footnotes; footnote_counter = &main_footnote_counter; printFootnotes( *main_stream); @@ -3487,6 +3542,13 @@ main( int argc, char **argv) { } } + if ( pre_main_filename) { + printFootnotes( *pre_stream); + close_html( *pre_stream); + assert_file_write( *pre_stream, pre_main_filename); + delete pre_stream; + } + assert_file_write( *index_stream, index_filename); delete index_stream; diff --git a/Packages/Manual_tools/src/cc_manual_to_html b/Packages/Manual_tools/src/cc_manual_to_html index 21c9bb8829f..60030aa3b83 100755 --- a/Packages/Manual_tools/src/cc_manual_to_html +++ b/Packages/Manual_tools/src/cc_manual_to_html @@ -274,8 +274,8 @@ set options = "${cgal_dir} -config ${config_path}/ -tmp ${new_tmp_path}/ ${aux_f if ( $?DEBUG) echo "# Step 1: convert each LaTeX file into an HTML file." if ($show_main_switch) then - if ( $?DEBUG) echo "cc_extract_html -date "${DEFAULT_DATE}" -release "${DEFAULT_RELEASE}" -title "${DEFAULT_TITLE}" -author "${DEFAULT_AUTHOR}" ${options} ${in_files}" - cc_extract_html -date "${DEFAULT_DATE}" -release "${DEFAULT_RELEASE}" -title "${DEFAULT_TITLE}" -author "${DEFAULT_AUTHOR}" ${options} ${in_files} + if ( $?DEBUG) echo "cc_extract_html -date "${DEFAULT_DATE}" -release "${DEFAULT_RELEASE}" -title "${DEFAULT_TITLE}" -author "${DEFAULT_AUTHOR}" ${options} -main main.html ${in_files}" + cc_extract_html -date "${DEFAULT_DATE}" -release "${DEFAULT_RELEASE}" -title "${DEFAULT_TITLE}" -author "${DEFAULT_AUTHOR}" ${options} -main main.html ${in_files} else if ( $?DEBUG) echo "cc_extract_html -date "${DEFAULT_DATE}" -release "${DEFAULT_RELEASE}" -title "${DEFAULT_TITLE}" -author "${DEFAULT_AUTHOR}" ${options} ${in_files} >/dev/null" cc_extract_html -date "${DEFAULT_DATE}" -release "${DEFAULT_RELEASE}" -title "${DEFAULT_TITLE}" -author "${DEFAULT_AUTHOR}" ${options} ${in_files} >/dev/null @@ -491,7 +491,7 @@ echo "$0 "'$Revision$'" (c) Lutz Kettner" echo "Usage: $0 [] " echo " -defaults show the settings of the internal variables." echo " -extended extended organization among multiple dir's." -echo " -show_main show the translation result for the main file." +echo " -show_main put the result for the main file in main.html." echo " -date set a date for the manual." echo " -release set a release number for the manual." echo " -title set a title text for the manual." diff --git a/Packages/Manual_tools/src/html_lex.yy b/Packages/Manual_tools/src/html_lex.yy index 2b0cc79f9c1..ab3c7a4fbad 100644 --- a/Packages/Manual_tools/src/html_lex.yy +++ b/Packages/Manual_tools/src/html_lex.yy @@ -145,7 +145,7 @@ floatNumber ({signNumber}\.|{signNumber}\.{number}) expNumber ({floatNumber}|{signNumber}){exp}{signNumber} No ({signNumber}|{floatNumber}|{expNumber}) operator [^a-zA-Z_0-9\n\r\t \\] -measure {signNumber}{letter}{letter} +measure (({signNumber})|({floatNumber})){letter}{letter} rmblockintro ([\{][\\](rm))|([\\]((text)|(math))rm[\{]) ttblockintro ([\{][\\](tt))|([\\]((text)|(math))tt[\{]) emblockintro ([\{][\\](em))|([\\]emph[\{]) @@ -296,8 +296,8 @@ calblockintro ([\{][\\](cal))|([\\]mathcal[\{]) [\\]verb{noletter} { /* match LaTeX \verb"..." constructs */ BEGIN( VerbMode); stop_character = yytext[ yyleng-1]; - yylval.string.text = "
";
-		    yylval.string.len  = 5;
+		    yylval.string.text = "";
+		    yylval.string.len  = 4;
 	  	    return STRING;
                 }
 {ws}	{
@@ -308,8 +308,8 @@ calblockintro   ([\{][\\](cal))|([\\]mathcal[\{])
 .	{
 		    if ( yytext[0] == stop_character) {
 		        BEGIN( INITIAL);
-	                yylval.string.text = "
"; - yylval.string.len = 6; + yylval.string.text = ""; + yylval.string.len = 5; return STRING; } if ( yytext[0] == '\n') { @@ -1413,15 +1413,16 @@ calblockintro ([\{][\\](cal))|([\\]mathcal[\{]) } {ttblockintro} { /* TeX styles like {\tt ... */ + skipspaces(); return TTBLOCKINTRO; } -{emblockintro} { return EMBLOCKINTRO; } -{itblockintro} { return ITBLOCKINTRO; } -{scblockintro} { return SCBLOCKINTRO; } -{bfblockintro} { return BFBLOCKINTRO; } -{rmblockintro} { return RMBLOCKINTRO; } -{sfblockintro} { return SFBLOCKINTRO; } -{calblockintro} { return CALBLOCKINTRO; } +{emblockintro} { skipspaces();return EMBLOCKINTRO;} +{itblockintro} { skipspaces();return ITBLOCKINTRO;} +{scblockintro} { skipspaces();return SCBLOCKINTRO;} +{bfblockintro} { skipspaces();return BFBLOCKINTRO;} +{rmblockintro} { skipspaces();return RMBLOCKINTRO;} +{sfblockintro} { skipspaces();return SFBLOCKINTRO;} +{calblockintro} {skipspaces();return CALBLOCKINTRO;} [\\]tt/{noletter} { skipspaces(); diff --git a/Packages/Manual_tools/src/html_syntax.y b/Packages/Manual_tools/src/html_syntax.y index 3fad7f52a8f..490b30c33ad 100644 --- a/Packages/Manual_tools/src/html_syntax.y +++ b/Packages/Manual_tools/src/html_syntax.y @@ -327,9 +327,9 @@ stmt: string { handleBuffer( * $1); group: '{' input '}' - | blockintro + | blockintro { handleString( $1.text);} input - '}' {} + '}' { handleString( $1.text + strlen( $1.text)+1);} ; /* Auxiliary Rules */