Mercurial > hg > octave-terminal
changeset 6111:ed81d74118bb
[project @ 2006-10-27 02:43:23 by jwe]
author | jwe |
---|---|
date | Fri, 27 Oct 2006 02:43:24 +0000 |
parents | 8e5edd73e504 |
children | 05257ee9753d |
files | liboctave/ChangeLog liboctave/Makefile.in liboctave/lo-cutils.c liboctave/lo-utils.h liboctave/strcasecmp.c liboctave/strncase.c src/ChangeLog src/Makefile.in src/cutils.c src/strcasecmp.c src/strncase.c src/utils.h |
diffstat | 12 files changed, 143 insertions(+), 127 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,12 @@ +2006-10-26 John W. Eaton <jwe@octave.org> + + * lo-cutils.c (octave_strcasecmp, octave-strncasecmp): + Move here from src/cutils.c. + * lo-utils.h: Provide decls. + * strcasecmp.c: Move here from src/strcasecmp.c. + * strncase.c: Move here from src/strncase.c. + * Makefile.in (LIBOCTAVE_C_SOURCES): Add them to the list. + 2006-10-26 Michael Goffioul <michael.goffioul@swing.be> * kpse.cc [! MSVC]: Don't include win32lib.h.
--- a/liboctave/Makefile.in +++ b/liboctave/Makefile.in @@ -134,7 +134,8 @@ LIBOCTAVE_C_SOURCES := f2c-main.c filemode.c getopt.c getopt1.c \ lo-cieee.c lo-cutils.c mkdir.c oct-getopt.c \ randgamma.c randmtzig.c randpoisson.c rename.c \ - rmdir.c strftime.c strptime.c tempname.c tempnam.c + rmdir.c strftime.c strptime.c strcasecmp.c strncase.c \ + tempname.c tempnam.c \ LIBOCTAVE_SOURCES := $(LIBOCTAVE_CXX_SOURCES) $(LIBOCTAVE_C_SOURCES)
--- a/liboctave/lo-cutils.c +++ b/liboctave/lo-cutils.c @@ -93,6 +93,18 @@ #endif OCTAVE_API int +octave_strcasecmp (const char *s1, const char *s2) +{ + return strcasecmp (s1, s2); +} + +OCTAVE_API int +octave_strncasecmp (const char *s1, const char *s2, size_t n) +{ + return strncasecmp (s1, s2, n); +} + +OCTAVE_API int octave_gethostname (char *name, int namelen) { return gethostname (name, namelen);
--- a/liboctave/lo-utils.h +++ b/liboctave/lo-utils.h @@ -55,6 +55,10 @@ extern "C" OCTAVE_API char *oct_strptime (const char *buf, const char *format, struct tm *tm); +extern "C" OCTINTERP_API int octave_strcasecmp (const char *s1, const char *s2); + +extern "C" OCTINTERP_API int octave_strncasecmp (const char *s1, const char *s2, size_t n); + extern OCTAVE_API double octave_read_double (std::istream& is); extern OCTAVE_API Complex octave_read_complex (std::istream& is);
new file mode 100644 --- /dev/null +++ b/liboctave/strcasecmp.c @@ -0,0 +1,53 @@ +/* Copyright (C) 1991, 1992 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library 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. + +The GNU C Library 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 the GNU C Library; see the file COPYING. If +not, write to the Free Software Foundation, Inc., 51 Franklin Street, +Fifth Floor, Boston, MA 02110-1301, USA. */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#ifndef HAVE_STRCASECMP + +#include <ctype.h> +#include <string.h> + +/* Compare S1 and S2, ignoring case, returning less than, equal to or + greater than zero if S1 is lexiographically less than, + equal to or greater than S2. */ +int +strcasecmp (const char *s1, const char *s2) +{ + register const unsigned char *p1 = (const unsigned char *) s1; + register const unsigned char *p2 = (const unsigned char *) s2; + unsigned char c1, c2; + + if (p1 == p2) + return 0; + + do + { + c1 = tolower (*p1++); + c2 = tolower (*p2++); + if (c1 == '\0') + break; + } + while (c1 == c2); + + return c1 - c2; +} + +#endif
new file mode 100644 --- /dev/null +++ b/liboctave/strncase.c @@ -0,0 +1,53 @@ +/* Copyright (C) 1992 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library 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. + +The GNU C Library 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 the GNU C Library; see the file COPYING. If +not, write to the Free Software Foundation, Inc., 51 Franklin Street, +Fifth Floor, Boston, MA 02110-1301, USA. */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#ifndef HAVE_STRNCASECMP + +#include <ctype.h> +#include <string.h> + +/* Compare no more than N characters of S1 and S2, + ignoring case, returning less than, equal to or + greater than zero if S1 is lexicographically less + than, equal to or greater than S2. */ +int +strncasecmp (const char *s1, const char *s2, size_t n) +{ + register const unsigned char *p1 = (const unsigned char *) s1; + register const unsigned char *p2 = (const unsigned char *) s2; + unsigned char c1, c2; + + if (p1 == p2 || n == 0) + return 0; + + do + { + c1 = tolower (*p1++); + c2 = tolower (*p2++); + if (c1 == '\0' || c1 != c2) + return c1 - c2; + } while (--n > 0); + + return c1 - c2; +} + +#endif
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,12 @@ 2006-10-26 John W. Eaton <jwe@octave.org> + * cutils.c (octave_strcasecmp, octave-strncasecmp): + Move to liboctave/lo-cutils.c. + * utils.h: Delete decls. + * strcasecmp.c: Move to liboctave/strcasecmp.c. + * strncase.c: Move to liboctave/strncase.c. + * Makefile.in (DIST_SRC): Delete them from the list. + * bitfcns.cc (bitshift): If A < 0, return -bitshift (-A, N, MASK). 2006-10-26 Michael Goffioul <michael.goffioul@swing.be>
--- a/src/Makefile.in +++ b/src/Makefile.in @@ -176,10 +176,9 @@ oct-obj.cc oct-prcstrm.cc oct-procbuf.cc oct-stream.cc \ octave.cc zfstream.cc oct-strstrm.cc oct-lvalue.cc pager.cc \ parse.y pr-output.cc procstream.cc sighandlers.cc \ - siglist.c sparse-xdiv.cc sparse-xpow.cc strcasecmp.c \ - strncase.c strfns.cc symtab.cc syscalls.cc sysdep.cc \ - token.cc toplev.cc unwind-prot.cc utils.cc variables.cc \ - xdiv.cc xpow.cc \ + siglist.c sparse-xdiv.cc sparse-xpow.cc strfns.cc \ + symtab.cc syscalls.cc sysdep.cc token.cc toplev.cc \ + unwind-prot.cc utils.cc variables.cc xdiv.cc xpow.cc \ $(OV_SRC) \ $(PT_SRC)
--- a/src/cutils.c +++ b/src/cutils.c @@ -114,18 +114,6 @@ } int -octave_strcasecmp (const char *s1, const char *s2) -{ - return strcasecmp (s1, s2); -} - -int -octave_strncasecmp (const char *s1, const char *s2, size_t n) -{ - return strncasecmp (s1, s2, n); -} - -int octave_raw_vsnprintf (char *buf, size_t n, const char *fmt, va_list args) { return vsnprintf (buf, n, fmt, args);
deleted file mode 100644 --- a/src/strcasecmp.c +++ /dev/null @@ -1,53 +0,0 @@ -/* Copyright (C) 1991, 1992 Free Software Foundation, Inc. -This file is part of the GNU C Library. - -The GNU C Library 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. - -The GNU C Library 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 the GNU C Library; see the file COPYING. If -not, write to the Free Software Foundation, Inc., 51 Franklin Street, -Fifth Floor, Boston, MA 02110-1301, USA. */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#ifndef HAVE_STRCASECMP - -#include <ctype.h> -#include <string.h> - -/* Compare S1 and S2, ignoring case, returning less than, equal to or - greater than zero if S1 is lexiographically less than, - equal to or greater than S2. */ -int -strcasecmp (const char *s1, const char *s2) -{ - register const unsigned char *p1 = (const unsigned char *) s1; - register const unsigned char *p2 = (const unsigned char *) s2; - unsigned char c1, c2; - - if (p1 == p2) - return 0; - - do - { - c1 = tolower (*p1++); - c2 = tolower (*p2++); - if (c1 == '\0') - break; - } - while (c1 == c2); - - return c1 - c2; -} - -#endif
deleted file mode 100644 --- a/src/strncase.c +++ /dev/null @@ -1,53 +0,0 @@ -/* Copyright (C) 1992 Free Software Foundation, Inc. -This file is part of the GNU C Library. - -The GNU C Library 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. - -The GNU C Library 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 the GNU C Library; see the file COPYING. If -not, write to the Free Software Foundation, Inc., 51 Franklin Street, -Fifth Floor, Boston, MA 02110-1301, USA. */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#ifndef HAVE_STRNCASECMP - -#include <ctype.h> -#include <string.h> - -/* Compare no more than N characters of S1 and S2, - ignoring case, returning less than, equal to or - greater than zero if S1 is lexicographically less - than, equal to or greater than S2. */ -int -strncasecmp (const char *s1, const char *s2, size_t n) -{ - register const unsigned char *p1 = (const unsigned char *) s1; - register const unsigned char *p2 = (const unsigned char *) s2; - unsigned char c1, c2; - - if (p1 == p2 || n == 0) - return 0; - - do - { - c1 = tolower (*p1++); - c2 = tolower (*p2++); - if (c1 == '\0' || c1 != c2) - return c1 - c2; - } while (--n > 0); - - return c1 - c2; -} - -#endif
--- a/src/utils.h +++ b/src/utils.h @@ -99,10 +99,6 @@ extern "C" OCTINTERP_API void octave_usleep (unsigned int useconds); -extern "C" OCTINTERP_API int octave_strcasecmp (const char *s1, const char *s2); - -extern "C" OCTINTERP_API int octave_strncasecmp (const char *s1, const char *s2, size_t n); - extern "C" OCTINTERP_API int octave_raw_vsnprintf (char *buf, size_t n, const char *fmt, va_list args);