Deleted Added
full compact
tc.str.c (100616) tc.str.c (131962)
1/* $Header: /src/pub/tcsh/tc.str.c,v 3.10 2002/03/08 17:36:47 christos Exp $ */
1/* $Header: /src/pub/tcsh/tc.str.c,v 3.13 2004/02/21 20:34:25 christos Exp $ */
2/*
3 * tc.str.c: Short string package
4 * This has been a lesson of how to write buggy code!
5 */
6/*-
7 * Copyright (c) 1980, 1991 The Regents of the University of California.
8 * All rights reserved.
9 *

--- 18 unchanged lines hidden (view full) ---

28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 */
34#include "sh.h"
35
2/*
3 * tc.str.c: Short string package
4 * This has been a lesson of how to write buggy code!
5 */
6/*-
7 * Copyright (c) 1980, 1991 The Regents of the University of California.
8 * All rights reserved.
9 *

--- 18 unchanged lines hidden (view full) ---

28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 */
34#include "sh.h"
35
36RCSID("$Id: tc.str.c,v 3.10 2002/03/08 17:36:47 christos Exp $")
36RCSID("$Id: tc.str.c,v 3.13 2004/02/21 20:34:25 christos Exp $")
37
38#define MALLOC_INCR 128
39
40#ifdef SHORT_STRINGS
41Char **
42blk2short(src)
43 register char **src;
44{

--- 259 unchanged lines hidden (view full) ---

304 }
305 if (*str1 == '\0')
306 return(0);
307 str1++, str2++;
308 } while (--n != 0);
309 return(0);
310}
311
37
38#define MALLOC_INCR 128
39
40#ifdef SHORT_STRINGS
41Char **
42blk2short(src)
43 register char **src;
44{

--- 259 unchanged lines hidden (view full) ---

304 }
305 if (*str1 == '\0')
306 return(0);
307 str1++, str2++;
308 } while (--n != 0);
309 return(0);
310}
311
312int
313s_strcasecmp(str1, str2)
314 register const Char *str1, *str2;
315{
316 unsigned char c1, c2, l1 = 0, l2 = 0;
317 for (; *str1 && ((*str1 == *str2 && (l1 = l2 = 0) == 0) ||
318 ((c1 = (unsigned char)*str1) == *str1 &&
319 (c2 = (unsigned char)*str2) == *str2 &&
320 (l1 = tolower(c1)) == (l2 = tolower(c2)))); str1++, str2++)
321 continue;
322 /*
323 * The following case analysis is necessary so that characters which look
324 * negative collate low against normal characters but high against the
325 * end-of-string NUL.
326 */
327 if (*str1 == '\0' && *str2 == '\0')
328 return (0);
329 else if (*str1 == '\0')
330 return (-1);
331 else if (*str2 == '\0')
332 return (1);
333 else if (l1 == l2) /* They are zero when they are equal */
334 return (*str1 - *str2);
335 else
336 return (l1 - l2);
337}
338
312Char *
313s_strsave(s)
314 register const Char *s;
315{
316 Char *n;
317 register Char *p;
318
319 if (s == 0)

--- 104 unchanged lines hidden ---
339Char *
340s_strsave(s)
341 register const Char *s;
342{
343 Char *n;
344 register Char *p;
345
346 if (s == 0)

--- 104 unchanged lines hidden ---