Anonymous avatar Anonymous committed 9737316

Support for libparted-1.9

Comments (0)

Files changed (7)

+21/07/2009 Christian <mail.kristian@yahoo.it>
+	
+	* Handle system where `ped_free' is not defined.
+
 08/03/2009 Christian <mail.kristian@yahoo.it>
 
 	* configure.ac: Better check's for readline and termcap
 # 2.59 is needed by GNULib modules
 AC_PREREQ([2.59])
-AC_INIT(fdisk, 1.2.1, [bug-fdisk@gnu.org])
+AC_INIT(fdisk, 1.2.2, [bug-fdisk@gnu.org])
 AC_CONFIG_AUX_DIR(autotools)
 
 AM_INIT_AUTOMAKE
 CHECK_LIBPARTED([1.7.0], ,
 	AC_MSG_ERROR([*** libparted >= 1.7.0 not installed - please install first ***]))
 AC_SUBST(PARTED_LIBS)
+
+LIBS="$LIBS -lparted"
+# 7 July 2009: New version of libparted does not have ped_free
+GFDISK_libparted_ped_free=ped_free
+AC_MSG_CHECKING([for ped_free in libparted])
+AC_LINK_IFELSE(
+	[AC_LANG_PROGRAM([[extern void ped_free( );]], [[ped_free(); return 0;]])],
+	[AC_MSG_RESULT(yes)], [GFDISK_libparted_ped_free=free; AC_MSG_RESULT([no])])
+AC_DEFINE_UNQUOTED([PED_FREE], [$GFDISK_libparted_ped_free], 
+	[Defined to `free' in system where libparted does not export ped_free])
+
 LIBS="$XLIBS"
 
 dnl ncurses
     along with this program; if not, write to the Free Software
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */
+#if HAVE_CONFIG_H
+#include "../config.h"
+#endif
 
-#include "../config.h"
 #include "common.h"
 #include "hacks.h"
 /*#include "command.h"*/
 		}
 		refresh();
 	}
-	if (*value) ped_free (*value);
+	if (*value) PED_FREE (*value);
 	*value = strdup(buf);
 	return 1;
 	
 		}
 		else
 			selected = do_strlist(prompt,words,0);
-		if (*value) ped_free(*value);
+		if (*value) PED_FREE(*value);
 		*value = str_list_convert_node(selected);
 		return (*value != NULL);
 	}
 			_("Partition %s is being used.  You must unmount it "
 			  "before you modify it."),
 			path);
-		ped_free (path);
+		PED_FREE (path);
 		return 0;
 	}
-	ped_free (path);
+	PED_FREE (path);
 	return 1;
 }
 
 				} else {
 					strncpy(buf,_("Size"),SMALLBUF);
 				}
-				if (temp) ped_free(temp);
-				if (temp2) ped_free(temp2);
+				if (temp) PED_FREE(temp);
+				if (temp2) PED_FREE(temp2);
 				def_str = ped_unit_format(dev,length);
 				if (def_str) temp = strdup(def_str);
 				if (!uiquery->getstring(buf, &temp, NULL, NULL, 1)) {
-					if (temp) ped_free(temp);
-					if (def_str) ped_free(def_str);
+					if (temp) PED_FREE(temp);
+					if (def_str) PED_FREE(def_str);
 					return 0;
 				}
 
 						length = min_len;
 					}
 				}
-				if (temp) ped_free(temp);
-				if (def_str) ped_free(def_str);
+				if (temp) PED_FREE(temp);
+				if (def_str) PED_FREE(def_str);
 			}
 			/* If we place it at the beginning, we will have range
 			   with the end sector and conversly if we place it at
 		if (!(opts & NO_RANGE)) {
 			if (!value->range)
 				value->range = ped_geometry_new (dev,value->sector,1);
-			ped_free (def_str);
-			ped_free (input);
+			PED_FREE (def_str);
+			PED_FREE (input);
 			return value->range != NULL;
 		}
-		ped_free (def_str);
-		ped_free(input);
+		PED_FREE (def_str);
+		PED_FREE(input);
 		return 1;
 	}
 
-	ped_free (def_str);
+	PED_FREE (def_str);
 	if (!input) {
 		value->sector = 0;
 		if (!(opts & NO_RANGE)) {
 	} else {
 		valid = ped_unit_parse(input, dev, &(value->sector),
 		                                   &(value->range));
-		ped_free (input);
+		PED_FREE (input);
 	}
 	return valid;
 }
                 ped_geometry_destroy (pos->end.range);
 
         if (start_usr != NULL)
-                ped_free (start_usr);
+                PED_FREE (start_usr);
         if (end_usr != NULL)
-                ped_free (end_usr);
+                PED_FREE (end_usr);
         if (start_sol != NULL)
-                ped_free (start_sol);
+                PED_FREE (start_sol);
         if (end_sol != NULL)
-                ped_free (end_sol);
+                PED_FREE (end_sol);
 	if (newpart) *newpart = part;
         return 1;
 
                 ped_geometry_destroy (pos->end.range);
 
         if (start_usr != NULL)
-                ped_free (start_usr);
+                PED_FREE (start_usr);
         if (end_usr != NULL)
-                ped_free (end_usr);
+                PED_FREE (end_usr);
         if (start_sol != NULL)
-                ped_free (start_sol);
+                PED_FREE (start_sol);
         if (end_sol != NULL)
-                ped_free (end_sol);
+                PED_FREE (end_sol);
 
         return 0;
 }
                 fs_type->name, ped_partition_type_get_name (part->type),
                 found_start, found_end);
         ped_geometry_destroy (probed);
-        ped_free (found_start);
-        ped_free (found_end);
+        PED_FREE (found_start);
+        PED_FREE (found_end);
 
         switch (ex_opt) {
                 case PED_EXCEPTION_CANCEL: return -1;
 	part_chs = ped_unit_format_custom(part->disk->dev,part->geom.end,
 	                                  PED_UNIT_CHS);
 	sscanf(part_chs, "%d,%d,%d", &end_cyl, &end_head, &end_sector);
-	ped_free(part_chs);
+	PED_FREE(part_chs);
 
 	/* If, for example, this is a msdos logical partition, it has a
            tail of one sector, specifying the next partition. */
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */
 
