ccStyle accepts font changes. Empty class name triggers error message.

Boldface as font in C code added.
This commit is contained in:
Lutz Kettner 1997-05-23 12:41:54 +00:00
parent 12346c22b1
commit 1c861ef193
5 changed files with 102 additions and 30 deletions

View File

@ -158,6 +158,8 @@ const char* new_remember_font( char c) {
return new_remember_font( tt_font); return new_remember_font( tt_font);
case 'I': case 'I':
return new_remember_font( it_font); return new_remember_font( it_font);
case 'B':
return new_remember_font( bf_font);
default: default:
font_tag_buffer[0] = '\\'; font_tag_buffer[0] = '\\';
font_tag_buffer[1] = c; font_tag_buffer[1] = c;
@ -1099,6 +1101,41 @@ char* convert_C_to_html( const char* txt) {
return formatted; return formatted;
} }
char* convert_ccStyle2_to_html( const char* txt) {
if ( txt == NULL) {
char *q = new char[1];
q[0] = '\0';
return q;
}
char* s = new char[ strlen_ascii_to_html( txt) + 1];
char* p = s;
while( *txt) {
if ( *txt == '\\' && isupper(txt[1]) && txt[2] == '\\') {
const char* q = new_remember_font( txt[1]);
while ( *q)
*p++ = *q++;
txt += 2;
} else
*p++ = *txt;
++txt;
}
*p = '\0';
return s;
}
char* convert_ccStyle_to_html( const char* txt) {
current_font = it_font;
char* tmp = convert_ccStyle2_to_html( txt);
const char* end_font = new_font_tags( it_font);
char* formatted = new char[ strlen( tmp) + strlen( end_font) + 8];
strcpy( formatted, "<I>");
strcat( formatted, tmp);
strcat( formatted, end_font);
strcat( formatted, "</I>");
delete[] tmp;
return formatted;
}
// No longer is a scope operator appended. // No longer is a scope operator appended.
char* convert_ascii_to_scrambled_html( const char* txt) { char* convert_ascii_to_scrambled_html( const char* txt) {
char* s = new char[ strlen_ascii_to_html( txt) + 1 char* s = new char[ strlen_ascii_to_html( txt) + 1
@ -3052,6 +3089,15 @@ char cross_link_anchor_buffer[ cross_link_anchor_len];
int cross_link_anchor_counter = 0; int cross_link_anchor_counter = 0;
const char* handleHtmlCrossLink( const char* key, bool tmpl_class) { const char* handleHtmlCrossLink( const char* key, bool tmpl_class) {
// test empty key.
const char* p = key;
while( p && isspace(*p))
p++;
if ( !p || *p == '\0') {
printErrorMessage( EmptyCrossLinkError);
exit( 1);
}
char *tmp_name = convert_ascii_to_html( key); char *tmp_name = convert_ascii_to_html( key);
*anchor_stream << "[a-zA-Z0-9_]\"" << tmp_name *anchor_stream << "[a-zA-Z0-9_]\"" << tmp_name
<< "\" { ECHO; }" << endl; << "\" { ECHO; }" << endl;
@ -3089,6 +3135,15 @@ const char* handleHtmlCrossLink( const char* key, bool tmpl_class) {
} }
void handleClasses( const char* classname, const char* template_cls) { void handleClasses( const char* classname, const char* template_cls) {
// test empty classname.
const char* p = classname;
while( p && isspace(*p))
p++;
if ( !p || *p == '\0') {
printErrorMessage( EmptyClassNameError);
exit( 1);
}
// Name manipulation. // Name manipulation.
if ( template_cls) if ( template_cls)
template_class_name = newstr( template_cls); template_class_name = newstr( template_cls);

View File

@ -254,12 +254,12 @@ if ( "$in_files" == "") goto usage
# Make a subdirectory for the temp_path: # Make a subdirectory for the temp_path:
# -------------------------------------- # --------------------------------------
set tmp_name = "extract_html_tmp" set tmp_name = "extract_html_tmp_$USER"
if ( $?DEBUG) echo "# Make a subdirectory 'extract_html_tmp' for the tmp_path." if ( $?DEBUG) echo "# Make a subdirectory $tmp_name for the tmp_path."
set new_tmp_path = ${tmp_path}/${tmp_name} set new_tmp_path = ${tmp_path}/${tmp_name}
if ( -d ${new_tmp_path}) then if ( -d ${new_tmp_path}) then
echo "error: the subdirectory 'extract_html_tmp' for the tmp_path exists already." echo "error: the subdirectory $tmp_name for the tmp_path exists already."
echo " type 'rm -r ${new_tmp_path}' to remove it." echo " type 'rm -r ${new_tmp_path}' to remove it."
goto usage goto usage
endif endif

View File

@ -195,7 +195,9 @@ enum ErrorNumber {
IncludeNestingTooDeepError, IncludeNestingTooDeepError,
IncludeOpenError, IncludeOpenError,
ChapterStructureError, ChapterStructureError,
UnknownIndexCategoryError UnknownIndexCategoryError,
EmptyClassNameError,
EmptyCrossLinkError
}; };

View File

@ -1430,6 +1430,12 @@ calblockintro ([\{][\\](cal))|([\\]mathcal[\{])
yylval.string.len = -1; yylval.string.len = -1;
return STRING; return STRING;
} }
<CCMode,ccStyleMode>[\\]bf/{noletter} {
skipspaces();
yylval.string.text = "\\B\\";
yylval.string.len = -1;
return STRING;
}
<CCMode,ccStyleMode>[\\]ccFont/{noletter} { <CCMode,ccStyleMode>[\\]ccFont/{noletter} {
skipspaces(); skipspaces();
yylval.string.text = "\\I\\"; yylval.string.text = "\\I\\";
@ -1559,18 +1565,27 @@ void init_scanner( FILE* in){
void skipspaces( void) { void skipspaces( void) {
int c = yyinput(); int c = yyinput();
while( c && c <= ' ') while( c && c <= ' ') {
if ( c == '\n')
line_number++;
c = yyinput(); c = yyinput();
}
unput( c); unput( c);
} }
void skipoptionalparam( void) { void skipoptionalparam( void) {
int c = yyinput(); int c = yyinput();
while( c && c <= ' ') while( c && c <= ' ') {
if ( c == '\n')
line_number++;
c = yyinput(); c = yyinput();
}
if ( c == '[') if ( c == '[')
while( c && c != ']') while( c && c != ']') {
if ( c == '\n')
line_number++;
c = yyinput(); c = yyinput();
}
else else
unput( c); unput( c);
} }

View File

@ -54,6 +54,7 @@ int CCMode = 0;
extern char* class_name; extern char* class_name;
extern char* formatted_class_name; extern char* formatted_class_name;
char* text_block_to_string( const Text& T); char* text_block_to_string( const Text& T);
char* convert_ccStyle_to_html( const char* txt);
/* for the bibliography */ /* for the bibliography */
/* ==================== */ /* ==================== */
@ -273,10 +274,12 @@ stmt: string { handleBuffer( * $1);
| CREATIONVARIABLE {} | CREATIONVARIABLE {}
| CCSTYLE '{' nested_token_sequence '}' { | CCSTYLE '{' nested_token_sequence '}' {
set_INITIAL = 1; set_INITIAL = 1;
handleString( "<I>"); char* s = text_block_to_string( *$3);
handleText( * $3); char* p = convert_ccStyle_to_html(s);
handleString( "</I>"); handleString( p);
current_font = unknown_font; current_font = unknown_font;
delete[] p;
delete[] s;
delete $3; delete $3;
} }
| INCLUDE '{' comment_sequence '}' { | INCLUDE '{' comment_sequence '}' {
@ -847,23 +850,15 @@ compound_comment: '{' full_comment_sequence '}' {
$2); $2);
} }
| CCSTYLE '{' nested_token_sequence '}' { | CCSTYLE '{' nested_token_sequence '}' {
$$ = $3; set_INITIAL = 1;
set_INITIAL = 1; char* s = text_block_to_string( *$3);
if ( $$->isEmpty() || char* p = convert_ccStyle_to_html(s);
$$->head().isSpace) // should not $$ = new Text( managed);
$$->cons( *new TextToken( "<I>", 1)); $$->cons( *new TextToken( p));
else current_font = unknown_font;
$$->head().prepend( "<I>"); delete[] p;
InListFIter< TextToken> ix( * $$); delete[] s;
ForAll( ix) { delete $3;
if ( ix.isLast())
if ( ix->isSpace)
$$->append( *new TextToken(
"</I>", 1));
else
ix->add( "</I>");
}
current_font = unknown_font;
} }
| verbatim_style { | verbatim_style {
$$ = new Text( managed); $$ = new Text( managed);
@ -1240,6 +1235,10 @@ const char* errorMessage( ErrorNumber n) {
return "Malformed chapter structure: one chapter per file"; return "Malformed chapter structure: one chapter per file";
case UnknownIndexCategoryError: case UnknownIndexCategoryError:
return "Unknown index category in optional argument of \\ccHtmlIndex"; return "Unknown index category in optional argument of \\ccHtmlIndex";
case EmptyClassNameError:
return "The classname was empty";
case EmptyCrossLinkError:
return "The key for a cross link was empty";
} }
return "UNKNOWN ERROR MESSAGE NUMBER"; return "UNKNOWN ERROR MESSAGE NUMBER";
} }
@ -1254,13 +1253,14 @@ void printErrorMessage( ErrorNumber n){
// ----------------- // -----------------
Text* blockintroProcessing( const char* text, int len, Text* t) { Text* blockintroProcessing( const char* text, int len, Text* t) {
if ( len < 0) { /* Hack! Here we know that t has to get capitalized.*/ if ( len < 0) { /* Hack! Here we know that t has to get capitalized.*/
len = 4; len = strlen(text);
InListFIter< TextToken> ix( *t); InListFIter< TextToken> ix( *t);
ForAll( ix) { ForAll( ix) {
if ( ! (*ix).isSpace) { if ( ! (*ix).isSpace) {
char *s = (*ix).string; char *s = (*ix).string;
while ( *s) { while ( *s) {
*s++ = toupper( *s); *s = toupper( *s);
s++;
} }
} }
} }
@ -1275,7 +1275,7 @@ Text* blockintroProcessing( const char* text, int len, Text* t) {
Buffer* blockintroProcessing( const char* text, int len, Buffer* t) { Buffer* blockintroProcessing( const char* text, int len, Buffer* t) {
if ( len < 0) { /* Hack! Here we know that t has to get capitalized.*/ if ( len < 0) { /* Hack! Here we know that t has to get capitalized.*/
len = 4; len = strlen(text);
t->capitalize(); t->capitalize();
} }
t->prepend( text, len); t->prepend( text, len);