removed unused extract_last_token() and the required memrchr implementation

This commit is contained in:
Martin Willi
2009-02-18 09:45:54 +00:00
parent 6ce32d8719
commit 2d887e8e08
5 changed files with 3 additions and 89 deletions
-1
View File
@@ -707,7 +707,6 @@ dnl ==========================================
AC_HAVE_LIBRARY(dl)
AC_CHECK_FUNCS(backtrace)
AC_CHECK_FUNCS(dladdr)
AC_REPLACE_FUNCS(memrchr)
AC_MSG_CHECKING([for gcc atomic operations])
AC_TRY_RUN(
-1
View File
@@ -47,7 +47,6 @@ utils/identification.c utils/identification.h \
utils/iterator.h \
utils/lexparser.c utils/lexparser.h \
utils/linked_list.c utils/linked_list.h \
utils/memrchr.c \
utils/hashtable.c utils/hashtable.h \
utils/enumerator.c utils/enumerator.h \
utils/optionsfrom.c utils/optionsfrom.h \
+3 -37
View File
@@ -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
*/
-5
View File
@@ -46,11 +46,6 @@ bool extract_token(chunk_t *token, const char termination, chunk_t *src);
*/
bool extract_token_str(chunk_t *token, const char *termination, chunk_t *src);
/**
* 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);
/**
* Fetches a new text line terminated by \n or \r\n
*/
-45
View File
@@ -1,45 +0,0 @@
/*
* Copyright (C) 2008 Thomas Jarosch
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
#ifndef HAVE_MEMRCHR
#include <string.h>
void *memrchr(const void *s, int c, size_t n)
{
unsigned char *reverse_search;
if (s == NULL || n == 0)
{
return NULL;
}
reverse_search = s + n;
for (;;)
{
if (*reverse_search == (unsigned char)c)
{
return reverse_search;
}
else if (reverse_search == s)
{
break;
}
reverse_search--;
}
return NULL;
}
#endif