Author Topic: Astyle Question, Linux style brackets  (Read 4116 times)

fthieme

  • Guest
Astyle Question, Linux style brackets
« on: February 21, 2007, 09:30:31 pm »
Hi,

I just took a look at Code::Blocks (svn 3627) and I lik it so far. But there are some question:

1. The code formating tab is just for astyle which has to be run manually, right? Is there anything like "astyle on the fly"?

2. I use a custom astyle setup with Linux style brackets. I don't get it. Some is rendered right, some not.

this is right
Code
void qser_close_card(int config_number)
{
    struct request_type close_request;

    if (!config_is_open(config_number)) {
        return ;
    }

    close_request.type = rClose;
    close_request.serial_thread = config_get_serial_thread(config_number);

    enqueue_client_request(close_request);
}

but that not:
Code
int dequeue_client_request(struct request_type *client_request, pthread_t serial_thread)
{
    int request_pos = 0;
    int answer_pos = -1;

    /* ensure exclusive access */
    pthread_mutex_lock(&client_request_mutex);

    for (request_pos = 0; request_pos < max_client_request; request_pos++)
    {
        if (client_requests[request_pos].serial_thread == serial_thread) {
            answer_pos = request_pos;
            break;
        }
    }

    if (request_pos > -1)
    {
        /* move data and clean up */
        memcpy(client_request, &client_requests[answer_pos],
               sizeof(struct request_type));
        memset(&client_requests[answer_pos], sizeof(struct request_type), 0);
        new_client_requests--;
    }
    /* FIXME what to do if this fails? */

    /* free exclusive access */
    pthread_mutex_unlock(&client_request_mutex);

    return answer_pos;
}

don't know why.

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
Re: Astyle Question, Linux style brackets
« Reply #1 on: February 22, 2007, 01:52:38 am »
"AStyle on the fly"? Sorry, there's not such thing.

I just tried your code snippets and the keyword struct in the parameter list of dequeue_client_request is the cause of the problem. If you remove that keyword the plugin will format it correctly.

I have no idea if that bug is reported in the AStyle's bug tracker, or if it's already fixed in the latest version. I'm gonna update it soon anyway.

fthieme

  • Guest
Re: Astyle Question, Linux style brackets
« Reply #2 on: February 22, 2007, 08:48:05 am »
I meant some code formating on the fly like in the astyle settings.

So I should file an astyle bug report?

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
Re: Astyle Question, Linux style brackets
« Reply #3 on: February 24, 2007, 01:04:32 am »
Nop, there's not a code formatter on the fly.

I just tested the newest version of AStyle and it has the same problem. Please check the bug is not reported already in the bug tracker of AStyle, and if it's not then file one @ http://sourceforge.net/tracker/?group_id=2319&atid=102319