projects
/
ncurses.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
ncurses 5.7 - patch 20090718
[ncurses.git]
/
ncurses
/
tinfo
/
strings.c
diff --git
a/ncurses/tinfo/strings.c
b/ncurses/tinfo/strings.c
index 5fa68caf75346edb5ad0a366544c790b3e9aeec1..78cd2ef4f5f510ca7a4bdc36349b9f9d62f81626 100644
(file)
--- a/
ncurses/tinfo/strings.c
+++ b/
ncurses/tinfo/strings.c
@@
-1,5
+1,5
@@
/****************************************************************************
/****************************************************************************
- * Copyright (c) 2000
Free Software Foundation, Inc.
*
+ * Copyright (c) 2000
-2003,2007 Free Software Foundation, Inc.
*
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
@@
-36,7
+36,7
@@
#include <curses.priv.h>
#include <curses.priv.h>
-MODULE_ID("$Id: strings.c,v 1.
3 2000/12/10 02:55:08
tom Exp $")
+MODULE_ID("$Id: strings.c,v 1.
6 2007/08/11 17:12:17
tom Exp $")
/****************************************************************************
* Useful string functions (especially for mvcur)
/****************************************************************************
* Useful string functions (especially for mvcur)
@@
-44,8
+44,7
@@
MODULE_ID("$Id: strings.c,v 1.3 2000/12/10 02:55:08 tom Exp $")
#if !HAVE_STRSTR
NCURSES_EXPORT(char *)
#if !HAVE_STRSTR
NCURSES_EXPORT(char *)
-_nc_strstr
-(const char *haystack, const char *needle)
+_nc_strstr(const char *haystack, const char *needle)
{
size_t len1 = strlen(haystack);
size_t len2 = strlen(needle);
{
size_t len1 = strlen(haystack);
size_t len2 = strlen(needle);
@@
-53,7
+52,7
@@
_nc_strstr
while ((len1 != 0) && (len1-- >= len2)) {
if (!strncmp(haystack, needle, len2)) {
while ((len1 != 0) && (len1-- >= len2)) {
if (!strncmp(haystack, needle, len2)) {
- result = haystack;
+ result =
(char *)
haystack;
break;
}
haystack++;
break;
}
haystack++;
@@
-63,16
+62,18
@@
_nc_strstr
#endif
/*
#endif
/*
- * Initialize the descriptor so we can append to it.
+ * Initialize the descriptor so we can append to it. Note that 'src' may
+ * be a null pointer (see _nc_str_null), so the corresponding strcat and
+ * strcpy calls have to allow for this.
*/
NCURSES_EXPORT(string_desc *)
*/
NCURSES_EXPORT(string_desc *)
-_nc_str_init
-(string_desc * dst, char *src, size_t len)
+_nc_str_init(string_desc * dst, char *src, size_t len)
{
if (dst != 0) {
dst->s_head = src;
dst->s_tail = src;
dst->s_size = len - 1;
{
if (dst != 0) {
dst->s_head = src;
dst->s_tail = src;
dst->s_size = len - 1;
+ dst->s_init = dst->s_size;
if (src != 0)
*src = 0;
}
if (src != 0)
*src = 0;
}
@@
-83,8
+84,7
@@
_nc_str_init
* Initialize the descriptor for only tracking the amount of memory used.
*/
NCURSES_EXPORT(string_desc *)
* Initialize the descriptor for only tracking the amount of memory used.
*/
NCURSES_EXPORT(string_desc *)
-_nc_str_null
-(string_desc * dst, size_t len)
+_nc_str_null(string_desc * dst, size_t len)
{
return _nc_str_init(dst, 0, len);
}
{
return _nc_str_init(dst, 0, len);
}
@@
-93,8
+93,7
@@
_nc_str_null
* Copy a descriptor
*/
NCURSES_EXPORT(string_desc *)
* Copy a descriptor
*/
NCURSES_EXPORT(string_desc *)
-_nc_str_copy
-(string_desc * dst, string_desc * src)
+_nc_str_copy(string_desc * dst, string_desc * src)
{
*dst = *src;
return dst;
{
*dst = *src;
return dst;
@@
-135,7
+134,7
@@
_nc_safe_strcpy(string_desc * dst, const char *src)
strcpy(dst->s_head, src);
dst->s_tail = dst->s_head + len;
}
strcpy(dst->s_head, src);
dst->s_tail = dst->s_head + len;
}
- dst->s_size
-=
len;
+ dst->s_size
= dst->s_init -
len;
return TRUE;
}
}
return TRUE;
}
}