Changeset 9b20126 in mainline for uspace/lib/pcut/src/assert.c


Ignore:
Timestamp:
2014-09-19T08:23:01Z (10 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c85a57f
Parents:
15d0046
Message:

Update PCUT to newest version

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/pcut/src/assert.c

    r15d0046 r9b20126  
    3535 */
    3636
     37/** We need _BSD_SOURCE because of vsnprintf() when compiling under C89. */
     38#define _BSD_SOURCE
     39
    3740#include "internal.h"
    3841#include <setjmp.h>
     
    5255static int message_buffer_index = 0;
    5356
    54 /** Announce that assertion failed.
    55  *
    56  * @warning This function may not return.
    57  *
    58  * @param fmt printf-style formatting string.
    59  *
    60  */
    61 void pcut_failed_assertion_fmt(const char *fmt, ...) {
     57void pcut_failed_assertion_fmt(const char *filename, int line, const char *fmt, ...) {
     58        va_list args;
    6259        char *current_buffer = message_buffer[message_buffer_index];
     60        size_t offset = 0;
    6361        message_buffer_index = (message_buffer_index + 1) % MESSAGE_BUFFER_COUNT;
    6462
    65         va_list args;
    66         va_start(args, fmt);
    67         vsnprintf(current_buffer, MAX_MESSAGE_LENGTH, fmt, args);
    68         va_end(args);
     63        snprintf(current_buffer, MAX_MESSAGE_LENGTH, "%s:%d: ", filename, line);
     64        offset = pcut_str_size(current_buffer);
     65
     66        if (offset + 1 < MAX_MESSAGE_LENGTH) {
     67                va_start(args, fmt);
     68                vsnprintf(current_buffer + offset, MAX_MESSAGE_LENGTH - offset, fmt, args);
     69                va_end(args);
     70        }
    6971
    7072        pcut_failed_assertion(current_buffer);
Note: See TracChangeset for help on using the changeset viewer.