コード例 #1
0
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();
}
コード例 #2
0
ファイル: gdocsect.c プロジェクト: MikeyG/open-watcom-v2
void    gml_titlep( 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;
    }
    gml_doc_xxx( doc_sect_titlep );
    g_spacing_ln = layout_work.titlep.spacing;

    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
    }
}
コード例 #3
0
ファイル: gsyssym.c プロジェクト: Azarien/open-watcom-v2
static  void    init_date_time( void )
{
    time_t      now;
    struct tm   *tmbuf;
    char        *p;

    now = time( NULL );
    tmbuf = localtime( &now );

    strftime( dateval, sizeof( dateval ), "%B %d, %Y", tmbuf );

    p = strstr( dateval, " 0" );        // search for leading zero
    if( p != NULL ) {                   // 'September 02, 2009'
        p++;
        *p = ' ';
        while( *p ) {                   // becomes
            *p = *(p + 1);              // 'September 2, 2009'
            p++;
        }
    }
    sysdate0.value = dateval;
    add_symvar( &global_dict, "date", dateval, no_subscript, 0 );

    strftime( dayofmval, sizeof( dayofmval ), "%e", tmbuf );
    sysdayofm0.value = dayofmval;

    strftime( dayofwval, sizeof( dayofwval ), "%w", tmbuf );
    dayofwval[0] += 1;                  // make 0-6 sun-sat 1-7
    sysdayofw0.value = dayofwval;

    strftime( dayofyval, sizeof( dayofyval ), "%j", tmbuf );
    sysdayofy0.value = dayofyval;

    strftime( hourval, sizeof( hourval ), "%H", tmbuf );
    syshour0.value = hourval;

    strftime( minuteval, sizeof( minuteval ), "%M", tmbuf );
    sysminute0.value = minuteval;

    strftime( monthval, sizeof( monthval ), "%m", tmbuf );
    sysmonth0.value = monthval;

    strftime( pdayofwval, sizeof( pdayofwval ), "%A", tmbuf );
    syspdayofw0.value = pdayofwval;

    strftime( pmonthval, sizeof( pmonthval ), "%B", tmbuf );
    syspmonth0.value = pmonthval;

    strftime( pyearval, sizeof( pyearval ), "%Y", tmbuf );
    syspyear0.value = pyearval;
    sysyear0.value = &pyearval[2];      // year without century

    strftime( timeval, sizeof( timeval ), "%T", tmbuf );
    systime0.value = timeval;
    syssecond0.value = &timeval[6];

    add_symvar( &global_dict, "time", timeval, no_subscript, 0 );

}
コード例 #4
0
ファイル: gsyssym.c プロジェクト: Azarien/open-watcom-v2
static  void    init_predefined_symbols( void )
{
    char    wkstring[MAX_L_AS_STR];

    add_symvar( &global_dict, "amp", "&", no_subscript, predefined );

    wkstring[1] = '\0';
    wkstring[0] = GML_CHAR_DEFAULT;
    add_symvar( &global_dict, "gml", wkstring, no_subscript, predefined );

}
コード例 #5
0
ファイル: gdocsect.c プロジェクト: MikeyG/open-watcom-v2
void    gml_gdoc( gml_tag gtag )
{
    char        *   p;

    gtag = gtag;
    scan_err = false;
    p = scan_start;
    if( *p ) p++;

    while( *p == ' ' ) {                // over WS to attribute
        p++;
    }
    if( *p &&
        ! (strnicmp( "sec ", p, 4 ) &&  // look for "sec " or "sec="
           strnicmp( "sec=", p, 4 )) ) {
        char        quote;
        char    *   valstart;

        p += 3;
        while( *p == ' ' ) {
            p++;
        }
        if( *p == '=' ) {
            p++;
            while( *p == ' ' ) {
                p++;
            }
        }
        if( *p == '"' || *p == '\'' ) {
            quote = *p;
            ++p;
        } else {
            quote = ' ';
        }
        valstart = p;
        while( *p && *p != quote ) {
            ++p;
        }
        *p = '\0';

        add_symvar( &global_dict, "$sec", valstart, no_subscript, 0 );
    } else {
        add_symvar( &global_dict, "$sec", "", no_subscript, 0 );// set nullstring
    }

    gml_doc_xxx( doc_sect_gdoc );
    if( !ProcFlags.fb_document_done ) { // the very first section/page
        do_layout_end_processing();
    }
    return;
}
コード例 #6
0
ファイル: gusertag.c プロジェクト: ABratovic/open-watcom-v2
static  void    add_defaults_to_dict( gtentry * ge, symvar * * dict )
{
    gaentry     *   ga;
    gavalentry  *   gaval;
    char        *   valp;
    int             rc;

    for( ga = ge->attribs; ga != NULL; ga = ga->next ) {// for all attributes

        ga->attflags = set_att_proc_flags( ga->attflags );
        if( ga->attflags & att_off ) {  // attribute inactive
            continue;
        }
        if( ga->attflags & (att_def | att_auto) ) {  // with default
            for( gaval = ga->vals; gaval != NULL; gaval = gaval->next ) {
                if( gaval->valflags & (val_def | val_auto) ) {// value is default
                    valp = NULL;
                    if( gaval->valflags & val_value ) { // short string
                        valp = gaval->a.value;
                    } else {
                        if( gaval->valflags & val_valptr ) {// long string
                            valp = gaval->a.valptr;
                        }
                    }
                    if( gaval->valflags & val_range ) { // range default
                        sprintf( token_buf, "%d", gaval->a.range[2] );
                        valp = token_buf;
                    }
                    if( valp != NULL ) {
                        rc = add_symvar( dict, ga->name, valp,
                                         no_subscript, local_var );
                    }
                }
            }
        }
    }
    return;
}
コード例 #7
0
void    gml_title( const gmltag * entry )
{
    char        *   p;
    doc_element *   cur_el;
    text_line   *   p_line      = NULL;
    int8_t          t_spacing;
    font_number     font_save;

    if( !((ProcFlags.doc_sect == doc_sect_titlep) ||
          (ProcFlags.doc_sect_nxt == doc_sect_titlep)) ) {
        g_err( err_tag_wrong_sect, entry->tagname, ":TITLEP section" );
        err_count++;
        show_include_stack();
    }
    p = scan_start;
    if( *p && *p != '.' ) p++;

    while( *p == ' ' ) {                // over WS to attribute
        p++;
    }
    if( *p &&
        ! (strnicmp( "stitle ", p, 7 ) &&   // look for stitle
           strnicmp( "stitle=", p, 7 )) ) {
        char        quote;
        char    *   valstart;

        p += 6;
        while( *p == ' ' ) {
            p++;
        }
        if( *p == '=' ) {
            p++;
            while( *p == ' ' ) {
                p++;
            }
        }
        if( *p == '"' || *p == '\'' ) {
            quote = *p;
            ++p;
        } else {
            quote = ' ';
        }
        valstart = p;
        while( *p && *p != quote ) {
            ++p;
        }
        *p = '\0';
        if( !ProcFlags.stitle_seen ) {  // first stitle goes into dictionary
            add_symvar( &global_dict, "$stitle", valstart, no_subscript, 0 );
            ProcFlags.stitle_seen = true;
        }
        p++;
    }

    if( *p == '.' ) p++;                // over '.'
    if( !ProcFlags.title_text_seen ) {
        if( *p ) {                      // first title goes into dictionary
            add_symvar( &global_dict, "$title", p, no_subscript, 0 );
        }
    }

    start_doc_sect();                   // if not already done

    font_save = g_curr_font;
    g_curr_font = layout_work.title.font;
    t_spacing = layout_work.titlep.spacing;
    if( !ProcFlags.title_tag_top ) {
        set_skip_vars( NULL, &layout_work.title.pre_top_skip, NULL, t_spacing, 
                       g_curr_font );
        ProcFlags.title_tag_top = true;
    } else {
        set_skip_vars( &layout_work.title.skip, NULL, NULL, t_spacing, 
                       g_curr_font );
    }
    
    p_line = alloc_text_line();
    p_line->line_height = wgml_fonts[g_curr_font].line_height;
    if( *p ) {
        prep_title_line( p_line, p );
    }
    cur_el = init_doc_el( el_text, p_line->line_height );
    cur_el->element.text.first = p_line;
    p_line = NULL;
    insert_col_main( cur_el );

    g_curr_font = font_save;
    scan_start = scan_stop + 1;
}
コード例 #8
0
ファイル: gdate.c プロジェクト: Azarien/open-watcom-v2
void    gml_date( gml_tag gtag )
{
    char        *   p;
    doc_element *   cur_el;
    text_line   *   p_line;
    spacing_line    spacing_ln;
    font_number     font_save;

    if( !((ProcFlags.doc_sect == doc_sect_titlep) ||
          (ProcFlags.doc_sect_nxt == doc_sect_titlep)) ) {
        g_err( err_tag_wrong_sect, gml_tagname( gtag ), ":TITLEP section" );
        err_count++;
        show_include_stack();
    }

    if( ProcFlags.date_tag_seen ) {     // only one DATE tag allowed
        xx_line_err( err_2nd_date, buff2 );
    }

    ProcFlags.date_tag_seen = true;
    p = scan_start;
    if( *p && *p == '.' ) p++;          // over . to docnum

    while( *p == ' ' ) {                // over WS to attribute
        p++;
    }

    if( *p ) {                                              // date specified
        add_symvar( &global_dict, "date", p, no_subscript, 0 );
    }

    start_doc_sect();                   // if not already done

    p_line = alloc_text_line();
    p_line->line_height = wgml_fonts[layout_work.docnum.font].line_height;

    prep_date_line( p_line, p );

    spacing_ln = layout_work.titlep.spacing;
    font_save = g_curr_font;
    g_curr_font = layout_work.date.font;

    /************************************************************/
    /*  pre_skip is treated as pre_top_skip because it is       */
    /*  always used at the top of the page, despite the docs    */
    /************************************************************/
    set_skip_vars( NULL, &layout_work.date.pre_skip, NULL, spacing_ln, g_curr_font );

    cur_el = alloc_doc_el( el_text );
    cur_el->depth = p_line->line_height + g_spacing;
    cur_el->subs_skip = g_subs_skip;
    cur_el->top_skip = g_top_skip;
    cur_el->element.text.overprint = ProcFlags.overprint;
    ProcFlags.overprint = false;
    cur_el->element.text.spacing = g_spacing;
    cur_el->element.text.first = p_line;
    ProcFlags.skips_valid = false;
    p_line = NULL;
    insert_col_main( cur_el );

    g_curr_font = font_save;
    scan_start = scan_stop;
}
コード例 #9
0
ファイル: gusertag.c プロジェクト: ABratovic/open-watcom-v2
bool        process_tag( gtentry * ge, mac_entry * me )
{
    bool            processed;
    gaentry     *   ga;
    gavalentry  *   gaval;
    char        *   p;
    char        *   p2;
    int             rc;
    char            quote;
    char            longwork[20];
    bool            tag_end_found = false;

    processed = true;
    init_dict( &loc_dict );

    add_defaults_to_dict( ge, &loc_dict );

    /***********************************************************************/
    /*  scan input for attributes and / or tagtext                         */
    /***********************************************************************/

    p = tok_start + ge->namelen + 1;    // over tagname

    if( ge->attribs != NULL ) {     // only process attributes if they exist
        while( *p == ' ' ) {        // not yet end of tag, process attributes

            while( *p == ' ' ) {        // over WS to attribute
                p++;
            }
            if( *p == '.' ) {
                tag_end_found = true;
                break;
            }
            p2 = token_buf;
            while( is_id_char( *p ) ) {
                *p2++ = *p++;
            }
            *p2 = '\0';
            if( p2 != token_buf ) {     // ignore nullstring
                for( ga = ge->attribs; ga != NULL; ga = ga->next ) {// all attrs
                    if( !stricmp( ga->name, token_buf ) ) {
                        ga->attflags |= att_proc_seen; // attribute specified
                        if( ga->attflags & att_auto ) {
                            auto_att_err();
                            break;
                        }

                        if( *p == '=' ) {   // value follows
                            ga->attflags |= att_proc_val;

                            p++;        // over =
                            p2 = token_buf;
                            if( is_quote_char( *p ) ) {
                                quote = *p++;
                                while( *p && *p != quote ) {// quoted value
                                    *p2++ = *p++;
                                }
                                if( *p == quote ) {
                                    p++;// over ending quote
                                }
                            } else {
                                quote = '\0';
                                while( *p && (*p != ' ') && (*p != '.') ) {
                                    *p2++ = *p++;
                                }
                            }
                            *p2 = '\0';
                            if( ga->attflags & att_off ) {// attribute inactive
                                continue;
                            }
                            if( ga->attflags & att_upper ) {// uppercase option
                                strupr( token_buf );
                            }

                            scan_err = check_att_value( ga );

                        } else {// special for range set default2 if no value
                            if( ga->attflags & att_range ) {
                                for( gaval = ga->vals; gaval != NULL;
                                     gaval = gaval->next ) {
                                     if( gaval->valflags & val_range ) {
                                        break;
                                     }
                                }
                                if( gaval != NULL ) {
                                     sprintf( token_buf, "%d",
                                              gaval->a.range[3] );
                                     rc = add_symvar( &loc_dict, ga->name,
                                                      token_buf, no_subscript,
                                                      local_var );
                                }
                            }
                        }
                        break;
                    }
                }
                if( ga == NULL ) {      // attribute Not found
                    char        linestr[MAX_L_AS_STR];

                    processed = false;
                    wng_count++;
                    //***WARNING*** SC--040: 'abd' is not a valid attribute name
                    g_warn( wng_att_name, token_buf );
                    if( input_cbs->fmflags & II_macro ) {
                        ultoa( input_cbs->s.m->lineno, linestr, 10 );
                        g_info( inf_mac_line, linestr, input_cbs->s.m->mac->name );
                    } else {
                        ultoa( input_cbs->s.f->lineno, linestr, 10 );
                        g_info( inf_file_line, linestr, input_cbs->s.f->filename );
                    }
                    show_include_stack();
                }
            }
            /***************************************************************/
            /*  check for tag end .                                        */
            /***************************************************************/
            if( *p == ' ' ) {
                continue;               // not yet at buffer / tag end
            }
#if 0
            /***************************************************************/
            /*  continue scanning for attriutes on next line if not tag end*/
            /*  This does not work for constructs such as                  */
            /*                                                             */
            /*  :hdref refid=diffs                                         */
            /*  .bd to determine if you need to recompile your application.*/
            /*  from docs\doc\gs\intro.gml line 37 f                       */
            /***************************************************************/

            if( *p != '.' ) { //
                if( get_line( true ) ) {
                    p = buff2;
                } else {
                    *p = '\0';
                }
            } else {
                tag_end_found = true;
            }
#else
            if( (*p == '.') || (*p == '\0') ) {
                tag_end_found = true;
            }
#endif
        }

        /*******************************************************************/
        /*  check for missing reqrd attributes                             */
        /*******************************************************************/
        *token_buf = '\0';
        for( ga = ge->attribs; ga != NULL; ga = ga->next ) {// for all attrs
            if( ga->attflags & att_req ) {
                if( !(ga->attflags & att_proc_seen) ) {
                    if( *token_buf != '\0' ) {
                        strcat( token_buf, " '" );
                    } else {
                        strcpy( token_buf, "'" );
                    }
                    strcat( token_buf, ga->name );
                    strcat( token_buf, "' " );
                }
            }
        }
        if( *token_buf != '\0' ) {      // some req attr missing
            char        linestr[MAX_L_AS_STR];

        // the errmsg in wgml 4.0 is wrong, it shows the macroname, not tag.
// ****ERROR**** SC--047: For the tag '@willi', the required attribute(s)
//                       'muss2'
//                       'muss'
//                       have not been specified

            processed = false;
            err_count++;
            g_err( err_att_req, ge->name, token_buf );
            if( input_cbs->fmflags & II_macro ) {
                ultoa( input_cbs->s.m->lineno, linestr, 10 );
                g_info( inf_mac_line, linestr, input_cbs->s.m->mac->name );
            } else {
                ultoa( input_cbs->s.f->lineno, linestr, 10 );
                g_info( inf_file_line, linestr, input_cbs->s.f->filename );
            }
            show_include_stack();
        }

        if( *p == '.' ) {               // does text follow tag end
            if( strlen( p + 1 ) > 0 ) {
                if( ge->tagflags & tag_texterr ) { // no text allowed
                    tag_text_err( ge->name );
                    processed = false;
                }
            } else {
                if( ge->tagflags & tag_textreq ) {  // reqrd text missing
                    tag_text_req_err( ge->name );
                    processed = false;
                }
            }
            strcpy( token_buf, p + 1 );
            rc = add_symvar( &loc_dict, "_", token_buf, no_subscript, local_var );
            p += strlen( token_buf );
        }

        scan_start = p + 1;             // all processed
        /*******************************************************************/
        /*  add standard symbols to dict                                   */
        /*******************************************************************/

        rc = add_symvar( &loc_dict, "_tag", ge->name, no_subscript, local_var );
        ge->usecount++;
        sprintf( longwork, "%d", ge->usecount );
        rc = add_symvar( &loc_dict, "_n", longwork, no_subscript, local_var );


        add_macro_cb_entry( me, ge );   // prepare GML macro as input
        input_cbs->local_dict = loc_dict;
        inc_inc_level();                // start new include level
        if( ge->tagflags & tag_cont ) {   // +++++++++++++++++++ TBD trial
            post_space = 0;
            ProcFlags.ct = true;
        }

        if( input_cbs->fmflags & II_research && GlobalFlags.firstpass ) {
            print_sym_dict( input_cbs->local_dict );
        }
    } else {                            // user-defined tag has no attributes
        if( ge->tagflags & tag_texterr ) {  // no text allowed
            // '.' or CW_sep_char immediately after the tag does not count as text
            if( (*p == '.') || (*p == CW_sep_char ) ) {
                p++;
            }
            while( *p == ' ' ) {        // spaces don't count as text
                p++;
            }
            if( *p ) {                  // text found
                tag_text_err( ge->name );
                processed = false;
                return( processed );
            }
        }
        if( ge->tagflags & tag_textreq ) {  // text is required
            // per wgml 4.0 behavior
            if( *p == CW_sep_char ) {
                processed = false;
                return( processed );
            }
            // '.' immediately after the tag does not count as text
            if( *p == '.' ) {
                p++;
            }
            while( *p == ' ' ) {        // spaces don't count as text
                p++;
            }
            if( !*p ) {                 // no text found
                tag_text_req_err( ge->name );
                processed = false;
                return( processed );
            }
        }
        // per wgml 4.0 behavior
        if( *p == CW_sep_char ) {
            processed = false;
            return( processed );
        }
        // '.' immediately after the tag is not passed to the macro
        if( *p == '.' ) {
            p++;
        }
        strcpy( token_buf, p );
        rc = add_symvar( &loc_dict, "_", token_buf, no_subscript, local_var );
        p += strlen( token_buf );

        scan_start = p + 1;             // all processed
        /*******************************************************************/
        /*  add standard symbols to dict                                   */
        /*******************************************************************/

        rc = add_symvar( &loc_dict, "_tag", ge->name, no_subscript, local_var );
        ge->usecount++;
        sprintf( longwork, "%d", ge->usecount );
        rc = add_symvar( &loc_dict, "_n", longwork, no_subscript, local_var );


        add_macro_cb_entry( me, ge );   // prepare GML macro as input
        input_cbs->local_dict = loc_dict;
        inc_inc_level();                // start new include level
        if( ge->tagflags & tag_cont ) { // +++++++++++++++++++ TBD trial
            post_space = 0;
            ProcFlags.ct = true;
        }

        if( input_cbs->fmflags & II_research && GlobalFlags.firstpass ) {
            print_sym_dict( input_cbs->local_dict );
        }
    }

    return( processed );
}
コード例 #10
0
ファイル: gusertag.c プロジェクト: ABratovic/open-watcom-v2
static bool check_att_value( gaentry * ga )
{
    gavalentry  *   gaval;
    char        *   valp;
    long            attval;
    bool            msg_done;
    int             rc;

    scan_err = true;
    msg_done = false;
    for( gaval = ga->vals; gaval != NULL; gaval = gaval->next ) {
        if( gaval->valflags & val_any ) {
            scan_err = false;           // any value is allowed
            break;
        }

        valp = NULL;
        if( gaval->valflags & val_value ) {
            valp = gaval->a.value;
        } else {
            if( gaval->valflags & val_valptr ) {
                valp = gaval->a.valptr;
            }
        }
        if( valp != NULL ) {
            if( !strcmp( token_buf, valp ) ) {
                scan_err = false;       // value is allowed
                break;
            }
        } else {
            if( gaval->valflags & val_range ) {
                attval = strtol( token_buf, NULL, 10 );
                if( attval < gaval->a.range[0] ||
                    attval > gaval->a.range[1]  ) {
                    xx_err( ERR_ATT_RANGE_INV );// value outside range
                    msg_done = true;
                    break;
                }
            } else {
                if( gaval->valflags & val_length ) {
                    if( strlen( token_buf ) > gaval->a.length ) {
                        xx_err( err_att_len_inv );  // value too long
                        msg_done = true;
                    } else {
                        scan_err = false;
                    }
                    break;
                }
            }
        }
    }
    if( !scan_err ) {
        rc = add_symvar( &loc_dict, ga->name, token_buf,
                         no_subscript, local_var );
    } else {
        if( !msg_done ) {
            att_val_err( ga->name );
        }
    }
    return( scan_err );
}
コード例 #11
0
ファイル: ghx.c プロジェクト: Azarien/open-watcom-v2
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;
}
コード例 #12
0
void    scr_dc( void )
{
    char        *   pa;
    char        *   p;
    char            c;
    int             len;
    int             k;
    char    string[2] = { 0, 0 };
    int             opt;
    static const char   options[5] [5] = { "cw", "gml", "tb", "stop" };
                                        // please add new options at end
    int const   max_opt = sizeof( options) / sizeof( options[0] );

    p = scan_start;
    while( *p && *p != ' ' ) {          // over dc
        p++;
    }
    while( *p && *p == ' ' ) {          // next word start = option
        p++;
    }
    pa = p;
    while( *p && *p != ' ' ) {          // end of word
        p++;
    }
    len = p - pa;
    opt = 0;
    if( len > 0 ) {
        for( k = 0; k < max_opt; k++ ) {
            if( !strnicmp( pa, options[k], len ) ) {
                opt = k + 1;
                break;
            }
        }
    }
    if( opt == 0 ) {                   // omitted / unknown / not implemented
        dc_opt_warn_len( pa, len );
        return;
    }
    while( *p && *p == ' ' ) {          // next word start = option value
        p++;
    }
    pa = p;
    c = '\0';
    while( *p && *p != ' ' ) {          // end of word
        p++;
    }
    len = p - pa;
    if( len == 1 ) {
        c = *pa;
    }
    switch( opt ) {
    case 1 :                            // CW option
        if( len > 2 ) {
            if( len == 3 ) {
                if( strnicmp( pa, "OFF", len ) ) {
                    xx_line_err_len( err_dc_not_off, pa, len );   // only OFF is valid
                    return;
                }
            } else {
                xx_line_err_len( err_dc_not_off, pa, len );   // only OFF is valid
                return;
            }
        } else {
            c = parse_char( pa, len );
        }
        scan_restart = pa + len;
        CW_sep_char = c;
        add_to_sysdir( "$cw", CW_sep_char );
        break;
    case 2 :                            // GML option
        if( len > 2 ) {
            if( len == 3 ) {
                if( strnicmp( pa, "OFF", len ) ) {
                    xx_line_err_len( err_dc_not_off, pa, len );   // only OFF is valid
                    return;
                }
                c = ' ';                    // OFF is blank
            } else {
                xx_line_err_len( err_dc_not_off, pa, len );   // only OFF is valid
                return;
            }
        } else {
            c = parse_char( pa, len );
        }
        scan_restart = pa + len;
        GML_char = c;
        string[0] = c;
        add_symvar( &global_dict, "gml", string, no_subscript,
                    predefined );
        add_to_sysdir( "$gml", GML_char );
        break;
    case 3 :                            // TB option
        if( len > 2 ) {
            if( len == 3 ) {
                if( strnicmp( pa, "OFF", len ) ) {
                    xx_line_err_len( err_dc_not_off, pa, len );  // only OFF is valid
                    return;
                }
                c = 0x09;               // OFF is 0x09
            } else {
                xx_line_err_len( err_dc_not_off, pa, len );  // only OFF is valid
                return;
            }
        } else {
            c = parse_char( pa, len );
        }
        scan_restart = pa + len;
        tab_char = c;
        string[0] = c;
        add_to_sysdir( "$tb", tab_char );
        add_to_sysdir( "$tab", tab_char );
        break;
    case 4 :                            // STOP option

/***************************************************************************/
/*  when the documentation refers to "script", this may be quite literal:  */
/*  setting STOP to OFF has no effect when WSCRIPT is specificed           */
/*  whether ".dc stop" with a list of characters has any effect is unknown */
/*  so doing nothing is the appropriate implementation, at least for now   */
/*                                                                         */
/*  the only use is ".dc stop off" found in                                */
/*        docs\doc\whelp\whelp.gml line 765                                */
/***************************************************************************/

        scan_restart = pa + len;
        break;

    default:                            // unknown / unimplemented option
        dc_opt_warn_len( pa, len );
        break;
    }
    return;
}