diff options
author | Mattias Andrée <maandree@operamail.com> | 2015-05-11 21:09:50 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2015-05-11 21:09:50 +0200 |
commit | 063dfdc4f91072858789781fdf30940ef30307e1 (patch) | |
tree | 4689db6a788ce8552b5577e192b8344d7bd88808 | |
parent | bump version (diff) | |
download | libgamma-063dfdc4f91072858789781fdf30940ef30307e1.tar.gz libgamma-063dfdc4f91072858789781fdf30940ef30307e1.tar.bz2 libgamma-063dfdc4f91072858789781fdf30940ef30307e1.tar.xz |
libgamma_perror supports NULL and empty string in the same ways as perror
Signed-off-by: Mattias Andrée <maandree@operamail.com>
-rw-r--r-- | src/lib/libgamma-error.c.gpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/lib/libgamma-error.c.gpp b/src/lib/libgamma-error.c.gpp index 3d124eb..27c2008 100644 --- a/src/lib/libgamma-error.c.gpp +++ b/src/lib/libgamma-error.c.gpp @@ -108,17 +108,29 @@ void libgamma_perror(const char* name, int error_code) long int gid = (long int)libgamma_group_gid; if (libgamma_group_name == NULL) /* Group name unknown. */ - fprintf(stderr, "%s: %s: %ld\n", name, error, gid); + if (name && *name) + fprintf(stderr, "%s: %s: %ld\n", name, error, gid); + else + fprintf(stderr, "%s: %ld\n", error, gid); else /* Group name known, ID is second class. */ - fprintf(stderr, "%s: %s: %s (%ld)\n", name, error, libgamma_group_name, gid); + if (name && *name) + fprintf(stderr, "%s: %s: %s (%ld)\n", name, error, libgamma_group_name, gid); + else + fprintf(stderr, "%s: %s (%ld)\n", error, libgamma_group_name, gid); } else if (error_code < LIBGAMMA_ERROR_MIN) /* If the error code does not exist, print "(?)" */ - fprintf(stderr, "%s: (?)\n", name); + if (name && *name) + fprintf(stderr, "%s: (?)\n", name); + else + fprintf(stderr, "(?)\n"); else /* Print the name of the error. */ - fprintf(stderr, "%s: %s\n", name, libgamma_name_of_error(error_code)); + if (name && *name) + fprintf(stderr, "%s: %s\n", name, libgamma_name_of_error(error_code)); + else + fprintf(stderr, "%s\n", libgamma_name_of_error(error_code)); } |