scdoc: update to 1.6.1.

This commit is contained in:
maxice8 2019-01-21 03:37:46 -02:00 committed by maxice8
parent 070e74372b
commit 64d6c064d8
2 changed files with 5 additions and 97 deletions

View file

@ -1,90 +0,0 @@
From 599a615cb84799e1a50764ebecb27b459f629a3f Mon Sep 17 00:00:00 2001
From: Silvan Jegen <s.jegen@gmail.com>
Date: Wed, 2 Jan 2019 01:01:49 +0100
Subject: [PATCH] Don't use a GNU-extension for $SOURCE_DATE_EPOCH parsing
Code gratefully copied from the link below.
https://reproducible-builds.org/docs/source-date-epoch/#c
---
src/main.c | 44 +++++++++++++++++++++++++++++++++-----------
1 file changed, 33 insertions(+), 11 deletions(-)
diff --git a/src/main.c b/src/main.c
index 645d521..eab674e 100644
--- src/main.c
+++ src/main.c
@@ -1,6 +1,8 @@
#define _XOPEN_SOURCE 600
#include <assert.h>
#include <ctype.h>
+#include <errno.h>
+#include <limits.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
@@ -11,6 +13,7 @@
#include "util.h"
char *strstr(const char *haystack, const char *needle);
+char *strerror(int errnum);
static int parse_section(struct parser *p) {
str_t *section = str_create();
@@ -67,23 +70,42 @@ static void parse_preamble(struct parser *p) {
str_t *extras[2] = { NULL };
int section = -1;
uint32_t ch;
+ time_t date_time;
char date[256];
char *source_date_epoch = getenv("SOURCE_DATE_EPOCH");
if (source_date_epoch != NULL) {
- struct tm source_date_epoch_tm;
- char *ret = strptime(source_date_epoch, "%s", &source_date_epoch_tm);
- if (ret == NULL || *ret != '\0') {
- fprintf(stderr,
- "Error: $SOURCE_DATE_EPOCH is set but malformed.\n");
- exit(1);
+ unsigned long long epoch;
+ char *endptr;
+ errno = 0;
+ epoch = strtoull(source_date_epoch, &endptr, 10);
+ if ((errno == ERANGE && (epoch == ULLONG_MAX || epoch == 0))
+ || (errno != 0 && epoch == 0)) {
+ fprintf(stderr, "$SOURCE_DATE_EPOCH: strtoull: %s\n",
+ strerror(errno));
+ exit(EXIT_FAILURE);
}
- strftime(date, sizeof(date), "%F", &source_date_epoch_tm);
+ if (endptr == source_date_epoch) {
+ fprintf(stderr, "$SOURCE_DATE_EPOCH: No digits were found: %s\n",
+ endptr);
+ exit(EXIT_FAILURE);
+ }
+ if (*endptr != '\0') {
+ fprintf(stderr, "$SOURCE_DATE_EPOCH: Trailing garbage: %s\n",
+ endptr);
+ exit(EXIT_FAILURE);
+ }
+ if (epoch > ULONG_MAX) {
+ fprintf(stderr, "$SOURCE_DATE_EPOCH: value must be smaller than or "
+ "equal to %lu but was found to be: %llu \n",
+ ULONG_MAX, epoch);
+ exit(EXIT_FAILURE);
+ }
+ date_time = epoch;
} else {
- time_t now;
- time(&now);
- struct tm *now_tm = localtime(&now);
- strftime(date, sizeof(date), "%F", now_tm);
+ date_time = time(NULL);
}
+ struct tm *date_tm = localtime(&date_time);
+ strftime(date, sizeof(date), "%F", date_tm);
while ((ch = parser_getch(p)) != UTF8_INVALID) {
if ((ch < 0x80 && isalnum(ch)) || ch == '_' || ch == '-' || ch == '.') {
int ret = str_append_ch(name, ch);
--
2.18.1

View file

@ -1,14 +1,14 @@
# Template file for 'scdoc'
pkgname=scdoc
version=1.6.0
revision=2
version=1.6.1
revision=1
build_style=gnu-makefile
short_desc="Tool for generating roff manual pages"
maintainer="Julio Galvan <juliogalvan@protonmail.com>"
license="MIT"
homepage="https://git.sr.ht/~sircmpwn/scdoc"
distfiles="https://git.sr.ht/~sircmpwn/scdoc/archive/${version}.tar.gz"
checksum=a396bc070c8734d7cafe3a3481c8cffacd83b3effdeb28de43e2cdac889643b1
checksum=b8ed537b9dcec1f2f546cc194dfe2263eea9adf49b37a8b71cebb7d5e91d979b
if [ "$CROSS_BUILD" ]; then
hostmakedepends+=" scdoc"
@ -16,11 +16,9 @@ fi
pre_build() {
if [ "$CROSS_BUILD" ]; then
sed -i "s|^HOST_SCDOC=.*|HOST_SCDOC=/usr/bin/scdoc|g" Makefile
vsed -e "s|^HOST_SCDOC=.*|HOST_SCDOC=/usr/bin/scdoc|g" -i Makefile
fi
sed -i "s/\" VERSION \"/ ${version}/g" src/main.c
# 1.6.0 use glibc extensions to parse that
unset SOURCE_DATE_EPOCH
sed -e "s/\" VERSION \"/ ${version}/g" -i src/main.c
}
post_install() {