Imported Upstream version 1.8.0
[platform/upstream/augeas.git] / src / augtool.c
index b6ab4a7..17300c4 100644 (file)
@@ -65,8 +65,10 @@ char *history_file = NULL;
  * General utilities
  */
 
-/* Not static, since prototype is in internal.h */
-int xasprintf(char **strp, const char *format, ...) {
+/* Private copy of xasprintf from internal to avoid Multiple definition in
+ * static builds.
+ */
+static int _xasprintf(char **strp, const char *format, ...) {
   va_list args;
   int result;
 
@@ -180,7 +182,9 @@ static char *readline_command_generator(const char *text, int state) {
         "get", "label", "ins", "load", "ls", "match",
         "mv", "cp", "rename", "print", "dump-xml", "rm", "save", "set", "setm",
         "clearm", "span", "store", "retrieve", "transform", "load-file",
-        "help", "touch", "insert", "move", "copy", "errors", NULL };
+        "help", "touch", "insert", "move", "copy", "errors", "source", "context",
+        "info",
+        NULL };
 
     static int current = 0;
     const char *name;
@@ -268,13 +272,13 @@ static void readline_init(void) {
     if (home_dir == NULL)
         goto done;
 
-    if (xasprintf(&history_dir, "%s/.augeas", home_dir) < 0)
+    if (_xasprintf(&history_dir, "%s/.augeas", home_dir) < 0)
         goto done;
 
     if (mkdir(history_dir, 0755) < 0 && errno != EEXIST)
         goto done;
 
-    if (xasprintf(&history_file, "%s/history", history_dir) < 0)
+    if (_xasprintf(&history_file, "%s/history", history_dir) < 0)
         goto done;
 
     stifle_history(500);
@@ -639,7 +643,7 @@ static void add_transforms(char *ts, size_t tslen) {
     bool added_transform = false;
 
     while ((t = argz_next(ts, tslen, t))) {
-        r = xasprintf(&command, "transform %s", t);
+        r = _xasprintf(&command, "transform %s", t);
         if (r < 0)
             fprintf(stderr, "error: Failed to add transform %s: could not allocate memory\n", t);
 
@@ -664,7 +668,7 @@ static void load_files(char *ts, size_t tslen) {
     char *t = NULL;
 
     while ((t = argz_next(ts, tslen, t))) {
-        r = xasprintf(&command, "load-file %s", t);
+        r = _xasprintf(&command, "load-file %s", t);
         if (r < 0)
             fprintf(stderr, "error: Failed to load file %s: could not allocate memory\n", t);