string utility

git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@367 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
NishiOwO
2025-10-16 12:04:50 +00:00
parent 6dfb78ec7d
commit 1b98baa677
4 changed files with 53 additions and 1 deletions

View File

@@ -32,7 +32,7 @@ L_CFLAGS = $(DEPINC) $(CFLAGS) -fPIC -D_MILSKO
L_LDFLAGS = $(LDFLAGS)
L_LIBS = $(LIBS)
L_OBJS = src/core.o src/default.o src/draw.o src/lowlevel.o src/font.o src/boldfont.o src/error.o src/unicode.o src/color.o src/messagebox.o src/directory.o
L_OBJS = src/core.o src/default.o src/draw.o src/lowlevel.o src/font.o src/boldfont.o src/error.o src/unicode.o src/color.o src/messagebox.o src/directory.o src/string.o
L_OBJS += external/ds.o external/image.o
L_OBJS += src/widget/window.o src/widget/button.o src/widget/frame.o src/widget/menu.o src/widget/submenu.o src/widget/image.o src/widget/scrollbar.o src/widget/checkbox.o src/widget/label.o src/widget/entry.o src/widget/numberentry.o src/widget/viewport.o src/widget/listbox.o
L_OBJS += src/cursor/default.o src/cursor/cross.o src/cursor/text.o

View File

@@ -21,6 +21,7 @@
#include <Mw/Icon.h>
#include <Mw/MessageBox.h>
#include <Mw/Directory.h>
#include <Mw/String.h>
#include <Mw/Widget/Window.h>
#include <Mw/Widget/Menu.h>

34
include/Mw/String.h Normal file
View File

@@ -0,0 +1,34 @@
/* $Id$ */
/*!
* %file Mw/String.h
* %brief String utilities
*/
#ifndef __MW_STRING_H__
#define __MW_STRING_H__
#include <Mw/MachDep.h>
#ifdef __cplusplus
extern "C" {
#endif
/*!
* %brief Duplicates a string
* %param str String
* %return String
*/
MWDECL char* MwStringDupliacte(const char* str);
/*!
* %brief Concatenates 2 strings
* %param str1 String
* %param str2 String
* %return String
*/
MWDECL char* MwStringConcat(const char* str1, const char* str2);
#ifdef __cplusplus
}
#endif
#endif

17
src/string.c Normal file
View File

@@ -0,0 +1,17 @@
/* $Id$ */
#include <Mw/Milsko.h>
char* MwStringDupliacte(const char* str) {
char* r = malloc(strlen(str) + 1);
strcpy(r, str);
return r;
}
char* MwStringConcat(const char* str1, const char* str2) {
char* r = malloc(strlen(str1) + strlen(str2) + 1);
strcpy(r, str1);
strcat(r, str2);
return r;
}