1
0
Fork 0

stdlib: Add Lth_strlocal and Lth_strdup_str

master
Marrub 2016-10-19 10:00:10 -04:00
parent 93377a9dc7
commit 22421f7eeb
3 changed files with 33 additions and 3 deletions

View File

@ -16,8 +16,13 @@
// Extern Functions ----------------------------------------------------------|
// str
char *Lth_strdup(char const *s);
__str Lth_strdup_str(char const *s);
char *Lth_strdup_str(__str s);
__str Lth_strentdup(char const *s);
__str Lth_strlocal(__str s);
// Print
void Lth_PrintString(char const *s);
#endif//lithos3__Lth_stdlib_h

View File

@ -27,7 +27,7 @@ Lth_Font *Lth_FontNew(char const *name)
Lth_Font *font = calloc(1, sizeof(Lth_Font));
Lth_assert(font != NULL);
font->name = Lth_strdup_str(name);
font->name = Lth_strentdup(name);
return font;
}

View File

@ -36,9 +36,24 @@ char *Lth_strdup(char const *s)
//
// Lth_strdup_str
//
// Duplicates a string entity, allocating a new string.
//
char *Lth_strdup_str(__str s)
{
Lth_assert(s != NULL);
size_t len = ACS_StrLen(s);
char *ret = calloc(len + 1, 1);
Lth_assert(ret != NULL);
for(size_t i = 0; i < len; i++) ret[i] = s[i];
return ret;
}
//
// Lth_strentdup
//
// Duplicates a string into a new string entity.
//
__str Lth_strdup_str(char const *s)
__str Lth_strentdup(char const *s)
{
Lth_assert(s != NULL);
size_t len = strlen(s);
@ -47,6 +62,16 @@ __str Lth_strdup_str(char const *s)
return ACS_EndStrParam();
}
//
// Lth_strlocal
//
__str Lth_strlocal(__str s)
{
ACS_BeginPrint();
ACS_PrintLocalized(s);
return ACS_EndStrParam();
}
//
// Lth_PrintString
//