Lines 1-76
Link Here
|
1 |
--- src/utils.c.orig Thu Mar 16 23:14:30 2006 |
|
|
2 |
+++ src/utils.c Fri Mar 17 16:04:57 2006 |
3 |
@@ -553,6 +553,10 @@ |
4 |
int |
5 |
check_node_name( const char * const node_name, const char * const node_header) |
6 |
{ |
7 |
+ size_t header_len; |
8 |
+ char *header, *str_start, *c; |
9 |
+ int res; |
10 |
+ |
11 |
/* if either one of node_name or node_header is NULL or a zero |
12 |
* sized string, we have nothing to check, so return success */ |
13 |
if ( (node_name==NULL) || (node_header==NULL) |
14 |
@@ -561,15 +565,15 @@ |
15 |
return 1; |
16 |
} |
17 |
|
18 |
- size_t header_len = strlen(node_header); |
19 |
+ header_len = strlen(node_header); |
20 |
|
21 |
/* copy node_header to a local string which can be mutilated */ |
22 |
/* don't use strdup here, as xmalloc handles all errors */ |
23 |
- char *header = xmalloc( header_len + 1 ); |
24 |
+ header = xmalloc( header_len + 1 ); |
25 |
strcpy(header, node_header); |
26 |
|
27 |
/* search for "Node: foobar," in node_header */ |
28 |
- char *str_start = strstr(header, "Node: "); |
29 |
+ str_start = strstr(header, "Node: "); |
30 |
if (str_start==NULL) /* no match */ |
31 |
{ |
32 |
return 0; |
33 |
@@ -577,14 +581,14 @@ |
34 |
/* advance str_start to the start of the node name */ |
35 |
str_start += strlen("Node: "); |
36 |
/* and search for the next comma, tab, or newline */ |
37 |
- char *c = str_start; |
38 |
+ c = str_start; |
39 |
while ( (*c!=',') && (*c!='\t') && (*c!='\n') && (*c!='\0') ) c++; |
40 |
*c = '\0'; |
41 |
|
42 |
/* so, now str_start point to a \0-terminated string containing the |
43 |
* node name from the header. |
44 |
* Let's compare it with the node_name we're looking for */ |
45 |
- int res = strcmp(str_start, node_name); |
46 |
+ res = strcmp(str_start, node_name); |
47 |
|
48 |
/* we're done, so free alloc'ed vars */ |
49 |
xfree(header); |
50 |
@@ -637,20 +641,22 @@ |
51 |
int |
52 |
width_of_string( const char * const mbs, const int len) |
53 |
{ |
54 |
+ int width; |
55 |
+ char *str; |
56 |
+ wchar_t *wstr; |
57 |
+ |
58 |
if (len<0) return -1; |
59 |
if (len==0) return 0; |
60 |
|
61 |
- int width; |
62 |
- |
63 |
/* copy the string to a local buffer, because we only want to |
64 |
* compare the first len bytes */ |
65 |
- char *str = xmalloc(len+1); |
66 |
+ str = xmalloc(len+1); |
67 |
memcpy(str, mbs, len); |
68 |
|
69 |
#ifdef USE_WCHAR |
70 |
|
71 |
/* allocate a widestring */ |
72 |
- wchar_t *wstr = xmalloc( (len+1)*sizeof(wchar_t) ); |
73 |
+ wstr = xmalloc( (len+1)*sizeof(wchar_t) ); |
74 |
|
75 |
mbstowcs(wstr, str, len); |
76 |
width = wcswidth(wstr, len); |