Commit Graph

26 Commits

Author SHA1 Message Date
Richard W.M. Jones
e2c7bddf10 Update copyright dates for 2023
Run this command across the source:

  perl -pi.bak -e 's/(20[012][0-9])-20[12][012]/$1-2023/g' `git ls-files`

and remove changes to po{,-docs}/*.po{,t} (these will be regenerated
later when we run 'make dist').
2023-02-07 10:50:48 +00:00
Richard W.M. Jones
0e17236d7d Update copyright dates to 2020. 2020-03-06 19:32:32 +00:00
Richard W.M. Jones
05d4fcb64d Update copyright dates for 2019.
This command run over the source:

perl -pi.bak -e 's/(20[01][0-9])-2018/$1-2019/g' `git ls-files`
2019-01-08 11:58:30 +00:00
Richard W.M. Jones
212762c593 Update copyright dates for 2018.
Run the following command over the source:

  perl -pi.bak -e 's/(20[01][0-9])-2017/$1-2018/g' `git ls-files`
2018-01-04 15:30:10 +00:00
Richard W.M. Jones
ee206d7ba8 Use Unicode single quotes ‘’ in place of short single quoted strings throughout.
Only in end-user messages and documentation.  This change was done
mostly mechanically using the Perl script attached below.

I also changed don't -> don’t etc and made some other simple fixes.

See also: https://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html

----------
 #!/usr/bin/perl -w

use strict;
use Locale::PO;

my $re = qr{'([-\w%.,=?*/]+)'};

my %files = ();

foreach my $filename ("po/libguestfs.pot", "po-docs/libguestfs-docs.pot") {
    my $poref = Locale::PO->load_file_asarray($filename);

    foreach my $po (@$poref) {
        if ($po->msgid =~ $re) {
            my @refs = split /\s+/, $po->reference;
            foreach my $ref (@refs) {
                my ($file, $lineno) = split /:/, $ref, 2;
                $file =~ s{^\.\./}{};
                if (exists $files{$file}) {
                    push @{$files{$file}}, $lineno;
                } else {
                    $files{$file} = [$lineno];
                }
            }
        }
    }
}

foreach my $file (sort keys %files) {
    unless (-w $file) {
        warn "warning: $file is probably generated\n"; # have to edit generator
        next;
    }
    my @lines = sort { $a <=> $b } @{$files{$file}};

    #print "editing $file at lines ", join (", ", @lines), " ...\n";
    open FILE, "<$file" or die "$file: $!";
    my @all = ();
    push @all, $_ while <FILE>;
    close FILE;

    my $ext = $file;
    $ext =~ s/^.*\.//;

    foreach (@lines) {
        # Don't mess with verbatim sections in POD files.
        next if $ext eq "pod" && $all[$_-1] =~ m/^ /;

        unless ($all[$_-1] =~ $re) {
            # this can happen for multi-line strings, have to edit it
            # by hand
            warn "warning: $file:$_ does not contain expected content\n";
            next;
        }
        $all[$_-1] =~ s/$re/‘$1’/g;
    }

    rename "$file", "$file.bak";
    open FILE, ">$file" or die "$file: $!";
    print FILE $_ for @all;
    close FILE;
    my $mode = (stat ("$file.bak"))[2];
    chmod ($mode & 0777, "$file");
}
2017-04-04 18:47:37 +01:00
Pino Toscano
55bf7de97c Update copyright dates for 2017
Run the following command over the source:

  perl -pi.bak -e 's/(20[01][0-9])-2016/$1-2017/g' `git ls-files`

(Thanks Rich for the perl snippet, as used in past years.)
2017-01-03 16:48:21 +01:00
Richard W.M. Jones
ea71e00d1a fish: Add internal documentation to several files. 2016-05-08 20:59:36 +01:00
Richard W.M. Jones
fdfedcb4ef Use 'error' function for fprintf followed by exit.
Like with the previous commit, this replaces instances of:

  if (something_bad) {
    fprintf (stderr, "%s: error message\n", guestfs_int_program_name);
    exit (EXIT_FAILURE);
  }

with:

  if (something_bad)
    error (EXIT_FAILURE, 0, "error message");

(except in a few cases were errno was incorrectly being ignored, in
which case I have fixed that).

It's slightly more complex than the previous commit because we must be
careful to:

 - Remove the program name (since error(3) prints it).

 - Remove any trailing \n character from the message.

Candidates for replacement were found using:

  pcregrep --buffer-size 10M -M '\bfprintf\b.*\n.*\bexit\b' `git ls-files`
2016-04-04 17:57:38 +01:00
Richard W.M. Jones
129e4938ba Use 'error' function consistently throughout.
Wherever we had code which did:

  if (something_bad) {
    perror (...);
    exit (EXIT_FAILURE);
  }

replace this with use of the error(3) function:

  if (something_bad)
    error (EXIT_FAILURE, errno, ...);

