separated "standard library" string functions into bas_string.[ch]

This commit is contained in:
Markus Fröschle
2013-02-26 11:04:25 +00:00
parent 4073542762
commit 435f1ee659
6 changed files with 94 additions and 72 deletions

View File

@@ -35,6 +35,7 @@
#include <stdarg.h>
#include "MCF5475.h"
#include "bas_printf.h"
#include "bas_string.h"
/*
* Lexical definitions.
@@ -71,35 +72,6 @@ static void xputchar(int c)
);
}
#define isdigit(c) (((c) >= '0') && ((c) <= '9'))
#define isupper(c) ((c) >= 'A' && ((c) <= 'Z'))
#define islower(c) ((c) >= 'a' && ((c) <= 'z'))
#define isalpha(c) (isupper((c)) || islower(c))
#define tolower(c) (isupper(c) ? ((c) + 'a' - 'A') : (c))
static int atoi(const char *c)
{
int value = 0;
while (isdigit(*c))
{
value *= 10;
value += (int) (*c - '0');
c++;
}
return value;
}
size_t strlen(const char *s)
{
int length = 0;
while (*s++)
{
length++;
}
return length;
}
static void doprnt(void (*addchar)(int), const char *sfmt, va_list ap)
{
char buf[128]; /* FIXME: this gets allocated in BSS which is not reachable in -mpcrel code */