string.c
上传用户:qin5330
上传日期:2007-01-05
资源大小:114k
文件大小:14k
- /*
- ** Copyright (C) 1995, 1996, 1997, 1998 Hewlett-Packard Company
- ** Originally by Kevin Hughes, kev@kevcom.com, 3/11/94
- **
- ** This program and library is free software; you can redistribute it and/or
- ** modify it under the terms of the GNU (Library) General Public License
- ** as published by the Free Software Foundation; either version 2
- ** of the License, or any later version.
- **
- ** This program is distributed in the hope that it will be useful,
- ** but WITHOUT ANY WARRANTY; without even the implied warranty of
- ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ** GNU (Library) General Public License for more details.
- **
- ** You should have received a copy of the GNU (Library) General Public License
- ** along with this program; if not, write to the Free Software
- ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- **---------------------------------------------------------
- ** ** ** PATCHED 5/13/96, CJC
- ** Added MatchAndChange for regex in replace rule G.Hill 2/10/98
- */
- #include "swish.h"
- #include "string.h"
- #include "mem.h"
- /* My own case-insensitive strstr().
- */
- char *lstrstr(s, t)
- char *s;
- char *t;
- {
- int i, j, k, l;
-
- for (i = 0; s[i]; i++) {
- for (j = 0, l = k = i; s[k] && t[j] &&
- tolower(s[k]) == tolower(t[j]); j++, k++)
- ;
- if (t[j] == ' ')
- return s + l;
- }
- return NULL;
- }
- /* Another case insensitive comparison by M.Gaulin*/
- int ourstricmp(const char* s1, const char* s2)
- {
- while (*s1 && *s2)
- {
- char c1 = *s1++;
- char c2 = *s2++;
- int diff = (tolower(c1) - tolower(c2));
- if (diff)
- return diff;
- }
- return (*s1 - *s2);
- }
- /* Gets the next word in a line. If the word's in quotes,
- ** include blank spaces in the word or phrase.
- */
- char *getword(line, skiplen)
- char *line;
- int *skiplen;
- {
- int i, inquotes;
- char *start;
- static char word[MAXSTRLEN];
-
- start = line;
- if (!(*line))
- return "