update to snownews-1.5.10

it contains patches from Martynas Venckus:

- net-support.c: HTTP header only needs to be ASCII in the token
- xmlparse.c: Convert feed title to target charset, too. Should
probaly be in interface.c
- main.c, interface.h, interface.c: Add a signal handler for resizing
to work on many other ncurses implementations
- conversions.c: Determine output charset with nl_langinfo()

ok kili@
This commit is contained in:
martynas 2008-09-12 20:07:15 +00:00
parent 2c3ac8569e
commit b2e1264316
9 changed files with 14 additions and 253 deletions

View File

@ -1,8 +1,7 @@
# $OpenBSD: Makefile,v 1.21 2008/07/20 17:09:26 martynas Exp $
# $OpenBSD: Makefile,v 1.22 2008/09/12 20:07:15 martynas Exp $
COMMENT= text mode rss newsreader
DISTNAME= snownews-1.5.9
PKGNAME= ${DISTNAME}p2
DISTNAME= snownews-1.5.10
CATEGORIES= www
MASTER_SITES= ${HOMEPAGE}download/

View File

@ -1,5 +1,5 @@
MD5 (snownews-1.5.9.tar.gz) = Dz3KhaNjhqcgM7g6ICxVng==
RMD160 (snownews-1.5.9.tar.gz) = R4yLYOO/sfDrEyaMbesqJYgxqms=
SHA1 (snownews-1.5.9.tar.gz) = o8d4Jywa5ZnhHyg/qxvSZ8o68BE=
SHA256 (snownews-1.5.9.tar.gz) = YTc3LCcJZD5+vNqJPeZWdXq9iN3JPIJ7eXZTH9j6Bk0=
SIZE (snownews-1.5.9.tar.gz) = 170666
MD5 (snownews-1.5.10.tar.gz) = ITp1Q7qzGn3+WnbBc81dSQ==
RMD160 (snownews-1.5.10.tar.gz) = RlD8GUxFj78hL4HPxeYICj1Psm0=
SHA1 (snownews-1.5.10.tar.gz) = 5aBoQY8080NyZ+/2NWcpudhxRwE=
SHA256 (snownews-1.5.10.tar.gz) = dtkdF+/PpIFPbpbiBDD7IWvXbxkEU7LLTh+zMKip3ug=
SIZE (snownews-1.5.10.tar.gz) = 171699

View File

