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; 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); 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; 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. Copyright 2006-2009 Chung, Hyung-Hwan.
This file is part of QSE. This file is part of QSE.
@ -31,12 +31,12 @@
/** /**
* The QSE_MMGR_GETDFL() macro returns the default memory manager. * 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. * 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 * 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 */ 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 #ifdef __cplusplus
} }
#endif #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. Copyright 2006-2009 Chung, Hyung-Hwan.
This file is part of QSE. This file is part of QSE.
@ -625,6 +625,34 @@ qse_char_t* qse_strxnend (
qse_size_t len2 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 * string conversion
*/ */

View File

@ -23,6 +23,13 @@
*/ */
#define QSE_ENDIAN_LITTLE #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__) #if defined(__WATCOMC__)
# define QSE_SIZEOF_CHAR 1 # define QSE_SIZEOF_CHAR 1
# define QSE_SIZEOF_SHORT 2 # define QSE_SIZEOF_SHORT 2
@ -41,18 +48,12 @@
# define QSE_SIZEOF___INT32 4 # define QSE_SIZEOF___INT32 4
# define QSE_SIZEOF___INT64 8 # define QSE_SIZEOF___INT64 8
# define QSE_SIZEOF___INT128 0 # define QSE_SIZEOF___INT128 0
#
# define QSE_SIZEOF_OFF64_T 0
# define QSE_SIZEOF_OFF_T 8
#
# define QSE_CHAR_IS_WCHAR
#else #else
# error Define the size of various data types. # error Define the size of various data types.
#endif #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 = \ libqsecmn_la_SOURCES = \
syscall.h mem.h \ syscall.h mem.h \
mem.c xma.c fma.c chr.c chr_cnv.c rex.c \ 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 \ lda.c oht.c htb.c rbt.c sll.c gdl.c dll.c opt.c \
tio.c tio_get.c tio_put.c \ tio.c tio_get.c tio_put.c \
fio.c pio.c sio.c \ fio.c pio.c sio.c \

View File

@ -73,7 +73,7 @@ am__installdirs = "$(DESTDIR)$(libdir)"
LTLIBRARIES = $(lib_LTLIBRARIES) LTLIBRARIES = $(lib_LTLIBRARIES)
libqsecmn_la_DEPENDENCIES = libqsecmn_la_DEPENDENCIES =
am_libqsecmn_la_OBJECTS = mem.lo xma.lo fma.lo chr.lo chr_cnv.lo \ 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 \ 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 \ 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 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 = \ libqsecmn_la_SOURCES = \
syscall.h mem.h \ syscall.h mem.h \
mem.c xma.c fma.c chr.c chr_cnv.c rex.c \ 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 \ lda.c oht.c htb.c rbt.c sll.c gdl.c dll.c opt.c \
tio.c tio_get.c tio_put.c \ tio.c tio_get.c tio_put.c \
fio.c pio.c sio.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_bas.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str_cnv.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_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)/str_utl.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/time.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@ @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. Copyright 2006-2009 Chung, Hyung-Hwan.
This file is part of QSE. This file is part of QSE.
@ -430,7 +430,7 @@ static void mmgr_free (void* data, void* ptr)
free (ptr); free (ptr);
} }
static qse_mmgr_t mmgr = static qse_mmgr_t builtin_mmgr =
{ {
mmgr_alloc, mmgr_alloc,
mmgr_realloc, mmgr_realloc,
@ -438,4 +438,14 @@ static qse_mmgr_t mmgr =
QSE_NULL 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. Copyright 2006-2009 Chung, Hyung-Hwan.
This file is part of QSE. This file is part of QSE.

View File

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

View File

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

View File

@ -42,7 +42,7 @@ WVList
0 0
10 10
WPickList WPickList
35 36
11 11
MItem MItem
3 3
@ -594,47 +594,47 @@ WVList
135 135
MItem MItem
32 32
..\..\..\..\..\lib\cmn\str_utl.c ..\..\..\..\..\lib\cmn\str_spn.c
136 136
WString WString
4 4
COBJ COBJ
137 137
WVList 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 0
142 138
WVList WVList
0 0
11 11
1 1
1 1
0 0
143 139
MItem MItem
29 32
..\..\..\..\..\lib\cmn\time.c ..\..\..\..\..\lib\cmn\str_utl.c
144 140
WString WString
4 4
COBJ COBJ
145 141
WVList 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 0
146 146
WVList WVList
@ -645,8 +645,8 @@ WVList
0 0
147 147
MItem MItem
28 29
..\..\..\..\..\lib\cmn\tio.c ..\..\..\..\..\lib\cmn\time.c
148 148
WString WString
4 4
@ -663,8 +663,8 @@ WVList
0 0
151 151
MItem MItem
32 28
..\..\..\..\..\lib\cmn\tio_get.c ..\..\..\..\..\lib\cmn\tio.c
152 152
WString WString
4 4
@ -682,7 +682,7 @@ WVList
155 155
MItem MItem
32 32
..\..\..\..\..\lib\cmn\tio_put.c ..\..\..\..\..\lib\cmn\tio_get.c
156 156
WString WString
4 4
@ -699,8 +699,8 @@ WVList
0 0
159 159
MItem MItem
28 32
..\..\..\..\..\lib\cmn\xma.c ..\..\..\..\..\lib\cmn\tio_put.c
160 160
WString WString
4 4
@ -717,26 +717,26 @@ WVList
0 0
163 163
MItem MItem
3 28
*.h ..\..\..\..\..\lib\cmn\xma.c
164 164
WString WString
3 4
NIL COBJ
165 165
WVList WVList
0 0
166 166
WVList WVList
0 0
-1 11
1 1
1 1
0 0
167 167
MItem MItem
28 3
..\..\..\..\..\lib\cmn\mem.h *.h
168 168
WString WString
3 3
@ -747,14 +747,14 @@ WVList
170 170
WVList WVList
0 0
163 -1
1 1
1 1
0 0
171 171
MItem MItem
32 28
..\..\..\..\..\lib\cmn\syscall.h ..\..\..\..\..\lib\cmn\mem.h
172 172
WString WString
3 3
@ -765,7 +765,25 @@ WVList
174 174
WVList WVList
0 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
1 1
0 0