extern void gml_index( const gmltag * entry ) { if( ProcFlags.doc_sect_nxt == doc_sect_egdoc ) { xx_line_err( err_eof_expected, tok_start ); return; } if( ProcFlags.doc_sect_nxt == doc_sect_index ) {// duplicate :INDEX tag scan_start = scan_stop + 1; // ignore this call return; // wgml4 OS/2 crashes with page fault } if( !((ProcFlags.doc_sect == doc_sect_backm) || (ProcFlags.doc_sect_nxt == doc_sect_backm)) ) { xx_line_err( err_doc_sec_expected_1, tok_start ); return; } if( !GlobalFlags.index ) { // index option not active return; } scr_process_break(); gml_doc_xxx( doc_sect_index ); /* When gen_index() is finalized, the resets may need to be moved */ g_indent = 0; g_indentr = 0; set_h_start(); /// I suspect start_doc_sect() will be needed here! gen_index(); // output the formatted index }
static void gml_ehp_esf_common( const gmltag * entry, e_tags t ) { char * p; tag_cb * wk; entry = entry; if( nest_cb->c_tag != t ) { // unexpected exxx tag if( nest_cb->c_tag == t_NONE ) { g_err_tag_no( str_tags[t + 1] );// no exxx expected } else { g_err_tag_nest( str_tags[nest_cb->c_tag + 1] ); // exxx expected } } else { wk = nest_cb; nest_cb = nest_cb->prev; add_tag_cb_to_pool( wk ); g_curr_font = nest_cb->font; scan_err = false; p = scan_start; if( *p == '.' ) p++; // over '.' if( *p ) { process_text( p, g_curr_font ); } if( !ProcFlags.concat && (input_cbs->fmflags & II_eol) ) { scr_process_break(); // ensure line is output } } scan_start = scan_stop + 1; }
static void gml_ehp_esf_common( gml_tag egtag ) { char * p; tag_cb * wk; if( !g_err_gml_etag( egtag ) ) { wk = nest_cb; nest_cb = nest_cb->prev; add_tag_cb_to_pool( wk ); g_curr_font = nest_cb->font; // recompute space at SOL if inline end tag - TBD if( (post_space !=0) && (input_cbs->fmflags & II_sol) ) { post_space = wgml_fonts[g_curr_font].spc_width; } scan_err = false; p = scan_start; if( *p == '.' ) p++; // over '.' if( *p ) { process_text( p, g_curr_font ); } if( !ProcFlags.concat && (input_cbs->fmflags & II_eol) ) { scr_process_break(); // ensure line is output } } scan_start = scan_stop; }
void proc_p_pc( p_lay_tag * p_pc ) { char * p; scan_err = false; p = scan_start; ProcFlags.keep_left_margin = true; // special Note indent start_doc_sect(); // if not already done scr_process_break(); if( nest_cb->c_tag == t_NONE ) { g_cur_left = g_page_left + g_indent;// left start TBD } else { g_cur_left = g_cur_left; } // possibly indent first line g_cur_h_start = g_cur_left + conv_hor_unit( &(p_pc->line_indent) ); g_cur_threshold = layout_work.widow.threshold; // standard threshold if( *p == '.' ) p++; // over '.' set_skip_vars( &(p_pc->pre_skip), NULL, &(p_pc->post_skip), spacing, g_curr_font ); post_space = 0; process_text( p, g_curr_font ); scan_start = scan_stop + 1; return; }
extern void gml_abstract( const gmltag * entry ) { if( ProcFlags.doc_sect_nxt == doc_sect_egdoc ) { xx_line_err( err_eof_expected, tok_start ); return; } if( !ProcFlags.frontm_seen ) { xx_line_err( err_doc_sec_expected_1, tok_start ); return; } if( blank_lines > 0 ) { set_skip_vars( NULL, NULL, NULL, 0, 0 ); // set g_blank_lines } scr_process_break(); gml_doc_xxx( doc_sect_abstract ); g_cur_left = g_page_left; g_cur_h_start = g_page_left; if( layout_work.hx.hx_sect[hds_abstract].header ) { start_doc_sect(); // a header is enough } g_indent = 0; g_indentr = 0; set_h_start(); }
static void gml_xl_lp_common( e_tags t ) { char * p; end_lp(); // terminate :LP if active init_nest_cb(); nest_cb->p_stack = copy_to_nest_stack(); nest_cb->c_tag = t; scan_err = false; p = scan_start; if( *p == '.' ) p++; // possible tag end if( t != t_LP ) { // text only allowed for :LP if( t != t_DL && t != t_GL ) { // DL/GL don't require LI/LP ProcFlags.need_li_lp = true; // :LI or :LP next } start_doc_sect(); // if not already done if( g_line_indent == 0 ) { ProcFlags.para_starting = false; // clear for this tag's first break } scr_process_break(); if( *p ) { process_text( p, g_curr_font ); } } return; }
extern void gml_titlep( const gmltag * entry ) { if( ProcFlags.doc_sect_nxt == doc_sect_egdoc ) { xx_line_err( err_eof_expected, tok_start ); return; } if( !ProcFlags.frontm_seen ) { xx_line_err( err_doc_sec_expected_1, tok_start ); return; } scr_process_break(); gml_doc_xxx( doc_sect_titlep ); add_symvar( &global_dict, "$stitle", "", no_subscript, 0 );// set nullstring add_symvar( &global_dict, "$title", "", no_subscript, 0 );// set nullstring rs_loc = titlep_tag; if( input_cbs->fmflags & II_file ) { // save line number titlep_lineno = input_cbs->s.f->lineno; } else if( input_cbs->fmflags & II_tag_mac ) { titlep_lineno = input_cbs->s.m->lineno; } else { titlep_lineno = 0; // not clear what to do here } save_indent = g_indent; save_indentr = g_indentr; g_indent = 0; g_indentr = 0; set_h_start(); }
static void gml_hp_sf_common( const gmltag * entry, int level, e_tags t ) { char * p; entry = entry; init_nest_cb(); nest_cb->p_stack = copy_to_nest_stack(); if( level >= wgml_font_cnt ) { // invalid font use default level = 0; } nest_cb->font = level; g_curr_font = level; nest_cb->c_tag = t; scan_err = false; p = scan_start; if( *p == '.' ) p++; // over '.' if( *p ) { process_text( p, g_curr_font ); } if( !ProcFlags.concat && (input_cbs->fmflags & II_eol) ) { scr_process_break(); // ensure line is output } scan_start = scan_stop + 1; return; }
static void gml_li_sl( const gmltag * entry ) { char * p; int32_t t_left_indent_1 = 0; int32_t t_left_indent_2 = 0; int32_t t_right_indent = 0; scan_err = false; p = scan_start; if( nest_cb == NULL ) { xx_nest_err( err_li_lp_no_list ); // tag must be in a list scan_start = scan_stop + 1; return; } scr_process_break(); if( ProcFlags.need_li_lp ) { // first :li for this list set_skip_vars( &nest_cb->xl_pre_skip, NULL, NULL, 1, g_curr_font ); } else if( !nest_cb->compact ) { set_skip_vars( &((sl_lay_level *)(nest_cb->lay_tag))->skip, NULL, NULL, 1, g_curr_font ); } else { // compact set_skip_vars( NULL, NULL, NULL, 1, g_curr_font ); } ProcFlags.keep_left_margin = true; // keep special Note indent /* Use original indents, not values possibly modified by IN */ t_left_indent_1 = conv_hor_unit( &((sl_lay_level *)(nest_cb->lay_tag))->left_indent, g_curr_font ) + nest_cb->prev->left_indent + nest_cb->prev->align; t_left_indent_2 = conv_hor_unit( &((sl_lay_level *)(nest_cb->lay_tag))->left_indent, g_curr_font ); t_right_indent = -1 * conv_hor_unit( &((sl_lay_level *)(nest_cb->lay_tag))->right_indent, g_curr_font ) + nest_cb->prev->right_indent; g_cur_left = nest_cb->lm + t_left_indent_2; g_page_right = nest_cb->rm + t_right_indent; g_cur_h_start = g_cur_left; post_space = 0; ju_x_start = g_cur_h_start; g_curr_font = ((sl_lay_level *)(nest_cb->lay_tag))->font; if( *p == '.' ) p++; // over '.' while( *p == ' ' ) p++; // skip initial spaces ProcFlags.need_li_lp = false; if( *p ) { process_text( p, g_curr_font ); // if text follows } /* Set indents to their original values for the next LI */ nest_cb->left_indent = t_left_indent_1; nest_cb->right_indent = t_right_indent; scan_start = scan_stop + 1; return; }
extern void gml_figlist( const gmltag * entry ) { scr_process_break(); figlist_toc |= gs_figlist; if( GlobalFlags.lastpass && (pass > 1) ) { gen_figlist(); } }
void gml_eul( const gmltag * entry ) { scr_process_break(); if( nest_cb->c_tag == t_UL ) { set_skip_vars( NULL, NULL, &((ul_lay_tag *)(nest_cb->lay_tag))->post_skip, 1, g_curr_font ); } gml_exl_common( entry, t_UL ); }
extern void gml_frontm( const gmltag * entry ) { scr_process_break(); gml_doc_xxx( doc_sect_frontm ); if( !ProcFlags.fb_document_done ) { // the very first section/page do_layout_end_processing(); } ProcFlags.frontm_seen = true; }
void gml_egdoc( gml_tag gtag ) { gtag = gtag; if( g_blank_lines_ln > 0 ) { set_skip_vars( NULL, NULL, NULL, 0, 0 ); // set g_blank_lines } scr_process_break(); // outputs last element in file if( !ProcFlags.start_section ) { start_doc_sect(); // if not already done } gml_doc_xxx( doc_sect_egdoc ); }
extern void gml_pb( const gmltag * entry ) { scan_err = false; start_doc_sect(); // if not already done scr_process_break(); scan_start = scan_stop + 1; return; }
extern void gml_pb( gml_tag gtag ) { /* unused parameters */ (void)gtag; scan_err = false; start_doc_sect(); // if not already done scr_process_break(); scan_start = scan_stop; return; }
void gml_backm( gml_tag gtag ) { gtag = gtag; if( g_blank_lines_ln > 0 ) { set_skip_vars( NULL, NULL, NULL, 0, 0 ); // set g_blank_lines } scr_process_break(); gml_doc_xxx( doc_sect_backm ); ProcFlags.frontm_seen = false; // no longer in FRONTM section if( !ProcFlags.fb_document_done ) { // the very first section/page do_layout_end_processing(); } }
extern void gml_pb( gml_tag gtag ) { gtag = gtag; scan_err = false; start_doc_sect(); // if not already done scr_process_break(); scan_start = scan_stop; return; }
void gml_eul( const gmltag * entry ) { if( g_line_indent == 0 ) { ProcFlags.para_starting = false; // clear for this tag's break } scr_process_break(); set_skip_vars( NULL, NULL, &((ul_lay_level *)(nest_cb->lay_tag))->post_skip, 1, g_curr_font ); gml_exl_common( entry, t_UL ); if( ul_cur_level == 1 ) { ul_cur_level = layout_work.ul.max_level; } else { ul_cur_level++; } }
extern void gml_appendix( const gmltag * entry ) { if( blank_lines > 0 ) { set_skip_vars( NULL, NULL, NULL, 0, 0 ); // set g_blank_lines } scr_process_break(); gml_doc_xxx( doc_sect_appendix ); ProcFlags.frontm_seen = false; // no longer in FRONTM section if( !ProcFlags.fb_document_done ) { // the very first section/page do_layout_end_processing(); } g_indent = 0; g_indentr = 0; set_h_start(); }
void gml_exmp( const gmltag * entry ) { tag_cb * wk; entry = entry; scr_process_break(); if( !ProcFlags.xmp_active ) { // no preceding :XMP tag g_err_tag_prec( "XMP" ); scan_start = scan_stop + 1; return; } g_curr_font = font_save; ProcFlags.xmp_active = false; ProcFlags.justify = justify_save; wk = nest_cb; nest_cb = nest_cb->prev; add_tag_cb_to_pool( wk ); /* place the accumulated xlines on the proper page */ ProcFlags.group_elements = false; if( t_doc_el_group.first != NULL ) { t_doc_el_group.depth += (t_doc_el_group.first->blank_lines + t_doc_el_group.first->subs_skip); } if( (t_doc_el_group.depth + t_page.cur_depth) > t_page.max_depth ) { /* the block won't fit on this page */ if( t_doc_el_group.depth <= t_page.max_depth ) { /* the block will be on the next page */ do_page_out(); reset_t_page(); } } while( t_doc_el_group.first != NULL ) { insert_col_main( t_doc_el_group.first ); t_doc_el_group.first = t_doc_el_group.first->next; } t_doc_el_group.depth = 0; t_doc_el_group.last = NULL; scan_start = scan_stop + 1; return; }
static void gml_li_sl( const gmltag * entry ) { char * p; entry = entry; scan_err = false; p = scan_start; if( nest_cb == NULL ) { xx_nest_err( err_li_lp_no_list ); // tag must be in a list scan_start = scan_stop + 1; return; } scr_process_break(); if( ProcFlags.need_li_lp ) { // first :li for this list set_skip_vars( &((sl_lay_tag *)(nest_cb->lay_tag))->pre_skip, NULL, NULL, 1, g_curr_font ); } else if( !nest_cb->compact ) { set_skip_vars( &((sl_lay_tag *)(nest_cb->lay_tag))->skip, NULL, NULL, 1, g_curr_font ); } else { // compact set_skip_vars( NULL, NULL, NULL, 1, g_curr_font ); } ProcFlags.keep_left_margin = true; // keep special Note indent g_cur_left = nest_cb->lm + nest_cb->left_indent; g_cur_h_start = g_cur_left; g_page_right = nest_cb->rm - nest_cb->right_indent; post_space = 0; g_cur_h_start = g_cur_left; ju_x_start = g_cur_h_start; spacing = ((sl_lay_tag *)(nest_cb->lay_tag))->spacing; g_curr_font = ((sl_lay_tag *)(nest_cb->lay_tag))->font; if( *p == '.' ) p++; // over '.' while( *p == ' ' ) p++; // skip initial spaces ProcFlags.need_li_lp = false; if( *p ) { process_text( p, g_curr_font ); // if text follows } scan_start = scan_stop + 1; return; }
extern void gml_etitlep( const gmltag * entry ) { tag_cb * wk; scr_process_break(); gml_doc_xxx( doc_sect_etitlep ); rs_loc = 0; titlep_lineno = 0; if( nest_cb != NULL ) { // guard against no FRONTM, empty TITLEP section g_indent = save_indent; g_indentr = save_indentr; set_h_start(); wk = nest_cb; nest_cb = nest_cb->prev; add_tag_cb_to_pool( wk ); } }
void gml_preface( gml_tag gtag ) { gtag = gtag; if( ProcFlags.doc_sect_nxt == doc_sect_egdoc ) { xx_line_err( err_eof_expected, tok_start ); return; } if( !ProcFlags.frontm_seen ) { xx_line_err( err_doc_sec_expected_1, tok_start ); return; } if( g_blank_lines_ln > 0 ) { set_skip_vars( NULL, NULL, NULL, 0, 0 ); // set g_blank_lines } scr_process_break(); gml_doc_xxx( doc_sect_preface ); g_spacing_ln = layout_work.preface.spacing; }
void gml_body( gml_tag gtag ) { gtag = gtag; if( g_blank_lines_ln > 0 ) { set_skip_vars( NULL, NULL, NULL, 0, 0 ); // set g_blank_lines } scr_process_break(); gml_doc_xxx( doc_sect_body ); ProcFlags.just_override = true; // justify for first line ?? TBD g_cur_left = g_page_left; g_cur_h_start = g_page_left + conv_hor_unit( &layout_work.p.line_indent ); ProcFlags.frontm_seen = false; // no longer in FRONTM section if( !ProcFlags.fb_document_done ) { // the very first section/page do_layout_end_processing(); } }
extern void gml_backm( const gmltag * entry ) { if( !ProcFlags.fb_document_done ) { // the very first section/page do_layout_end_processing(); } if( blank_lines > 0 ) { set_skip_vars( NULL, NULL, NULL, 0, 0 ); // set g_blank_lines } scr_process_break(); gml_doc_xxx( doc_sect_backm ); ProcFlags.frontm_seen = false; // no longer in FRONTM section g_cur_left = g_page_left; g_cur_h_start = g_page_left; if( layout_work.hx.hx_sect[hds_backm].header ) { start_doc_sect(); // a header is enough } g_indent = 0; g_indentr = 0; }
void proc_p_pc( p_lay_tag * p_pc ) { char * p; scan_err = false; p = scan_start; ProcFlags.keep_left_margin = true; // special Note indent start_doc_sect(); // if not already done if( g_line_indent == 0 ) { ProcFlags.para_starting = false; // clear for this tag's break } scr_process_break(); g_line_indent = conv_hor_unit( &(p_pc->line_indent), g_curr_font ); g_cur_left = g_page_left + g_indent + nest_cb->left_indent + nest_cb->align;// left start TBD // possibly indent first line g_cur_h_start = g_cur_left + g_line_indent; g_cur_threshold = layout_work.widow.threshold; // standard threshold if( *p == '.' ) p++; // over '.' set_skip_vars( &(p_pc->pre_skip), NULL, &(p_pc->post_skip), spacing, g_curr_font ); ProcFlags.para_starting = true; // for next break, not this tag's break post_space = 0; if( *p ) { process_text( p, g_curr_font ); } scan_start = scan_stop + 1; return; }
extern void gml_body( const gmltag * entry ) { if( blank_lines > 0 ) { set_skip_vars( NULL, NULL, NULL, 0, 0 ); // set g_blank_lines } scr_process_break(); gml_doc_xxx( doc_sect_body ); ProcFlags.just_override = true; // justify for first line ?? TBD g_cur_left = g_page_left; g_cur_h_start = g_page_left + conv_hor_unit( &layout_work.p.line_indent, g_curr_font ); ProcFlags.frontm_seen = false; // no longer in FRONTM section if( !ProcFlags.fb_document_done ) { // the very first section/page do_layout_end_processing(); } if( layout_work.hx.hx_sect[hds_body].header ) { start_doc_sect(); // a header is enough } g_indent = 0; g_indentr = 0; set_h_start(); }
static void gml_hp_sf_common( gml_tag gtag, int level ) { char * p; /* unused parameters */ (void)gtag; // keep any existing post_space, even if CT follows -- TBD if( (input_cbs->fmflags & II_sol) ) { ProcFlags.fsp = true; if( post_space == 0 ) { post_space = wgml_fonts[g_curr_font].spc_width; // TBD } } init_nest_cb( true ); if( level >= wgml_font_cnt ) { // invalid font use default level = 0; } nest_cb->font = level; g_curr_font = level; nest_cb->gtag = gtag; scan_err = false; p = scan_start; if( *p == '.' ) p++; // over '.' if( *p ) { process_text( p, g_curr_font ); } if( !ProcFlags.concat && (input_cbs->fmflags & II_eol) ) { scr_process_break(); // ensure line is output } scan_start = scan_stop; return; }
extern void gml_note( const gmltag * entry ) { char * p; font_number font_save; text_chars * marker; uint32_t spc_cnt; scan_err = false; p = scan_start; start_doc_sect(); // if not already done scr_process_break(); font_save = g_curr_font; g_curr_font = layout_work.note.font; set_skip_vars( &layout_work.note.pre_skip, NULL, &layout_work.note.post_skip, spacing, g_curr_font ); post_space = 0; if( nest_cb->c_tag == t_NONE ) { g_cur_left = g_page_left + conv_hor_unit( &layout_work.note.left_indent, g_curr_font ); } else { g_cur_left += conv_hor_unit( &layout_work.note.left_indent, g_curr_font ); } g_cur_h_start = g_cur_left; ProcFlags.keep_left_margin = true; // keep special Note indent start_line_with_string( layout_work.note.string, layout_work.note.font, false ); /* the value of post_space after start_line_with_string() is wrong for */ /* two reasons: 1) it uses the wrong font; 2) it is at most "1" even if */ /* more than one space appears at the end of the note_string. */ spc_cnt = post_space / wgml_fonts[g_curr_font].spc_width; post_space = spc_cnt * wgml_fonts[font_save].spc_width; if( (t_line != NULL) && (t_line->last != NULL) ) { g_cur_left += t_line->last->width + post_space; } g_cur_h_start = g_cur_left; ju_x_start = g_cur_h_start; spacing = layout_work.note.spacing; g_curr_font = layout_work.defaults.font; set_skip_vars( NULL, NULL, NULL, spacing, g_curr_font ); if( *p == '.' ) p++; // over '.' while( *p == ' ' ) p++; // skip initial space if( *p ) { // if text follows post_space = 0; process_text( p, g_curr_font ); } else if( !ProcFlags.concat && ProcFlags.has_aa_block && (t_line != NULL) && (post_space > 0) ) { /* only create marker if line not empty, */ /* :NOTE note_string is not nullstring and ends in at least 1 space */ marker = alloc_text_chars( NULL, 0, font_save ); marker->x_address = g_cur_h_start; if( t_line->first == NULL ) { t_line->first = marker; t_line->last = t_line->first; } else { marker->prev = t_line->last; t_line->last->next = marker; t_line->last = t_line->last->next; } post_space = 0; } g_curr_font = font_save; scan_start = scan_stop + 1; return; }
void gml_binclude( gml_tag gtag ) { bool depth_found = false; bool file_found = false; bool has_rec_type = false; bool reposition; bool reposition_found = false; char file[FILENAME_MAX]; char rt_buff[MAX_FILE_ATTR]; char * p; doc_element * cur_el; su depth_su; uint32_t depth; size_t len; if( (ProcFlags.doc_sect < doc_sect_gdoc) ) { if( (ProcFlags.doc_sect_nxt < doc_sect_gdoc) ) { xx_tag_err( err_tag_before_gdoc, gml_tagname( gtag ) ); scan_start = scan_stop; return; } } len = 0; file[0] = '\0'; rt_buff[0] = '\0'; p = scan_start; for( ;; ) { while( *p == ' ' ) { // over WS to attribute p++; } if( *p == '\0' ) { // end of line: get new line if( !(input_cbs->fmflags & II_eof) ) { if( get_line( true ) ) { // next line for missing attribute process_line(); if( (*scan_start == SCR_char) || // cw found: end-of-tag (*scan_start == GML_char) ) { // tag found: end-of-tag ProcFlags.tag_end_found = true; break; } else { p = scan_start; // new line is part of current tag continue; } } } } if( !strnicmp( "file", p, 4 ) ) { p += 4; p = get_att_value( p ); if( val_start == NULL ) { break; } file_found = true; len = val_len; if( len >= FILENAME_MAX ) len = FILENAME_MAX - 1; memcpy( file, val_start, len ); file[len] = '\0'; split_attr_file( file, rt_buff, MAX_FILE_ATTR ); if( (rt_buff[0] != '\0') ) { has_rec_type = true; if( rt_buff[0] != 't' ) { xx_warn( wng_rec_type_binclude ); } } if( ProcFlags.tag_end_found ) { break; } } else if( !strnicmp( "depth", p, 5 ) ) { p += 5; p = get_att_value( p ); if( val_start == NULL ) { break; } depth_found = true; if( att_val_to_su( &depth_su, true ) ) { return; } depth = conv_vert_unit( &depth_su, g_spacing_ln ); if( ProcFlags.tag_end_found ) { break; } } else if( !strnicmp( "reposition", p, 10 ) ) { p += 10; p = get_att_value( p ); if( val_start == NULL ) { break; } reposition_found = true; if( !strnicmp( "start", val_start, 5 ) ) { reposition = true; // moving following text down by depth } else if( !strnicmp( "end", val_start, 3 ) ) { reposition = false; // device at proper position after insertion } else { xx_line_err( err_inv_att_val, val_start ); scan_start = scan_stop; return; } if( ProcFlags.tag_end_found ) { break; } } else { // no match = end-of-tag in wgml 4.0 ProcFlags.tag_end_found = true; break; } } // detect missing required attributes if( !depth_found || !file_found || !reposition_found ) { xx_err( err_att_missing ); scan_start = scan_stop; return; } scr_process_break(); // flush existing text start_doc_sect(); // if not already done cur_el = alloc_doc_el( el_binc ); if( reposition && depth ) { cur_el->depth = depth; // otherwise, it will be "0" } if( depth > 0 ) { set_skip_vars( NULL, NULL, NULL, 1, g_curr_font ); cur_el->blank_lines = g_blank_lines; g_blank_lines = 0; cur_el->subs_skip = g_subs_skip; cur_el->top_skip = g_top_skip; } cur_el->element.binc.depth = depth; cur_el->element.binc.cur_left = g_cur_h_start; cur_el->element.binc.has_rec_type = has_rec_type; ProcFlags.skips_valid = false; memcpy( cur_el->element.binc.file, file, len + 1 ); insert_col_main( cur_el ); scan_start = scan_stop; // skip following text }