Esempio n. 1
0
static void syspgnumrdfun( symvar *e ) // roman page no.
{
    e = e;
    int_to_roman( page, syspgnumrdstr, sizeof( syspgnumrdstr ) );
    strcat( syspgnumrdstr, "." );
    return;
};
Esempio n. 2
0
static void syspgnumcfun( symvar *e )  // roman page no UPPER
{
    e = e;
    int_to_roman( page, syspgnumcstr, sizeof( syspgnumcstr ) );
    strupr( syspgnumcstr );
    return;
};
char* add_roman(char augend[], char addend[]) {
  int x = roman_to_int(augend);
  int y = roman_to_int(addend);
  int sum = x + y;

  return int_to_roman(sum);
}
char* subtract_roman(char minuend[], char subtrahend[]) {
  int x = roman_to_int(minuend);
  int y = roman_to_int(subtrahend);
  int difference = x - y;

  return int_to_roman(difference);
}
Esempio n. 5
0
static void syspgnumcdfun( symvar * e ) // roman page no UPPER.
{
    int_to_roman( page, syspgnumcdstr, sizeof( syspgnumcdstr ) );
    strupr( syspgnumcdstr );
    strcat( syspgnumcdstr, "." );
    return;
};
Esempio n. 6
0
char *  format_num( uint32_t n, char * r, size_t rsize, num_style ns )
{
    size_t      pos;
    size_t      pos1;
    char    *   p;
    char    *   rp;
    char        temp[MAX_L_AS_STR + 3]; // +3 for () and decimal point
    char        a1;
    char        a2;
    char        charbase;


    p = temp;
    pos = 0;
    if( ns & xpa_style ) {
        *p++ = '(';                     // start number with left paren
        if( ++pos >= rsize ) {
            return( NULL );             // result field overflow
        }
    }
    if( ns & (a_style | b_style) ) {    // alphabetic limit 2 'digits'
    /************************************************************************/
    /*  Arbitrary limit Value 728 = 2 characters    extend if needed    TBD */
    /************************************************************************/
        if( n >= 27*27 || (n < 1) ) {   // only 2 letters supported
            return( NULL );             // and numbers > zero
        }
        if( ns & a_style ) {
            charbase = 'a' - 1;
        } else {
            charbase = 'A' - 1;
        }
    }
    switch( ns & char1_style ) {
    case a_style :                      // lower case alphabetic
    case b_style :                      // UPPER case alphabetic
        a1 = n / 27;
        a2 = n % 27;
        if( a1 > 0 ) {
            *p++ = charbase + a1;
            if( ++pos >= rsize ) {
                return( NULL );         // result field overflow
            }
            *p++ = charbase + 1 + a2;
            if( ++pos >= rsize ) {
                return( NULL );         // result field overflow
            }
        } else {
            *p++ = charbase + a2;
            if( ++pos >= rsize ) {
                return( NULL );         // result field overflow
            }
        }
        break;
    case h_style :                      // arabic
        ultoa( n, p, 10 );
        pos1 = strlen( p );
        pos += pos1;
        if( pos >= rsize ) {
            return( NULL );             // result field overflow
        }
        p += pos1;
        break;
    case r_style :                      // lower case roman
        rp = int_to_roman( n, p, rsize - pos );
        if( rp == NULL ) {
            return( NULL );             // field overflow
        }
        pos1 = strlen( rp );
        p += pos1;
        break;
    case c_style :                      // UPPER case roman
        rp = int_to_roman( n, p, rsize - pos );
        if( rp == NULL ) {
            return( NULL );             // field overflow
        }
        strupr( p );
        pos1 = strlen( rp );
        p += pos1;
        break;
    default:
        out_msg( "Logic error in gutil.c int_to_roman()\n" );
        err_count++;
        g_suicide();
        break;
    }

    if( ns & xd_style ) {
        *p++ = '.';                     // decimalpoint follows
        if( ++pos >= rsize ) {
            return( NULL );             // result field overflow
        }
    }
    if( ns & xpb_style ) {
        *p++ = ')';                     // right paren follows
        if( ++pos >= rsize ) {
            return( NULL );             // result field overflow
        }
    }
    *p = '\0';                          // terminate string
    strcpy( r, temp );                  // copy temp string to result
    return( r );
}
Esempio n. 7
0
static void syspgnumrfun( symvar *e ) // roman page no
{
    e = e;
    int_to_roman( page, syspgnumrstr, sizeof( syspgnumrstr ) );
    return;
};