@ -1,52 +1,20 @@
$OpenBSD: patch-conversions_c,v 1.7 2008/01/14 22:40:39 martynas Exp $
--- conversions.c.orig Tue Jan 8 11:41:02 2008
+++ conversions.c Sat Jan 12 21:30:42 2008
@@ -21,6 +21,7 @@
*
*/
+#include <sys/types.h>
#include <string.h>
#include <iconv.h>
#include <stdio.h>
@@ -30,6 +31,7 @@
$OpenBSD: patch-conversions_c,v 1.8 2008/09/12 20:07:15 martynas Exp $
--- conversions.c.orig Mon Jul 28 12:26:16 2008
+++ conversions.c Fri Sep 12 22:33:53 2008
@@ -31,7 +31,7 @@
#include <errno.h>
#include <libxml/HTMLparser.h>
#include <langinfo.h>
-/*#include <md5.h>*/
+#include <md5.h>
#include "os-support.h"
@@ -48,7 +50,6 @@
#include "interface.h"
@@ -51,7 +51,6 @@
#include "ui-support.h"
#include "setup.h"
-#include "md5.h"
#include "digcalc.h"
-#include "md5.h"
extern struct entity *first_entity;
@@ -63,17 +64,22 @@ char * iconvert (char * inbuf) {
iconv_t cd; /* Iconvs conversion descriptor. */
char *outbuf, *outbuf_first; /* We need two pointers so we do not lose
the string starting position. */
+ char target_charset[64];
size_t inbytesleft, outbytesleft;
+ (void)strlcpy(target_charset, nl_langinfo(CODESET), sizeof(target_charset));
+
/* Take a shortcut. */
- if (strcasecmp (TARGET_CHARSET, "UTF-8") == 0)
+ if (strcasecmp (target_charset, "UTF-8") == 0)
return strdup(inbuf);
inbytesleft = strlen(inbuf);
outbytesleft = strlen(inbuf);
+ (void)strlcat(target_charset, "//TRANSLIT", sizeof(target_charset));
+
/* cd = iconv_open(nl_langinfo(CODESET), "UTF-8"); */
- cd = iconv_open (TARGET_CHARSET, "UTF-8");
+ cd = iconv_open (target_charset, "UTF-8");
if (cd == (iconv_t) -1) {
return NULL;
}

View File

@ -1,74 +0,0 @@
$OpenBSD: patch-interface_c,v 1.1 2008/06/09 22:54:38 martynas Exp $
--- interface.c.orig Sun Feb 17 15:43:58 2008
+++ interface.c Sat Jun 7 13:46:09 2008
@@ -31,6 +31,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
+#include <signal.h>
#include "config.h"
#include "main.h"
@@ -52,6 +53,8 @@ extern int use_colors;
extern struct categories *first_category;
extern int cursor_always_visible;
+static int resize_dirty = 0;
+
struct feed *first_bak = NULL; /* Backup first pointer for filter mode.
Needs to be global so it can be used in the signal handler.
Must be set to NULL by default and whenever it's not used anymore! */
@@ -63,6 +66,13 @@ struct scrolltext {
struct scrolltext * prev_ptr;
};
+#ifdef SIGWINCH
+void sig_winch(int p)
+{
+ resize_dirty = 1;
+}
+#endif
+
/* View newsitem in scrollable window.
* Speed of this code has been greatly increased in 1.2.1.
*/
@@ -346,10 +356,14 @@ void UIDisplayItem (struct newsitem * current_item, st
if (linenumber+(LINES-7) < maxlines)
linenumber++;
}
- if (uiinput == KEY_RESIZE) {
+ if (resize_dirty || uiinput == KEY_RESIZE) {
rewrap = 1;
/* Reset maxlines, otherwise the program will scroll to far down. */
maxlines = 0;
+
+ endwin();
+ refresh();
+ resize_dirty = 0;
}
if (uiinput == keybindings.about)
UIAbout();
@@ -792,6 +806,11 @@ int UIDisplayFeed (struct feed * current_feed) {
UIAbout();
if (uiinput == keybindings.feedinfo)
FeedInfo(current_feed);
+ if (resize_dirty || uiinput == KEY_RESIZE) {
+ endwin();
+ refresh();
+ resize_dirty = 0;
+ }
/* Redraw screen on ^L */
if (uiinput == 12)
forceredraw = 1;
@@ -1625,6 +1644,11 @@ void UIMainInterface (void) {
/* Reconstruct filter. */
filteractivated = 1;
}
+ }
+ if (resize_dirty || uiinput == KEY_RESIZE) {
+ endwin();
+ refresh();
+ resize_dirty = 0;
}
/* Redraw screen on ^L */
if (uiinput == 12)

View File

@ -1,11 +0,0 @@
$OpenBSD: patch-interface_h,v 1.1 2008/06/09 22:54:38 martynas Exp $
--- interface.h.orig Sun Feb 17 15:43:58 2008
+++ interface.h Tue Mar 18 14:01:16 2008
@@ -24,6 +24,7 @@
#ifndef INTERFACE_H
#define INTERFACE_H
+void sig_winch(int p);
void UIMainInterface (void);
#endif

View File

@ -1,29 +0,0 @@
$OpenBSD: patch-main_c,v 1.3 2008/06/09 22:54:38 martynas Exp $
--- main.c.orig Sun Feb 17 15:43:58 2008
+++ main.c Tue Mar 18 13:56:06 2008
@@ -142,6 +142,10 @@ void badOption (const char * arg) {
}
int main (int argc, char *argv[]) {
+#ifdef SIGWINCH
+ struct sigaction act;
+#endif
+
int autoupdate = 0; /* Automatically update feeds on app start... or not if set to 0. */
int numfeeds; /* Number of feeds loaded from Config(). */
int i = 0;
@@ -202,6 +206,14 @@ int main (int argc, char *argv[]) {
/* Call the reaper */
signal (SIGCHLD, sigChildHandler);
+#ifdef SIGWINCH
+ /* Set up SIGWINCH handler */
+ sigemptyset(&act.sa_mask);
+ act.sa_flags = 0;
+ act.sa_handler = sig_winch;
+ sigaction(SIGWINCH, &act, NULL);
+#endif
+
InitCurses();
/* Check if configfiles exist and create/read them. */

View File

@ -1,21 +0,0 @@
$OpenBSD: patch-net-support_c,v 1.1 2008/02/18 17:48:48 martynas Exp $
--- net-support.c.orig Tue Jan 8 11:41:02 2008
+++ net-support.c Mon Feb 18 00:07:00 2008
@@ -243,7 +243,7 @@ int NetSupportAuth (struct feed * cur_ptr, const char
return 0;
}
-/* HTTP header may only contain ASCII characters.
+/* HTTP token may only contain ASCII characters.
*
* Ensure that we don't hit the terminating \0 in a string
* with the for loop.
@@ -262,6 +262,8 @@ int checkValidHTTPHeader (const unsigned char * header
if (((header[i] < 32) || (header[i] > 127)) &&
(header[i] != '\r') && (header[i] != '\n'))
return -1;
+ if (header[i] == ':')
+ break;
}
return 0;
}

View File

@ -1,48 +0,0 @@
$OpenBSD: patch-netio_c,v 1.1 2008/06/09 22:54:38 martynas Exp $
--- netio.c.orig Sun Feb 17 15:43:58 2008
+++ netio.c Sat Jun 7 15:29:06 2008
@@ -44,6 +44,7 @@
#include <sys/stat.h>
#include <sys/time.h>
#include <assert.h>
+#include <fcntl.h>
#include <ncurses.h>
@@ -87,7 +88,12 @@ int NetPoll (struct feed * cur_ptr, int * my_socket, i
if (rw == NET_READ) {
FD_SET(*my_socket, &rfdsr);
- if (select (*my_socket+1, &rfdsr, NULL, NULL, &tv) == 0) {
+ do {
+ retval = select (*my_socket+1, &rfdsr, NULL, NULL,
+ &tv);
+ }
+ while (retval == -1 && errno == EINTR);
+ if (retval == 0) {
/* Timed out */
cur_ptr->netio_error = NET_ERR_TIMEOUT;
return -1;
@@ -101,7 +107,12 @@ int NetPoll (struct feed * cur_ptr, int * my_socket, i
}
} else if (rw == NET_WRITE) {
FD_SET(*my_socket, &rfdsw);
- if (select (*my_socket+1, NULL, &rfdsw, NULL, &tv) == 0) {
+ do {
+ retval = select (*my_socket+1, NULL, &rfdsw, NULL,
+ &tv);
+ }
+ while (retval == -1 && errno == EINTR);
+ if (retval == 0) {
/* Timed out */
cur_ptr->netio_error = NET_ERR_TIMEOUT;
return -1;
@@ -158,6 +169,8 @@ int NetConnect (int * my_socket, char * host, struct f
return -1;
}
+ fcntl(*my_socket, F_SETFL, O_NONBLOCK);
+
/* If proxyport is 0 we didn't execute the if http_proxy statement in main
so there is no proxy. On any other value of proxyport do proxyrequests instead. */
if (proxyport == 0) {

View File

@ -1,23 +0,0 @@
$OpenBSD: patch-xmlparse_c,v 1.1 2008/06/09 23:03:15 martynas Exp $
--- xmlparse.c.orig Sun Feb 17 15:43:58 2008
+++ xmlparse.c Tue Mar 18 18:09:33 2008
@@ -316,6 +316,7 @@ int DeXML (struct feed * cur_ptr) {
xmlDocPtr doc;
xmlNodePtr cur;
struct newsitem *cur_item;
+ char *converted;
if (cur_ptr->feed == NULL)
return -1;
@@ -424,6 +425,11 @@ int DeXML (struct feed * cur_ptr) {
/* Set -> title to something if it's a NULL pointer to avoid crash with strdup below. */
if (cur_ptr->title == NULL)
cur_ptr->title = strdup (cur_ptr->feedurl);
+ converted = iconvert (cur_ptr->title);
+ if (converted != NULL) {
+ free (cur_ptr->title);
+ cur_ptr->title = converted;
+ }
cur_ptr->original = strdup (cur_ptr->title);
/* Restore custom title. */