Sha256: ba7e326648a3f24e49df91c8ceaf2e8da0d9efe8d57627958f46963beae80f2e

Contents?: true

Size: 812 Bytes

Versions: 24

Compression:

Stored size: 812 Bytes

Contents

/* err.c
 * Copyright (c) 2011, Peter Ohler
 * All rights reserved.
 */

#include <stdarg.h>

#include "err.h"

void
ox_err_set(Err e, VALUE clas, const char *format, ...) {
    va_list	ap;

    va_start(ap, format);
    e->clas = clas;
    vsnprintf(e->msg, sizeof(e->msg) - 1, format, ap);
    va_end(ap);
}

void
ox_err_raise(Err e) {
    rb_raise(e->clas, "%s", e->msg);
}

void
_ox_err_set_with_location(Err err, const char *msg, const char *xml, const char *current, const char* file, int line) {
    int	xline = 1;
    int	col = 1;

    for (; xml < current && '\n' != *current; current--) {
	col++;
    }
    for (; xml < current; current--) {
	if ('\n' == *current) {
	    xline++;
	}
    }
    ox_err_set(err, ox_parse_error_class, "%s at line %d, column %d [%s:%d]\n", msg, xline, col, file, line);
}

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
ox-2.6.0 ext/ox/err.c
ox-2.5.0 ext/ox/err.c
ox-2.4.13 ext/ox/err.c
ox-2.4.12 ext/ox/err.c
ox-2.4.11 ext/ox/err.c
ox-2.4.9 ext/ox/err.c
ox-2.4.8 ext/ox/err.c
ox-2.4.7 ext/ox/err.c
ox-2.4.6 ext/ox/err.c
ox-2.4.5 ext/ox/err.c
ox-2.4.4 ext/ox/err.c
ox-2.4.3 ext/ox/err.c
ox-2.4.2 ext/ox/err.c
ox-2.4.1 ext/ox/err.c
ox-2.4.0 ext/ox/err.c
ox-2.3.0 ext/ox/err.c
ox-2.2.4 ext/ox/err.c
ox-2.2.3 ext/ox/err.c
ox-2.2.2 ext/ox/err.c
ox-2.2.1 ext/ox/err.c