removed unused extract_last_token() and the required memrchr implementation
This commit is contained in:
@@ -14,16 +14,8 @@
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/* memrchr is a GNU extension */
|
||||
#define _GNU_SOURCE
|
||||
#include <string.h>
|
||||
|
||||
#include "lexparser.h"
|
||||
|
||||
#ifndef HAVE_MEMRCHR
|
||||
void *memrchr(const void *s, int c, size_t n);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* eat whitespace
|
||||
*/
|
||||
@@ -33,7 +25,7 @@ bool eat_whitespace(chunk_t *src)
|
||||
{
|
||||
src->ptr++; src->len--;
|
||||
}
|
||||
return src->len > 0 && *src->ptr != '#';
|
||||
return src->len > 0 && *src->ptr != '#';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,11 +46,11 @@ bool extract_token(chunk_t *token, const char termination, chunk_t *src)
|
||||
if (termination == ' ')
|
||||
{
|
||||
u_char *eot_tab = memchr(src->ptr, '\t', src->len);
|
||||
|
||||
|
||||
/* check if a tab instead of a space terminates the token */
|
||||
eot = ( eot_tab == NULL || (eot && eot < eot_tab) ) ? eot : eot_tab;
|
||||
}
|
||||
|
||||
|
||||
/* initialize empty token */
|
||||
*token = chunk_empty;
|
||||
|
||||
@@ -105,32 +97,6 @@ bool extract_token_str(chunk_t *token, const char *termination, chunk_t *src)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* extracts a token ending with the last occurrence of a given termination symbol
|
||||
*/
|
||||
bool extract_last_token(chunk_t *token, const char termination, chunk_t *src)
|
||||
{
|
||||
u_char *eot = memrchr(src->ptr, termination, src->len);
|
||||
|
||||
/* initialize empty token */
|
||||
*token = chunk_empty;
|
||||
|
||||
if (eot == NULL) /* termination symbol not found */
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* extract token */
|
||||
token->ptr = src->ptr;
|
||||
token->len = (u_int)(eot - src->ptr);
|
||||
|
||||
/* advance src pointer after termination symbol */
|
||||
src->ptr = eot + 1;
|
||||
src->len -= (token->len + 1);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* fetches a new line terminated by \n or \r\n
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user