git.annexia.org
/
libguestfs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Debian: Extra packages needed to run C API tests.
[libguestfs.git]
/
fish
/
glob.c
diff --git
a/fish/glob.c
b/fish/glob.c
index
f20da84
..
509532b
100644
(file)
--- a/
fish/glob.c
+++ b/
fish/glob.c
@@
-1,5
+1,5
@@
/* guestfish - the filesystem interactive shell
/* guestfish - the filesystem interactive shell
- * Copyright (C) 2009
Red Hat Inc.
+ * Copyright (C) 2009
-2010 Red Hat 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
*
* 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
@@
-28,10
+28,10
@@
/* A bit tricky because in the case where there are multiple
* paths we have to perform a Cartesian product.
*/
/* A bit tricky because in the case where there are multiple
* paths we have to perform a Cartesian product.
*/
-static void glob_issue (char *cmd,
in
t argc, char ***globs, int *posn, int *count, int *r);
+static void glob_issue (char *cmd,
size_
t argc, char ***globs, int *posn, int *count, int *r);
int
int
-
do_glob (const char *cmd, in
t argc, char *argv[])
+
run_glob (const char *cmd, size_
t argc, char *argv[])
{
/* For 'glob cmd foo /s* /usr/s*' this could be:
*
{
/* For 'glob cmd foo /s* /usr/s*' this could be:
*
@@
-46,7
+46,8
@@
do_glob (const char *cmd, int argc, char *argv[])
char **globs[argc];
int posn[argc];
int count[argc];
char **globs[argc];
int posn[argc];
int count[argc];
- int i, r = 0;
+ size_t i;
+ int r = 0;
if (argc < 1) {
fprintf (stderr, _("use 'glob command [args...]'\n"));
if (argc < 1) {
fprintf (stderr, _("use 'glob command [args...]'\n"));
@@
-69,46
+70,46
@@
do_glob (const char *cmd, int argc, char *argv[])
if (argv[i][0] == '/') {
pp = guestfs_glob_expand (g, argv[i]);
if (pp == NULL) { /* real error in glob_expand */
if (argv[i][0] == '/') {
pp = guestfs_glob_expand (g, argv[i]);
if (pp == NULL) { /* real error in glob_expand */
- fprintf (stderr, _("glob: guestfs_glob_expand call failed: %s\n"),
- argv[i]);
- goto error0;
+
fprintf (stderr, _("glob: guestfs_glob_expand call failed: %s\n"),
+
argv[i]);
+
goto error0;
}
/* If there were no matches, then we add a single element list
* containing just the original argv[i] string.
*/
if (pp[0] == NULL) {
}
/* If there were no matches, then we add a single element list
* containing just the original argv[i] string.
*/
if (pp[0] == NULL) {
- char **pp2;
-
- pp2 = realloc (pp, sizeof (char *) * 2);
- if (pp2 == NULL) {
- perror ("realloc");
- free (pp);
- goto error0;
- }
- pp = pp2;
-
- pp[0] = strdup (argv[i]);
- if (pp[0] == NULL) {
- perror ("strdup");
- free (pp);
- goto error0;
- }
- pp[1] = NULL;
+
char **pp2;
+
+
pp2 = realloc (pp, sizeof (char *) * 2);
+
if (pp2 == NULL) {
+
perror ("realloc");
+
free (pp);
+
goto error0;
+
}
+
pp = pp2;
+
+
pp[0] = strdup (argv[i]);
+
if (pp[0] == NULL) {
+
perror ("strdup");
+
free (pp);
+
goto error0;
+
}
+
pp[1] = NULL;
}
}
/* Doesn't begin with '/' */
else {
pp = malloc (sizeof (char *) * 2);
if (pp == NULL) {
}
}
/* Doesn't begin with '/' */
else {
pp = malloc (sizeof (char *) * 2);
if (pp == NULL) {
- perror ("malloc");
- goto error0;
+
perror ("malloc");
+
goto error0;
}
pp[0] = strdup (argv[i]);
if (pp[0] == NULL) {
}
pp[0] = strdup (argv[i]);
if (pp[0] == NULL) {
- perror ("strdup");
- free (pp);
- goto error0;
+
perror ("strdup");
+
free (pp);
+
goto error0;
}
pp[1] = NULL;
}
}
pp[1] = NULL;
}
@@
-129,25
+130,21
@@
do_glob (const char *cmd, int argc, char *argv[])
}
static void
}
static void
-glob_issue (char *cmd,
in
t argc,
- char ***globs, int *posn, int *count,
- int *r)
+glob_issue (char *cmd,
size_
t argc,
+
char ***globs, int *posn, int *count,
+
int *r)
{
{
-
in
t i;
+
size_
t i;
char *argv[argc+1];
argv[0] = cmd;
argv[argc] = NULL;
again:
char *argv[argc+1];
argv[0] = cmd;
argv[argc] = NULL;
again:
- printf ("%s", argv[0]);
- for (i = 1; i < argc; ++i) {
+ for (i = 1; i < argc; ++i)
argv[i] = globs[i][posn[i]];
argv[i] = globs[i][posn[i]];
- printf (" %s", argv[i]);
- }
- printf ("\n");
- if (issue_command (argv[0], &argv[1]) == -1)
+ if (issue_command (argv[0], &argv[1]
, NULL
) == -1)
*r = -1; /* ... but don't exit */
for (i = argc-1; i >= 1; --i) {
*r = -1; /* ... but don't exit */
for (i = argc-1; i >= 1; --i) {