/*
- * "$Id: search.c 7720 2008-07-11 22:46:21Z mike $"
+ * "$Id: search.c 11558 2014-02-06 18:33:34Z msweet $"
*
- * Search routines for CUPS.
+ * Search routines for CUPS.
*
- * Copyright 2007-2011 by Apple Inc.
- * Copyright 1997-2006 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2006 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * Contents:
- *
- * cgiCompileSearch() - Compile a search string.
- * cgiDoSearch() - Do a search of some text.
- * cgiFreeSearch() - Free a compiled search context.
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*/
/*
char *s, /* Regular expression string */
*sptr, /* Pointer into RE string */
*sword; /* Pointer to start of word */
- int slen; /* Allocated size of RE string */
+ size_t slen; /* Allocated size of RE string */
const char *qptr, /* Pointer into query string */
*qend; /* End of current word */
const char *prefix; /* Prefix to add to next word */
int quoted; /* Word is quoted */
- int wlen; /* Word length */
+ size_t wlen; /* Word length */
char *lword; /* Last word in query */
for (qend = qptr + 1; *qend && !isspace(*qend); qend ++);
}
- wlen = qend - qptr;
+ wlen = (size_t)(qend - qptr);
/*
* Look for logic words: AND, OR
* string + RE overhead...
*/
- wlen = (sptr - s) + 2 * 4 * wlen + 2 * strlen(prefix) + 11;
+ wlen = (size_t)(sptr - s) + 2 * 4 * wlen + 2 * strlen(prefix) + 11;
if (lword)
wlen += strlen(lword);
* Add the prefix string...
*/
- strcpy(sptr, prefix);
+ memcpy(sptr, prefix, strlen(prefix) + 1);
sptr += strlen(sptr);
/*
return (NULL);
}
- strcpy(sptr, ".*|.*");
+ memcpy(sptr, ".*|.*", 6);
sptr += 5;
- strcpy(sptr, lword2);
+ memcpy(sptr, lword2, strlen(lword2) + 1);
sptr += strlen(sptr);
- strcpy(sptr, ".*");
+ memcpy(sptr, ".*", 3);
sptr += 2;
- strcpy(sptr, lword);
+ memcpy(sptr, lword, strlen(lword) + 1);
sptr += strlen(sptr);
free(lword);
free(lword);
if (sptr > s)
- strcpy(sptr, ".*");
+ memcpy(sptr, ".*", 3);
else
{
/*
/*
- * End of "$Id: search.c 7720 2008-07-11 22:46:21Z mike $".
+ * End of "$Id: search.c 11558 2014-02-06 18:33:34Z msweet $".
*/