mirror of
https://github.com/rfivet/uemacs.git
synced 2025-01-21 15:46:23 -05:00
String index (&sin) function returns unicode position.
This commit is contained in:
parent
cf823e2fad
commit
c6baa2ff77
24
eval.c
24
eval.c
@ -1384,24 +1384,30 @@ static int sindex( char *source, char *pattern) {
|
|||||||
|
|
||||||
/* scanning through the source string */
|
/* scanning through the source string */
|
||||||
sp = source;
|
sp = source;
|
||||||
|
int idx = 1 ;
|
||||||
|
int pos = 0 ;
|
||||||
|
int len = strlen( source) ;
|
||||||
|
|
||||||
while (*sp) {
|
while (*sp) {
|
||||||
char *csp; /* ptr to source string during comparison */
|
char *csp; /* ptr to source string during comparison */
|
||||||
char *cp; /* ptr to place to check for equality */
|
char *cp; /* ptr to place to check for equality */
|
||||||
|
char c ;
|
||||||
|
unicode_t uc ;
|
||||||
|
|
||||||
/* scan through the pattern */
|
/* scan through the pattern */
|
||||||
cp = pattern;
|
cp = pattern;
|
||||||
csp = sp;
|
csp = sp;
|
||||||
while (*cp) {
|
|
||||||
if (!eq(*cp, *csp))
|
while( (c = *cp++) && eq( c, *csp))
|
||||||
break;
|
csp++ ;
|
||||||
++cp;
|
|
||||||
++csp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* was it a match? */
|
/* was it a match? */
|
||||||
if (*cp == 0)
|
if( c == 0)
|
||||||
return (int) (sp - source) + 1;
|
return idx ;
|
||||||
++sp;
|
|
||||||
|
idx += 1 ;
|
||||||
|
pos += utf8_to_unicode( source, pos, len, &uc) ;
|
||||||
|
sp = &source[ pos] ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* no match at all.. */
|
/* no match at all.. */
|
||||||
|
Loading…
Reference in New Issue
Block a user