Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#14 bug in %REP

closed-fixed
1
2008-07-16
2002-05-25
Anonymous
No

The PP_REP code in preproc.c forgets to check
whether a repeat count was specified or not.

Before "t = expand_smacro(tline->next);" it
should do something like this:

if (!tline->next) {
error(ERR_NONFATAL, "`%%rep' expects a repeat
count");
return 3;
}

Discussion

  • Logged In: YES
    user_id=806493

    There is patch that fixes this bug and makes %rep more similar
    with %macro (.nolist after repeat count, not only before - it
    would be better to remove the latter as it is not yet
    documented, but I may be wrong).

    This is diff with changes (of clean v0.98.36 preproc.c) in
    PP_REP branch:

    2498c2498
    < tline = tline->next;
    ---
    > do {
    2499d2498
    < if (tline->next && tline->next->type ==
    TOK_WHITESPACE)
    2501,2502c2500,2501
    < if (tline->next && tline->next->type == TOK_ID &&
    < !nasm_stricmp(tline->next->text, ".nolist"))
    ---
    > } while (tok_type_(tline, TOK_WHITESPACE));
    > if (tok_type_(tline, TOK_ID) &&
    2502a2502
    > !nasm_stricmp(tline->text, ".nolist"))
    2504d2503
    < tline = tline->next;
    2505a2505,2507
    > do {
    > tline = tline->next;
    > } while (tok_type_(tline, TOK_WHITESPACE));
    2507,2509c2509,2511
    < t = expand_smacro(tline->next);
    < tline->next = NULL;
    < free_tlist(origline);
    ---
    > if (!tline)
    > {
    > error(ERR_NONFATAL, "`%%rep' expects a repeat
    count");
    2509a2512,2515
    > return DIRECTIVE_FOUND;
    > }
    >
    > t = expand_smacro(tline);
    2515c2521
    < free_tlist(tline);
    ---
    > free_tlist(origline);
    2519c2525
    < error(ERR_WARNING,
    ---
    > {
    2519a2526,2533
    > if (tokval.t_type == TOKEN_ID &&
    > !nasm_stricmp(tokval.t_charptr, ".nolist"))
    > {
    > nolist = TRUE;
    > }
    > else
    > {
    > error(ERR_WARNING,
    2520a2535,2536
    > }
    > }

     
  • H. Peter Anvin
    H. Peter Anvin
    2003-09-06

    Logged In: YES
    user_id=58697

    unv - could you please send a unidiff (diff -u) for this fix
    and upload it as a file rather than cut and paste?

     
    • labels: --> Preprocessor Bugs
     
    • assigned_to: nobody --> unv
     
  • Logged In: YES
    user_id=806493

    I've uploaded this bugfix into CVS. It fixes #794686 bug also.

     
  • Logged In: NO

    What if the repeat count is specified by a local
    label named .nolist? 8-)

    Also, I can't seem to find your CVS submission.
    Do you have a URL?

     
    • priority: 5 --> 1
    • status: open --> open-works-for-me
     
    • status: open-works-for-me --> closed-fixed