The error(3) function is supplied by glibc, or by gnulib on platforms
which don't have it, and is much more flexible than perror(3).  Since
we already use error(3), there seems to be no downside to mandating it
everywhere.

Note there is one nasty catch with error(3): error (EXIT_SUCCESS, ...)
does *not* exit!  This is also the reason why error(3) cannot be
marked as __attribute__((noreturn)).

Because the examples can't use gnulib, I did not change them.

To search for multiline patterns of the above form, pcregrep -M turns
out to be very useful:

  pcregrep --buffer-size 10M -M '\bperror\b.*\n.*\bexit\b' `git ls-files`
2016-04-04 13:14:26 +01:00
Richard W.M. Jones
307c83177c Update copyright dates for 2016.
Run the following command over the source:

  perl -pi.bak -e 's/(20[01][0-9])-2015/$1-2016/g' `git ls-files`
2016-01-02 21:19:51 +00:00
Richard W.M. Jones
c5800dc97d Update copyright dates for 2015. 2015-01-17 09:08:15 +00:00
Richard W.M. Jones
6c971faecf Update copyright dates for 2014. 2014-01-02 16:53:34 +00:00
Richard W.M. Jones
7c8c6e0760 fish: Allow -N filename=type to use 'filename' instead of 'test1.img' (etc.)
So:

  guestfish -N fs

is equivalent to:

  guestfish -N test1.img=fs
2013-07-22 15:45:06 +01:00
Richard W.M. Jones
abe07ce2ca "guestfish" now means the "guest filesystem shell".
Remove the word "interactive" which implies that guestfish can only
(or often) be used interactively.
2013-04-09 23:21:42 +01:00
Richard W.M. Jones
42bffcd00a Remove all occurrences of the bad_cast (lowercase) function.
Not to be confused with the libxml2 macro 'BAD_CAST' which converts
from 'signed char *' to 'unsigned char *'.

The 'bad_cast' function was defined and used all over the place as a
replacement for a '(char *)' cast.  I think it is better to make these
casts explicit, instead of hiding them in an obscure function.
2013-02-01 14:16:51 +00:00
Richard W.M. Jones
6aa95e87c1 Remove "convenience header" "gettext.h" and use <libintl.h> instead.
gettextize provides a local file called "gettext.h".  Remove this and
use <libintl.h> from glibc headers instead.

Most of this change is mechanical: #include <libintl.h> in every C
file which uses any gettext function.  But also we remove the
gettext.h file, and adjust the "_" macros.

Note that this effectively removes the ./configure --disable-nls
option, although we don't know if that ever worked.
2012-05-01 08:57:55 +01:00
Matthew Booth
04ea1375c5 Update FSF address. 2011-11-08 14:43:07 +00:00
Richard W.M. Jones
c66d6f215e Unify guestfish and guestmount options processing (RHBZ#642932).
In guestfish, factor out the processing of the options -a, -c,
-d, -i, -m, -n, -r, -v, -V, -x into a separate set of files:
options.c, options.h, inspect.c, virt.c.

Change guestmount so that it uses these same files (from the
../fish directory) to process the same options.

This unifies the handling of these options between the two programs.
It also adds the useful inspection feature to guestmount, so you
can now do:

  guestmount -d Guest -i --ro mnt/
2010-10-27 12:04:16 +01:00
Richard W.M. Jones
8ea62c8d7f leak: Free list of drives and mountpoints in guestfish.
Previously the list of -a, -d, -m, -N parameters were leaked.  This
change frees them explicitly.

This is not such an important fix since guestfish is a one-shot
program, but it aids in finding other leaks in future.

(Found by valgrind).
2010-09-21 19:51:22 +01:00
Richard Jones
45f72c804b fish: Improve appearance of guestfish -N help output. 2010-09-08 10:24:22 +01:00
Richard Jones
fa918b166a fish: Allow guestfish -N help for listing prepared disk image help. 2010-09-08 09:59:32 +01:00
Richard Jones
60cdd02b02 fish: Generate list of prepared disk image types.
This commit shouldn't change the semantics of the code.
2010-09-08 09:59:29 +01:00
Richard Jones
48a216a06d fish: Fix '-N part' disk partition type sub-option. 2010-05-21 14:51:53 +01:00
Richard Jones
520d895383 fish: Fix guestfish -N option when called with unknown image type.
Previously it was falling off the end of the loop if you
called it with an unknown image type.
2010-05-13 16:22:10 +01:00
Richard Jones
846238a031 fish -N option unconditionally overwrites test*.img files.
This is more convenient and makes it consistent with the
'alloc' and 'sparse' commands.
2010-05-08 09:09:24 +01:00
Richard Jones
4a9b979a31 fish: Add -N option for making prepared disk images.
Previously you might have typed:

$ guestfish
><fs> alloc test1.img 100M
><fs> run
><fs> part-disk /dev/sda mbr
><fs> mkfs ext4 /dev/sda1

now you can do the same with:

$ guestfish -N fs:ext4

Some tests have also been updated to use this new
functionality.
2010-04-22 18:07:11 +01:00