[PATCH] portability: use last_component, not basename

Jim Meyering meyering at redhat.com
Thu Mar 5 17:49:55 UTC 2009


* libparted/arch/linux.c (read_device_sysfs_file): Use last_component
from gnulib's basename module, not the less-portable "basename" function.
(_device_get_partition_range): Likewise.
Reported by Karel Zak.
* debug/clearfat/Makefile.am (clearfat_LDADD): Link gnulib *after*
libparted, not before.
* partprobe/Makefile.am (partprobe_LDADD): Likewise.
* parted/Makefile.am (parted_LDADD): Likewise.
---
 debug/clearfat/Makefile.am |    2 +-
 libparted/arch/linux.c     |    5 +++--
 parted/Makefile.am         |    2 +-
 partprobe/Makefile.am      |    2 +-
 4 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/debug/clearfat/Makefile.am b/debug/clearfat/Makefile.am
index 7409f45..318fba1 100644
--- a/debug/clearfat/Makefile.am
+++ b/debug/clearfat/Makefile.am
@@ -3,8 +3,8 @@ noinst_PROGRAMS	= clearfat
 clearfat_SOURCES = clearfat.c

 clearfat_LDADD = \
-  $(top_builddir)/lib/libparted.la \
   $(top_builddir)/libparted/libparted.la \
+  $(top_builddir)/lib/libparted.la \
   $(INTLLIBS) $(LIBS) \
   $(PARTED_LIBS)

diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index 047ed50..afdf7f6 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -42,6 +42,7 @@

 #include "blkpg.h"
 #include "../architecture.h"
+#include "dirname.h"

 #if ENABLE_NLS
 #  include <libintl.h>
@@ -849,7 +850,7 @@ read_device_sysfs_file (PedDevice *dev, const char *file)
         char buf[256];

         snprintf (name_buf, 127, "/sys/block/%s/device/%s",
-                  basename (dev->path), file);
+                  last_component (dev->path), file);

         if ((f = fopen (name_buf, "r")) == NULL)
                 return NULL;
@@ -2278,7 +2279,7 @@ _device_get_partition_range(PedDevice* dev)
         bool        ok;

         r = snprintf(path, sizeof(path), "/sys/block/%s/range",
-                        basename(dev->path));
+                     last_component(dev->path));
         if(r < 0 || r >= sizeof(path))
                 return MAX_NUM_PARTS;

diff --git a/parted/Makefile.am b/parted/Makefile.am
index c699102..cb999b1 100644
--- a/parted/Makefile.am
+++ b/parted/Makefile.am
@@ -16,8 +16,8 @@ parted_SOURCES = command.c	\
 parted_CFLAGS = -DBUILDINFO=

 parted_LDADD = \
-  $(top_builddir)/lib/libparted.la \
   $(top_builddir)/libparted/libparted.la \
+  $(top_builddir)/lib/libparted.la \
   $(INTLLIBS) $(LIBS) \
   $(PARTED_LIBS)

diff --git a/partprobe/Makefile.am b/partprobe/Makefile.am
index cbb955f..ec6371c 100644
--- a/partprobe/Makefile.am
+++ b/partprobe/Makefile.am
@@ -5,8 +5,8 @@ sbin_PROGRAMS = partprobe
 partprobe_SOURCES = partprobe.c

 partprobe_LDADD = \
-  $(top_builddir)/lib/libparted.la \
   $(top_builddir)/libparted/libparted.la \
+  $(top_builddir)/lib/libparted.la \
   $(INTLLIBS) $(LIBS) \
   $(PARTED_LIBS)

--
1.6.2.rc1.285.gc5f54



More information about the parted-devel mailing list