diff --git a/qse/cmd/scm/scm.c b/qse/cmd/scm/scm.c index c807c9c0..f2d84993 100644 --- a/qse/cmd/scm/scm.c +++ b/qse/cmd/scm/scm.c @@ -223,18 +223,23 @@ int scm_main (int argc, qse_char_t* argv[]) qse_scm_io_t io = { get_input, put_output }; qse_scm_attachio (scm, &io); } - - -{ - int i; - for (i = 0; i<200; i++) + + +{ + int 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; - + qse_printf (QSE_T("QSESCM> ")); x1 = qse_scm_read (scm); if (x1 == QSE_NULL) diff --git a/qse/include/qse/cmn/mem.h b/qse/include/qse/cmn/mem.h index 7e2ba46a..bfe0b3d9 100644 --- a/qse/include/qse/cmn/mem.h +++ b/qse/include/qse/cmn/mem.h @@ -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 diff --git a/qse/include/qse/cmn/str.h b/qse/include/qse/cmn/str.h index 0cf442a5..56c7da80 100644 --- a/qse/include/qse/cmn/str.h +++ b/qse/include/qse/cmn/str.h @@ -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 */ diff --git a/qse/include/qse/conf_os2.h b/qse/include/qse/conf_os2.h index c2c27d32..6f859e7a 100644 --- a/qse/include/qse/conf_os2.h +++ b/qse/include/qse/conf_os2.h @@ -14,14 +14,21 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - You should have received a copy of the GNU Lesser General Public + You should have received a copy of the GNU Lesser General Public License along with QSE. If not, see . */ -/* OS/2 for other platforms than x86? - * If so, the endian should be defined selectively +/* OS/2 for other platforms than x86? + * If so, the endian should be defined selectively + */ +#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 */ -#define QSE_ENDIAN_LITTLE #if defined(__WATCOMC__) # define QSE_SIZEOF_CHAR 1 @@ -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 diff --git a/qse/lib/cmn/Makefile.am b/qse/lib/cmn/Makefile.am index 875f7412..67b0b9d1 100644 --- a/qse/lib/cmn/Makefile.am +++ b/qse/lib/cmn/Makefile.am @@ -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 \ diff --git a/qse/lib/cmn/Makefile.in b/qse/lib/cmn/Makefile.in index 1f822a4e..d43f105e 100644 --- a/qse/lib/cmn/Makefile.in +++ b/qse/lib/cmn/Makefile.in @@ -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@ diff --git a/qse/lib/cmn/mem.c b/qse/lib/cmn/mem.c index ffa12bf1..fbc209ed 100644 --- a/qse/lib/cmn/mem.c +++ b/qse/lib/cmn/mem.c @@ -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); +} diff --git a/qse/lib/cmn/pio.c b/qse/lib/cmn/pio.c index 0bbbcab2..3b734824 100644 --- a/qse/lib/cmn/pio.c +++ b/qse/lib/cmn/pio.c @@ -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. @@ -308,7 +308,7 @@ qse_pio_t* qse_pio_init ( * handle[0] inherited. set the flag not to inherit handle[1]. */ if (DosSetFHState (handle[1], OPEN_FLAGS_NOINHERIT) != NO_ERROR) goto oops; - /* Need to do somthing like this to set the flag instead? + /* Need to do somthing like this to set the flag instead? ULONG state; DosQueryFHState (handle[1], &state); DosSetFHState (handle[1], state | OPEN_FLAGS_NOINHERIT); */ @@ -467,37 +467,37 @@ qse_pio_t* qse_pio_init ( cmd_file = QSE_MT("cmd.exe"); } else - { - qse_mchar_t* mptr; - - #ifdef QSE_CHAR_IS_MCHAR - qse_size_t mn = qse_strlen(cmd); - cmd_line = qse_strdup2 (cmd, QSE_T(" "), pio->mmgr); + { + qse_mchar_t* mptr; + + #ifdef QSE_CHAR_IS_MCHAR + qse_size_t mn = qse_strlen(cmd); + cmd_line = qse_strdup2 (cmd, QSE_T(" "), pio->mmgr); if (cmd_line == QSE_NULL) goto oops; - #else - qse_size_t n, mn; - n = qse_wcstombslen (cmd, &mn); - if (cmd[n] != QSE_T('\0')) goto oops; /* illegal sequence in cmd */ - - mn = mn + 1; - cmd_line = QSE_MMGR_ALLOC (pio->mmgr, mn * QSE_SIZEOF(qse_char_t)); - if (cmd_line == QSE_NULL) goto oops; - + #else + qse_size_t n, mn; + n = qse_wcstombslen (cmd, &mn); + if (cmd[n] != QSE_T('\0')) goto oops; /* illegal sequence in cmd */ + + mn = mn + 1; + cmd_line = QSE_MMGR_ALLOC (pio->mmgr, mn * QSE_SIZEOF(qse_char_t)); + if (cmd_line == QSE_NULL) goto oops; + qse_wcstombs (cmd, cmd_line, &mn); - #endif - - /* TODO: enhance this part by: - * supporting file names containing whitespaces. - * detecting the end of the file name better. - * doing better parsing of the command line. - */ - - /* NOTE: you must separate the command name and the parameters with - * a space. "pstat.exe /c" is ok while "pstat.exe/c" is not. */ - mptr = qse_mbschr (cmd_line, QSE_MT(' ')); - if (mptr) *mptr = QSE_MT('\0'); - cmd_line[mn+1] = QSE_MT('\0'); /* the second '\0' at the end */ - cmd_file = cmd_line; + #endif + + /* TODO: enhance this part by: + * supporting file names containing whitespaces. + * detecting the end of the file name better. + * doing better parsing of the command line. + */ + + /* NOTE: you must separate the command name and the parameters with + * a space. "pstat.exe /c" is ok while "pstat.exe/c" is not. */ + mptr = qse_mbschr (cmd_line, QSE_MT(' ')); + if (mptr) *mptr = QSE_MT('\0'); + cmd_line[mn+1] = QSE_MT('\0'); /* the second '\0' at the end */ + cmd_file = cmd_line; } /* execute the command line */ @@ -697,7 +697,7 @@ qse_pio_t* qse_pio_init ( /* no field or an error */ goto child_oops; } - + /* calculate the length of the string after splitting */ for (wl = 0, n = fcnt; n > 0; ) { @@ -707,8 +707,8 @@ qse_pio_t* qse_pio_init ( n = qse_wcsntombsnlen (wcmd, wl, &mn); if (n != wl) goto child_oops; } - - /* prepare to reserve 1 more slot for the terminating '\0' + + /* prepare to reserve 1 more slot for the terminating '\0' * by incrementing mn by 1. */ mn = mn + 1; diff --git a/qse/watcom/debug/os2/lib/cmn/qsecmn.tgt b/qse/watcom/debug/os2/lib/cmn/qsecmn.tgt index e88b23f5..954b12ef 100755 --- a/qse/watcom/debug/os2/lib/cmn/qsecmn.tgt +++ b/qse/watcom/debug/os2/lib/cmn/qsecmn.tgt @@ -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 diff --git a/qse/watcom/qse.wpj b/qse/watcom/qse.wpj index 9caa9f13..96b863ca 100755 --- a/qse/watcom/qse.wpj +++ b/qse/watcom/qse.wpj @@ -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 diff --git a/qse/watcom/release/os2/lib/cmn/qsecmn.tgt b/qse/watcom/release/os2/lib/cmn/qsecmn.tgt index 20bd7e52..8ecbb688 100755 --- a/qse/watcom/release/os2/lib/cmn/qsecmn.tgt +++ b/qse/watcom/release/os2/lib/cmn/qsecmn.tgt @@ -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