view src/lib-fts/fts-filter-common.c @ 22656:1789bf2a1e01

director: Make sure HOST-RESET-USERS isn't used with max_moving_users=0 The reset command would just hang in that case. doveadm would never have sent this, so this is just an extra sanity check.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Sun, 05 Nov 2017 23:51:56 +0200
parents 2e2563132d5f
children cb108f786fb4
line wrap: on
line source

/* Copyright (c) 2016-2017 Dovecot authors, see the included COPYING file */

#include "lib.h"
#include "str.h"
#include "buffer.h"
#include "unichar.h"
#include "fts-filter-private.h"
#include "fts-filter-common.h"
#include "fts-tokenizer-common.h"

void fts_filter_truncate_token(string_t *token, size_t max_length)
{
	if (str_len(token) <= max_length)
		return;

	size_t len = max_length;
	fts_tokenizer_delete_trailing_partial_char(token->data, &len);
	str_truncate(token, len);
	i_assert(len <= max_length);
}