ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

strpbrk.c
Go to the documentation of this file.
00001 /*
00002  * $Id$
00003  */
00004 #include <limits.h>
00005 #include <string.h>
00006 
00007 #define BIT_SIZE (CHAR_BIT * sizeof(unsigned long) / sizeof(char))
00008 
00009 char* strpbrk(const char *s1, const char *s2)
00010 {
00011     if (*s2 == 0)
00012     {
00013        return 0;
00014     }
00015     if (*(s2+1) == 0)
00016     {
00017        return strchr(s1, *s2);
00018     }
00019     else if (*(s2+2) == 0)
00020     {
00021        char *s3, *s4;
00022        s3 = strchr(s1, *s2);
00023        s4 = strchr(s1, *(s2+1));
00024        if (s3 == 0)
00025        {
00026           return s4;
00027        }
00028        else if (s4 == 0)
00029        {
00030           return s3;
00031        }
00032        return s3 < s4 ? s3 : s4;
00033     }
00034     else
00035     {
00036        unsigned long char_map[(1 << CHAR_BIT) / BIT_SIZE] = {0, };
00037        const unsigned char* str = (const unsigned char*)s1;
00038        while (*s2)
00039        {
00040           char_map[*(const unsigned char*)s2 / BIT_SIZE] |= (1 << (*(const unsigned char*)s2 % BIT_SIZE));
00041           s2++;
00042        }
00043        while (*str)
00044        {
00045           if (char_map[*str / BIT_SIZE] & (1 << (*str % BIT_SIZE)))
00046           {
00047              return (char*)((size_t)str);
00048           }
00049           str++;
00050        }
00051     }
00052     return 0;
00053 }
00054 

Generated on Sat May 26 2012 04:35:36 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.