diff --git a/qse/include/qse/cmn/str.h b/qse/include/qse/cmn/str.h index a0858b2c..7eadc733 100644 --- a/qse/include/qse/cmn/str.h +++ b/qse/include/qse/cmn/str.h @@ -1,5 +1,5 @@ /* - * $Id: str.h 425 2011-04-03 14:57:23Z hyunghwan.chung $ + * $Id: str.h 427 2011-04-07 06:46:25Z hyunghwan.chung $ * Copyright 2006-2009 Chung, Hyung-Hwan. This file is part of QSE. @@ -1347,44 +1347,99 @@ qse_size_t qse_wcsupr ( #endif /** - * The qse_strspl() function splits a string into fields. + * The qse_mbsspl() function splits a string into fields. */ -int qse_strspl ( - qse_char_t* str, - const qse_char_t* delim, - qse_char_t lquote, - qse_char_t rquote, - qse_char_t escape +int qse_mbsspl ( + qse_mchar_t* str, + const qse_mchar_t* delim, + qse_mchar_t lquote, + qse_mchar_t rquote, + qse_mchar_t escape ); /** - * The qse_strspltrn() function splits a string translating special + * The qse_wcsspl() function splits a string into fields. + */ +int qse_wcsspl ( + qse_wchar_t* str, + const qse_wchar_t* delim, + qse_wchar_t lquote, + qse_wchar_t rquote, + qse_wchar_t escape +); + +/** + * The qse_mbsspltrn() function splits a string translating special * escape sequences. * The argument @a trset is a translation character set which is composed * of multiple character pairs. An escape character followed by the * first character in a pair is translated into the second character - * in the pair. If trset is QSE_NULL, no translation is performed. + * in the pair. If trset is #QSE_NULL, no translation is performed. * * Let's translate a sequence of '\n' and '\r' to a new line and a carriage * return respectively. * @code - * qse_strspltrn (str, QSE_T(':'), QSE_T('['), QSE_T(']'), QSE_T('\\'), QSE_T("n\nr\r"), &nfields); + * nfields = qse_mbsspltrn ( + * str, QSE_MT(':'), QSE_MT('['), QSE_MT(']'), + * QSE_MT('\\'), QSE_MT("n\nr\r") + * ); * @endcode * Given [xxx]:[\rabc\ndef]:[] as an input, the example breaks the second * fields to abcdef where is a carriage return and is a * new line. * - * If you don't need any translation, you may call qse_strspl() alternatively. + * If you don't need translation, you may call qse_mbsspl() instead. + * @return number of resulting fields on success, -1 on failure */ -int qse_strspltrn ( - qse_char_t* str, - const qse_char_t* delim, - qse_char_t lquote, - qse_char_t rquote, - qse_char_t escape, - const qse_char_t* trset +int qse_mbsspltrn ( + qse_mchar_t* str, + const qse_mchar_t* delim, + qse_mchar_t lquote, + qse_mchar_t rquote, + qse_mchar_t escape, + const qse_mchar_t* trset ); +/** + * The qse_wcsspltrn() function splits a string translating special + * escape sequences. + * The argument @a trset is a translation character set which is composed + * of multiple character pairs. An escape character followed by the + * first character in a pair is translated into the second character + * in the pair. If trset is #QSE_NULL, no translation is performed. + * + * Let's translate a sequence of '\n' and '\r' to a new line and a carriage + * return respectively. + * @code + * nfields = qse_wcsspltrn ( + * str, QSE_WT(':'), QSE_WT('['), QSE_WT(']'), + * QSE_WT('\\'), QSE_WT("n\nr\r") + * ); + * @endcode + * Given [xxx]:[\rabc\ndef]:[] as an input, the example breaks the second + * fields to abcdef where is a carriage return and is a + * new line. + * + * If you don't need translation, you may call qse_wcsspl() instead. + * @return number of resulting fields on success, -1 on failure + */ +int qse_wcsspltrn ( + qse_wchar_t* str, + const qse_wchar_t* delim, + qse_wchar_t lquote, + qse_wchar_t rquote, + qse_wchar_t escape, + const qse_wchar_t* trset +); + +#ifdef QSE_CHAR_IS_MCHAR +# define qse_strspl(str,delim,lquote,rquote,escape) qse_mbsspl(str,delim,lquote,rquote,escape) +# define qse_strspltrn(str,delim,lquote,rquote,escape,trset) qse_mbsspltrn(str,delim,lquote,rquote,escape,trset) +#else +# define qse_strspl(str,delim,lquote,rquote,escape) qse_wcsspl(str,delim,lquote,rquote,escape) +# define qse_strspltrn(str,delim,lquote,rquote,escape,trset) qse_wcsspltrn(str,delim,lquote,rquote,escape,trset) +#endif + /** * The qse_strtrmx() function strips leading spaces and/or trailing * spaces off a string depending on the opt parameter. You can form diff --git a/qse/lib/cmn/Makefile.am b/qse/lib/cmn/Makefile.am index f93138e8..b64aab80 100644 --- a/qse/lib/cmn/Makefile.am +++ b/qse/lib/cmn/Makefile.am @@ -10,8 +10,8 @@ libqsecmn_la_SOURCES = \ syscall.h mem.h \ mem.c xma.c fma.c chr.c chr_cnv.c rex.c \ str_bas.c str_cat.c str_chr.c str_cnv.c str_cmp.c str_cpy.c str_dup.c \ - str_dyn.c str_fcpy.c str_len.c str_pbrk.c str_put.c str_spn.c str_str.c \ - str_subst.c str_utl.c str_word.c \ + str_dyn.c str_fcpy.c str_len.c str_pbrk.c str_put.c str_spl.c \ + str_spn.c str_str.c str_subst.c str_utl.c str_word.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 175072da..7e3cc3ed 100644 --- a/qse/lib/cmn/Makefile.in +++ b/qse/lib/cmn/Makefile.in @@ -75,7 +75,7 @@ libqsecmn_la_DEPENDENCIES = am_libqsecmn_la_OBJECTS = mem.lo xma.lo fma.lo chr.lo chr_cnv.lo \ rex.lo str_bas.lo str_cat.lo str_chr.lo str_cnv.lo str_cmp.lo \ str_cpy.lo str_dup.lo str_dyn.lo str_fcpy.lo str_len.lo \ - str_pbrk.lo str_put.lo str_spn.lo str_str.lo str_subst.lo \ + str_pbrk.lo str_put.lo str_spl.lo str_spn.lo str_str.lo str_subst.lo \ str_utl.lo str_word.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 \ @@ -268,8 +268,8 @@ libqsecmn_la_SOURCES = \ syscall.h mem.h \ mem.c xma.c fma.c chr.c chr_cnv.c rex.c \ str_bas.c str_cat.c str_chr.c str_cnv.c str_cmp.c str_cpy.c str_dup.c \ - str_dyn.c str_fcpy.c str_len.c str_pbrk.c str_put.c str_spn.c str_str.c \ - str_subst.c str_utl.c str_word.c \ + str_dyn.c str_fcpy.c str_len.c str_pbrk.c str_put.c str_spl.c \ + str_spn.c str_str.c str_subst.c str_utl.c str_word.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 \ @@ -399,6 +399,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str_len.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str_pbrk.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str_put.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str_spl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str_spn.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str_str.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str_subst.Plo@am__quote@ diff --git a/qse/lib/cmn/str_spl.c b/qse/lib/cmn/str_spl.c new file mode 100644 index 00000000..ed52e6ef --- /dev/null +++ b/qse/lib/cmn/str_spl.c @@ -0,0 +1,594 @@ +/* + * $Id$ + * + Copyright 2006-2009 Chung, Hyung-Hwan. + This file is part of QSE. + + QSE is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation, either version 3 of + the License, or (at your option) any later version. + + QSE is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + 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 + License along with QSE. If not, see . + */ + +#include +#include + +int qse_mbsspltrn ( + qse_mchar_t* s, const qse_mchar_t* delim, + qse_mchar_t lquote, qse_mchar_t rquote, + qse_mchar_t escape, const qse_mchar_t* trset) +{ + qse_mchar_t* p = s, *d; + qse_mchar_t* sp = QSE_NULL, * ep = QSE_NULL; + int delim_mode; + int cnt = 0; + + if (delim == QSE_NULL) delim_mode = 0; + else + { + delim_mode = 1; + for (d = (qse_mchar_t*)delim; *d != QSE_MT('\0'); d++) + if (!QSE_ISMSPACE(*d)) delim_mode = 2; + } + + if (delim_mode == 0) + { + /* skip preceding space characters */ + while (QSE_ISMSPACE(*p)) p++; + + /* when 0 is given as "delim", it has an effect of cutting + preceding and trailing space characters off "s". */ + if (lquote != QSE_MT('\0') && *p == lquote) + { + qse_mbscpy (p, p + 1); + + for (;;) + { + if (*p == QSE_MT('\0')) return -1; + + if (escape != QSE_MT('\0') && *p == escape) + { + if (trset != QSE_NULL && p[1] != QSE_MT('\0')) + { + const qse_mchar_t* ep = trset; + while (*ep != QSE_MT('\0')) + { + if (p[1] == *ep++) + { + p[1] = *ep; + break; + } + } + } + + qse_mbscpy (p, p + 1); + } + else + { + if (*p == rquote) + { + p++; + break; + } + } + + if (sp == 0) sp = p; + ep = p; + p++; + } + while (QSE_ISMSPACE(*p)) p++; + if (*p != QSE_MT('\0')) return -1; + + if (sp == 0 && ep == 0) s[0] = QSE_MT('\0'); + else + { + ep[1] = QSE_MT('\0'); + if (s != (qse_mchar_t*)sp) qse_mbscpy (s, sp); + cnt++; + } + } + else + { + while (*p) + { + if (!QSE_ISMSPACE(*p)) + { + if (sp == 0) sp = p; + ep = p; + } + p++; + } + + if (sp == 0 && ep == 0) s[0] = QSE_MT('\0'); + else + { + ep[1] = QSE_MT('\0'); + if (s != (qse_mchar_t*)sp) qse_mbscpy (s, sp); + cnt++; + } + } + } + else if (delim_mode == 1) + { + qse_mchar_t* o; + + while (*p) + { + o = p; + while (QSE_ISMSPACE(*p)) p++; + if (o != p) { qse_mbscpy (o, p); p = o; } + + if (lquote != QSE_MT('\0') && *p == lquote) + { + qse_mbscpy (p, p + 1); + + for (;;) + { + if (*p == QSE_MT('\0')) return -1; + + if (escape != QSE_MT('\0') && *p == escape) + { + if (trset != QSE_NULL && p[1] != QSE_MT('\0')) + { + const qse_mchar_t* ep = trset; + while (*ep != QSE_MT('\0')) + { + if (p[1] == *ep++) + { + p[1] = *ep; + break; + } + } + } + qse_mbscpy (p, p + 1); + } + else + { + if (*p == rquote) + { + *p++ = QSE_MT('\0'); + cnt++; + break; + } + } + p++; + } + } + else + { + o = p; + for (;;) + { + if (*p == QSE_MT('\0')) + { + if (o != p) cnt++; + break; + } + if (QSE_ISMSPACE (*p)) + { + *p++ = QSE_MT('\0'); + cnt++; + break; + } + p++; + } + } + } + } + else /* if (delim_mode == 2) */ + { + qse_mchar_t* o; + int ok; + + while (*p != QSE_MT('\0')) + { + o = p; + while (QSE_ISMSPACE(*p)) p++; + if (o != p) { qse_mbscpy (o, p); p = o; } + + if (lquote != QSE_MT('\0') && *p == lquote) + { + qse_mbscpy (p, p + 1); + + for (;;) + { + if (*p == QSE_MT('\0')) return -1; + + if (escape != QSE_MT('\0') && *p == escape) + { + if (trset != QSE_NULL && p[1] != QSE_MT('\0')) + { + const qse_mchar_t* ep = trset; + while (*ep != QSE_MT('\0')) + { + if (p[1] == *ep++) + { + p[1] = *ep; + break; + } + } + } + + qse_mbscpy (p, p + 1); + } + else + { + if (*p == rquote) + { + *p++ = QSE_MT('\0'); + cnt++; + break; + } + } + p++; + } + + ok = 0; + while (QSE_ISMSPACE(*p)) p++; + if (*p == QSE_MT('\0')) ok = 1; + for (d = (qse_mchar_t*)delim; *d != QSE_MT('\0'); d++) + { + if (*p == *d) + { + ok = 1; + qse_mbscpy (p, p + 1); + break; + } + } + if (ok == 0) return -1; + } + else + { + o = p; sp = ep = 0; + + for (;;) + { + if (*p == QSE_MT('\0')) + { + if (ep) + { + ep[1] = QSE_MT('\0'); + p = &ep[1]; + } + cnt++; + break; + } + for (d = (qse_mchar_t*)delim; *d != QSE_MT('\0'); d++) + { + if (*p == *d) + { + if (sp == QSE_NULL) + { + qse_mbscpy (o, p); p = o; + *p++ = QSE_MT('\0'); + } + else + { + qse_mbscpy (&ep[1], p); + qse_mbscpy (o, sp); + o[ep - sp + 1] = QSE_MT('\0'); + p = &o[ep - sp + 2]; + } + cnt++; + /* last empty field after delim */ + if (*p == QSE_MT('\0')) cnt++; + goto exit_point; + } + } + + if (!QSE_ISMSPACE (*p)) + { + if (sp == QSE_NULL) sp = p; + ep = p; + } + p++; + } +exit_point: + ; + } + } + } + + return cnt; +} + +int qse_mbsspl ( + qse_mchar_t* s, const qse_mchar_t* delim, + qse_mchar_t lquote, qse_mchar_t rquote, qse_mchar_t escape) +{ + return qse_mbsspltrn (s, delim, lquote, rquote, escape, QSE_NULL); +} + +int qse_wcsspltrn ( + qse_wchar_t* s, const qse_wchar_t* delim, + qse_wchar_t lquote, qse_wchar_t rquote, + qse_wchar_t escape, const qse_wchar_t* trset) +{ + qse_wchar_t* p = s, *d; + qse_wchar_t* sp = QSE_NULL, * ep = QSE_NULL; + int delim_mode; + int cnt = 0; + + if (delim == QSE_NULL) delim_mode = 0; + else + { + delim_mode = 1; + for (d = (qse_wchar_t*)delim; *d != QSE_WT('\0'); d++) + if (!QSE_ISWSPACE(*d)) delim_mode = 2; + } + + if (delim_mode == 0) + { + /* skip preceding space characters */ + while (QSE_ISWSPACE(*p)) p++; + + /* when 0 is given as "delim", it has an effect of cutting + preceding and trailing space characters off "s". */ + if (lquote != QSE_WT('\0') && *p == lquote) + { + qse_wcscpy (p, p + 1); + + for (;;) + { + if (*p == QSE_WT('\0')) return -1; + + if (escape != QSE_WT('\0') && *p == escape) + { + if (trset != QSE_NULL && p[1] != QSE_WT('\0')) + { + const qse_wchar_t* ep = trset; + while (*ep != QSE_WT('\0')) + { + if (p[1] == *ep++) + { + p[1] = *ep; + break; + } + } + } + + qse_wcscpy (p, p + 1); + } + else + { + if (*p == rquote) + { + p++; + break; + } + } + + if (sp == 0) sp = p; + ep = p; + p++; + } + while (QSE_ISWSPACE(*p)) p++; + if (*p != QSE_WT('\0')) return -1; + + if (sp == 0 && ep == 0) s[0] = QSE_WT('\0'); + else + { + ep[1] = QSE_WT('\0'); + if (s != (qse_wchar_t*)sp) qse_wcscpy (s, sp); + cnt++; + } + } + else + { + while (*p) + { + if (!QSE_ISWSPACE(*p)) + { + if (sp == 0) sp = p; + ep = p; + } + p++; + } + + if (sp == 0 && ep == 0) s[0] = QSE_WT('\0'); + else + { + ep[1] = QSE_WT('\0'); + if (s != (qse_wchar_t*)sp) qse_wcscpy (s, sp); + cnt++; + } + } + } + else if (delim_mode == 1) + { + qse_wchar_t* o; + + while (*p) + { + o = p; + while (QSE_ISWSPACE(*p)) p++; + if (o != p) { qse_wcscpy (o, p); p = o; } + + if (lquote != QSE_WT('\0') && *p == lquote) + { + qse_wcscpy (p, p + 1); + + for (;;) + { + if (*p == QSE_WT('\0')) return -1; + + if (escape != QSE_WT('\0') && *p == escape) + { + if (trset != QSE_NULL && p[1] != QSE_WT('\0')) + { + const qse_wchar_t* ep = trset; + while (*ep != QSE_WT('\0')) + { + if (p[1] == *ep++) + { + p[1] = *ep; + break; + } + } + } + qse_wcscpy (p, p + 1); + } + else + { + if (*p == rquote) + { + *p++ = QSE_WT('\0'); + cnt++; + break; + } + } + p++; + } + } + else + { + o = p; + for (;;) + { + if (*p == QSE_WT('\0')) + { + if (o != p) cnt++; + break; + } + if (QSE_ISWSPACE (*p)) + { + *p++ = QSE_WT('\0'); + cnt++; + break; + } + p++; + } + } + } + } + else /* if (delim_mode == 2) */ + { + qse_wchar_t* o; + int ok; + + while (*p != QSE_WT('\0')) + { + o = p; + while (QSE_ISWSPACE(*p)) p++; + if (o != p) { qse_wcscpy (o, p); p = o; } + + if (lquote != QSE_WT('\0') && *p == lquote) + { + qse_wcscpy (p, p + 1); + + for (;;) + { + if (*p == QSE_WT('\0')) return -1; + + if (escape != QSE_WT('\0') && *p == escape) + { + if (trset != QSE_NULL && p[1] != QSE_WT('\0')) + { + const qse_wchar_t* ep = trset; + while (*ep != QSE_WT('\0')) + { + if (p[1] == *ep++) + { + p[1] = *ep; + break; + } + } + } + + qse_wcscpy (p, p + 1); + } + else + { + if (*p == rquote) + { + *p++ = QSE_WT('\0'); + cnt++; + break; + } + } + p++; + } + + ok = 0; + while (QSE_ISWSPACE(*p)) p++; + if (*p == QSE_WT('\0')) ok = 1; + for (d = (qse_wchar_t*)delim; *d != QSE_WT('\0'); d++) + { + if (*p == *d) + { + ok = 1; + qse_wcscpy (p, p + 1); + break; + } + } + if (ok == 0) return -1; + } + else + { + o = p; sp = ep = 0; + + for (;;) + { + if (*p == QSE_WT('\0')) + { + if (ep) + { + ep[1] = QSE_WT('\0'); + p = &ep[1]; + } + cnt++; + break; + } + for (d = (qse_wchar_t*)delim; *d != QSE_WT('\0'); d++) + { + if (*p == *d) + { + if (sp == QSE_NULL) + { + qse_wcscpy (o, p); p = o; + *p++ = QSE_WT('\0'); + } + else + { + qse_wcscpy (&ep[1], p); + qse_wcscpy (o, sp); + o[ep - sp + 1] = QSE_WT('\0'); + p = &o[ep - sp + 2]; + } + cnt++; + /* last empty field after delim */ + if (*p == QSE_WT('\0')) cnt++; + goto exit_point; + } + } + + if (!QSE_ISWSPACE (*p)) + { + if (sp == QSE_NULL) sp = p; + ep = p; + } + p++; + } +exit_point: + ; + } + } + } + + return cnt; +} + +int qse_wcsspl ( + qse_wchar_t* s, const qse_wchar_t* delim, + qse_wchar_t lquote, qse_wchar_t rquote, qse_wchar_t escape) +{ + return qse_wcsspltrn (s, delim, lquote, rquote, escape, QSE_NULL); +} diff --git a/qse/lib/cmn/str_utl.c b/qse/lib/cmn/str_utl.c index d1a45a25..688892a6 100644 --- a/qse/lib/cmn/str_utl.c +++ b/qse/lib/cmn/str_utl.c @@ -1,5 +1,5 @@ /* - * $Id: str_utl.c 297 2009-10-08 13:09:19Z hyunghwan.chung $ + * $Id: str_utl.c 427 2011-04-07 06:46:25Z hyunghwan.chung $ * Copyright 2006-2009 Chung, Hyung-Hwan. This file is part of QSE. @@ -22,296 +22,6 @@ #include #include "mem.h" -#define ISSPACE(c) \ - ((c) == QSE_T(' ') || (c) == QSE_T('\t') || (c) == QSE_T('\n') || \ - (c) == QSE_T('\r') || (c) == QSE_T('\v') && (c) == QSE_T('\f')) - -int qse_strspltrn ( - qse_char_t* s, const qse_char_t* delim, - qse_char_t lquote, qse_char_t rquote, - qse_char_t escape, const qse_char_t* trset) -{ - qse_char_t* p = s, *d; - qse_char_t* sp = QSE_NULL, * ep = QSE_NULL; - int delim_mode; - int cnt = 0; - - if (delim == QSE_NULL) delim_mode = 0; - else - { - delim_mode = 1; - for (d = (qse_char_t*)delim; *d != QSE_T('\0'); d++) - if (!QSE_ISSPACE(*d)) delim_mode = 2; - } - - if (delim_mode == 0) - { - /* skip preceding space characters */ - while (QSE_ISSPACE(*p)) p++; - - /* when 0 is given as "delim", it has an effect of cutting - preceding and trailing space characters off "s". */ - if (lquote != QSE_T('\0') && *p == lquote) - { - qse_strcpy (p, p + 1); - - for (;;) - { - if (*p == QSE_T('\0')) return -1; - - if (escape != QSE_T('\0') && *p == escape) - { - if (trset != QSE_NULL && p[1] != QSE_T('\0')) - { - const qse_char_t* ep = trset; - while (*ep != QSE_T('\0')) - { - if (p[1] == *ep++) - { - p[1] = *ep; - break; - } - } - } - - qse_strcpy (p, p + 1); - } - else - { - if (*p == rquote) - { - p++; - break; - } - } - - if (sp == 0) sp = p; - ep = p; - p++; - } - while (QSE_ISSPACE(*p)) p++; - if (*p != QSE_T('\0')) return -1; - - if (sp == 0 && ep == 0) s[0] = QSE_T('\0'); - else - { - ep[1] = QSE_T('\0'); - if (s != (qse_char_t*)sp) qse_strcpy (s, sp); - cnt++; - } - } - else - { - while (*p) - { - if (!QSE_ISSPACE(*p)) - { - if (sp == 0) sp = p; - ep = p; - } - p++; - } - - if (sp == 0 && ep == 0) s[0] = QSE_T('\0'); - else - { - ep[1] = QSE_T('\0'); - if (s != (qse_char_t*)sp) qse_strcpy (s, sp); - cnt++; - } - } - } - else if (delim_mode == 1) - { - qse_char_t* o; - - while (*p) - { - o = p; - while (QSE_ISSPACE(*p)) p++; - if (o != p) { qse_strcpy (o, p); p = o; } - - if (lquote != QSE_T('\0') && *p == lquote) - { - qse_strcpy (p, p + 1); - - for (;;) - { - if (*p == QSE_T('\0')) return -1; - - if (escape != QSE_T('\0') && *p == escape) - { - if (trset != QSE_NULL && p[1] != QSE_T('\0')) - { - const qse_char_t* ep = trset; - while (*ep != QSE_T('\0')) - { - if (p[1] == *ep++) - { - p[1] = *ep; - break; - } - } - } - qse_strcpy (p, p + 1); - } - else - { - if (*p == rquote) - { - *p++ = QSE_T('\0'); - cnt++; - break; - } - } - p++; - } - } - else - { - o = p; - for (;;) - { - if (*p == QSE_T('\0')) - { - if (o != p) cnt++; - break; - } - if (QSE_ISSPACE (*p)) - { - *p++ = QSE_T('\0'); - cnt++; - break; - } - p++; - } - } - } - } - else /* if (delim_mode == 2) */ - { - qse_char_t* o; - int ok; - - while (*p != QSE_T('\0')) - { - o = p; - while (QSE_ISSPACE(*p)) p++; - if (o != p) { qse_strcpy (o, p); p = o; } - - if (lquote != QSE_T('\0') && *p == lquote) - { - qse_strcpy (p, p + 1); - - for (;;) - { - if (*p == QSE_T('\0')) return -1; - - if (escape != QSE_T('\0') && *p == escape) - { - if (trset != QSE_NULL && p[1] != QSE_T('\0')) - { - const qse_char_t* ep = trset; - while (*ep != QSE_T('\0')) - { - if (p[1] == *ep++) - { - p[1] = *ep; - break; - } - } - } - - qse_strcpy (p, p + 1); - } - else - { - if (*p == rquote) - { - *p++ = QSE_T('\0'); - cnt++; - break; - } - } - p++; - } - - ok = 0; - while (QSE_ISSPACE(*p)) p++; - if (*p == QSE_T('\0')) ok = 1; - for (d = (qse_char_t*)delim; *d != QSE_T('\0'); d++) - { - if (*p == *d) - { - ok = 1; - qse_strcpy (p, p + 1); - break; - } - } - if (ok == 0) return -1; - } - else - { - o = p; sp = ep = 0; - - for (;;) - { - if (*p == QSE_T('\0')) - { - if (ep) - { - ep[1] = QSE_T('\0'); - p = &ep[1]; - } - cnt++; - break; - } - for (d = (qse_char_t*)delim; *d != QSE_T('\0'); d++) - { - if (*p == *d) - { - if (sp == QSE_NULL) - { - qse_strcpy (o, p); p = o; - *p++ = QSE_T('\0'); - } - else - { - qse_strcpy (&ep[1], p); - qse_strcpy (o, sp); - o[ep - sp + 1] = QSE_T('\0'); - p = &o[ep - sp + 2]; - } - cnt++; - /* last empty field after delim */ - if (*p == QSE_T('\0')) cnt++; - goto exit_point; - } - } - - if (!QSE_ISSPACE (*p)) - { - if (sp == QSE_NULL) sp = p; - ep = p; - } - p++; - } -exit_point: - ; - } - } - } - - return cnt; -} - -int qse_strspl ( - qse_char_t* s, const qse_char_t* delim, - qse_char_t lquote, qse_char_t rquote, qse_char_t escape) -{ - return qse_strspltrn (s, delim, lquote, rquote, escape, QSE_NULL); -} - qse_char_t* qse_strtrmx (qse_char_t* str, int opt) { qse_char_t* p = str; diff --git a/qse/watcom/debug/os2/lib/cmn/qsecmn.tgt b/qse/watcom/debug/os2/lib/cmn/qsecmn.tgt index 3fc355fa..27efd417 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 -48 +49 11 MItem 3 @@ -692,7 +692,7 @@ WVList 155 MItem 32 -..\..\..\..\..\lib\cmn\str_spn.c +..\..\..\..\..\lib\cmn\str_spl.c 156 WString 4 @@ -710,7 +710,7 @@ WVList 159 MItem 32 -..\..\..\..\..\lib\cmn\str_str.c +..\..\..\..\..\lib\cmn\str_spn.c 160 WString 4 @@ -727,8 +727,8 @@ WVList 0 163 MItem -34 -..\..\..\..\..\lib\cmn\str_subst.c +32 +..\..\..\..\..\lib\cmn\str_str.c 164 WString 4 @@ -745,8 +745,8 @@ WVList 0 167 MItem -32 -..\..\..\..\..\lib\cmn\str_utl.c +34 +..\..\..\..\..\lib\cmn\str_subst.c 168 WString 4 @@ -763,8 +763,8 @@ WVList 0 171 MItem -33 -..\..\..\..\..\lib\cmn\str_word.c +32 +..\..\..\..\..\lib\cmn\str_utl.c 172 WString 4 @@ -781,8 +781,8 @@ WVList 0 175 MItem -29 -..\..\..\..\..\lib\cmn\time.c +33 +..\..\..\..\..\lib\cmn\str_word.c 176 WString 4 @@ -799,8 +799,8 @@ WVList 0 179 MItem -28 -..\..\..\..\..\lib\cmn\tio.c +29 +..\..\..\..\..\lib\cmn\time.c 180 WString 4 @@ -817,8 +817,8 @@ WVList 0 183 MItem -32 -..\..\..\..\..\lib\cmn\tio_get.c +28 +..\..\..\..\..\lib\cmn\tio.c 184 WString 4 @@ -836,7 +836,7 @@ WVList 187 MItem 32 -..\..\..\..\..\lib\cmn\tio_put.c +..\..\..\..\..\lib\cmn\tio_get.c 188 WString 4 @@ -853,8 +853,8 @@ WVList 0 191 MItem -28 -..\..\..\..\..\lib\cmn\xma.c +32 +..\..\..\..\..\lib\cmn\tio_put.c 192 WString 4 @@ -871,26 +871,26 @@ WVList 0 195 MItem -3 -*.h +28 +..\..\..\..\..\lib\cmn\xma.c 196 WString -3 -NIL +4 +COBJ 197 WVList 0 198 WVList 0 --1 +11 1 1 0 199 MItem -28 -..\..\..\..\..\lib\cmn\mem.h +3 +*.h 200 WString 3 @@ -901,14 +901,14 @@ WVList 202 WVList 0 -195 +-1 1 1 0 203 MItem -32 -..\..\..\..\..\lib\cmn\syscall.h +28 +..\..\..\..\..\lib\cmn\mem.h 204 WString 3 @@ -919,7 +919,25 @@ WVList 206 WVList 0 -195 +199 +1 +1 +0 +207 +MItem +32 +..\..\..\..\..\lib\cmn\syscall.h +208 +WString +3 +NIL +209 +WVList +0 +210 +WVList +0 +199 1 1 0 diff --git a/qse/watcom/debug/win32/lib/cmn/qsecmn.tgt b/qse/watcom/debug/win32/lib/cmn/qsecmn.tgt index e8be2176..6625c3aa 100755 --- a/qse/watcom/debug/win32/lib/cmn/qsecmn.tgt +++ b/qse/watcom/debug/win32/lib/cmn/qsecmn.tgt @@ -42,7 +42,7 @@ WVList 0 10 WPickList -48 +49 11 MItem 3 @@ -692,7 +692,7 @@ WVList 155 MItem 32 -..\..\..\..\..\lib\cmn\str_spn.c +..\..\..\..\..\lib\cmn\str_spl.c 156 WString 4 @@ -710,7 +710,7 @@ WVList 159 MItem 32 -..\..\..\..\..\lib\cmn\str_str.c +..\..\..\..\..\lib\cmn\str_spn.c 160 WString 4 @@ -727,8 +727,8 @@ WVList 0 163 MItem -34 -..\..\..\..\..\lib\cmn\str_subst.c +32 +..\..\..\..\..\lib\cmn\str_str.c 164 WString 4 @@ -745,8 +745,8 @@ WVList 0 167 MItem -32 -..\..\..\..\..\lib\cmn\str_utl.c +34 +..\..\..\..\..\lib\cmn\str_subst.c 168 WString 4 @@ -763,8 +763,8 @@ WVList 0 171 MItem -33 -..\..\..\..\..\lib\cmn\str_word.c +32 +..\..\..\..\..\lib\cmn\str_utl.c 172 WString 4 @@ -781,8 +781,8 @@ WVList 0 175 MItem -29 -..\..\..\..\..\lib\cmn\time.c +33 +..\..\..\..\..\lib\cmn\str_word.c 176 WString 4 @@ -799,8 +799,8 @@ WVList 0 179 MItem -28 -..\..\..\..\..\lib\cmn\tio.c +29 +..\..\..\..\..\lib\cmn\time.c 180 WString 4 @@ -817,8 +817,8 @@ WVList 0 183 MItem -32 -..\..\..\..\..\lib\cmn\tio_get.c +28 +..\..\..\..\..\lib\cmn\tio.c 184 WString 4 @@ -836,7 +836,7 @@ WVList 187 MItem 32 -..\..\..\..\..\lib\cmn\tio_put.c +..\..\..\..\..\lib\cmn\tio_get.c 188 WString 4 @@ -853,8 +853,8 @@ WVList 0 191 MItem -28 -..\..\..\..\..\lib\cmn\xma.c +32 +..\..\..\..\..\lib\cmn\tio_put.c 192 WString 4 @@ -871,26 +871,26 @@ WVList 0 195 MItem -3 -*.h +28 +..\..\..\..\..\lib\cmn\xma.c 196 WString -3 -NIL +4 +COBJ 197 WVList 0 198 WVList 0 --1 +11 1 1 0 199 MItem -28 -..\..\..\..\..\lib\cmn\mem.h +3 +*.h 200 WString 3 @@ -901,14 +901,14 @@ WVList 202 WVList 0 -195 +-1 1 1 0 203 MItem -32 -..\..\..\..\..\lib\cmn\syscall.h +28 +..\..\..\..\..\lib\cmn\mem.h 204 WString 3 @@ -919,7 +919,25 @@ WVList 206 WVList 0 -195 +199 +1 +1 +0 +207 +MItem +32 +..\..\..\..\..\lib\cmn\syscall.h +208 +WString +3 +NIL +209 +WVList +0 +210 +WVList +0 +199 1 1 0 diff --git a/qse/watcom/qse.wpj b/qse/watcom/qse.wpj index acb6d939..b3e7d870 100755 --- a/qse/watcom/qse.wpj +++ b/qse/watcom/qse.wpj @@ -72,7 +72,7 @@ WRect 3160 5700 4240 -1 +0 0 19 WFileName @@ -143,7 +143,7 @@ WFileName 28 debug/os2/lib/cmn/qsecmn.tgt 31 -32 +35 32 VComponent 33 @@ -207,7 +207,7 @@ WFileName 30 debug/win32/lib/cmn/qsecmn.tgt 18 -22 +26 44 VComponent 45 diff --git a/qse/watcom/release/os2/lib/cmn/qsecmn.tgt b/qse/watcom/release/os2/lib/cmn/qsecmn.tgt index 84379fc2..e0534412 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 -48 +49 11 MItem 3 @@ -756,7 +756,7 @@ WVList 171 MItem 32 -..\..\..\..\..\lib\cmn\str_spn.c +..\..\..\..\..\lib\cmn\str_spl.c 172 WString 4 @@ -774,7 +774,7 @@ WVList 175 MItem 32 -..\..\..\..\..\lib\cmn\str_str.c +..\..\..\..\..\lib\cmn\str_spn.c 176 WString 4 @@ -791,8 +791,8 @@ WVList 0 179 MItem -34 -..\..\..\..\..\lib\cmn\str_subst.c +32 +..\..\..\..\..\lib\cmn\str_str.c 180 WString 4 @@ -809,48 +809,48 @@ WVList 0 183 MItem -32 -..\..\..\..\..\lib\cmn\str_utl.c +34 +..\..\..\..\..\lib\cmn\str_subst.c 184 WString 4 COBJ 185 WVList -1 -186 -MVState -187 -WString -3 -WCC -188 -WString -25 -o?2??Include directories: -1 -189 -WString -54 -"$(%watcom)/h;$(%watcom)/h/os2;..\..\..\..\..\include" 0 -190 +186 WVList 0 11 1 1 0 -191 +187 MItem -33 -..\..\..\..\..\lib\cmn\str_word.c -192 +32 +..\..\..\..\..\lib\cmn\str_utl.c +188 WString 4 COBJ -193 +189 WVList +1 +190 +MVState +191 +WString +3 +WCC +192 +WString +25 +o?2??Include directories: +1 +193 +WString +54 +"$(%watcom)/h;$(%watcom)/h/os2;..\..\..\..\..\include" 0 194 WVList @@ -861,8 +861,8 @@ WVList 0 195 MItem -29 -..\..\..\..\..\lib\cmn\time.c +33 +..\..\..\..\..\lib\cmn\str_word.c 196 WString 4 @@ -879,8 +879,8 @@ WVList 0 199 MItem -28 -..\..\..\..\..\lib\cmn\tio.c +29 +..\..\..\..\..\lib\cmn\time.c 200 WString 4 @@ -897,8 +897,8 @@ WVList 0 203 MItem -32 -..\..\..\..\..\lib\cmn\tio_get.c +28 +..\..\..\..\..\lib\cmn\tio.c 204 WString 4 @@ -916,7 +916,7 @@ WVList 207 MItem 32 -..\..\..\..\..\lib\cmn\tio_put.c +..\..\..\..\..\lib\cmn\tio_get.c 208 WString 4 @@ -933,8 +933,8 @@ WVList 0 211 MItem -28 -..\..\..\..\..\lib\cmn\xma.c +32 +..\..\..\..\..\lib\cmn\tio_put.c 212 WString 4 @@ -951,26 +951,26 @@ WVList 0 215 MItem -3 -*.h +28 +..\..\..\..\..\lib\cmn\xma.c 216 WString -3 -NIL +4 +COBJ 217 WVList 0 218 WVList 0 --1 +11 1 1 0 219 MItem -28 -..\..\..\..\..\lib\cmn\mem.h +3 +*.h 220 WString 3 @@ -981,14 +981,14 @@ WVList 222 WVList 0 -215 +-1 1 1 0 223 MItem -32 -..\..\..\..\..\lib\cmn\syscall.h +28 +..\..\..\..\..\lib\cmn\mem.h 224 WString 3 @@ -999,7 +999,25 @@ WVList 226 WVList 0 -215 +219 +1 +1 +0 +227 +MItem +32 +..\..\..\..\..\lib\cmn\syscall.h +228 +WString +3 +NIL +229 +WVList +0 +230 +WVList +0 +219 1 1 0