Mercurial > mplayer.hg
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 |
rev | line source |
---|---|
28744 | 1 /* |
2 * vsscanf implementation for systems that do not have it in libc | |
3 * | |
4 * This file is part of MPlayer. | |
5 * | |
6 * MPlayer is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * MPlayer is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License along | |
17 * with MPlayer; if not, write to the Free Software Foundation, Inc., | |
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
19 */ | |
8290
1dd8fe0776d3
Add our own vsscanf implementation, in case the system's libc does not have
jkeil
parents:
diff
changeset
|
20 |
28744 | 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 } |