Re: String intersection

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jul 25, 2007 at 12:15:19PM +0100, Bahadir Balban wrote:
> Is there a function in the kernel that does string intersection?
> Functions in string.c doesn't seem to do what I want, e.g.:
>
> +#include <linux/string.h>
> +
> +/* AND'ing two strings (checks intersection) */
> +static int strand(char *s1, char *s2)
> +{
> +	int i, j;
> +	int slen1 = strlen(s1);
> +	int slen2 = strlen(s2);
> +
> +	for(i = 0; i < slen1; i++)
> +		for(j = 0; j < slen2; j++)
> +			if (s1[i] == s2[j])
> +        		        return 1;
> +    return 0;
> +}

That's just strpbrk(), which is available. Only difference is the
return value. See lib/string.h .


Erik

-- 
They're all fools. Don't worry. Darwin may be slow, but he'll
eventually get them. -- Matthew Lammers in alt.sysadmin.recovery

Attachment: signature.asc
Description: Digital signature


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux