]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/tinfo/strings.c
ncurses 6.2 - patch 20210508
[ncurses.git] / ncurses / tinfo / strings.c
index d5377fe07a51bb2f2775e5c67a6f150fa43b1ff2..a1d8beb63f31e6db47f6e6c6b58df25588b93acc 100644 (file)
@@ -1,5 +1,6 @@
 /****************************************************************************
 /****************************************************************************
- * Copyright (c) 2000,2003 Free Software Foundation, Inc.                   *
+ * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2000-2012,2017 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            *
@@ -35,8 +36,9 @@
 **/
 
 #include <curses.priv.h>
 **/
 
 #include <curses.priv.h>
+#include <tic.h>
 
 
-MODULE_ID("$Id: strings.c,v 1.5 2003/08/16 23:46:00 tom Exp $")
+MODULE_ID("$Id: strings.c,v 1.10 2020/02/02 23:34:34 tom Exp $")
 
 /****************************************************************************
  * Useful string functions (especially for mvcur)
 
 /****************************************************************************
  * Useful string functions (especially for mvcur)
@@ -52,7 +54,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++;
@@ -105,12 +107,12 @@ _nc_str_copy(string_desc * dst, string_desc * src)
 NCURSES_EXPORT(bool)
 _nc_safe_strcat(string_desc * dst, const char *src)
 {
 NCURSES_EXPORT(bool)
 _nc_safe_strcat(string_desc * dst, const char *src)
 {
-    if (src != 0) {
+    if (PRESENT(src)) {
        size_t len = strlen(src);
 
        if (len < dst->s_size) {
            if (dst->s_tail != 0) {
        size_t len = strlen(src);
 
        if (len < dst->s_size) {
            if (dst->s_tail != 0) {
-               strcpy(dst->s_tail, src);
+               _nc_STRCPY(dst->s_tail, src, dst->s_size);
                dst->s_tail += len;
            }
            dst->s_size -= len;
                dst->s_tail += len;
            }
            dst->s_size -= len;
@@ -126,12 +128,12 @@ _nc_safe_strcat(string_desc * dst, const char *src)
 NCURSES_EXPORT(bool)
 _nc_safe_strcpy(string_desc * dst, const char *src)
 {
 NCURSES_EXPORT(bool)
 _nc_safe_strcpy(string_desc * dst, const char *src)
 {
-    if (src != 0) {
+    if (PRESENT(src)) {
        size_t len = strlen(src);
 
        if (len < dst->s_size) {
            if (dst->s_head != 0) {
        size_t len = strlen(src);
 
        if (len < dst->s_size) {
            if (dst->s_head != 0) {
-               strcpy(dst->s_head, src);
+               _nc_STRCPY(dst->s_head, src, dst->s_size);
                dst->s_tail = dst->s_head + len;
            }
            dst->s_size = dst->s_init - len;
                dst->s_tail = dst->s_head + len;
            }
            dst->s_size = dst->s_init - len;