[Pinfo-devel] r313 - in pinfo/trunk: . src
Bas Zoetekouw
bas at alioth.debian.org
Sun Sep 19 13:20:44 UTC 2010
Author: bas
Date: 2010-09-19 13:20:39 +0000 (Sun, 19 Sep 2010)
New Revision: 313
Modified:
pinfo/trunk/NEWS
pinfo/trunk/src/filehandling_functions.c
pinfo/trunk/src/manual.c
pinfo/trunk/src/utils.c
pinfo/trunk/src/video.c
Log:
Move vriable declaration to the beginning of blocks to accomodate non-gcc compilers
Modified: pinfo/trunk/NEWS
===================================================================
--- pinfo/trunk/NEWS 2010-09-19 13:16:40 UTC (rev 312)
+++ pinfo/trunk/NEWS 2010-09-19 13:20:39 UTC (rev 313)
@@ -1,6 +1,8 @@
0.6.10:
- Fix issue with handling of suspend/resume and character input
(thanks to Scott Mcdermott for the patch)
+ - Move variable declarations to the start of a block, to accomodate non-gcc
+ compilers. Thanks to Anonymous for the patches submitted to Alioth.
0.6.9
- New maintainer: Bas Zoetekouw <bas at debian.org>
Modified: pinfo/trunk/src/filehandling_functions.c
===================================================================
--- pinfo/trunk/src/filehandling_functions.c 2010-09-19 13:16:40 UTC (rev 312)
+++ pinfo/trunk/src/filehandling_functions.c 2010-09-19 13:20:39 UTC (rev 313)
@@ -139,6 +139,7 @@
char name[256];
char file[256];
int i;
+ char *nameend, *filestart, *fileend, *dot;
id = opendirfile(0);
if (!id)
@@ -146,8 +147,6 @@
read_item(id, type, message, lines);
- char *nameend, *filestart, *fileend, *dot;
-
/* search for node-links in every line */
for (i = 1; i < Lines; i++)
{
@@ -160,6 +159,7 @@
&& (strncasecmp(filename, Message[i] + 2, filenamelen) == 0)
)
{
+ char *tmp;
/* skip this hit if it is not a perfect match and
* we have already found a previous partial match */
@@ -170,7 +170,7 @@
}
/* find the name of the node link */
- char *tmp = name;
+ tmp = name;
strncpy(file, filestart + 1, fileend - filestart - 1);
file[fileend - filestart - 1] = 0;
strncpy(name, fileend + 1, dot - fileend - 1);
Modified: pinfo/trunk/src/manual.c
===================================================================
--- pinfo/trunk/src/manual.c 2010-09-19 13:16:40 UTC (rev 312)
+++ pinfo/trunk/src/manual.c 2010-09-19 13:20:39 UTC (rev 313)
@@ -797,7 +797,7 @@
if ((!strchr(p_t1, '(')) &&(!is_in_manlinks(manlinks, p_t1)))
{
char tempchar;
- int breakpos;
+ int breakpos, cols_before_link;
i = mylink - tmp - 1;
if (i < 0)
i++;
@@ -830,7 +830,7 @@
*/
/* calculate the number of columns in front of the link */
- int cols_before_link = width_of_string(tmp, i-1);
+ cols_before_link = width_of_string(tmp, i-1);
/* a small check */
if (!((use_apropos) &&(manualhistorylength == 0)))
Modified: pinfo/trunk/src/utils.c
===================================================================
--- pinfo/trunk/src/utils.c 2010-09-19 13:16:40 UTC (rev 312)
+++ pinfo/trunk/src/utils.c 2010-09-19 13:20:39 UTC (rev 313)
@@ -558,6 +558,10 @@
int
check_node_name( const char * const node_name, const char * const node_header)
{
+ size_t header_len;
+ char *header, *str_start, *c;
+ int res;
+
/* if either one of node_name or node_header is NULL or a zero
* sized string, we have nothing to check, so return success */
if ( (node_name==NULL) || (node_header==NULL)
@@ -566,15 +570,15 @@
return 1;
}
- size_t header_len = strlen(node_header);
+ header_len = strlen(node_header);
/* copy node_header to a local string which can be mutilated */
/* don't use strdup here, as xmalloc handles all errors */
- char *header = xmalloc( header_len + 1 );
+ header = xmalloc( header_len + 1 );
strcpy(header, node_header);
/* search for "Node: foobar," in node_header */
- char *str_start = strstr(header, "Node: ");
+ str_start = strstr(header, "Node: ");
if (str_start==NULL) /* no match */
{
return 0;
@@ -582,14 +586,14 @@
/* advance str_start to the start of the node name */
str_start += strlen("Node: ");
/* and search for the next comma, tab, or newline */
- char *c = str_start;
+ c = str_start;
while ( (*c!=',') && (*c!='\t') && (*c!='\n') && (*c!='\0') ) c++;
*c = '\0';
/* so, now str_start point to a \0-terminated string containing the
* node name from the header.
* Let's compare it with the node_name we're looking for */
- int res = strcmp(str_start, node_name);
+ res = strcmp(str_start, node_name);
/* we're done, so free alloc'ed vars */
xfree(header);
@@ -642,20 +646,24 @@
int
width_of_string( const char * const mbs, const int len)
{
+ int width;
+ char *str;
+#ifdef USE_WCHAR
+ wchar_t *wstr;
+#endif /* USE_WCHAR */
+
if (len<0) return -1;
if (len==0) return 0;
- int width;
-
/* copy the string to a local buffer, because we only want to
* compare the first len bytes */
- char *str = xmalloc(len+1);
+ str = xmalloc(len+1);
memcpy(str, mbs, len);
#ifdef USE_WCHAR
/* allocate a widestring */
- wchar_t *wstr = xmalloc( (len+1)*sizeof(wchar_t) );
+ wstr = xmalloc( (len+1)*sizeof(wchar_t) );
mbstowcs(wstr, str, len);
width = wcswidth(wstr, len);
Modified: pinfo/trunk/src/video.c
===================================================================
--- pinfo/trunk/src/video.c 2010-09-19 13:16:40 UTC (rev 312)
+++ pinfo/trunk/src/video.c 2010-09-19 13:20:39 UTC (rev 313)
@@ -88,9 +88,10 @@
attrset(normal);
for (i = pos;(i < lines) &&(i < pos + maxy - 2); i++)
{
+ int tmp;
+
if (!message[i]) continue;
-
- int tmp = strlen(message[i]) - 1;
+ tmp = strlen(message[i]) - 1;
message[i][tmp] = 0;
if (tmp>column)
mvaddstr(i + 1 - pos, 0, message[i]+column);
@@ -263,12 +264,13 @@
{
regmatch_t pmatch[1];
long maxpos = pos +(maxy - 2);
+ int maxregexp;
if (maxpos > lines)
{
maxpos = lines;
}
- int maxregexp = aftersearch ? h_regexp_num + 1 : h_regexp_num;
+ maxregexp = aftersearch ? h_regexp_num + 1 : h_regexp_num;
/*
* if it is after search, then we have user defined regexps+
* a searched regexp to highlight
@@ -285,6 +287,9 @@
/* check if this regexp is present on this line */
while (!regexec(&h_regexp[j], str, 1, pmatch, 0))
{
+ int x, y;
+ char tmp;
+
/* yes, found something, so highlight it */
int n = pmatch[0].rm_eo - pmatch[0].rm_so;
@@ -292,12 +297,12 @@
str += pmatch[0].rm_so;
/* calculate position on screen */
- int x = calculate_len(message[i], str);
- int y = i - pos + 1;
+ x = calculate_len(message[i], str);
+ y = i - pos + 1;
/* save the char after the end of the match,
* and replace it by \0 */
- char tmp = str[n];
+ tmp = str[n];
str[n] = 0;
/* write out the highlighted match to screen */
More information about the Pinfo-devel
mailing list