added qse_mbsxword()/qse_wcsxword() and related functions
This commit is contained in:
		| @ -11,7 +11,7 @@ libqsecmn_la_SOURCES = \ | ||||
| 	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_pbrk.c str_put.c str_spn.c str_str.c \ | ||||
| 	str_subst.c str_utl.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 \ | ||||
|  | ||||
| @ -75,10 +75,10 @@ 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_pbrk.lo str_put.lo \ | ||||
| 	str_spn.lo str_str.lo str_subst.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 | ||||
| 	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 assert.lo main.lo stdio.lo | ||||
| libqsecmn_la_OBJECTS = $(am_libqsecmn_la_OBJECTS) | ||||
| libqsecmn_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ | ||||
| 	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ | ||||
| @ -268,7 +268,7 @@ libqsecmn_la_SOURCES = \ | ||||
| 	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_pbrk.c str_put.c str_spn.c str_str.c \ | ||||
| 	str_subst.c str_utl.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 \ | ||||
| @ -401,6 +401,7 @@ distclean-compile: | ||||
| @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str_str.Plo@am__quote@ | ||||
| @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str_subst.Plo@am__quote@ | ||||
| @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str_utl.Plo@am__quote@ | ||||
| @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/str_word.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_get.Plo@am__quote@ | ||||
|  | ||||
							
								
								
									
										114
									
								
								qse/lib/cmn/str_word.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										114
									
								
								qse/lib/cmn/str_word.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,114 @@ | ||||
| /* | ||||
|  * $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 <http://www.gnu.org/licenses/>. | ||||
|  */ | ||||
|  | ||||
| #include <qse/cmn/str.h> | ||||
| #include <qse/cmn/chr.h> | ||||
|  | ||||
| const qse_mchar_t* qse_mbsxword ( | ||||
| 	const qse_mchar_t* str, qse_size_t len, const qse_mchar_t* word) | ||||
| { | ||||
| 	/* find a full word in a string */ | ||||
|  | ||||
| 	const qse_mchar_t* ptr = str; | ||||
| 	const qse_mchar_t* end = str + len; | ||||
| 	const qse_mchar_t* s; | ||||
|  | ||||
| 	do | ||||
| 	{ | ||||
| 		while (ptr < end && QSE_ISMSPACE(*ptr)) ptr++; | ||||
| 		if (ptr >= end) return QSE_NULL; | ||||
|  | ||||
| 		s = ptr; | ||||
| 		while (ptr < end && !QSE_ISMSPACE(*ptr)) ptr++; | ||||
|  | ||||
| 		if (qse_mbsxcmp (s, ptr-s, word) == 0) return s; | ||||
| 	} | ||||
| 	while (ptr < end); | ||||
|  | ||||
| 	return QSE_NULL; | ||||
| } | ||||
|  | ||||
| const qse_mchar_t* qse_mbsxcaseword ( | ||||
| 	const qse_mchar_t* str, qse_size_t len, const qse_mchar_t* word) | ||||
| { | ||||
| 	const qse_mchar_t* ptr = str; | ||||
| 	const qse_mchar_t* end = str + len; | ||||
| 	const qse_mchar_t* s; | ||||
|  | ||||
| 	do | ||||
| 	{ | ||||
| 		while (ptr < end && QSE_ISMSPACE(*ptr)) ptr++; | ||||
| 		if (ptr >= end) return QSE_NULL; | ||||
|  | ||||
| 		s = ptr; | ||||
| 		while (ptr < end && !QSE_ISMSPACE(*ptr)) ptr++; | ||||
|  | ||||
| 		if (qse_mbsxcasecmp (s, ptr-s, word) == 0) return s; | ||||
| 	} | ||||
| 	while (ptr < end); | ||||
|  | ||||
| 	return QSE_NULL; | ||||
| } | ||||
|  | ||||
| const qse_wchar_t* qse_wcsxword ( | ||||
| 	const qse_wchar_t* str, qse_size_t len, const qse_wchar_t* word) | ||||
| { | ||||
| 	/* find a full word in a string */ | ||||
|  | ||||
| 	const qse_wchar_t* ptr = str; | ||||
| 	const qse_wchar_t* end = str + len; | ||||
| 	const qse_wchar_t* s; | ||||
|  | ||||
| 	do | ||||
| 	{ | ||||
| 		while (ptr < end && QSE_ISWSPACE(*ptr)) ptr++; | ||||
| 		if (ptr >= end) return QSE_NULL; | ||||
|  | ||||
| 		s = ptr; | ||||
| 		while (ptr < end && !QSE_ISWSPACE(*ptr)) ptr++; | ||||
|  | ||||
| 		if (qse_wcsxcmp (s, ptr-s, word) == 0) return s; | ||||
| 	} | ||||
| 	while (ptr < end); | ||||
|  | ||||
| 	return QSE_NULL; | ||||
| } | ||||
|  | ||||
| const qse_wchar_t* qse_wcsxcaseword ( | ||||
| 	const qse_wchar_t* str, qse_size_t len, const qse_wchar_t* word) | ||||
| { | ||||
| 	const qse_wchar_t* ptr = str; | ||||
| 	const qse_wchar_t* end = str + len; | ||||
| 	const qse_wchar_t* s; | ||||
|  | ||||
| 	do | ||||
| 	{ | ||||
| 		while (ptr < end && QSE_ISWSPACE(*ptr)) ptr++; | ||||
| 		if (ptr >= end) return QSE_NULL; | ||||
|  | ||||
| 		s = ptr; | ||||
| 		while (ptr < end && !QSE_ISWSPACE(*ptr)) ptr++; | ||||
|  | ||||
| 		if (qse_wcsxcasecmp (s, ptr-s, word) == 0) return s; | ||||
| 	} | ||||
| 	while (ptr < end); | ||||
|  | ||||
| 	return QSE_NULL; | ||||
| } | ||||
		Reference in New Issue
	
	Block a user