Exemple #1
0
void    scr_co( void )
{
    char        *   pa;
    char        *   p;
    int             len;
    char            cwcurr[4 ];

    cwcurr[0] = SCR_char;
    cwcurr[1] = 'c';
    cwcurr[2] = 'o';
    cwcurr[3] = '\0';
    p = scan_start;
    while( *p && *p != ' ' ) {          // over cw
        p++;
    }
    while( *p && *p == ' ' ) {          // next word start
        p++;
    }
    pa = p;

    while( *p && *p != ' ' ) {          // end of word
        p++;
    }
    len = p - pa;
    switch( len ) {
    case 0 :                            // omitted means ON
        ProcFlags.concat = true;
        scan_restart = pa;
        break;
    case 2 :                            // only ON valid
        if( !strnicmp( "ON", pa, 2 ) ) {
            if( save_post_skip > 0 ) {     // only if it exists
                g_post_skip = save_post_skip;
                save_post_skip = 0;
            }
            ProcFlags.concat = true;
            scan_restart = pa + len;
        } else {
            xx_opt_err( cwcurr, pa );
        }
        break;
    case 3 :                            // only OFF valid
        if( !strnicmp( "OFF", pa, 3 ) ) {
            if( g_post_skip > 0 ) {     // only if it exists
                save_post_skip = g_post_skip;
                g_post_skip = 0;
            }
            ProcFlags.concat = false;
            scan_restart = pa + len;
        } else {
            xx_opt_err( cwcurr, pa );
        }
        break;
    default:
        xx_opt_err( cwcurr, pa );
        break;
    }
    return;
}
Exemple #2
0
void scr_cp( void )
{
    char        *   pa;
    char        *   p;
    int             len;
    getnum_block    gn;
    condcode        cc;
    char            cwcurr[4];

    cwcurr[0] = SCR_char;
    cwcurr[1] = 'c';
    cwcurr[2] = 'p';
    cwcurr[3] = '\0';

    p = scan_start;
    while( *p && *p != ' ' ) {          // over cw
        p++;
    }
    while( *p && *p == ' ' ) {          // next word start
        p++;
    }
    pa = p;

    while( *p && *p != ' ' ) {          // end of word
        p++;
    }
    len = p - pa;
    if( len > 0 ) {                     // no action if no parm
        gn.argstart = pa;
        gn.argstop  = scan_stop;
        gn.ignore_blanks = 0;

        cc = getnum ( &gn );            // try to get numeric value
        if( cc == notnum ) {
            xx_opt_err( cwcurr, pa );
            scan_restart = scan_stop +1;
        } else {
            if( gn.result > 0 ) {       // ignore values < 1
                if( ((gn.result * wgml_fonts[g_curr_font].line_height) +
                                t_page.cur_depth) > t_page.max_depth ) {
                    last_page_out();
                    reset_t_page();
                }
            }
            scan_restart = gn.argstart;
        }
    } else {
        scan_restart = scan_stop +1;
    }
    return;
}
Exemple #3
0
static void process_co_ju( bool both , char *cwcurr )
{
    char        *   pa;
    char        *   p;
    int             len;

    p = scan_start;
    while( *p && *p != ' ' ) {          // over cw
        p++;
    }
    while( *p && *p == ' ' ) {          // next word start
        p++;
    }
    pa = p;

    while( *p && *p != ' ' ) {          // end of word
        p++;
    }
    len = p - pa;
    switch( len ) {
    case 0 :                            // omitted means ON
        if( both ) {
            ProcFlags.concat = true;
        }
        ProcFlags.justify = ju_on;
        scan_restart = p;
        break;
    case 2 :                            // only ON valid
        if( !strnicmp( "ON", pa, 2 ) ) {
            if( both ) {
                ProcFlags.concat = true;
                g_post_skip = 0;
            }
            ProcFlags.justify = ju_on;
            scan_restart = pa + len;
        } else {
            xx_opt_err( cwcurr, pa );
        }
        break;
    case 3 :                            // only OFF valid
        if( !strnicmp( "OFF", pa, 3 ) ) {
            if( both ) {
                ProcFlags.concat = false;
                g_post_skip = 0;
            }
            ProcFlags.justify = ju_off;
            scan_restart = pa + len;
        } else {
            xx_opt_err( cwcurr, pa );
        }
        break;
    case 4 :                            // Left or half valid
        if( !strnicmp( "LEFT", pa, 4 ) ) {
            if( both ) {
                ProcFlags.concat = true;
            }

            /***************************************************************/
            /*  .ju left is treated as .ju off by wgml4.0                  */
            /*  system variable &SYSJU is set to OFF                       */
            /***************************************************************/
            ProcFlags.justify = ju_off; // left is like off for wgml 4.0
            scan_restart = pa + len;
        } else {
            if( !strnicmp( "HALF", pa, 4 ) ) {
                if( both ) {
                    ProcFlags.concat = true;
                }
                ProcFlags.justify = ju_half;
                scan_restart = pa + len;
            } else {
                xx_opt_err( cwcurr, pa );
            }
        }
        break;
    case 5 :                            // only Right valid
        if( !strnicmp( "RIGHT", pa, 5 ) ) {
            if( both ) {
                ProcFlags.concat = true;
            }
            ProcFlags.justify = ju_right;
            scan_restart = pa + len;
        } else {
            xx_opt_err( cwcurr, pa );
        }
        break;
    case 6 :                            // center or inside valid
        if( !strnicmp( "CENTER", pa, 6 ) || !strnicmp( "CENTRE", pa, 6 ) ) {
            if( both ) {
                ProcFlags.concat = true;
            }
            ProcFlags.justify = ju_centre;
            scan_restart = pa + len;
        } else {
            if( !strnicmp( "INSIDE", pa, 6 ) ) {
                if( both ) {
                    ProcFlags.concat = true;
                }
                ProcFlags.justify = ju_inside;
                scan_restart = pa + len;
            } else {
                xx_opt_err( cwcurr, pa );
            }
        }
        break;
    case 7 :                            // only outside valid
        if( !strnicmp( "OUTSIDE", pa, 7 ) ) {
            if( both ) {
                ProcFlags.concat = true;
            }
            ProcFlags.justify = ju_outside;
            scan_restart = pa + len;
        } else {
            xx_opt_err( cwcurr, pa );
        }
        break;
    default:
        xx_opt_err( cwcurr, pa );
        break;
    }
    return;
}
Exemple #4
0
void    scr_ix( void )
{
    condcode        cc;                 // resultcode from getarg()
    static char     cwcurr[4] = {" ix"};// control word string for errmsg
    int             lvl;              // max index level in control word data
    int             k;
    int             comp_len;// compare length for searching existing entries
    int             comp_res;           // compare result
    char        *   ix[3];              // index string(s) to add
    uint32_t        ixlen[3];           // corresponding lengths
    ix_h_blk    * * ixhwork;            // anchor point for insert
    ix_h_blk    *   ixhwk;              // index block
    ix_h_blk    *   ixhcurr[3];         // active index heading block per lvl
    ix_e_blk    *   ixewk;              // index entry block
    bool            do_nothing;         // true if index string duplicate
    uint32_t        wkpage;


    scan_restart = scan_stop + 1;

    if( !(GlobalFlags.index && GlobalFlags.lastpass) ) {
        return;                         // no need to process .ix
    }                                   // no index wanted or not lastpass
    cwcurr[0] = SCR_char;
    lvl = 0;                            // index level

//  if( ProcFlags.page_started ) {
//      wkpage = page;
//  } else {
    wkpage = page + 1;              // not quite clear TBD
//  }

    garginit();                         // over control word

    while( lvl < 3 ) {                  // try to get 3 lvls of index

        cc = getarg();

        if( cc == omit || cc == quotes0 ) { // no (more) arguments
            if( lvl == 0 ) {
                parm_miss_err( cwcurr );
                return;
            } else {
                break;
            }
        } else {
            if( *tok_start == '.' && arg_flen == 1  ) {
                if( lvl > 0 ) {
                    xx_opt_err( cwcurr, tok_start );
                    break;             // .ix s1 s2 . ref format not supprted
                }
                cc = getarg();
                if( cc == pos || cc == quotes ) {   // .ix . dump ???
                    if( arg_flen == 4 ) {
                        if( !strnicmp( tok_start, "DUMP", 4 ) ) {

                            ixdump( index_dict );

                            break;
                        }
                    }
                    xx_opt_err( cwcurr, tok_start );// unknown option
                } else {
                    parm_miss_err( cwcurr );
                    return;
                }
                break;                  // no index entry text
            }
            ix[lvl] = tok_start;
            *(tok_start + arg_flen) = 0;
            ixlen[lvl] = arg_flen;
            lvl++;
        }
    }
    cc = getarg();
    /***************************************************************************/
    /*  The docu says .ix "I1" "I2" "I3" "extra" is invalid, but WGML4 accepts */
    /*  it without error and processes it like the :I3 pg="extra" attribute    */
    /***************************************************************************/
//  if( cc != omit ) {
//      parm_extra_err( cwcurr, tok_start - (cc == quotes) );
//      return;
//  }

    if( lvl > 0 ) {                     // we have at least one index string

        ixhwork = &index_dict;
        for( k = 0; k < lvl; ++k ) {
            do_nothing = false;
            while( *ixhwork != NULL ) { // find alfabetic point to insert
                comp_len = ixlen[k];
                if( comp_len > (*ixhwork)->ix_term_len )
                    comp_len = (*ixhwork)->ix_term_len;
                ++comp_len;
                comp_res = strnicmp( ix[k], (*ixhwork)->ix_term, comp_len );
                if( comp_res > 0 ) {    // new is later in alfabet
                    ixhwork = &((*ixhwork)->next);
                    continue;
                }
                if( comp_res == 0 ) {   // equal
                    if( ixlen[k] == (*ixhwork)->ix_term_len ) {
                        do_nothing = true;
                        break;          // entry already there
                    }
                    if( ixlen[k] > (*ixhwork)->ix_term_len ) {
                        ixhwork = &((*ixhwork)->next);
                        continue;       // new is longer
                    }
                }
                break;                  // insert point reached
            }
            if( !do_nothing ) {
                // insert point reached
                ixhwk = mem_alloc( sizeof( ix_h_blk ) );
                ixhwk->next  = *ixhwork;
                ixhwk->ix_lvl= k + 1;
                ixhwk->lower = NULL;
                ixhwk->entry = NULL;
                ixhwk->prt_term = NULL;
                ixhwk->prt_term_len = 0;
                ixhwk->ix_term_len   = ixlen[k];
                ixhwk->ix_term = mem_alloc( ixlen[k] + 1 );
                strcpy_s( ixhwk->ix_term, ixlen[k] + 1, ix[k] );
                *ixhwork = ixhwk;
            } else {            // string already in dictionary at this level
                ixhwk = *ixhwork;
            }
            ixhcurr[lvl] = ixhwk;
            if( k < lvl ) {
                ixhwork = &(ixhwk->lower); // next lower level
            }
        }

        // now add the pageno to index entry
        if( ixhwk->entry == NULL ) {    // first pageno for entry

            /***************************************************************************/
            /*  The docu says .ix "I1" "I2" "I3" "extra" is invalid, but WGML4 accepts */
            /*  it without error and processes it like the :I3 pg="extra" attribute    */
            /*  try to process the extra parm                                          */
            /***************************************************************************/
            if( cc != omit ) {
                *(tok_start + arg_flen) = 0;
                fill_ix_e_blk( &(ixhwk->entry), ixhwk, pgstring, tok_start, arg_flen );
            } else {
                fill_ix_e_blk( &(ixhwk->entry), ixhwk, pgpageno, NULL, 0 );
            }
        } else {
            ixewk = ixhwk->entry;
            while( ixewk->next != NULL ) {  // find last entry
                ixewk = ixewk->next;
            }
            if( (ixewk->entry_typ >= pgstring) || (ixewk->page_no != wkpage) ) {
                // if last entry doesn't point to current page create entry
                if( cc != omit ) {
                    *(tok_start + arg_flen) = 0;
                    fill_ix_e_blk( &(ixewk->next), ixhwk, pgstring, tok_start, arg_flen );
                } else {
                    fill_ix_e_blk( &(ixewk->next), ixhwk, pgpageno, NULL, 0 );
                }
            }
        }
    }
    return;
}
Exemple #5
0
void scr_pa( void )
{
    char        *   pa;
    char        *   p;
    int             len;
    char            cwcurr[4];

    cwcurr[0] = SCR_char;
    cwcurr[1] = 'p';
    cwcurr[2] = 'a';
    cwcurr[3] = '\0';

    p = scan_start;
    while( *p && *p != ' ' ) {          // over cw
        p++;
    }
    while( *p && *p == ' ' ) {          // next word start
        p++;
    }
    pa = p;

    while( *p && *p != ' ' ) {          // end of word
        p++;
    }
    len = p - pa;
    switch( len ) {
    case 7 :
        if( strnicmp( "NOSTART", pa, 7 ) ) {
            xx_opt_err( cwcurr, pa );
            break;
        }
        /* fallthru for NOSTART */
    case 0 :
        last_page_out();                // default action
        reset_t_page();
        break;
    case 3 :
        if( !strnicmp( "ODD", pa, 3 ) ) {
            last_page_out();
            reset_t_page();
            if( (page & 1) ) {          // next page would be even
                do_page_out();
                reset_t_page();
            }
        } else {
            xx_opt_err( cwcurr, pa );
        }
        break;
    case 4 :
        if( !strnicmp( "EVEN", pa, 4 ) ) {
            last_page_out();
            reset_t_page();
            if( !(page & 1) ) {         // next page would be odd
                do_page_out();
                reset_t_page();
            }
        } else {
            xx_opt_err( cwcurr, pa );
        }
        break;
    default:
        xx_opt_err( cwcurr, pa );
        break;
    }
    scan_restart = scan_stop +1;
    return;
}