# HG changeset patch # User John W. Eaton # Date 1264056576 18000 # Node ID 06bd6e57f889697df6de6d90795466ae2bd63f28 # Parent 37150167a72a389f94aae1dac4e259a71ae36ad7 use rmdir module from gnulib diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2010-01-21 John W. Eaton + + * bootstrap.conf (gnulib_modules): Include rmdir in the list. + 2010-01-21 John W. Eaton * bootstrap.conf (gnulib_modules): Include c-strcase in the list. diff --git a/bootstrap.conf b/bootstrap.conf --- a/bootstrap.conf +++ b/bootstrap.conf @@ -27,6 +27,7 @@ lstat mkdir mkfifo + rmdir stat strftime times diff --git a/liboctave/ChangeLog b/liboctave/ChangeLog --- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,11 @@ +2010-01-21 John W. Eaton + + * lo-cutils.c (octave_rmdir): New function. + * lo-utils.h: Provide decl. + * file-ops.cc (file_ops::rmdir): Call octave_rmdir. + * Makefile.am (LIBOCTAVE_C_SOURCES): Remove rmdir.c from the list. + * rmdir.c: Delete. + 2010-01-21 John W. Eaton * Makefile.am (LIBOCTAVE_C_SOURCES): Remove strcasecmp.c and diff --git a/liboctave/Makefile.am b/liboctave/Makefile.am --- a/liboctave/Makefile.am +++ b/liboctave/Makefile.am @@ -464,7 +464,6 @@ randmtzig.c \ randpoisson.c \ rename.c \ - rmdir.c \ strptime.c \ tempnam.c \ tempname.c diff --git a/liboctave/file-ops.cc b/liboctave/file-ops.cc --- a/liboctave/file-ops.cc +++ b/liboctave/file-ops.cc @@ -291,17 +291,13 @@ int status = -1; -#if defined (HAVE_RMDIR) - status = ::rmdir (name.c_str ()); + status = octave_rmdir (name.c_str ()); if (status < 0) { using namespace std; msg = ::strerror (errno); } -#else - msg = NOT_SUPPORTED ("rmdir"); -#endif return status; } diff --git a/liboctave/lo-cutils.c b/liboctave/lo-cutils.c --- a/liboctave/lo-cutils.c +++ b/liboctave/lo-cutils.c @@ -92,6 +92,12 @@ #endif OCTAVE_API int +octave_rmdir (const char *name) +{ + return rmdir (name); +} + +OCTAVE_API int octave_strcasecmp (const char *s1, const char *s2) { return strcasecmp (s1, s2); diff --git a/liboctave/lo-utils.h b/liboctave/lo-utils.h --- a/liboctave/lo-utils.h +++ b/liboctave/lo-utils.h @@ -54,6 +54,8 @@ extern "C" OCTAVE_API void octave_qsort (void *base, size_t n, size_t size, int (*cmp) (const void *, const void *)); +extern "C" OCTAVE_API int octave_rmdir (const char *name); + extern "C" OCTAVE_API char *oct_strptime (const char *buf, const char *format, struct tm *tm); diff --git a/liboctave/rmdir.c b/liboctave/rmdir.c deleted file mode 100644 --- a/liboctave/rmdir.c +++ /dev/null @@ -1,95 +0,0 @@ -/* rmdir.c -- BSD compatible remove directory function for System V - Copyright (C) 1988, 1990 Free Software Foundation, Inc. - - 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., 51 Franklin Street, Fifth Floor, Boston, MA - 02110-1301 USA. */ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#ifndef HAVE_RMDIR - -#ifdef HAVE_SYS_TYPES_H -#include -#endif -#include - -#include -#ifndef errno -extern int errno; -#endif - -#ifdef STAT_MACROS_BROKEN -#undef S_ISDIR -#endif - -#if !defined(S_ISDIR) && defined(S_IFDIR) -#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) -#endif - -#include "safe-stat.h" - -/* rmdir adapted from GNU tar. */ - -/* Remove directory DPATH. - Return 0 if successful, -1 if not. */ - -int -rmdir (dpath) - char *dpath; -{ - int cpid, status; - struct stat statbuf; - - if (SAFE_STAT (dpath, &statbuf) != 0) - return -1; /* errno already set */ - - if (!S_ISDIR (statbuf.st_mode)) - { - errno = ENOTDIR; - return -1; - } - - cpid = fork (); - switch (cpid) - { - case -1: /* cannot fork */ - return -1; /* errno already set */ - - case 0: /* child process */ - execl ("/bin/rmdir", "rmdir", dpath, (char *) 0); - _exit (1); - - default: /* parent process */ - - /* Wait for kid to finish. */ - - while (wait (&status) != cpid) - /* Do nothing. */ ; - - if (status & 0xFFFF) - { - - /* /bin/rmdir failed. */ - - errno = EIO; - return -1; - } - return 0; - } -} - -#endif