~ubuntu-branches/ubuntu/precise/eglibc/precise-201308281639

« back to all changes in this revision

Viewing changes to string/_strerror.c

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2012-02-08 01:58:09 UTC
  • mfrom: (1.5.3) (288.1.12 precise)
  • Revision ID: package-import@ubuntu.com-20120208015809-ulscst7uteq3e22z
Tags: 2.15~pre6-0ubuntu10
Merge from Debian (r5151, 2.13-26).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 1991,93,95,96,97,98,2000,2002,2006
 
1
/* Copyright (C) 1991,93,95,96,97,98,2000,2002,2006,2011
2
2
   Free Software Foundation, Inc.
3
3
   This file is part of the GNU C Library.
4
4
 
18
18
   02111-1307 USA.  */
19
19
 
20
20
#include <libintl.h>
 
21
#include <stdbool.h>
21
22
#include <stdio.h>
 
23
#include <stdlib.h>
22
24
#include <string.h>
23
25
#include <sys/param.h>
24
26
#include <stdio-common/_itoa.h>
43
45
         `int' of 8 bytes we never need more than 20 digits.  */
44
46
      char numbuf[21];
45
47
      const char *unk = _("Unknown error ");
46
 
      const size_t unklen = strlen (unk);
 
48
      size_t unklen = strlen (unk);
47
49
      char *p, *q;
 
50
      bool negative = errnum < 0;
48
51
 
49
52
      numbuf[20] = '\0';
50
 
      p = _itoa_word (errnum, &numbuf[20], 10, 0);
 
53
      p = _itoa_word (abs (errnum), &numbuf[20], 10, 0);
51
54
 
52
55
      /* Now construct the result while taking care for the destination
53
56
         buffer size.  */
54
57
      q = __mempcpy (buf, unk, MIN (unklen, buflen));
 
58
      if (negative && unklen < buflen)
 
59
        {
 
60
          *q++ = '-';
 
61
          ++unklen;
 
62
        }
55
63
      if (unklen < buflen)
56
64
        memcpy (q, p, MIN ((size_t) (&numbuf[21] - p), buflen - unklen));
57
65