Mercurial > gnulib
annotate lib/anytostr.c @ 17363:5a51fb7777a9
sys_select, sys_time: port 2013-01-30 Solaris 2.6 fix to Cygwin
Problem reported by Marco Atzeri in
<http://lists.gnu.org/archive/html/bug-gnulib/2013-03/msg00000.html>.
* lib/sys_select.in.h [HAVE_SYS_SELECT_H && _CYGWIN_SYS_TIME_H]:
Simply delegate to the system <sys/select.h> in this case too.
Also, pay attention to _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TIME_H only
if OSF/1, since otherwise Cygwin breaks, and it doesn't seem to
be needed on Solaris either.
* lib/sys_time.in.h [_CYGWIN_SYS_TIME_H]:
Simply delgate to the system <sys/time.h> in this case.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Tue, 19 Mar 2013 09:08:47 -0700 |
parents | e542fd46ad6f |
children | 9a6c1c655351 |
rev | line source |
---|---|
13400
4a25c1663687
inttostr: add a new function, inttostr, and tests
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
1 /* anytostr.c -- convert integers to printable strings |
4a25c1663687
inttostr: add a new function, inttostr, and tests
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
2 |
17249
e542fd46ad6f
maint: update all copyright year number ranges
Eric Blake <eblake@redhat.com>
parents:
16201
diff
changeset
|
3 Copyright (C) 2001, 2006, 2008-2013 Free Software Foundation, Inc. |
13400
4a25c1663687
inttostr: add a new function, inttostr, and tests
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
4 |
4a25c1663687
inttostr: add a new function, inttostr, and tests
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
5 This program is free software: you can redistribute it and/or modify |
4a25c1663687
inttostr: add a new function, inttostr, and tests
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
6 it under the terms of the GNU General Public License as published by |
4a25c1663687
inttostr: add a new function, inttostr, and tests
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
7 the Free Software Foundation; either version 3 of the License, or |
4a25c1663687
inttostr: add a new function, inttostr, and tests
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
8 (at your option) any later version. |
4a25c1663687
inttostr: add a new function, inttostr, and tests
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
9 |
4a25c1663687
inttostr: add a new function, inttostr, and tests
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
10 This program is distributed in the hope that it will be useful, |
4a25c1663687
inttostr: add a new function, inttostr, and tests
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
4a25c1663687
inttostr: add a new function, inttostr, and tests
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4a25c1663687
inttostr: add a new function, inttostr, and tests
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
13 GNU General Public License for more details. |
4a25c1663687
inttostr: add a new function, inttostr, and tests
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
14 |
4a25c1663687
inttostr: add a new function, inttostr, and tests
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
15 You should have received a copy of the GNU General Public License |
4a25c1663687
inttostr: add a new function, inttostr, and tests
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
4a25c1663687
inttostr: add a new function, inttostr, and tests
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
17 |
4a25c1663687
inttostr: add a new function, inttostr, and tests
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
18 /* Written by Paul Eggert */ |
4a25c1663687
inttostr: add a new function, inttostr, and tests
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
19 |
13824
d5c7df915328
inttostr: simplify by removing unnecessary redundancy
Paul Eggert <eggert@cs.ucla.edu>
parents:
13821
diff
changeset
|
20 /* Tell gcc not to warn about the (i < 0) test, below. */ |
d5c7df915328
inttostr: simplify by removing unnecessary redundancy
Paul Eggert <eggert@cs.ucla.edu>
parents:
13821
diff
changeset
|
21 #if (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) || 4 < __GNUC__ |
d5c7df915328
inttostr: simplify by removing unnecessary redundancy
Paul Eggert <eggert@cs.ucla.edu>
parents:
13821
diff
changeset
|
22 # pragma GCC diagnostic ignored "-Wtype-limits" |
d5c7df915328
inttostr: simplify by removing unnecessary redundancy
Paul Eggert <eggert@cs.ucla.edu>
parents:
13821
diff
changeset
|
23 #endif |
d5c7df915328
inttostr: simplify by removing unnecessary redundancy
Paul Eggert <eggert@cs.ucla.edu>
parents:
13821
diff
changeset
|
24 |
13400
4a25c1663687
inttostr: add a new function, inttostr, and tests
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
25 #include <config.h> |
4a25c1663687
inttostr: add a new function, inttostr, and tests
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
26 |
4a25c1663687
inttostr: add a new function, inttostr, and tests
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
27 #include "inttostr.h" |
4a25c1663687
inttostr: add a new function, inttostr, and tests
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
28 |
4a25c1663687
inttostr: add a new function, inttostr, and tests
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
29 /* Convert I to a printable string in BUF, which must be at least |
4a25c1663687
inttostr: add a new function, inttostr, and tests
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
30 INT_BUFSIZE_BOUND (INTTYPE) bytes long. Return the address of the |
4a25c1663687
inttostr: add a new function, inttostr, and tests
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
31 printable string, which need not start at BUF. */ |
4a25c1663687
inttostr: add a new function, inttostr, and tests
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
32 |
4a25c1663687
inttostr: add a new function, inttostr, and tests
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
33 char * __attribute_warn_unused_result__ |
4a25c1663687
inttostr: add a new function, inttostr, and tests
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
34 anytostr (inttype i, char *buf) |
4a25c1663687
inttostr: add a new function, inttostr, and tests
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
35 { |
4a25c1663687
inttostr: add a new function, inttostr, and tests
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
36 char *p = buf + INT_STRLEN_BOUND (inttype); |
4a25c1663687
inttostr: add a new function, inttostr, and tests
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
37 *p = 0; |
4a25c1663687
inttostr: add a new function, inttostr, and tests
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
38 |
13821
1cf23bf4f6e4
inttostr: revert most-recent change
Paul Eggert <eggert@cs.ucla.edu>
parents:
13820
diff
changeset
|
39 if (i < 0) |
13400
4a25c1663687
inttostr: add a new function, inttostr, and tests
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
40 { |
4a25c1663687
inttostr: add a new function, inttostr, and tests
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
41 do |
4a25c1663687
inttostr: add a new function, inttostr, and tests
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
42 *--p = '0' - i % 10; |
4a25c1663687
inttostr: add a new function, inttostr, and tests
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
43 while ((i /= 10) != 0); |
4a25c1663687
inttostr: add a new function, inttostr, and tests
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
44 |
4a25c1663687
inttostr: add a new function, inttostr, and tests
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
45 *--p = '-'; |
4a25c1663687
inttostr: add a new function, inttostr, and tests
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
46 } |
4a25c1663687
inttostr: add a new function, inttostr, and tests
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
47 else |
4a25c1663687
inttostr: add a new function, inttostr, and tests
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
48 { |
4a25c1663687
inttostr: add a new function, inttostr, and tests
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
49 do |
4a25c1663687
inttostr: add a new function, inttostr, and tests
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
50 *--p = '0' + i % 10; |
4a25c1663687
inttostr: add a new function, inttostr, and tests
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
51 while ((i /= 10) != 0); |
4a25c1663687
inttostr: add a new function, inttostr, and tests
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
52 } |
4a25c1663687
inttostr: add a new function, inttostr, and tests
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
53 |
4a25c1663687
inttostr: add a new function, inttostr, and tests
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
54 return p; |
4a25c1663687
inttostr: add a new function, inttostr, and tests
Jim Meyering <meyering@redhat.com>
parents:
diff
changeset
|
55 } |