Menu

#91 coan prints error when meets ", ##VA_ARGS"

v6.0.1
open
None
5
2018-01-29
2018-01-29
Moonhee Lee
No

V6.0.1 coan can not parse "##VA_ARGS" of preprocessor.

If there are "#define FOO(a, ...) bar(a,##VA_ARGS)" codes in source, it will print error although it is appropriate code.

And, I think that it relate to

{
    size_t mark = pos;
    ptrdiff_t p(pos);
    while (--p >= 0 && isspace(_fmt[p])){}
    if (p < 0) {
        throw error_misplaced_token_paste();
    }
    pos = p;
    size_t i_off;
    size_t h_off;
    if (specifier::get_ending_at(_fmt,pos,i_off,h_off) != string::npos) {
        _fmt[h_off] = char(handling::substitute_arg);
    } else if (!identifier::is_valid_char(_fmt[pos]) && _fmt[pos] != '#') {
    // THIS CONDITION IS RELATED WITH ", ##VA_ARGS".
        throw error_bad_token_paste();
    }
    size_t start_cut = pos + 1;
    pos = mark + 2;
    for (   ;pos < _fmt.length() && isspace(_fmt[pos]); ++pos){}
    if (pos >= _fmt.length()) {
        throw error_misplaced_token_paste();
    }
    if (specifier::get_at(_fmt,pos,i_off,h_off) != string::npos) {
        _fmt[h_off] = char(handling::substitute_arg);
    } else if (!identifier::is_valid_char(_fmt[pos]) && _fmt[pos] != '#') {
        throw error_bad_token_paste();
    }
    size_t cut_len = pos - start_cut;
    _fmt.erase(start_cut,cut_len);
    return -cut_len;
}

Thank you.

Related

bugs: #91

Discussion

  • Jonathan Leffler

    You reference VA_ARGS, but that has no special meaning in C. Are you
    thinking of VA_ARGS (with double leading and trailing underscores)?
    Would the code work differently if you spelled it that way?

    On Sun, Jan 28, 2018 at 8:55 PM, Moonhee Lee <lunarvel@users.sourceforge.net

    wrote:


    Status: open
    Group: v6.0.1
    Created: Mon Jan 29, 2018 04:55 AM UTC by Moonhee Lee
    Last Updated: Mon Jan 29, 2018 04:55 AM UTC
    Owner: Mike Kinghan

    V6.0.1 coan can not parse "##VA_ARGS" of preprocessor.

    If there are "#define FOO(a, ...) bar(a,##VA_ARGS)" codes in source, it
    will print error although it is appropriate code.

    And, I think that it relate to

    {
    size_t mark = pos;
    ptrdiff_t p(pos);
    while (--p >= 0 && isspace(_fmt[p])){}
    if (p < 0) {
    throw error_misplaced_token_paste();
    }
    pos = p;
    size_t i_off;
    size_t h_off;
    if (specifier::get_ending_at(_fmt,pos,i_off,h_off) != string::npos) {
    _fmt[h_off] = char(handling::substitute_arg);
    } else if (!identifier::is_valid_char(_fmt[pos]) && _fmt[pos] != '#') {
    // THIS CONDITION IS RELATED WITH ", ##VA_ARGS".
    throw error_bad_token_paste();
    }
    size_t start_cut = pos + 1;
    pos = mark + 2;
    for ( ;pos < _fmt.length() && isspace(_fmt[pos]); ++pos){}
    if (pos >= _fmt.length()) {
    throw error_misplaced_token_paste();
    }
    if (specifier::get_at(_fmt,pos,i_off,h_off) != string::npos) {
    _fmt[h_off] = char(handling::substitute_arg);
    } else if (!identifier::is_valid_char(_fmt[pos]) && _fmt[pos] != '#') {
    throw error_bad_token_paste();
    }
    size_t cut_len = pos - start_cut;
    _fmt.erase(start_cut,cut_len);
    return -cut_len;}

    Thank you.

    Sent from sourceforge.net because you indicated interest in
    https://sourceforge.net/p/coan2/bugs/91/

    To unsubscribe from further messages, please visit
    https://sourceforge.net/auth/subscriptions/

    --
    Jonathan Leffler jonathan.leffler@gmail.com #include <disclaimer.h>
    Guardian of DBD::Informix - v2015.1101 - http://dbi.perl.org
    "Blessed are we who can laugh at ourselves, for we shall never cease to be
    amused."</disclaimer.h>

     

    Related

    bugs: #91

    • Moonhee Lee

      Moonhee Lee - 2018-01-30

      Oh, it's my fault obviously.
      replace "VA_ARGS" to "__VA_ARGS__"

      Thank you.

       

      Last edit: Moonhee Lee 2018-01-30

Log in to post a comment.

MongoDB Logo MongoDB