-#include "../config.h"
+#if HAVE_CONFIG_H
+# include "../config.h"
+#endif
+
 #include "common.h"
 #include "hacks.h"
 #include "command.h"
 			_("Partition %s is being used.  You must unmount it "
 			  "before you modify it with Parted."),
 			path);
-		ped_free (path);
+		PED_FREE (path);
 		return 0;
 	}
-	ped_free (path);
+	PED_FREE (path);
 	return 1;
 }
 
 			return 0;
 	}
 	if (peek_word)
-		ped_free (peek_word);
+		PED_FREE (peek_word);
 
 
 	pos.start.sector = 0LL;
 
 	printf ("%s (%s)\n", compact, percent);
 
-	ped_free (compact);
-	ped_free (percent);
+	PED_FREE (compact);
+	PED_FREE (percent);
 }
 
 static int
 		if (compat_mode)
 			check_partition_consistency(part);
 	}
-	ped_free (cyl_size);
+	PED_FREE (cyl_size);
 
 	/*if (fdisk_list_table == 1)
 	  do_quit (disk);*/
 		part_chs = ped_unit_format_custom(dev, part->geom.start,
 	                                          PED_UNIT_CHS);
 		sscanf(part_chs, "%d,%d,%d", &start_cyl, &start_head, &start_sector);
-		ped_free(part_chs);
+		PED_FREE (part_chs);
 
 		part_chs = ped_unit_format_custom(dev, part->geom.end,
 	                                          PED_UNIT_CHS);
 		sscanf(part_chs, "%d,%d,%d", &end_cyl, &end_head, &end_sector);
-		ped_free(part_chs);
+		PED_FREE (part_chs);
 
 
 		is_boot = ped_partition_get_flag(part,PED_PARTITION_BOOT);
 		fs_type->name, ped_partition_type_get_name (part->type),
 		found_start, found_end);
 	ped_geometry_destroy (probed);
-	ped_free (found_start);
-	ped_free (found_end);
+	PED_FREE (found_start);
+	PED_FREE (found_end);
 
 	switch (ex_opt) {
 		case PED_EXCEPTION_CANCEL: return -1;
 #include <unistd.h>
 #include <setjmp.h>
 
-#include "config.h"
+#if HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 #include "command.h"
 #include "strlist.h"
 #include "ui.h"
 	if (input && *value && !strcmp (input, def_str)) {
 		if (range) {
 			*range = ped_geometry_new (dev, *value, 1);
-			ped_free (def_str);
+			PED_FREE (def_str);
 			return *range != NULL;
 		}
 
-		ped_free (def_str);
+		PED_FREE (def_str);
 		return 1;
 	}
 
-	ped_free (def_str);
+	PED_FREE (def_str);
 	if (!input) {
 		*value = 0;
 		if (range)
 
 	if (flag_name) {
 		*flag = ped_partition_flag_get_by_name (flag_name);
-		ped_free (flag_name);
+		PED_FREE (flag_name);
 		return 1;
 	} else {
 		return 0;

tests/functions.c

 #include <parted/parted.h>
 /* #include <endian.h> */
 #include <string.h>
+#include "../config.h"
 #include "../src/strlist.h"
 #include "functions.h"
 #include "../src/common.h"
 			}
 			if (!found) return 0;
 		}
-		if (*value) ped_free (*value);
+		if (*value) PED_FREE (*value);
 		*value = strdup(s);
 	}
 	return 1;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.