~ubuntu-branches/ubuntu/vivid/curl/vivid

« back to all changes in this revision

Viewing changes to lib/strequal.c

  • Committer: Package Import Robot
  • Author(s): Sebastien Bacher
  • Date: 2013-05-07 12:16:37 UTC
  • mfrom: (3.4.37 sid)
  • Revision ID: package-import@ubuntu.com-20130507121637-9t3i98qgsyr9dw5d
Tags: 7.30.0-1ubuntu1
* Resynchronize on Debian. Remaining changes:
  - Drop dependencies not in main:
    + Build-Depends: Drop stunnel4 and libssh2-1-dev.
    + Drop libssh2-1-dev from binary package Depends.
  - Add new libcurl3-udeb package.
  - Add new curl-udeb package.
* Add warning to debian/patches/series.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 *                            | (__| |_| |  _ <| |___
6
6
 *                             \___|\___/|_| \_\_____|
7
7
 *
8
 
 * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
 
8
 * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
9
9
 *
10
10
 * This software is licensed as described in the file COPYING, which
11
11
 * you should have received as part of this distribution. The terms
77
77
  return toupper(*first) == toupper(*second);
78
78
#endif
79
79
}
80
 
 
81
 
#ifndef HAVE_STRLCAT
82
 
/*
83
 
 * The strlcat() function appends the NUL-terminated string src to the end
84
 
 * of dst. It will append at most size - strlen(dst) - 1 bytes, NUL-termi-
85
 
 * nating the result.
86
 
 *
87
 
 * The strlcpy() and strlcat() functions return the total length of the
88
 
 * string they tried to create.  For strlcpy() that means the length of src.
89
 
 * For strlcat() that means the initial length of dst plus the length of
90
 
 * src. While this may seem somewhat confusing it was done to make trunca-
91
 
 * tion detection simple.
92
 
 *
93
 
 *
94
 
 */
95
 
size_t Curl_strlcat(char *dst, const char *src, size_t siz)
96
 
{
97
 
  char *d = dst;
98
 
  const char *s = src;
99
 
  size_t n = siz;
100
 
  union {
101
 
    ssize_t sig;
102
 
     size_t uns;
103
 
  } dlen;
104
 
 
105
 
  /* Find the end of dst and adjust bytes left but don't go past end */
106
 
  while(n-- != 0 && *d != '\0')
107
 
    d++;
108
 
  dlen.sig = d - dst;
109
 
  n = siz - dlen.uns;
110
 
 
111
 
  if(n == 0)
112
 
    return(dlen.uns + strlen(s));
113
 
  while(*s != '\0') {
114
 
    if(n != 1) {
115
 
      *d++ = *s;
116
 
      n--;
117
 
    }
118
 
    s++;
119
 
  }
120
 
  *d = '\0';
121
 
 
122
 
  return(dlen.uns + (s - src));     /* count does not include NUL */
123
 
}
124
 
#endif