added qse_strspn() and qse_strcspn()

This commit is contained in:
hyung-hwan 2011-03-23 20:21:14 +00:00
parent e29dea930f
commit f83c2c133a
11 changed files with 240 additions and 143 deletions

View File

@ -228,10 +228,15 @@ int scm_main (int argc, qse_char_t* argv[])
{
int i;
for (i = 0; i<200; i++)
for (i = 0; i<2; i++)
pio1 (QSE_T("pstat.exe /c"), QSE_PIO_READOUT|QSE_PIO_WRITEIN|/*QSE_PIO_SHELL|*/QSE_PIO_DROPERR, QSE_PIO_OUT);
}
{
qse_printf (QSE_T("%d\n"), (int)qse_strspn (QSE_T("abcdefg"), QSE_T("cdab")));
qse_printf (QSE_T("%d\n"), (int)qse_strcspn (QSE_T("abcdefg"), QSE_T("fg")));
}
{
qse_scm_ent_t* x1, * x2;

View File

@ -1,5 +1,5 @@
/*
* $Id: mem.h 375 2010-11-30 11:35:28Z hyunghwan.chung $
* $Id: mem.h 407 2011-03-23 02:21:14Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
This file is part of QSE.
@ -31,12 +31,12 @@
/**
* The QSE_MMGR_GETDFL() macro returns the default memory manager.
*/
#define QSE_MMGR_GETDFL() (qse_mmgr)
#define QSE_MMGR_GETDFL() qse_getdflmmgr()
/**
* The QSE_MMGR_SETDFL() macro changes the default memory manager.
*/
#define QSE_MMGR_SETDFL(m) ((qse_mmgr)=(m))
#define QSE_MMGR_SETDFL(m) qse_setdflmmgr(m)
/**
* The QSE_MMGR_ALLOC() macro allocates a memory block of the @a size bytes
@ -187,6 +187,22 @@ void* qse_memrmem (
qse_size_t nl /**< number of bytes in the block */
);
/**
* The qse_getdflmmgr() function returns the default memory manager.
*/
qse_mmgr_t* qse_getdflmmgr (
void
);
/**
* The qse_setdflmmgr() function changes the default memory manager.
* If mmgr is #QSE_NULL, the memory manager is set to the builtin
* default.
*/
void qse_setdflmmgr (
qse_mmgr_t* mmgr
);
#ifdef __cplusplus
}
#endif

View File

@ -1,5 +1,5 @@
/*
* $Id: str.h 406 2011-03-21 14:03:01Z hyunghwan.chung $
* $Id: str.h 407 2011-03-23 02:21:14Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
This file is part of QSE.
@ -625,6 +625,34 @@ qse_char_t* qse_strxnend (
qse_size_t len2
);
qse_size_t qse_mbsspn (
const qse_mchar_t* str1,
const qse_mchar_t* str2
);
qse_size_t qse_wcsspn (
const qse_wchar_t* str1,
const qse_wchar_t* str2
);
qse_size_t qse_mbscspn (
const qse_mchar_t* str1,
const qse_mchar_t* str2
);
qse_size_t qse_wcscspn (
const qse_wchar_t* str1,
const qse_wchar_t* str2
);
#ifdef QSE_CHAR_IS_MCHAR
# define qse_strspn(str1,str2) qse_mbsspn(str1,str2)
# define qse_strcspn(str1,str2) qse_mbscspn(str1,str2)
#else
# define qse_strspn(str1,str2) qse_wcsspn(str1,str2)
# define qse_strcspn(str1,str2) qse_wcscspn(str1,str2)
#endif
/*
* string conversion
*/

View File

@ -23,6 +23,13 @@
*/
#define QSE_ENDIAN_LITTLE
/*
* You must define which character type to use as a default character here.
*
* #define QSE_CHAR_IS_WCHAR
* #define QSE_CHAR_IS_MCHAR
*/
#if defined(__WATCOMC__)
# define QSE_SIZEOF_CHAR 1
# define QSE_SIZEOF_SHORT 2
@ -41,18 +48,12 @@
# define QSE_SIZEOF___INT32 4
# define QSE_SIZEOF___INT64 8
# define QSE_SIZEOF___INT128 0
#
# define QSE_SIZEOF_OFF64_T 0
# define QSE_SIZEOF_OFF_T 8
#
# define QSE_CHAR_IS_WCHAR
#else
# error Define the size of various data types.
#endif
#define QSE_SIZEOF_OFF64_T 0
#define QSE_SIZEOF_OFF_T 8
/*
* OS/2 does not have wchar_t(Unicode) friendly APIs unlike Windows.
* You must define which character type to use as a default character here.
*
* #define QSE_CHAR_IS_WCHAR
* #define QSE_CHAR_IS_MCHAR
*/
#define QSE_CHAR_IS_WCHAR

