tesseract  3.03
/usr/local/google/home/jbreiden/tesseract-ocr-read-only/vs2010/port/strcasestr.cpp
Go to the documentation of this file.
00001 /*
00002 Permission is hereby granted, free of charge, to any person obtaining a copy
00003 of this software and associated documentation files (the "Software"), to
00004 deal in the Software without restriction, including without limitation the
00005 rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
00006 sell copies of the Software, and to permit persons to whom the Software is
00007 furnished to do so, subject to the following conditions:
00008 
00009 The above copyright notice and this permission notice shall be included in
00010 all copies of the Software and its Copyright notices. In addition publicly
00011 documented acknowledgment must be given that this software has been used if no
00012 source code of this software is made available publicly. Making the source
00013 available publicly means including the source for this software with the
00014 distribution, or a method to get this software via some reasonable mechanism
00015 (electronic transfer via a network or media) as well as making an offer to
00016 supply the source on request. This Copyright notice serves as an offer to
00017 supply the source on on request as well. Instead of this, supplying
00018 acknowledgments of use of this software in either Copyright notices, Manuals,
00019 Publicity and Marketing documents or any documentation provided with any
00020 product containing this software. This License does not apply to any software
00021 that links to the libraries provided by this software (statically or
00022 dynamically), but only to the software provided.
00023 
00024 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00025 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00026 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
00027 THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 
00028 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
00029 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00030 
00031 Source:
00032 Evil 1.7.4
00033 The Evil library tried to port some convenient Unix functions
00034 to the Windows (XP or CE) platform. They are planned to be used
00035 
00036 http://git.enlightenment.org/legacy/evil.git/tree/src/lib/evil_string.c?id=eeaddf80d0d547d4c216974038c0599b34359695
00037 */
00038 
00039 #include <stdlib.h>
00040 #include <string.h>
00041 #include <ctype.h>
00042 
00043 char *strcasestr(const char *haystack, const char *needle) {
00044    size_t length_needle;
00045    size_t length_haystack;
00046    size_t i;
00047 
00048    if (!haystack || !needle)
00049      return NULL;
00050 
00051    length_needle = strlen(needle);
00052    length_haystack = strlen(haystack) - length_needle + 1;
00053 
00054    for (i = 0; i < length_haystack; i++)
00055      {
00056         size_t j;
00057 
00058         for (j = 0; j < length_needle; j++)
00059           {
00060             unsigned char c1;
00061             unsigned char c2;
00062 
00063             c1 = haystack[i+j];
00064             c2 = needle[j];
00065             if (toupper(c1) != toupper(c2))
00066               goto next;
00067           }
00068         return (char *) haystack + i;
00069      next:
00070         ;
00071      }
00072 
00073    return NULL;
00074 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines