+/*
+ * 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 <stdarg.h>
#include <stdint.h>
#include <string.h>
-#include <wctype.h>
static inline char *cstrcat(int n, ...) {
int len = 0; va_list va; va_start(va,n);
}
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;