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 20101204
[ncurses.git]
/
ncurses
/
tinfo
/
strings.c
diff --git
a/ncurses/tinfo/strings.c
b/ncurses/tinfo/strings.c
index 8198ec4050adaccf5e7329c509e2b220b79bd996..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,14
+36,14
@@
#include <curses.priv.h>
#include <curses.priv.h>
-MODULE_ID("$Id")
+MODULE_ID("$Id
: strings.c,v 1.6 2007/08/11 17:12:17 tom Exp $
")
/****************************************************************************
* Useful string functions (especially for mvcur)
****************************************************************************/
#if !HAVE_STRSTR
/****************************************************************************
* Useful string functions (especially for mvcur)
****************************************************************************/
#if !HAVE_STRSTR
-char *
+NCURSES_EXPORT(char *)
_nc_strstr(const char *haystack, const char *needle)
{
size_t len1 = strlen(haystack);
_nc_strstr(const char *haystack, const char *needle)
{
size_t len1 = strlen(haystack);
@@
-52,7
+52,7
@@
_nc_strstr(const char *haystack, const char *needle)
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++;
@@
-62,15
+62,18
@@
_nc_strstr(const char *haystack, const char *needle)
#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.
*/
*/
-string_desc *
+NCURSES_EXPORT(string_desc *)
_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;
_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;
}
if (src != 0)
*src = 0;
}
@@
-80,7
+83,7
@@
_nc_str_init(string_desc * dst, char *src, size_t len)
/*
* Initialize the descriptor for only tracking the amount of memory used.
*/
/*
* Initialize the descriptor for only tracking the amount of memory used.
*/
-string_desc *
+NCURSES_EXPORT(string_desc *)
_nc_str_null(string_desc * dst, size_t len)
{
return _nc_str_init(dst, 0, len);
_nc_str_null(string_desc * dst, size_t len)
{
return _nc_str_init(dst, 0, len);
@@
-89,7
+92,7
@@
_nc_str_null(string_desc * dst, size_t len)
/*
* Copy a descriptor
*/
/*
* Copy a descriptor
*/
-string_desc *
+NCURSES_EXPORT(string_desc *)
_nc_str_copy(string_desc * dst, string_desc * src)
{
*dst = *src;
_nc_str_copy(string_desc * dst, string_desc * src)
{
*dst = *src;
@@
-99,7
+102,7
@@
_nc_str_copy(string_desc * dst, string_desc * src)
/*
* Replaces strcat into a fixed buffer, returning false on failure.
*/
/*
* Replaces strcat into a fixed buffer, returning false on failure.
*/
-bool
+NCURSES_EXPORT(bool)
_nc_safe_strcat(string_desc * dst, const char *src)
{
if (src != 0) {
_nc_safe_strcat(string_desc * dst, const char *src)
{
if (src != 0) {
@@
-120,7
+123,7
@@
_nc_safe_strcat(string_desc * dst, const char *src)
/*
* Replaces strcpy into a fixed buffer, returning false on failure.
*/
/*
* Replaces strcpy into a fixed buffer, returning false on failure.
*/
-bool
+NCURSES_EXPORT(bool)
_nc_safe_strcpy(string_desc * dst, const char *src)
{
if (src != 0) {
_nc_safe_strcpy(string_desc * dst, const char *src)
{
if (src != 0) {
@@
-131,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;
}
}