rpms/calendar/F-9 calendar-1.25-coding.patch, NONE, 1.1 Makefile.linux, 1.1, 1.2 calendar.spec, 1.1, 1.2
David Cantrell
dcantrel at fedoraproject.org
Thu Apr 9 20:39:53 UTC 2009
Author: dcantrel
Update of /cvs/pkgs/rpms/calendar/F-9
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv13772
Modified Files:
Makefile.linux calendar.spec
Added Files:
calendar-1.25-coding.patch
Log Message:
* Thu Apr 09 2009 David Cantrell <dcantrell at redhat.com> - 1.25-4
- Honor RPM_OPT_FLAGS and fix debuginfo (#494717)
- Convert output to locale's character coding
calendar-1.25-coding.patch:
--- NEW FILE calendar-1.25-coding.patch ---
diff -urN calendar-1.25.orig/calendar.h calendar-1.25/calendar.h
--- calendar-1.25.orig/calendar.h 2009-03-03 22:37:55.000000000 -0500
+++ calendar-1.25/calendar.h 2009-03-04 00:08:53.000000000 -0500
@@ -31,6 +31,8 @@
#include <sys/uio.h>
+#include <iconv.h>
+
extern struct passwd *pw;
extern int doall;
extern int bodun_always;
@@ -70,6 +72,7 @@
int (*getev)(int);
};
+void convprint(FILE *, iconv_t, char *);
void cal(void);
void closecal(FILE *);
int getday(char *);
diff -urN calendar-1.25.orig/io.c calendar-1.25/io.c
--- calendar-1.25.orig/io.c 2009-03-03 22:37:55.000000000 -0500
+++ calendar-1.25/io.c 2009-03-04 00:11:21.000000000 -0500
@@ -61,10 +61,17 @@
#include <string.h>
#include <unistd.h>
+#include <langinfo.h>
+#include <iconv.h>
+
#include "pathnames.h"
#include "calendar.h"
+#define ICONV_TRANSLIT "/" "/" "TRANSLIT"
+#define ICONV_FROMCODE "UTF-8"
+#define ICONV_BUFSIZ (128)
+
struct iovec header[] = {
{ "From: ", 6 },
{ NULL, 0 },
@@ -76,6 +83,39 @@
{ "Auto-Submitted: auto-generated\n\n", 32 },
};
+void
+convprint(FILE *fp, iconv_t ic, char *inputbuf)
+{
+ char *iconv_input;
+ char *iconv_output;
+ char outputbuf[ICONV_BUFSIZ];
+ size_t inputsz;
+ size_t outputsz;
+ size_t iconv_result;
+
+ iconv_input = inputbuf;
+ inputsz = strlen(inputbuf);
+
+ while (inputsz > 0)
+ {
+ iconv_output = outputbuf;
+ outputsz = sizeof(outputbuf) - 1;
+
+ iconv_result = iconv(
+ ic,
+ &iconv_input,
+ &inputsz,
+ &iconv_output,
+ &outputsz
+ );
+ if ((((size_t) -1) == iconv_result) && (E2BIG != errno))
+ {
+ return;
+ }
+ outputbuf[sizeof(outputbuf) - outputsz - 1] = '\0';
+ (void)fprintf(fp, "%s", outputbuf);
+ }
+}
void
cal(void)
@@ -86,6 +126,42 @@
struct match *m;
FILE *fp;
+ char *langinfo_coding;
+ char *iconv_coding;
+ iconv_t ic;
+ int use_iconv;
+
+ use_iconv = 1;
+ iconv_coding = NULL;
+ ic = (iconv_t) -1;
+ (void)setlocale(LC_ALL, "");
+ langinfo_coding = nl_langinfo(CODESET);
+ if ((NULL == langinfo_coding) || ('\0' == *langinfo_coding))
+ {
+ use_iconv = 0;
+ }
+ else
+ {
+ iconv_coding = malloc(
+ strlen(langinfo_coding) + sizeof(ICONV_TRANSLIT)
+ );
+ }
+
+ if (NULL == iconv_coding)
+ {
+ use_iconv = 0;
+ }
+ else
+ {
+ sprintf(iconv_coding, "%s%s", langinfo_coding, ICONV_TRANSLIT);
+ ic = iconv_open(iconv_coding, ICONV_FROMCODE);
+ }
+
+ if (((iconv_t) -1) == ic)
+ {
+ use_iconv = 0;
+ }
+
events = NULL;
cur_evt = NULL;
if ((fp = opencal()) == NULL)
@@ -101,6 +177,14 @@
if (buf[0] == '\0')
continue;
if (strncmp(buf, "LANG=", 5) == 0) {
+ if (use_iconv)
+ {
+ char *coding_start = strchr(buf, '.');
+ if (NULL != coding_start)
+ {
+ strcpy(coding_start, ".UTF-8");
+ }
+ }
(void) setlocale(LC_ALL, buf + 5);
setnnames();
if (!strcmp(buf + 5, "ru_RU.KOI8-R") ||
@@ -215,8 +299,17 @@
}
tmp = events;
while (tmp) {
+ if (use_iconv)
+ {
+ convprint(fp, ic, tmp->print_date);
+ convprint(fp, ic, *(tmp->desc));
+ (void)fputc((int) '\n', fp);
+ }
+ else
+ {
(void)fprintf(fp, "%s%s\n", tmp->print_date, *(tmp->desc));
- tmp = tmp->next;
+ }
+ tmp = tmp->next;
}
tmp = events;
while (tmp) {
@@ -226,6 +319,17 @@
tmp = tmp->next;
free(events);
}
+
+ if (NULL != iconv_coding)
+ {
+ free(iconv_coding);
+ }
+
+ if (((iconv_t) -1) != ic)
+ {
+ iconv_close(ic);
+ }
+
closecal(fp);
}
Index: Makefile.linux
===================================================================
RCS file: /cvs/pkgs/rpms/calendar/F-9/Makefile.linux,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Makefile.linux 20 Feb 2009 20:22:34 -0000 1.1
+++ Makefile.linux 9 Apr 2009 20:39:23 -0000 1.2
@@ -4,7 +4,7 @@
MANDIR = /usr/share/man
CC = gcc
-CFLAGS += -O2 -Wall -D_GNU_SOURCE -DTM_YEAR_BASE=1900
+CFLAGS = $(RPM_OPT_FLAGS) -D_GNU_SOURCE -DTM_YEAR_BASE=1900
SRCS = calendar.c io.c day.c pesach.c ostern.c paskha.c
OBJS = $(SRCS:.c=.o)
@@ -33,7 +33,7 @@
cd ../../ ; \
done
mkdir -p $(DESTDIR)/$(BINDIR) ; \
- install -s -m 0755 calendar $(DESTDIR)/$(BINDIR)/calendar ; \
+ install -m 0755 calendar $(DESTDIR)/$(BINDIR)/calendar ; \
mkdir -p $(DESTDIR)/$(MANDIR)/man1 ; \
install -m 0644 calendar.1 $(DESTDIR)/$(MANDIR)/man1/calendar.1
Index: calendar.spec
===================================================================
RCS file: /cvs/pkgs/rpms/calendar/F-9/calendar.spec,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- calendar.spec 20 Feb 2009 20:22:34 -0000 1.1
+++ calendar.spec 9 Apr 2009 20:39:23 -0000 1.2
@@ -1,7 +1,7 @@
Summary: Reminder utility
Name: calendar
Version: 1.25
-Release: 3%{?dist}
+Release: 4%{?dist}
License: BSD
Group: Applications/Productivity
URL: http://www.openbsd.org/cgi-bin/cvsweb/src/usr.bin/calendar
@@ -16,6 +16,7 @@
Source2: export-calendar-source.sh
Patch0: %{name}-1.25-linux.patch
+Patch1: %{name}-1.25-coding.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@@ -29,8 +30,17 @@
%prep
%setup -q
%patch0 -p1
+%patch1 -p1
%{__cp} %{SOURCE1} Makefile
+for c in calendars/*.*/* ; do
+ fromcode="$(%{__grep} '^LANG=' "$c" | %{__sed} 's/^LANG=\(.*\)\.\(.*\)\(@.*\)\{0,1\}/\2/')"
+ if [ ! -z "$fromcode" ]; then
+ iconv -f "$fromcode" -t "UTF-8" "$c" > "$c.conv"
+ %{__mv} "$c.conv" "$c"
+ fi
+done
+
%build
%{__make} %{?_smp_mflags}
@@ -48,6 +58,10 @@
%{_datadir}/calendar
%changelog
+* Thu Apr 09 2009 David Cantrell <dcantrell at redhat.com> - 1.25-4
+- Honor RPM_OPT_FLAGS and fix debuginfo (#494717)
+- Convert output to locale's character coding
+
* Tue Feb 17 2009 David Cantrell <dcantrell at redhat.com> - 1.25-3
- Use cvs status to get the revision number of calendar.c
More information about the scm-commits
mailing list