diff --git a/Makefile.linux b/Makefile.linux index 1a42d9c..4a076fa 100644 --- a/Makefile.linux +++ b/Makefile.linux @@ -4,7 +4,7 @@ BINDIR = /usr/bin 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 @@ install: calendar 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 diff --git a/calendar-1.25-coding.patch b/calendar-1.25-coding.patch new file mode 100644 index 0000000..655c6e8 --- /dev/null +++ b/calendar-1.25-coding.patch @@ -0,0 +1,176 @@ +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 + ++#include ++ + 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 + #include + ++#include ++#include ++ + #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); + } + diff --git a/calendar.spec b/calendar.spec index 37fee93..58a795d 100644 --- a/calendar.spec +++ b/calendar.spec @@ -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 @@ Source1: Makefile.linux 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 @@ week. %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 @@ week. %{_datadir}/calendar %changelog +* Thu Apr 09 2009 David Cantrell - 1.25-4 +- Honor RPM_OPT_FLAGS and fix debuginfo (#494717) +- Convert output to locale's character coding + * Tue Feb 17 2009 David Cantrell - 1.25-3 - Use cvs status to get the revision number of calendar.c