From 2aa3a2cbe7667ade5903c18d6719cf54cfaceb9e Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 7 Dec 2015 21:59:34 +0100 Subject: small fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- DEPENDENCIES | 2 +- Makefile | 4 ++-- po/sv.po | 18 +++++++++--------- src/scrotty.c | 14 ++++++++++---- 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/DEPENDENCIES b/DEPENDENCIES index 04fce66..ba9a00b 100644 --- a/DEPENDENCIES +++ b/DEPENDENCIES @@ -10,7 +10,7 @@ BUILD DEPENDENCIES: make coreutils libc - gcc (any cc can be used if WARN in Makefile is edited) + gcc (any c99 can be used if WARN in Makefile is edited) gettext (opt-out, for internationalisation) texinfo (opt-out, for info, pdf, dvi, ps, and html manuals) texlive-plainextra (opt-in, for pdf, dvi, and ps manuals) diff --git a/Makefile b/Makefile index e37b20f..9aed25e 100644 --- a/Makefile +++ b/Makefile @@ -85,7 +85,7 @@ WARN = -Wall -Wextra -pedantic -Wdouble-promotion -Wformat=2 -Winit-self -Wmissi -Wstrict-aliasing=1 -fstrict-overflow -Wfloat-equal -Wpadded -Waggregate-return \ -Wtraditional-conversion # The C standard for C code compilation -STD = -std=gnu99 +STD = -std=c99 # CPP flags DEFS = -D'DEVDIR="$(DEVDIR)"' -D'SYSDIR="$(SYSDIR)"' -D'PACKAGE="$(PKGNAME)"' \ -D'LOCALEDIR="$(LOCALEDIR)"' -D'PROGRAM_VERSION="$(VERSION)"' @@ -173,7 +173,7 @@ bin/mo/%/messages.mo: po/%.po obj/scrotty.pot: src/scrotty.c @$(MKDIR) -p obj - $(CPP) -DUSE_GETTEXT=1 < src/scrotty.c | \ + $(CPP) -DUSE_GETTEXT=1 src/scrotty.c | \ $(XGETTEXT) -o "$@" -Lc --from-code utf-8 --package-name scrotty \ --package-version 1.1 --no-wrap --force-po \ --copyright-holder 'Mattias Andrée (maandree@member.fsf.org)' - diff --git a/po/sv.po b/po/sv.po index aea7d5d..edbe34b 100644 --- a/po/sv.po +++ b/po/sv.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: scrotty 1.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-12-07 20:12+0100\n" +"POT-Creation-Date: 2015-12-07 21:59+0100\n" "PO-Revision-Date: 2015-12-07 18:50+0100\n" "Last-Translator: Mattias Andrée \n" "Language-Team: none\n" @@ -17,12 +17,12 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" -#: :598 +#: src/scrotty.c:604 #, c-format msgid "Saved framebuffer %i to %s,\n" msgstr "Bildrutebuffert %i sparad till %s.\n" -#: :640 +#: src/scrotty.c:646 #, c-format msgid "" "SYNOPSIS\n" @@ -93,7 +93,7 @@ msgstr "" "\tslutet av strängen, och om ett sådant även förekom direkt framför.\n" "\n" -#: :685 +#: src/scrotty.c:691 #, fuzzy, c-format msgid "" "%s\n" @@ -112,7 +112,7 @@ msgstr "" "\n" "Skriven av Mattias Andrée.\n" -#: :705 +#: src/scrotty.c:711 #, c-format msgid "" "scrotty -- Screenshot program for Linux's TTY\n" @@ -147,20 +147,20 @@ msgstr "" "Du skall ha fått en kopia av GNU General Public License tillsammans\n" "med det här programmet. Om inte, se .\n" -#: :767 :774 +#: src/scrotty.c:773 src/scrotty.c:780 #, c-format msgid "%s: %s. Type '%s --help' for help.\n" msgstr "%s: %s. Kör '%s --help' för hjälp.\n" -#: :767 +#: src/scrotty.c:773 msgid "Unrecognised option." msgstr "Val känns inte igen." -#: :774 +#: src/scrotty.c:780 msgid "--exec has no argument." msgstr "--exec har inget argument." -#: :811 +#: src/scrotty.c:817 #, c-format msgid "%s: %s: %s\n" msgstr "%s: %s: %s\n" diff --git a/src/scrotty.c b/src/scrotty.c index 1005cff..7b621f4 100644 --- a/src/scrotty.c +++ b/src/scrotty.c @@ -23,6 +23,7 @@ #endif +#define _POSIX_SOURCE #include #include #include @@ -416,9 +417,9 @@ static int evaluate (char *restrict buf, size_t n, const char *restrict pattern, ssize_t j = 0; int percent = 0, backslash = 0, dollar = 0, r; char c; - char* fmt; + char *fmt; time_t t; - struct tm tm; + struct tm *tm; /* Expand '$' and '\'. */ while ((c = *pattern++)) @@ -468,12 +469,14 @@ static int evaluate (char *restrict buf, size_t n, const char *restrict pattern, /* Expand '%'. */ t = time (NULL); - localtime_r (&t, &tm); + tm = localtime (&t); + if (tm == NULL) + goto fail; #ifdef __GNUC__ # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Wformat-nonliteral" #endif - if (strftime (buf, n, fmt, &tm) == 0) + if (strftime (buf, n, fmt, tm) == 0) goto enametoolong; /* No errors are defined for `strftime`. */ #ifdef __GNUC__ # pragma GCC diagnostic pop @@ -484,6 +487,9 @@ static int evaluate (char *restrict buf, size_t n, const char *restrict pattern, enametoolong: return errno = ENAMETOOLONG, -1; + fail: + return -1; + #undef P } -- cgit v1.2.3-70-g09d2