View File

@ -9,7 +9,7 @@ lib_LTLIBRARIES = libqsecmn.la
libqsecmn_la_SOURCES = \
syscall.h mem.h \
mem.c xma.c fma.c chr.c chr_cnv.c rex.c \
str_bas.c str_cnv.c str_dyn.c str_utl.c \
str_bas.c str_cnv.c str_dyn.c str_spn.c str_utl.c \
lda.c oht.c htb.c rbt.c sll.c gdl.c dll.c opt.c \
tio.c tio_get.c tio_put.c \
fio.c pio.c sio.c \

View File

@ -73,7 +73,7 @@ am__installdirs = "$(DESTDIR)$(libdir)"
LTLIBRARIES = $(lib_LTLIBRARIES)
libqsecmn_la_DEPENDENCIES =
am_libqsecmn_la_OBJECTS = mem.lo xma.lo fma.lo chr.lo chr_cnv.lo \
rex.lo str_bas.lo str_cnv.lo str_dyn.lo str_utl.lo lda.lo \
rex.lo str_bas.lo str_cnv.lo str_dyn.lo str_spn.lo str_utl.lo lda.lo \
oht.lo htb.lo rbt.lo sll.lo gdl.lo dll.lo opt.lo tio.lo \
tio_get.lo tio_put.lo fio.lo pio.lo sio.lo alg_search.lo \
alg_sort.lo time.lo misc.lo assert.lo main.lo stdio.lo
@ -264,7 +264,7 @@ lib_LTLIBRARIES = libqsecmn.la $(am__append_1)
libqsecmn_la_SOURCES = \
syscall.h mem.h \
mem.c xma.c fma.c chr.c chr_cnv.c rex.c \
str_bas.c str_cnv.c str_dyn.c str_utl.c \
str_bas.c str_cnv.c str_dyn.c str_spn.c str_utl.c \
lda.c oht.c htb.c rbt.c sll.c gdl.c dll.c opt.c \
tio.c tio_get.c tio_put.c \
fio.c pio.c sio.c \
@ -385,6 +385,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str_bas.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str_cnv.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str_dyn.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str_spn.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str_utl.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/time.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tio.Plo@am__quote@

View File

