Beispiel #1
0
Datei: mark.c Projekt: adsr/mlbuf
// Replace data between marks
int mark_replace_between_mark(mark_t* self, mark_t* other, char* data, bint_t data_len) {
    bint_t offset_a;
    bint_t offset_b;
    buffer_get_offset(self->bline->buffer, self->bline, self->col, &offset_a);
    buffer_get_offset(other->bline->buffer, other->bline, other->col, &offset_b);
    if (offset_a < offset_b) {
        return buffer_replace(self->bline->buffer, offset_a, offset_b - offset_a, data, data_len);
    }
    return buffer_replace(self->bline->buffer, offset_b, offset_a - offset_b, data, data_len);
}
Beispiel #2
0
/*
 * Convert a date from PostgreSQL to XML
 */
buffer *ows_psql_timestamp_to_xml_time(char *timestamp)
{
    buffer *time;

    assert(timestamp);

    time = buffer_init();
    buffer_add_str(time, timestamp);
    if (!time->use) return time;

    buffer_replace(time, " ", "T");

    if (check_regexp(time->buf, "\\+"))
        buffer_add_str(time, ":00");
    else
        buffer_add_str(time, "Z");

    return time;
}
Beispiel #3
0
int range_through_pipe(struct range *rng, const char *cmd)
{
	struct list *l, *to_pipe;
	int eno, ret = 0;

	to_pipe = buffer_extract_range(buffers_current(), rng);

	l = pipe_readwrite(cmd, to_pipe ? to_pipe : buffer_gethead(buffers_current()));

	if(l){
		if(l->data){
			if(to_pipe){
				struct list *inshere;

				inshere = buffer_getindex(buffers_current(), rng->start);

				if(inshere)
					buffer_insertlistbefore(buffers_current(), inshere, l);
				else
					buffer_appendlist(buffers_current(), l);

				list_free_nodata(to_pipe);
				to_pipe = NULL;
			}else{
				buffer_replace(buffers_current(), l);
			}

			buffer_modified(buffers_current()) = 1;
		}else{
			/* FIXME? assign to_pipe to "reg? restore into buffer? */
			list_free(l, free);
			ret = 1;
		}
	}

	eno = errno;
	if(to_pipe)
		list_free(to_pipe, free);
	errno = eno;

	return ret;
}