annotate osdep/vsscanf.c @ 33736:a5a54c7a15ce

Fix the precision loss in float -> 32bit conversion case, introduced by my earlier commit. Instead use method proposed by Reimar. Also, avoid using ldexp, it is slower than multiply with constant.
author iive
date Wed, 06 Jul 2011 23:35:39 +0000
parents 5cfef41a1771
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
28744
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
1 /*
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
2 * vsscanf implementation for systems that do not have it in libc
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
3 *
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
4 * This file is part of MPlayer.
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
5 *
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
6 * MPlayer is free software; you can redistribute it and/or modify
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
7 * it under the terms of the GNU General Public License as published by
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
9 * (at your option) any later version.
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
10 *
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
11 * MPlayer is distributed in the hope that it will be useful,
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
14 * GNU General Public License for more details.
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
15 *
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
16 * You should have received a copy of the GNU General Public License along
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
17 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
19 */
8290
1dd8fe0776d3 Add our own vsscanf implementation, in case the system's libc does not have
jkeil
parents:
diff changeset
20
28744
5cfef41a1771 Add standard license headers to files.
diego
parents: 21855
diff changeset
21 #include "config.h"
8290
1dd8fe0776d3 Add our own vsscanf implementation, in case the system's libc does not have
jkeil
parents:
diff changeset
22
1dd8fe0776d3 Add our own vsscanf implementation, in case the system's libc does not have
jkeil
parents:
diff changeset
23 #include <stdio.h>
1dd8fe0776d3 Add our own vsscanf implementation, in case the system's libc does not have
jkeil
parents:
diff changeset
24 #include <stdarg.h>
1dd8fe0776d3 Add our own vsscanf implementation, in case the system's libc does not have
jkeil
parents:
diff changeset
25
1dd8fe0776d3 Add our own vsscanf implementation, in case the system's libc does not have
jkeil
parents:
diff changeset
26 int
1dd8fe0776d3 Add our own vsscanf implementation, in case the system's libc does not have
jkeil
parents:
diff changeset
27 vsscanf(const char *str, const char *format, va_list ap)
1dd8fe0776d3 Add our own vsscanf implementation, in case the system's libc does not have
jkeil
parents:
diff changeset
28 {
1dd8fe0776d3 Add our own vsscanf implementation, in case the system's libc does not have
jkeil
parents:
diff changeset
29 /* XXX: can this be implemented in a more portable way? */
1dd8fe0776d3 Add our own vsscanf implementation, in case the system's libc does not have
jkeil
parents:
diff changeset
30 long p1 = va_arg(ap, long);
1dd8fe0776d3 Add our own vsscanf implementation, in case the system's libc does not have
jkeil
parents:
diff changeset
31 long p2 = va_arg(ap, long);
1dd8fe0776d3 Add our own vsscanf implementation, in case the system's libc does not have
jkeil
parents:
diff changeset
32 long p3 = va_arg(ap, long);
1dd8fe0776d3 Add our own vsscanf implementation, in case the system's libc does not have
jkeil
parents:
diff changeset
33 long p4 = va_arg(ap, long);
1dd8fe0776d3 Add our own vsscanf implementation, in case the system's libc does not have
jkeil
parents:
diff changeset
34 long p5 = va_arg(ap, long);
1dd8fe0776d3 Add our own vsscanf implementation, in case the system's libc does not have
jkeil
parents:
diff changeset
35 return sscanf(str, format, p1, p2, p3, p4, p5);
1dd8fe0776d3 Add our own vsscanf implementation, in case the system's libc does not have
jkeil
parents:
diff changeset
36 }