summaryrefslogtreecommitdiff
path: root/com32/lib
diff options
context:
space:
mode:
authorMichal Soltys <soltys@ziu.info>2011-03-07 23:47:31 +0100
committerMichal Soltys <soltys@ziu.info>2011-03-07 23:47:31 +0100
commit6b905c1968fe16007c9f446c7a1b1e71419767c7 (patch)
treec4abae0ecd039470ae9b3d1bc54ab758b546e9e1 /com32/lib
parentb9cc8bc0b6976cc92a21e2a8c8b155048e01d45e (diff)
parentc987272b97ecb89db19ee438dba0c8c2418f8ffe (diff)
downloadsyslinux-6b905c1968fe16007c9f446c7a1b1e71419767c7.tar.gz
Merge branch 'master' into chaindev
Diffstat (limited to 'com32/lib')
-rw-r--r--com32/lib/Makefile3
-rw-r--r--com32/lib/pci/scan.c10
-rw-r--r--com32/lib/skipspace.c8
-rw-r--r--com32/lib/suffix_number.c72
-rw-r--r--com32/lib/syslinux/load_linux.c37
-rw-r--r--com32/lib/vsscanf.c7
6 files changed, 85 insertions, 52 deletions
diff --git a/com32/lib/Makefile b/com32/lib/Makefile
index ed4bb31e..b2a51f3c 100644
--- a/com32/lib/Makefile
+++ b/com32/lib/Makefile
@@ -27,11 +27,14 @@ LIBOBJS = \
strtoumax.o vfprintf.o vprintf.o vsnprintf.o vsprintf.o \
asprintf.o vasprintf.o strlcpy.o strlcat.o \
vsscanf.o zalloc.o \
+ skipspace.o \
\
lmalloc.o lstrdup.o \
\
dprintf.o vdprintf.o \
\
+ suffix_number.o \
+ \
sys/readdir.o getcwd.o chdir.o fdopendir.o \
\
libgcc/__ashldi3.o libgcc/__udivdi3.o \
diff --git a/com32/lib/pci/scan.c b/com32/lib/pci/scan.c
index 2577b321..c8334b11 100644
--- a/com32/lib/pci/scan.c
+++ b/com32/lib/pci/scan.c
@@ -39,6 +39,7 @@
#include <sys/pci.h>
#include <com32.h>
#include <stdbool.h>
+#include <ctype.h>
#include <syslinux/zio.h>
#ifdef DEBUG
@@ -49,15 +50,6 @@
#define MAX_LINE 512
-/* searching the next char that is not a space */
-static char *skipspace(char *p)
-{
- while (*p && *p <= ' ')
- p++;
-
- return p;
-}
-
/* removing any \n found in a string */
static void remove_eol(char *string)
{
diff --git a/com32/lib/skipspace.c b/com32/lib/skipspace.c
new file mode 100644
index 00000000..5db26519
--- /dev/null
+++ b/com32/lib/skipspace.c
@@ -0,0 +1,8 @@
+#include <ctype.h>
+
+char *skipspace(const char *p)
+{
+ while (isspace((unsigned char)*p))
+ p++;
+ return (char *)p;
+}
diff --git a/com32/lib/suffix_number.c b/com32/lib/suffix_number.c
new file mode 100644
index 00000000..df073a00
--- /dev/null
+++ b/com32/lib/suffix_number.c
@@ -0,0 +1,72 @@
+/* ----------------------------------------------------------------------- *
+ *
+ * Copyright 2007-2009 H. Peter Anvin - All Rights Reserved
+ * Copyright 2009 Intel Corporation; author: H. Peter Anvin
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall
+ * be included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * ----------------------------------------------------------------------- */
+
+/*
+ * suffix_number.c
+ *
+ * Convert a string of a number with potential SI suffix to int-type
+ */
+
+#include <stdlib.h>
+#include <suffix_number.h>
+
+/* Get a value with a potential suffix (k/m/g/t/p/e) */
+unsigned long long suffix_number(const char *str)
+{
+ char *ep;
+ unsigned long long v;
+ int shift;
+
+ v = strtoull(str, &ep, 0);
+ switch (*ep | 0x20) {
+ case 'k':
+ shift = 10;
+ break;
+ case 'm':
+ shift = 20;
+ break;
+ case 'g':
+ shift = 30;
+ break;
+ case 't':
+ shift = 40;
+ break;
+ case 'p':
+ shift = 50;
+ break;
+ case 'e':
+ shift = 60;
+ break;
+ default:
+ shift = 0;
+ break;
+ }
+ v <<= shift;
+
+ return v;
+}
diff --git a/com32/lib/syslinux/load_linux.c b/com32/lib/syslinux/load_linux.c
index df793625..3ac6e5d0 100644
--- a/com32/lib/syslinux/load_linux.c
+++ b/com32/lib/syslinux/load_linux.c
@@ -38,6 +38,7 @@
#include <inttypes.h>
#include <string.h>
#include <minmax.h>
+#include <suffix_number.h>
#include <syslinux/align.h>
#include <syslinux/linux.h>
#include <syslinux/bootrm.h>
@@ -96,42 +97,6 @@ struct linux_header {
#define LOAD_HIGH 0x01
#define CAN_USE_HEAP 0x80
-/* Get a value with a potential suffix (k/m/g/t/p/e) */
-static unsigned long long suffix_number(const char *str)
-{
- char *ep;
- unsigned long long v;
- int shift;
-
- v = strtoull(str, &ep, 0);
- switch (*ep | 0x20) {
- case 'k':
- shift = 10;
- break;
- case 'm':
- shift = 20;
- break;
- case 'g':
- shift = 30;
- break;
- case 't':
- shift = 40;
- break;
- case 'p':
- shift = 50;
- break;
- case 'e':
- shift = 60;
- break;
- default:
- shift = 0;
- break;
- }
- v <<= shift;
-
- return v;
-}
-
/*
* Find the last instance of a particular command line argument
* (which should include the final =; do not use for boolean arguments)
diff --git a/com32/lib/vsscanf.c b/com32/lib/vsscanf.c
index d9fec51c..9a462c6a 100644
--- a/com32/lib/vsscanf.c
+++ b/com32/lib/vsscanf.c
@@ -47,13 +47,6 @@ enum bail {
bail_err /* Conversion mismatch */
};
-static const char *skipspace(const char *p)
-{
- while (isspace((unsigned char)*p))
- p++;
- return p;
-}
-
int vsscanf(const char *buffer, const char *format, va_list ap)
{
const char *p = format;