aboutsummaryrefslogtreecommitdiff
path: root/contrib/ncurses/ncurses/tinfo/strings.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/ncurses/ncurses/tinfo/strings.c')
-rw-r--r--contrib/ncurses/ncurses/tinfo/strings.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/contrib/ncurses/ncurses/tinfo/strings.c b/contrib/ncurses/ncurses/tinfo/strings.c
index 5fa68caf7534..d5377fe07a51 100644
--- a/contrib/ncurses/ncurses/tinfo/strings.c
+++ b/contrib/ncurses/ncurses/tinfo/strings.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright (c) 2000 Free Software Foundation, Inc. *
+ * Copyright (c) 2000,2003 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 *
@@ -36,7 +36,7 @@
#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.5 2003/08/16 23:46:00 tom Exp $")
/****************************************************************************
* 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 *)
-_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);
@@ -63,16 +62,18 @@ _nc_strstr
#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 *)
-_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;
+ dst->s_init = dst->s_size;
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 *)
-_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);
}
@@ -93,8 +93,7 @@ _nc_str_null
* 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;
@@ -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;
}
- dst->s_size -= len;
+ dst->s_size = dst->s_init - len;
return TRUE;
}
}