X-Git-Url: https://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fguicast%2Fcstrdup.h;h=2ab7b2ab0d5f140d20df673375d8007535cb113d;hb=86950895295c76a58e22d7a770092bf327309437;hp=59227cbe56ecea58ec160a500bc4e82a4a6a3d1c;hpb=7fd85fb66168f6b518c5f2d73e04036e87faa0e1;p=goodguy%2Fcinelerra.git diff --git a/cinelerra-5.1/guicast/cstrdup.h b/cinelerra-5.1/guicast/cstrdup.h index 59227cbe..2ab7b2ab 100644 --- a/cinelerra-5.1/guicast/cstrdup.h +++ b/cinelerra-5.1/guicast/cstrdup.h @@ -1,10 +1,30 @@ +/* + * CINELERRA + * Copyright (C) 2007-2020 William Morrow + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + */ + + #ifndef __CSTRDUP_H__ #define __CSTRDUP_H__ #include #include #include -#include static inline char *cstrcat(int n, ...) { int len = 0; va_list va; va_start(va,n); @@ -58,23 +78,33 @@ static inline int butf8(unsigned int v, char *&cp) } static inline int bstrcasecmp(const char *ap, const char *bp) -{ - int a, b, ret; +{ // not really correct, but what was left after MS port + int ret, a, b; do { - a = towlower(butf8(ap)); b = towlower(butf8(bp)); + if( (a=butf8(ap)) >= 'A' && a <= 'Z' ) a += 'a' - 'A'; + if( (b=butf8(bp)) >= 'A' && b <= 'Z' ) b += 'a' - 'A'; } while( !(ret=a-b) && a && b ); return ret; } static inline const char *bstrcasestr(const char *src, const char *tgt) { - int ssz = strlen(src), tsz = strlen(tgt), ret = 0; + int ssz = strlen(src), tsz = strlen(tgt); const char *cp = tgt; - wchar_t wtgt[tsz + 1], *tp = wtgt; - while( *cp ) *tp++ = towlower(butf8(cp)); + uint32_t wtgt[tsz+1], *tp = wtgt; + while( *cp ) { + int wch = butf8(cp); + if( wch >= 'A' && wch <= 'Z' ) wch += 'a' - 'A'; + *tp++ = wch; + } + *tp = 0; for( tsz=tp-wtgt; ssz>=tsz; ++src,--ssz ) { cp = src; tp = wtgt; - for( int i=tsz; --i>=0 && !(ret=towlower(butf8(cp))-*tp); ++tp ); + int ret = 0, wch = 0; + for( int i=tsz; --i>=0 && !ret && (wch=butf8(cp)); ) { + if( wch >= 'A' && wch <= 'Z' ) wch += 'a' - 'A'; + ret = wch - *tp++; + } if( !ret ) return src; } return 0;