Ejemplo n.º 1
0
static  void    gml_ixxx_common( const gmltag * entry, int hx_lvl )
{
    bool          idseen;
    bool          refidseen;
    bool          seeseen;
    bool          seeidseen;
    bool          pgseen;
    bool          printseen;
    char      *   p;
    ereftyp       pgvalue;
    char      *   pgtext;
    size_t        pgtextlen;
    size_t        printtxtlen;
    size_t        seetextlen;
    char      *   printtxt;
    char      *   seetext;
    ref_entry *   refwork;

    ref_entry     reid;
    ref_entry *   rewk;

    ref_entry     refid;
    ref_entry *   refwk;

    ref_entry     reseeid;
    ref_entry *   rswk;

    ix_h_blk  *   ihm1;
    ix_e_blk  *   ixewk;
    ix_e_blk  *   ixewksav;
    ix_h_blk  *   ixhwk;
    ix_h_blk  * * ixhwork;
    uint32_t      wkpage;
    size_t        txtlen;
    char      *   txt;
    char          hxstring[TAG_NAME_LENGTH +1];
    char          lvlc;

    if( !GlobalFlags.index ) {          // index option not active
        scan_start = scan_stop + 1;     // ignore tag
        return;
    }
    lvlc = '0' + (char)hx_lvl;
    *hxstring = GML_char;         // construct tagname for possible error msg
    strcpy_s( (hxstring + 1), TAG_NAME_LENGTH, entry->tagname );

    if( (hxstring[2] == lvlc) &&        // :Ix tags not allowed before :GDOC
        !((ProcFlags.doc_sect >= doc_sect_gdoc) ||
        (ProcFlags.doc_sect_nxt >= doc_sect_gdoc)) ) {

        g_err( err_tag_before_gdoc, hxstring );
        err_count++;
        file_mac_info();
        scan_start = scan_stop + 1;
        return;
    }

    if( hx_lvl > 1 ) {          // test for missing previous parent index tag
        if( ixhtag[hx_lvl - 1] == NULL ) {
            g_err( err_parent_undef );
            err_count++;
            file_mac_info();
            scan_start = scan_stop + 1;
            return;
        }
    }

    idseen    = false;
    pgseen    = false;
    refidseen = false;
    printseen = false;
    seeseen   = false;
    seeidseen = false;

    ixewk     = NULL;
    pgvalue   = pgnone;
    pgtext    = NULL;
    pgtextlen = 0;
    printtxt  = NULL;
    printtxtlen = 0;
    seetext   = NULL;

    wkpage    = page + 1;
    p         = scan_start;
    ProcFlags.tag_end_found = false;

    /***********************************************************************/
    /*  Scan attributes  for :Ix  :IHx :IREF                               */
    /*                                                                     */
    /*  id=                                                                */
    /*  refid=                                                             */
    /*  pg=                                                                */
    /*  print=                                                             */
    /*  see=                                                               */
    /*  seeid=                                                             */
    /***********************************************************************/

    for( ;; ) {
        if( ProcFlags.tag_end_found ) {
            break;
        }
        while( is_space_tab_char( *p ) ) {
            p++;
        }
        if( *p == '.'  ) {
            ProcFlags.tag_end_found = true;
            break;
        }
        if( *p == '\0' ) {
            break;
        }

        /*******************************************************************/
        /*  ID='xxxxxxxx'   for :Ix :IHx                                   */
        /*******************************************************************/

        if( !strnicmp( "id", p, 2 ) ) {
            p += 2;
            p = get_refid_value( p );
            if( (val_start != NULL) && (val_len > 0) ) {
                if( hx_lvl > 0 ) {      // :Ix :IHx
                    idseen = true;      // id attribute found
                    init_ref_entry( &reid, val_start, val_len );
                    rewk = find_refid( iref_dict, reid.id );
                    if( rewk != NULL ) {
                        if( rewk->lineno != reid.lineno ) {
                            g_err( inf_id_duplicate );
                            err_count++;
                            file_mac_info();
                            scan_start = scan_stop + 1;
                            return;
                        }
                    }
                } else {                // not allowed for :IREF
                    g_err( err_refid_not_allowed, hxstring );
                    err_count++;
                    file_mac_info();
                    scan_start = scan_stop + 1;
                    return;
                }
            }
            scan_start = p;
            continue;
        }


        /*******************************************************************/
        /*  REFID='xxxxxxxx'  for :IREF :I2 :I3                            */
        /*******************************************************************/

        if( !strnicmp( "refid", p, 5 ) ) {
            p += 5;
            p = get_refid_value( p );
            if( val_start != NULL && val_len > 0 ) {
                if( (hx_lvl == 0) || ((hx_lvl > 1) && (hxstring[2] == lvlc)) ) {
                    fill_id( &refid, val_start, val_len );
                    refidseen = true;   // refid attribute found
                    refwk = find_refid( iref_dict, refid.id );
                    if( refwk == NULL ) {   // refid not in dict
                        if( GlobalFlags.lastpass ) {// this is an error
                            g_err( inf_id_unknown );// during lastpass
                            err_count++;
                            file_mac_info();
                            scan_start = scan_stop + 1;
                            return;
                        }
                    }
                } else {                // not allowed for :I1 and :IHx
                    g_err( err_refid_not_allowed, hxstring );
                    err_count++;
                    file_mac_info();
                    scan_start = scan_stop + 1;
                    return;
                }
            }
            scan_start = p;
            continue;
        }


        /*******************************************************************/
        /*  PG=          for :IREF :Ix                                     */
        /*******************************************************************/

        if( !strnicmp( "pg", p, 2 ) ) {
            p += 2;
            p = get_att_value( p );

            scan_start = p;
            if( val_start == NULL || val_len == 0 ) {   // no valid pg
                continue;               // ignore
            }

            if( quote_char == '\0' ) {  // value not quoted
                if( !strnicmp( "start", val_start, 5 ) ) {
                    pgvalue = pgstart;
                } else if( !strnicmp( "end", val_start, 3 ) ) {
                    pgvalue = pgend;
                } else if( !strnicmp( "major", val_start, 5 ) ) {
                    pgvalue = pgmajor;
                } else {
                    continue;           // ignore
                }
            } else {
                pgvalue = pgstring;
                pgtext = mem_alloc( val_len + 1 );
                strncpy( pgtext, val_start, val_len );// use text instead of pageno
                *(pgtext + val_len) = '\0';
                pgtextlen = val_len;
            }
            pgseen = true;
            continue;
        }


        /*******************************************************************/
        /*  PRINT=    for :IHx                                             */
        /*******************************************************************/

        if( !strnicmp( "print", p, 5 ) ) {
            p += 5;
            p = get_att_value( p );

            scan_start = p;
            if( val_start == NULL || val_len == 0 ) {
                continue;               // ignore
            }
            printtxt = mem_alloc( val_len + 1 );
            printtxtlen = val_len;
            strncpy( printtxt, val_start, val_len );
            *(printtxt + val_len) = '\0';
            printseen = true;
            continue;
        }


        /*******************************************************************/
        /*  SEE='xxxxxxxx'  for :IREF :IH1 :IH2                            */
        /*******************************************************************/

        if( !strnicmp( "see", p, 3 ) ) {

            p += 3;
            p = get_att_value( p );

            scan_start = p;
            if( (val_start != NULL) || val_len > 0 ) {
                if( hx_lvl == 0  ||
                    ((hx_lvl < 3) && (hxstring[3] == lvlc)) ) {// :IREF :IH1 :IH2
                    seetext = mem_alloc( val_len +1 );
                    strncpy( seetext, val_start, val_len );
                    *(seetext + val_len) = '\0';
                    seetextlen = val_len;
                    seeseen = true;
                } else {                // not allowed for :IH3, :Ix
                    g_err( err_refid_not_allowed, hxstring );
                    err_count++;
                    file_mac_info();
                    scan_start = scan_stop + 1;
                    return;
                }
            }
            continue;
        }


        /*******************************************************************/
        /*  SEEID='xxxxxxxx'  for :IREF :IH1 :IH2                          */
        /*******************************************************************/

        if( !strnicmp( "seeid", p, 5 ) ) {
            p += 5;
            p = get_refid_value( p );
            if( (val_start != NULL) && (val_len > 0) ) {
                if( (hx_lvl <= 3) && (hxstring[3] == lvlc) ) {
                    seeidseen = true;
                    fill_id( &reseeid, val_start, val_len );// copy lower id
                    rswk = find_refid( iref_dict, reseeid.id );
                    if( rswk == NULL ) {// not in dict, this is an error
                        if( GlobalFlags.lastpass ) {  // during lastpass
                            g_err( inf_id_unknown );
                            err_count++;
                            file_mac_info();
                            scan_start = scan_stop + 1;
                            return;
                        }
                    }
                } else {                // not allowed for :IH3, :Ix :IREF
                    g_err( err_refid_not_allowed, hxstring );
                    err_count++;
                    file_mac_info();
                    scan_start = scan_stop + 1;
                    return;
                }
            }
            scan_start = p;
            continue;
        }


        /*******************************************************************/
        /* no more valid attributes                                        */
        /*******************************************************************/
        break;
    }

    if( ProcFlags.tag_end_found ) {     // tag end ?
        p++;
        if( hx_lvl > 0 ) {              // we need a text line for :Ix :IHx
            if( !*p ) {
                get_line( true );
                p = buff2;
            }
        }
    }


    /***********************************************************************/
    /* process the found attributes and the text line                      */
    /***********************************************************************/
    txt = p;
    txtlen = strlen( p );

    if( !pgseen ) {
        pgvalue = pgpageno;             // set default
    }

    if( hx_lvl == 0 ) {                 // :IREF tag

    /***********************************************************************/
    /* processing for :IREF                                                */
    /***********************************************************************/

        if( !refidseen ) {              // refid= missing
            g_err( err_att_missing );
            err_count++;
            file_mac_info();
            scan_start = scan_stop + 1;
            return;
        }
        if( GlobalFlags.lastpass ) {
            if( refidseen && (refwk != NULL) ) {
                ixhwk = refwk->u.refb.hblk;
            } else {
                ixhwk = ixhtag[hx_lvl];
            }

            /***************************************************************/
            /* create index entry with page no / text                      */
            /***************************************************************/
            if( ixhwk->entry == NULL ) {    // first entry
                ixewk = fill_ix_e_blk( &(ixhwk->entry), ixhwk, pgvalue, pgtext, pgtextlen );
            } else {
                if( pgvalue == pgmajor ) {  // major becomes first in chain
                    ixewksav = ixhwk->entry;
                    ixhwk->entry = NULL;
                    ixewk = fill_ix_e_blk( &(ixhwk->entry), ixhwk, pgvalue,
                                           pgtext, pgtextlen );
                    ixewk->next = ixewksav;
                } else {
                    ixewk = ixhwk->entry;
                    if( pgvalue < pgstring ) {  // pageno variants
                        if( ixewk->entry_typ < pgstring ) {
                            while( ixewk->next != NULL ) {// insert before pgstring
                                if( ixewk->next->entry_typ >= pgstring ) {
                                    break;
                                }
                                ixewk = ixewk->next;
                            }
                        } else {
                            ixewksav = ixhwk->entry;
                            ixhwk->entry = NULL;
                            ixewk = fill_ix_e_blk( &(ixhwk->entry), ixhwk,
                                                   pgvalue, pgtext, pgtextlen );
                            ixewk->next = ixewksav;
                        }
                        if( ixewk->u.page_no != wkpage ) {
                            ixewksav = ixewk->next;
                            ixewk->next = NULL;
                            ixewk = fill_ix_e_blk( &(ixewk->next), ixhwk, pgvalue,
                                                   pgtext, pgtextlen );
                            ixewk->next = ixewksav;
                        }
                    } else {
                        while( ixewk->next != NULL ) {  // find last entry
                            ixewk = ixewk->next;
                        }
                        ixewk = fill_ix_e_blk( &(ixewk->next), ixhwk, pgvalue,
                                               pgtext, pgtextlen );
                    }
                }
            }
        }
    } else                              // :Ix :IHx tags

    if( ((hxstring[2] == lvlc) ) ) {    // test for :Ix

    /***********************************************************************/
    /* processing for :Ix                                                  */
    /***********************************************************************/

        switch( hx_lvl ) {              // processing for :I1 :I2 :I3
        case 1 :
            ixhwork = &index_dict;
            ixhwk = find_create_ix_h_entry( ixhwork, &printtxt, printtxtlen,
                                            txt, txtlen, hx_lvl );
            printtxt = NULL;
            ixhtag[hx_lvl] = ixhwk;
            break;
        case 2 :
        case 3 :
            ihm1 = ixhtag[hx_lvl - 1];
            if( refidseen && (refwk != NULL) ) {
                if( hx_lvl > refwk->u.refb.hblk->ix_lvl ) {
                    ixhwork = &(refwk->u.refb.hblk->lower);
                } else {
                    ixhwork = &(refwk->u.refb.hblk);
                }
            } else {
                ixhwork = &(ixhtag[hx_lvl - 1]->lower);
            }
            ixhwk = find_create_ix_h_entry( ixhwork, &printtxt, printtxtlen,
                                            txt, txtlen, hx_lvl );
            printtxt = NULL;
            if( !refidseen ) {
                ixhtag[hx_lvl] = ixhwk;
            }
            break;
        default:
            break;
        }

        /*******************************************************************/
        /* create index entry with page no / text                          */
        /*******************************************************************/
        if( ixhwk->entry == NULL ) {    // first entry
            ixewk = fill_ix_e_blk( &(ixhwk->entry), ixhwk, pgvalue, pgtext,
                                   pgtextlen );
        } else {
            if( pgvalue == pgmajor ) {  // major becomes first in chain
                ixewksav = ixhwk->entry;
                ixhwk->entry = NULL;
                ixewk = fill_ix_e_blk( &(ixhwk->entry), ixhwk, pgvalue, pgtext,
                                       pgtextlen );
                ixewk->next = ixewksav;
            } else {
                ixewk = ixhwk->entry;
                if( pgvalue < pgstring ) {  // pageno variants
                    if( ixewk->entry_typ < pgstring ) {
                        while( ixewk->next != NULL ) {// insert before pgstring
                            if( ixewk->next->entry_typ >= pgstring ) {
                                break;
                            }
                            ixewk = ixewk->next;
                        }
                    } else {
                        ixewksav = ixhwk->entry;
                        ixhwk->entry = NULL;
                        ixewk = fill_ix_e_blk( &(ixhwk->entry), ixhwk,
                                               pgvalue, pgtext, pgtextlen );
                        ixewk->next = ixewksav;
                    }
                    if( ixewk->u.page_no != wkpage ) {
                        ixewksav = ixewk->next;
                        ixewk->next = NULL;
                        ixewk = fill_ix_e_blk( &(ixewk->next), ixhwk, pgvalue,
                                               pgtext, pgtextlen );
                        ixewk->next = ixewksav;
                    }
                } else {
                    while( ixewk->next != NULL ) {  // find last entry
                        ixewk = ixewk->next;
                    }
                    ixewk = fill_ix_e_blk( &(ixewk->next), ixhwk, pgvalue, pgtext,
                                           pgtextlen );
                }
            }
        }
    } else                              // :IHx

    if( ((hxstring[3] == lvlc) ) ) {    // test for :IHx

    /***********************************************************************/
    /* processing for :IHx                                                 */
    /***********************************************************************/

        switch( hx_lvl ) {              // processing for :IH1 :IH2 :IH3
        case 1 :
            ixhwork = &index_dict;
            ixhwk = find_create_ix_h_entry( ixhwork, &printtxt, printtxtlen,
                                            txt, txtlen, hx_lvl );
            printtxt = NULL;
            ixhtag[hx_lvl] = ixhwk;
            break;
        case 2 :
        case 3 :
            ihm1 = ixhtag[hx_lvl - 1];
            ixhwork = &(ixhtag[hx_lvl - 1]->lower);
            ixhwk = find_create_ix_h_entry( ixhwork, &printtxt, printtxtlen,
                                            txt, txtlen, hx_lvl );
            printtxt = NULL;
            ixhtag[hx_lvl] = ixhwk;
            break;
        default:
            break;
        }
        if( seeseen ) {
            pgvalue = pgsee;
            if( ixhwk->entry == NULL ) {
                ixewk = fill_ix_e_blk( &(ixhwk->entry), ixhwk, pgvalue,
                                       seetext, seetextlen );
            } else {
                ixewk = ixhwk->entry;
                while( ixewk->next != NULL ) {  // find last entry
                    ixewk = ixewk->next;
                }
                ixewk = fill_ix_e_blk( &(ixewk->next), ixhwk, pgvalue,
                                       seetext, seetextlen );
            }
        } else {
            if( seeidseen ) {
                ix_e_blk  * * anchor;

                pgvalue = pgsee;
                if( ixhwk->entry == NULL ) {
                    anchor = &(ixhwk->entry);
                } else {
                    ixewk = ixhwk->entry;
                    while( ixewk->next != NULL ) {  // find last entry
                        ixewk = ixewk->next;
                    }
                    anchor = &(ixewk->next);
                }
                if( rswk->u.refb.hblk->prt_term != NULL ) {
                    ixewk = fill_ix_e_blk( anchor, ixhwk,
                                           pgvalue, rswk->u.refb.hblk->prt_term,
                                           rswk->u.refb.hblk->prt_term_len );
                } else {
                    ixewk = fill_ix_e_blk( anchor, ixhwk,
                                           pgvalue, rswk->u.refb.hblk->ix_term,
                                           rswk->u.refb.hblk->ix_term_len );
                }
            }
        }
    }
    if( idseen ) {                 // ID specified create reference entry
        reid.u.refb.hblk = ixhwk;
        reid.u.refb.eblk = ixewk;
        reid.flags = rf_ix;
        refwork = mem_alloc( sizeof( reid ) );
        memcpy( refwork, &reid, sizeof( reid ) );
        add_ref_entry( &iref_dict, refwork );
    }

    if( pgtext != NULL ) {
        mem_free( pgtext );
    }
    if( printtxt != NULL ) {
        mem_free( printtxt );
    }
    if( seetext != NULL ) {
        mem_free( seetext );
    }
    scan_start = scan_stop + 1;
    return;
}
Ejemplo n.º 2
0
void    gml_hdref( const gmltag * entry )
{
    char    *   p;
    char    *   pa;
    char    *   pe;
    char    *   idp;
    char        quote;
    char        c;
    bool        idseen;
    bool        pageseen;
    bool        withpage;
    size_t      len;
    char        buf64[64];
    ref_entry   *   re;
    static char undefid[] = "\"Undefined Heading\" on page XXX";


    idseen = false;
    pageseen = false;
    withpage = false;
    p = scan_start;
    re = NULL;

    /***********************************************************************/
    /*  Scan attributes  for :HDREF                                        */
    /*  id=                                                                */
    /*  page=                                                              */
    /***********************************************************************/

    for( ;; ) {
        while( *p == ' ' ) {
            p++;
        }
        if( *p == '\0' || *p == '.'  ) {
            break;                      // tag end found
        }

        if( !strnicmp( "page=", p, 5 ) ) {
            p += 5;
            while( *p == ' ' ) {
                p++;
            }
            pa = p;
            if( !strnicmp( "yes", p, 3 ) ) {
                pageseen = true;
                withpage = true;
                p += 3;
            } else {
                if( !strnicmp( "no", p, 2 ) ) {
                    pageseen = true;
                    withpage = false;
                    p += 2;
                } else {
                   g_err( err_inv_att_val );
                   file_mac_info();
                   err_count++;
                   while( *p && (*p != '.') && (*p != ' ') ) p++;
                }
            }
            scan_start = p;
            continue;
        }

        if( !strnicmp( "refid=", p, 6 ) ) {
            p += 6;
            while( *p == ' ' ) {
                p++;
            }
            if( is_quote_char( *p ) ) {
                quote = *p;
                p++;
            } else {
                quote = '\0';
            }
            pa = p;
            while( *p && is_id_char( *p ) ) {
                p++;
            }
            len = __min( ID_LEN, p - pa );// restrict length as in ghx.c

            if( len > 0 ) {
                idseen = true;          // valid id attribute found
                pe = pa + len;
                c = *pe;
                *pe = '\0';
                re = find_refid( ref_dict, strlwr( pa ) );
                if( re != NULL ) {      // id found in ref dict
                    idp = mem_alloc( 4 + strlen( re->text_cap ) );
                    *idp = '"';         // decorate with quotes
                    strcpy( idp + 1, re->text_cap );
                    strcat( idp, "\"" );
                } else {
                    if( GlobalFlags.lastpass ) {
                        g_warn( wng_id_xxx, pa );
                        g_info( inf_id_unknown );
                        file_mac_info();
                        wng_count++;
                    }
                }
                *pe = c;
            }
            if( *p && (quote == *p) ) {
                p++;
            }

            scan_start = p;
            continue;
        }

        /*******************************************************************/
        /* no more valid attributes                                        */
        /*******************************************************************/
        break;
    }
    if( *p == '.' ) {                   // tag end ?
        p++;
    }
    if( idseen ) {                      // id attribute was specified
        bool concatsave = ProcFlags.concat;

        ProcFlags.concat = true;        // make process_text add to line
        if( re == NULL ) {              // undefined refid
            process_text( undefid, g_curr_font_num );
        } else {
            process_text( idp, g_curr_font_num );
            if( withpage || (!pageseen && (page != re->pageno)) ) {
                sprintf_s( buf64, sizeof( buf64 ), "on page %d", re->pageno );
                process_text( buf64, g_curr_font_num );
            }
            mem_free( idp );
        }
        ProcFlags.concat = concatsave;
    } else {
        g_err( err_att_missing );       // id attribute missing
        file_mac_info();
        err_count++;
    }

    scan_start = p;
    return;
}
Ejemplo n.º 3
0
static  void    gml_hx_common( gml_tag gtag, int hx_lvl )
{
    char    *   p;
    char    *   headp;
    bool        idseen;
    bool        stitleseen;
    int         rc;
    int         k;
    size_t      headlen;
    size_t      txtlen;
    char        hnumstr[64];
    ref_entry   *   re;
    ref_entry   *   rwk;
    static char hxstr[4] = ":HX";
    static char htextx[8] = "$htextX";
    static char headx[7]  = "$headX";

    gtag = gtag;

    *(hxstr + 2) = '0' + hx_lvl;
    htextx[6] = '0' + hx_lvl;
    hnumx[5] = '0' + hx_lvl;
    headx[5] = '0' + hx_lvl;

    switch( hx_lvl ) {
    case   0:
        if( !((ProcFlags.doc_sect == doc_sect_body) ||
            (ProcFlags.doc_sect_nxt == doc_sect_body)) ) {

            g_err( err_tag_wrong_sect, hxstr, ":BODY section" );
            err_count++;
            file_mac_info();
        }
        break;
    case  1:
        if( !((ProcFlags.doc_sect >= doc_sect_body) ||
            (ProcFlags.doc_sect_nxt >= doc_sect_body)) ) {

            g_err( err_tag_wrong_sect, hxstr, ":BODY :APPENDIX :BACKM sections" );
            err_count++;
            file_mac_info();
        }
        break;
    default:
        if( !((ProcFlags.doc_sect >= doc_sect_abstract) ||
            (ProcFlags.doc_sect_nxt >= doc_sect_abstract)) ) {

            g_err( err_tag_wrong_sect, hxstr, ":ABSTRACT section or later" );
            err_count++;
            file_mac_info();
        }
        break;
    }
    if( layout_work.hx[hx_lvl].number_form != num_none ) {
        layout_work.hx[hx_lvl].headn++;
    }

    idseen = false;
    stitleseen = false;
    p = scan_start;
    re = NULL;

    /***********************************************************************/
    /*  Scan attributes  for :Hx                                           */
    /*  id=                                                                */
    /*  stitle=                                                            */
    /***********************************************************************/

    for( ;; ) {
        while( *p == ' ' ) {
            p++;
        }
        if( *p == '\0' || *p == '.'  ) {
            break;                      // tag end found
        }
        if( !strnicmp( "stitle=", p, 7 ) ) {
            p += 6;
            stitleseen = true;

            /***************************************************************/
            /*  Although unsupported scan stitle='xxx'                     */
            /***************************************************************/
            g_warn( wng_unsupp_att, "stitle" );
            wng_count++;
            file_mac_info();

            p = get_att_value( p );

            scan_start = p;
            if( !ProcFlags.tag_end_found ) {
                continue;
            }
            break;
        }

        /*******************************************************************/
        /*  ID='xxxxxxxx'                                                  */
        /*******************************************************************/

        if( !strnicmp( "id=", p, 3 ) ) {
            p += 2;

            p = get_refid_value( p );

            if( val_len > 0 ) {
                idseen = true;          // valid id attribute found
                *(val_start + val_len) = '\0';

                if( re == NULL ) {      // prepare reference entry
                    re = mem_alloc( sizeof( ref_entry ) );
                    init_ref_entry( re, val_start, val_len );
                } else {
                    fill_id( re, val_start, val_len );
                }
            }
            scan_start = p;
            if( !ProcFlags.tag_end_found ) {
                continue;
            }
            break;
        }

        /*******************************************************************/
        /* no more valid attributes, process remaining input as header text*/
        /*******************************************************************/
        break;
    }
    if( *p == '.' ) {                   // tag end ?
        p++;
    }

    /************************************************************************/
    /*  set the global vars $headx, $headnumx, $htextx                      */
    /*    perhaps text translated to upper or lower case                    */
    /************************************************************************/
    while( *p == ' ' ) {                // ignore leading blanks
        p++;
    }
    if( *p ) {                          // text exists
        if( layout_work.hx[hx_lvl].cases == case_lower ) {
            strlwr( p );
        } else if( layout_work.hx[hx_lvl].cases == case_upper ) {
            strupr( p );
        }
    }
    rc = add_symvar( &global_dict, htextx, p, no_subscript, 0 );

    update_headnumx( hx_lvl, hnumstr, sizeof( hnumstr ) );

    txtlen = strlen( p );
    headlen = strlen( hnumstr) + txtlen + 2;
    headp = mem_alloc( headlen );
    if( layout_work.hx[hx_lvl].number_form != num_none ) {
        strcpy( headp, hnumstr); // numbered header
        strcat( headp, " " );
    } else {
        *headp = '\0';
    }
    strcat( headp, p );
    rc = add_symvar( &global_dict, headx, headp, no_subscript, 0 );

    out_msg( " %s\n", headp );          // always verbose output ? TBD

    mem_free( headp );

    /***********************************************************************/
    /*  if id  specified add it to reference dict                          */
    /***********************************************************************/
    if( idseen ) {
        rwk = find_refid( ref_dict, re->id );
        if( !rwk ) {                    // new entry
            if( txtlen > 0 ) {          // text line not empty
                re->u.info.text_cap = mem_alloc( txtlen + 1 );
                strcpy( re->u.info.text_cap, p );
            }
            add_ref_entry( &ref_dict, re );
            re = NULL;                  // free will be done via dictionary
        } else {
            /***************************************************************/
            /*  test for duplicate id                                      */
            /*  it is done with comparing line no only, in the hope that   */
            /*  two identical ids are not specified in different files on  */
            /*  the same line no.                                          */
            /***************************************************************/
            if( re->lineno != rwk->lineno ) {
                g_err( wng_id_xxx, re->id );
                g_info( inf_id_duplicate );
                file_mac_info();
                err_count++;
            }
            if( re->u.info.text_cap != NULL ) {
                mem_free( re->u.info.text_cap );
            }
            mem_free( re );
        }
    }

    if( layout_work.hx[hx_lvl].number_reset ) {
        for( k = hx_lvl + 1; k < 7; k++ ) {
            layout_work.hx[k].headn = 0;// reset following levels
            if( layout_work.hx[k].headnsub != NULL ) {
                *(layout_work.hx[k].headnsub->value) = '\0';
            }
        }
    }

    /***********************************************************************/
    /*  creation of actual heading                                         */
    /***********************************************************************/

    /***********************************************************************/
    /*  eject page(s) if specified                                         */
    /***********************************************************************/
    if( layout_work.hx[hx_lvl].page_eject != ej_no ) {

        if( ProcFlags.page_started ) {
            do_page_out();
            reset_t_page();
        }

        if( !ProcFlags.start_section ) {
            start_doc_sect();
        }
        set_headx_banners( hx_lvl );        // set possible banners
        reset_t_page();                     // and adjust page margins


        if( (layout_work.hx[hx_lvl].page_eject == ej_odd) && (page & 1) ) {
            do_page_out();              // next page would be even
            reset_t_page();
        } else if( (layout_work.hx[hx_lvl].page_eject == ej_even) && !(page & 1) ) {
            do_page_out();              // next page would be odd
            reset_t_page();
        }
    }

    if( layout_work.hx[hx_lvl].display_heading ) {

        hx_header( hx_lvl, hnumstr, p );
    }

    scan_start = scan_stop;
    return;
}
Ejemplo n.º 4
0
extern void gml_egdoc( const gmltag * entry )
{
    fwd_ref *   curr;
    
    if( blank_lines > 0 ) {
        set_skip_vars( NULL, NULL, NULL, 0, 0 );    // set g_blank_lines
    }
    scr_process_break();                        // outputs last element in file

    if( GlobalFlags.lastpass ) {                // output on last pass only
        if( passes == 1 ) {                     // first and only pass
            if( figlist_toc & gs_toc ) {        // only if TOC was found
                gen_toc();
            }
            if( figlist_toc & gs_figlist ) {    // only if FIGLIST was found
                gen_figlist();
            }
            curr = fig_fwd_refs;
            while( curr != NULL ) {     // output figure forward/undefined references
                if( find_refid( fig_ref_dict, curr->id ) != NULL ) {
                    fwd_id_warn( curr->id, "figure" );
                } else {
                    undef_id_warn( curr->id, "Figure" );
                }
                curr = curr->next;
            }
            curr = hd_fwd_refs;
            while( curr != NULL ) { // output header forward/undefined references
                if( find_refid( hd_ref_dict, curr->id ) != NULL ) {
                    fwd_id_warn( curr->id, "heading" );
                } else {
                    undef_id_warn( curr->id, "Heading" );
                }
                curr = curr->next;
            }
            curr = fn_fwd_refs;
            while( curr != NULL ) { // output footnote forward/undefined references
                if( find_refid( fn_ref_dict, curr->id ) != NULL ) {
                    fwd_id_warn( curr->id, "footnote" );
                } else {
                    undef_id_warn( curr->id, "Footnote" );
                }
                curr = curr->next;
            }
            if( figlist_toc ) {
                xx_simple_warn( wng_pass_1 );   // more than one pass needed 
            }
        } else {                                // last pass of at least 2
            curr = fig_fwd_refs;
            while( curr != NULL ) { // output figure undefined/page change references
                fwd_id_warn( curr->id, "figure" );
                curr = curr->next;
            }
            curr = hd_fwd_refs;
            while( curr != NULL ) { // output header undefined/page changereferences
                fwd_id_warn( curr->id, "heading" );
                curr = curr->next;
            }
            if( ProcFlags.new_pagenr ) {
                xx_simple_warn( wng_pass_many );// at least one more pass needed
            }
        }
        if( !GlobalFlags.index ) {          // index option not active
            xx_simple_warn( wng_index_opt );// give hint to activate index
        }
    }

    gml_doc_xxx( doc_sect_egdoc );
}