From 6b2fc9c63be9d1454cf9df8c00771fdd238ba465 Mon Sep 17 00:00:00 2001 From: Jan Breuer <jan.breuer@jaybee.cz> Date: 周三, 20 3月 2013 23:00:18 +0800 Subject: [PATCH] ANSI C89 modifications --- libscpi/src/utils.c | 32 +++++++++++++++++++++++++++----- 1 files changed, 27 insertions(+), 5 deletions(-) diff --git a/libscpi/src/utils.c b/libscpi/src/utils.c index 3df0069..8880636 100644 --- a/libscpi/src/utils.c +++ b/libscpi/src/utils.c @@ -147,7 +147,7 @@ return FALSE; } - if (strncasecmp(str1, str2, len2) == 0) { + if (SCPI_strncasecmp(str1, str2, len2) == 0) { return TRUE; } @@ -160,7 +160,7 @@ STATE_TEXT, STATE_LAST_WHITESPACE, STATE_COMMA, - STATE_ERROR, + STATE_ERROR }; typedef enum _locate_text_states locate_text_states; @@ -175,7 +175,7 @@ /** * Test locate text state, if it is correct final state */ -static inline bool_t isFinalState(locate_text_states state) { +static bool_t isFinalState(locate_text_states state) { return ( ((state) == STATE_COMMA) || ((state) == STATE_LAST_WHITESPACE) @@ -189,7 +189,7 @@ * @param nfa stores automaton state * @param c current char processed */ -static inline bool_t locateTextAutomaton(locate_text_nfa * nfa, unsigned char c) { +static bool_t locateTextAutomaton(locate_text_nfa * nfa, unsigned char c) { switch(nfa->state) { /* first state locating only white spaces */ case STATE_FIRST_WHITESPACE: @@ -284,7 +284,7 @@ * @param nfa stores automaton state * @param c current char processed */ -static inline bool_t locateStrAutomaton(locate_text_nfa * nfa, unsigned char c) { +static bool_t locateStrAutomaton(locate_text_nfa * nfa, unsigned char c) { switch(nfa->state) { /* first state locating only white spaces */ case STATE_FIRST_WHITESPACE: @@ -403,3 +403,25 @@ return compareStr(pattern, pattern_len, str, str_len) || compareStr(pattern, pattern_sep_pos_short, str, str_len); } + + +#if !HAVE_STRNLEN +/* use FreeBSD strnlen */ + +/*- + * Copyright (c) 2009 David Schultz <das@FreeBSD.org> + * All rights reserved. + */ +size_t +BSD_strnlen(const char *s, size_t maxlen) +{ + size_t len; + + for (len = 0; len < maxlen; len++, s++) { + if (!*s) + break; + } + return (len); +} +#endif + -- Gitblit v1.9.1