summaryrefslogtreecommitdiff
path: root/src/user/lib/libc/std
diff options
context:
space:
mode:
authorAlex AUVOLAT <alexis211@gmail.com>2012-05-19 14:07:01 +0200
committerAlex AUVOLAT <alexis211@gmail.com>2012-05-19 14:07:01 +0200
commit0d2f7645c3fb45d83497faf2a4b6fff8c3f175d1 (patch)
treea9038fce4cf81556fbdd5589caee8f4e9bfc5185 /src/user/lib/libc/std
parent499ca6c243b05da176a2d4bd9a2317f0b28afc7f (diff)
downloadTCE-0d2f7645c3fb45d83497faf2a4b6fff8c3f175d1.tar.gz
TCE-0d2f7645c3fb45d83497faf2a4b6fff8c3f175d1.zip
Added string class for FWIK.
Diffstat (limited to 'src/user/lib/libc/std')
-rw-r--r--src/user/lib/libc/std/stdio.c40
-rw-r--r--src/user/lib/libc/std/string.c40
2 files changed, 40 insertions, 40 deletions
diff --git a/src/user/lib/libc/std/stdio.c b/src/user/lib/libc/std/stdio.c
index 3595622..da2f094 100644
--- a/src/user/lib/libc/std/stdio.c
+++ b/src/user/lib/libc/std/stdio.c
@@ -20,46 +20,6 @@ void fprintf(FILE f, char* format, ...) {
va_end(ap);
}
-// INTERNAL, FOR FORMATTING
-
-static char* format_int(char* buf, int number) {
- if (number == 0) {
- *(buf++) = '0';
- return buf;
- }
- if (number < 0) {
- *(buf++) = '-';
- number = 0 - number;
- }
-
- int order = 0, temp = number, i;
- char numbers[] = "0123456789";
- while (temp > 0) {
- order++;
- temp /= 10;
- }
-
- for (i = order; i > 0; i--) {
- buf[i - 1] = numbers[number % 10];
- number /= 10;
- }
- return buf + order;
-}
-
-static char* format_hex(char *buf, unsigned v) {
- *(buf++) = '0';
- *(buf++) = 'x';
-
- int i;
- char hexdigits[] = "0123456789ABCDEF";
- for (i = 0; i < 8; i++) {
- *(buf++) = hexdigits[v >> 28];
- v = v << 4;
- }
- return buf;
-}
-
-
// FUNCTIONS
void fprint(FILE f, char *s) {
diff --git a/src/user/lib/libc/std/string.c b/src/user/lib/libc/std/string.c
index 5a41b7e..d8e4a48 100644
--- a/src/user/lib/libc/std/string.c
+++ b/src/user/lib/libc/std/string.c
@@ -79,3 +79,43 @@ uint16_t *memsetw(uint16_t *dest, uint16_t val, int count) {
}
return dest;
}
+
+
+// Formatting
+
+char* format_int(char* buf, int number) {
+ if (number == 0) {
+ *(buf++) = '0';
+ return buf;
+ }
+ if (number < 0) {
+ *(buf++) = '-';
+ number = 0 - number;
+ }
+
+ int order = 0, temp = number, i;
+ char numbers[] = "0123456789";
+ while (temp > 0) {
+ order++;
+ temp /= 10;
+ }
+
+ for (i = order; i > 0; i--) {
+ buf[i - 1] = numbers[number % 10];
+ number /= 10;
+ }
+ return buf + order;
+}
+
+char* format_hex(char *buf, unsigned v) {
+ *(buf++) = '0';
+ *(buf++) = 'x';
+
+ int i;
+ char hexdigits[] = "0123456789ABCDEF";
+ for (i = 0; i < 8; i++) {
+ *(buf++) = hexdigits[v >> 28];
+ v = v << 4;
+ }
+ return buf;
+}