Convert strsearch() arguments to const char *
Also clean up the implementation a little.
This commit is contained in:
@@ -132,12 +132,12 @@ char * base64_encode (const void *data, size_t size);
|
|||||||
/* From words.c */
|
/* From words.c */
|
||||||
#define SOS -32767
|
#define SOS -32767
|
||||||
#define EOS 32767
|
#define EOS 32767
|
||||||
char *BX_strsearch (register char *, char *, char *, int);
|
char *BX_strsearch(const char *, const char *, const char *, int);
|
||||||
char *BX_move_to_word (const char *, int);
|
char *BX_move_to_word(const char *, int);
|
||||||
char *BX_move_word_rel (const char *, char **, int);
|
char *BX_move_word_rel(const char *, char **, int);
|
||||||
char *BX_extract (char *, int, int);
|
char *BX_extract(char *, int, int);
|
||||||
char *BX_extract2 (const char *, int, int);
|
char *BX_extract2(const char *, int, int);
|
||||||
int BX_wild_match (const char *, const char *);
|
int BX_wild_match(const char *, const char *);
|
||||||
|
|
||||||
/* Used for connect_by_number */
|
/* Used for connect_by_number */
|
||||||
#define SERVICE_SERVER 0
|
#define SERVICE_SERVER 0
|
||||||
|
|||||||
@@ -199,7 +199,7 @@ extern Function_ptr *global;
|
|||||||
|
|
||||||
|
|
||||||
/* words.c reg.c */
|
/* words.c reg.c */
|
||||||
#define strsearch (*(char *(*)(char *, char *, char *, int ))global[STRSEARCH])
|
#define strsearch (*(char *(*)(const char *, const char *, const char *, int ))global[STRSEARCH])
|
||||||
#define move_to_word (*(char *(*)(const char *, int))global[MOVE_TO_WORD])
|
#define move_to_word (*(char *(*)(const char *, int))global[MOVE_TO_WORD])
|
||||||
#define move_word_rel (*(char *(*)(const char *, char **, int ))global[MOVE_WORD_REL])
|
#define move_word_rel (*(char *(*)(const char *, char **, int ))global[MOVE_WORD_REL])
|
||||||
#define extract (*(char *(*)(char *, int , int ))global[EXTRACT])
|
#define extract (*(char *(*)(char *, int , int ))global[EXTRACT])
|
||||||
|
|||||||
@@ -15,36 +15,45 @@ CVS_REVISION(words_c)
|
|||||||
#include "ircaux.h"
|
#include "ircaux.h"
|
||||||
#include "modval.h"
|
#include "modval.h"
|
||||||
|
|
||||||
/*
|
/* strsearch()
|
||||||
* search() looks for a character forward or backward from mark
|
*
|
||||||
|
* If how > 0, returns a pointer to the how'th matching character forwards
|
||||||
|
* from mark, in the string starting at start.
|
||||||
|
* If how < 0, returns a pointer to the -how'th matching character backwards
|
||||||
|
* from mark, in the string starting at start.
|
||||||
|
* If how == 0, returns NULL.
|
||||||
|
*
|
||||||
|
* NULL mark begins the search at start.
|
||||||
|
*
|
||||||
|
* A matching character is any character in chars, unless chars starts with ^,
|
||||||
|
* in which case a matching character is any character NOT in chars.
|
||||||
|
*
|
||||||
|
* If there are insufficient matching characters, NULL is returned.
|
||||||
*/
|
*/
|
||||||
extern char *BX_strsearch(register char *start, char *mark, char *chars, int how)
|
extern char *BX_strsearch(const char *start, const char *mark, const char *chars, int how)
|
||||||
{
|
{
|
||||||
|
const char *ptr = NULL;
|
||||||
|
|
||||||
if (!mark)
|
if (!mark)
|
||||||
mark = start;
|
mark = start;
|
||||||
|
|
||||||
if (how > 0) /* forward search */
|
if (how > 0) /* forward search */
|
||||||
{
|
{
|
||||||
mark = sindex(mark, chars);
|
for (; how > 0 && mark; how--)
|
||||||
how--;
|
|
||||||
for (; how > 0 && mark && *mark; how--)
|
|
||||||
mark = sindex(mark + 1, chars);
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (how == 0)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
else /* how < 0 */
|
|
||||||
{
|
{
|
||||||
mark = rsindex(mark, start, chars, -how);
|
ptr = sindex(mark, chars);
|
||||||
#if 0
|
if (ptr)
|
||||||
how++;
|
mark = ptr + 1;
|
||||||
for (;(how < 0) && *mark && **mark;how++)
|
else
|
||||||
*mark = rsindex(*mark-1, start, chars);
|
mark = NULL;
|
||||||
#endif
|
}
|
||||||
|
}
|
||||||
|
else if (how < 0)
|
||||||
|
{
|
||||||
|
ptr = rsindex(mark, start, chars, -how);
|
||||||
}
|
}
|
||||||
|
|
||||||
return mark;
|
return (char *)ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* move_to_word()
|
/* move_to_word()
|
||||||
|
|||||||
Reference in New Issue
Block a user