src/error.c

changeset 149
560772519ff9
parent 111
ee4b58dfcf7f
equal deleted inserted replaced
148:9f030f402699 149:560772519ff9
41 vprintf(fmt, ap); 41 vprintf(fmt, ap);
42 va_end(ap); 42 va_end(ap);
43 putchar('\n'); 43 putchar('\n');
44 } 44 }
45 45
46 void asc_error_(const char* file, unsigned line, char const* fmt, ...) { 46 void asc_error_(const char *file, unsigned line, const char *fmt, ...) {
47 asc_set_flag(asc_context.flags, ASC_FLAG_HAS_ERROR); 47 asc_set_flag(asc_context.flags, ASC_FLAG_HAS_ERROR);
48 48
49 // write to error buffer 49 // write to error buffer
50 CxBuffer* buf = &asc_context.error_buffer; 50 CxBuffer *buf = &asc_context.error_buffer;
51 size_t bufpos = buf->pos; 51 size_t bufpos = buf->pos;
52 va_list args; 52 va_list args;
53 va_start(args, fmt); 53 va_start(args, fmt);
54 int written = cx_vfprintf(buf, cxBufferWriteFunc, fmt, args); 54 int written = cx_vfprintf(buf, cxBufferWriteFunc, fmt, args);
55 cxBufferPut(buf, '\n'); 55 cxBufferPut(buf, '\n');
63 63
64 bool asc_has_error(void) { 64 bool asc_has_error(void) {
65 return asc_test_flag(asc_context.flags, ASC_FLAG_HAS_ERROR); 65 return asc_test_flag(asc_context.flags, ASC_FLAG_HAS_ERROR);
66 } 66 }
67 67
68 char const* asc_get_error(void) { 68 const char *asc_get_error(void) {
69 // we zero-terminate the current buffer contents before providing them 69 // we zero-terminate the current buffer contents before providing them
70 cxBufferPut(&asc_context.error_buffer, 0); 70 cxBufferPut(&asc_context.error_buffer, 0);
71 --asc_context.error_buffer.pos; 71 --asc_context.error_buffer.pos;
72 --asc_context.error_buffer.size; 72 --asc_context.error_buffer.size;
73 return asc_context.error_buffer.space; 73 return asc_context.error_buffer.space;

mercurial