fix missing stripostfix, and add stricmp (although one should use strcasecmp).

This commit is contained in:
Vítor Manuel de Morais Santos Costa
2009-11-23 13:41:07 +00:00
parent 56d9666197
commit 86715801bf
9 changed files with 2381 additions and 11045 deletions

View File

@@ -52,10 +52,12 @@ C_SOURCES=$(srcdir)/pl-buffer.c $(srcdir)/pl-ctype.c \
$(srcdir)/pl-stream.c $(srcdir)/pl-string.c \
$(srcdir)/pl-table.c \
$(srcdir)/pl-text.c \
$(srcdir)/pl-utils.c \
$(srcdir)/pl-yap.c @ENABLE_WINCONSOLE@ $(srcdir)/popen.c $(srcdir)/uxnt/uxnt.c
OBJS=pl-buffer.o pl-ctype.o pl-error.o pl-feature.o \
pl-file.o pl-files.o pl-os.o pl-privitf.o \
pl-stream.o pl-string.o pl-table.o pl-text.o pl-utf8.o \
pl-stream.o pl-string.o pl-table.o \
pl-text.o pl-utils.o pl-utf8.o \
pl-yap.o @ENABLE_WINCONSOLE@ uxnt.o
SOBJS=plstream@SHLIB_SUFFIX@

View File

@@ -80,3 +80,7 @@ extern const char _PL_char_types[]; /* array of character types */
#define toLowerW(c) ((unsigned)(c) <= 'Z' ? (c) + 'a' - 'A' : towlower(c))
#define makeLowerW(c) ((c) >= 'A' && (c) <= 'Z' ? toLower(c) : towlower(c))
#ifndef HAVE_STRICMP
int stricmp(const char *s1, const char *s2);
#endif

View File

@@ -573,6 +573,9 @@ int Unsetenv(char *name);
int System(char *cmd);
bool expandVars(const char *pattern, char *expanded, int maxlen);
/**** stuff from pl-utils.c ****/
bool stripostfix(char *s, char *e);
/**** SWI stuff (emulated in pl-yap.c) ****/
extern int writeAtomToStream(IOSTREAM *so, atom_t at);
extern int valueExpression(term_t t, Number r ARG_LD);

View File

@@ -0,0 +1,25 @@
#include "pl-incl.h"
#include "pl-ctype.h"
#ifndef HAVE_STRICMP
int
stricmp(const char *s1, const char *s2)
{ while(*s1 && makeLower(*s1) == makeLower(*s2))
s1++, s2++;
return makeLower(*s1) - makeLower(*s2);
}
#endif
bool
stripostfix(char *s, char *e)
{ int ls = strlen(s);
int le = strlen(e);
if ( ls >= le )
return stricmp(&s[ls-le], e) == 0;
return FALSE;
}