@ -1,5 +1,5 @@
/*
* $Id: mem.c 287 2009-09-15 10:01:02Z hyunghwan.chung $
* $Id: mem.c 407 2011-03-23 02:21:14Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
This file is part of QSE.
@ -430,7 +430,7 @@ static void mmgr_free (void* data, void* ptr)
free (ptr);
}
static qse_mmgr_t mmgr =
static qse_mmgr_t builtin_mmgr =
{
mmgr_alloc,
mmgr_realloc,
@ -438,4 +438,14 @@ static qse_mmgr_t mmgr =
QSE_NULL
};
qse_mmgr_t* qse_mmgr = &mmgr;
static qse_mmgr_t* dfl_mmgr = &builtin_mmgr;
qse_mmgr_t* qse_getdflmmgr ()
{
return dfl_mmgr;
}
void qse_setdflmmgr (qse_mmgr_t* mmgr)
{
dfl_mmgr = (mmgr? mmgr: &builtin_mmgr);
}

View File

@ -1,5 +1,5 @@
/*
* $Id: pio.c 405 2011-03-21 14:01:10Z hyunghwan.chung $
* $Id: pio.c 407 2011-03-23 02:21:14Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
This file is part of QSE.

View File

@ -42,7 +42,7 @@ WVList
0
10
WPickList
35
36
11
MItem
3
@ -530,7 +530,7 @@ WVList
119
MItem
32
..\..\..\..\..\lib\cmn\str_utl.c
..\..\..\..\..\lib\cmn\str_spn.c
120
WString
4
@ -547,8 +547,8 @@ WVList
0
123
MItem
29
..\..\..\..\..\lib\cmn\time.c
32
..\..\..\..\..\lib\cmn\str_utl.c
124
WString
4
@ -565,8 +565,8 @@ WVList
0
127
MItem
28
..\..\..\..\..\lib\cmn\tio.c
29
..\..\..\..\..\lib\cmn\time.c
128
WString
4
@ -583,8 +583,8 @@ WVList
0
131
MItem
32
..\..\..\..\..\lib\cmn\tio_get.c
28
..\..\..\..\..\lib\cmn\tio.c
132
WString
4
@ -602,7 +602,7 @@ WVList
135
MItem
32
..\..\..\..\..\lib\cmn\tio_put.c
..\..\..\..\..\lib\cmn\tio_get.c
136
WString
4
@ -619,8 +619,8 @@ WVList
0
139
MItem
28
..\..\..\..\..\lib\cmn\xma.c
32
..\..\..\..\..\lib\cmn\tio_put.c
140
WString
4
@ -637,26 +637,26 @@ WVList
0
143
MItem
3
*.h
28
..\..\..\..\..\lib\cmn\xma.c
144
WString
3
NIL
4
COBJ
145
WVList
0
146
WVList
0
-1
11
1
1
0
147
MItem
28
..\..\..\..\..\lib\cmn\mem.h
3
*.h
148
WString
3
@ -667,14 +667,14 @@ WVList
150
WVList
0
143
-1
1
1
0
151
MItem
32
..\..\..\..\..\lib\cmn\syscall.h
28
..\..\..\..\..\lib\cmn\mem.h
152
WString
3
@ -685,7 +685,25 @@ WVList
154
WVList
0
143
147
1
1
0
155
MItem
32
..\..\..\..\..\lib\cmn\syscall.h
156
WString
3
NIL
157
WVList
0
158
WVList
0
147
1
1
0

View File

@ -4,8 +4,8 @@ projectIdent
VpeMain
1
WRect
610
213
680
400
9320
9120
2
@ -73,7 +73,7 @@ VComponent
18
WRect
90
693
680
5700
4240
1
@ -89,7 +89,7 @@ VComponent
21
WRect
2100
853
840
5700
4240
1
@ -107,7 +107,7 @@ WRect
590
520
5700
4253
4240
1
0
25
@ -121,17 +121,17 @@ VComponent
27
WRect
430
333
320
5700
4253
4240
0
0
28
WFileName
28
debug/os2/lib/cmn/qsecmn.tgt
0
0
19
27
29
VComponent
30
@ -139,7 +139,7 @@ WRect
1050
1800
5700
4253
4240
0
0
31
@ -153,9 +153,9 @@ VComponent
33
WRect
2680
2093
2080
5700
4253
4240
0
0
34
@ -171,7 +171,7 @@ WRect
0
0
5700
4253
4240
0
0
37
@ -180,4 +180,4 @@ WFileName
debug/os2/cmd/scm/qsescm.tgt
0
1
35
26

View File

@ -42,7 +42,7 @@ WVList
0
10
WPickList
35
36
11
MItem
3
@ -594,47 +594,47 @@ WVList
135
MItem
32
..\..\..\..\..\lib\cmn\str_utl.c
..\..\..\..\..\lib\cmn\str_spn.c
136
WString
4
COBJ
137
WVList
1
138
MVState
139
WString
3
WCC
140
WString
25
o?2??Include directories:
1
141
WString
54
"$(%watcom)/h;$(%watcom)/h/os2;..\..\..\..\..\include"
0
142
138
WVList
0
11
1
1
0
143
139
MItem
29
..\..\..\..\..\lib\cmn\time.c
144
32
..\..\..\..\..\lib\cmn\str_utl.c
140
WString
4
COBJ
145
141
WVList
1
142
MVState
143
WString
3
WCC
144
WString
25
o?2??Include directories:
1
145
WString
54
"$(%watcom)/h;$(%watcom)/h/os2;..\..\..\..\..\include"
0
146
WVList
@ -645,8 +645,8 @@ WVList
0
147
MItem
28
..\..\..\..\..\lib\cmn\tio.c
29
..\..\..\..\..\lib\cmn\time.c
148
WString
4
@ -663,8 +663,8 @@ WVList
0
151
MItem
32
..\..\..\..\..\lib\cmn\tio_get.c
28
..\..\..\..\..\lib\cmn\tio.c
152
WString
4
@ -682,7 +682,7 @@ WVList
155
MItem
32
..\..\..\..\..\lib\cmn\tio_put.c
..\..\..\..\..\lib\cmn\tio_get.c
156
WString
4
@ -699,8 +699,8 @@ WVList
0
159
MItem
28
..\..\..\..\..\lib\cmn\xma.c
32
..\..\..\..\..\lib\cmn\tio_put.c
160
WString
4
@ -717,26 +717,26 @@ WVList
0
163
MItem
3
*.h
28
..\..\..\..\..\lib\cmn\xma.c
164
WString
3
NIL
4
COBJ
165
WVList
0
166
WVList
0
-1
11
1
1
0
167
MItem
28
..\..\..\..\..\lib\cmn\mem.h
3
*.h
168
WString
3
@ -747,14 +747,14 @@ WVList
170
WVList
0
163
-1
1
1
0
171
MItem
32
..\..\..\..\..\lib\cmn\syscall.h
28
..\..\..\..\..\lib\cmn\mem.h
172
WString
3
@ -765,7 +765,25 @@ WVList
174
WVList
0
163
167
1
1
0
175
MItem
32
..\..\..\..\..\lib\cmn\syscall.h
176
WString
3
NIL
177
WVList
0
178
WVList
0
167
1
1
0