1 /***************************************************************************
2  *  Copyright 1991, 1992, 1993, 1994, 1995, 1996, 2001, 2002               *
3  *    David R. Hill, Leonard Manzara, Craig Schock                         *
4  *                                                                         *
5  *  This program is free software: you can redistribute it and/or modify   *
6  *  it under the terms of the GNU General Public License as published by   *
7  *  the Free Software Foundation, either version 3 of the License, or      *
8  *  (at your option) any later version.                                    *
9  *                                                                         *
10  *  This program is distributed in the hope that it will be useful,        *
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of         *
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          *
13  *  GNU General Public License for more details.                           *
14  *                                                                         *
15  *  You should have received a copy of the GNU General Public License      *
16  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.  *
17  ***************************************************************************/
18 // 2014-09
19 // This file was copied from Gnuspeech and modified by Marcelo Y. Matuda.
20 
21 #include "en/letter_to_sound/ends_with.h"
22 
23 
24 
25 namespace GS {
26 namespace En {
27 
28 /******************************************************************************
29 *
30 *	function:	ends_with
31 *
32 *	purpose:	Return 0 if word doesn't end with set element, else
33 *                       pointer to char before ending.
34 *
35 *       arguments:      in, end, set
36 *
37 *	internal
38 *	functions:	none
39 *
40 *	library
41 *	functions:	none
42 *
43 ******************************************************************************/
44 const char*
ends_with(const char *,const char * end,const char * set)45 ends_with(const char* /* in */, const char* end, const char* set)
46 {
47 	//TODO: check limits (in)
48 
49 	const char* temp;
50 
51 	while (*set) {
52 		temp = end + 1;
53 		while (*--temp == *set) {
54 			set++;
55 		}
56 		if (*set == '/') {
57 			return temp;
58 		}
59 		while (*set++ != '/');
60 	}
61 	return nullptr;
62 }
63 
64 } /* namespace En */
65 } /* namespace GS */
66