Fixup fromcvs/togit conversion
[minix-pkgsrc.git] / news / knews / patches / patch-be
blob8c0bc3c1eecb30f2f7228b434e2e447c4d346422
1 $NetBSD$
3 --- src/expand.c.orig   Fri Jan  9 11:16:29 1998
4 +++ src/expand.c
5 @@ -110,49 +110,46 @@
6      return dest;
7  }
8  
9 -char *expand_path(char *file_name)
10 +char *expand_save_text(char *src)
11  {
12 -    char       *path = NULL;
13 +    char       *dest = NULL;
14      long       len = 0, pos = 0;
15      char       ch;
17 -    if (file_name[0] == '~' && file_name[1] == '/')
18 -       file_name += 2;
20 -    for (ch = *file_name++ ; ch != '\0' ; ch = *file_name++) {
21 +    for (ch = *src++ ; ch != '\0' ; ch = *src++) {
22         if (pos + 8 > len) {
23             len = pos + 256;
24 -           path = XtRealloc(path, len);
25 +           dest = XtRealloc(dest, len);
26         }
28         if (ch != '%')
29 -           path[pos++] = ch;
30 +           dest[pos++] = ch;
31         else {
32             char        *p, *c = NULL;
33             int         cap    = False;
34             int         slash  = False;
35             int         clen   = 0;
37 -           ch = *file_name++;
38 +           ch = *src++;
39             switch (ch) {
40             case '%':
41 -               path[pos++] = '%';
42 +               dest[pos++] = '%';
43                 continue; /* don't fall through */
44             case 'a':
45             case 'A':
46                 if (global.mode != NewsModeGroup &&
47                     global.mode != NewsModeThread) {
48                     fputs("knews: Not in a newsgroup!\n", stderr);
49 -                   XtFree(path);
50 +                   XtFree(dest);
51                     return NULL;
52                 }
53                 if (!global.curr_art) {
54                     fputs("knews: No selected article!\n", stderr);
55 -                   XtFree(path);
56 +                   XtFree(dest);
57                     return NULL;
58                 }
59 -               sprintf(path + pos, "%ld", global.curr_art->no);
60 -               pos += strlen(path + pos);
61 +               sprintf(dest + pos, "%ld", global.curr_art->no);
62 +               pos += strlen(dest + pos);
63                 continue;
64             case 'g':
65                 slash  = True;
66 @@ -180,7 +177,7 @@
67                 c = global.nntp_server;
68                 if (!c) {
69                     fputs("knews: nntp_server is NULL!\n", stderr);
70 -                   XtFree(path);
71 +                   XtFree(dest);
72                     return NULL;
73                 }
74                 p = strchr(c, ':');
75 @@ -192,7 +189,7 @@
76             default:
77                 fprintf(stderr,
78                         "knews: %%%c: Unknown format specifier.\n", ch);
79 -               XtFree(path);
80 +               XtFree(dest);
81                 return NULL;
82             }
84 @@ -202,7 +199,7 @@
85                     clen = strlen(c);
86                 } else {
87                     fputs("knews: Not in a newsgroup.\n", stderr);
88 -                   XtFree(path);
89 +                   XtFree(dest);
90                     return NULL;
91                 }
93 @@ -210,7 +207,7 @@
94                 continue;
95             if (pos + clen + 8 > len) {
96                 len = pos + clen + 256;
97 -               path = XtRealloc(path, len);
98 +               dest = XtRealloc(dest, len);
99             }
101             ch = *c++;
102 @@ -219,18 +216,32 @@
103             if (cap && islower((unsigned char)ch))
104                 ch = toupper((unsigned char)ch);
106 -           path[pos++] = ch;
107 +           dest[pos++] = ch;
108             while (clen-- > 0) {
109                 ch = *c++;
111                 if (ch == '.' && slash)
112                     ch ='/';
113 -               path[pos++] = ch;
114 +               dest[pos++] = ch;
115             }
116 -           path[pos] = '\0';
117 +           dest[pos] = '\0';
118         }
119      }
120 -    path[pos] = '\0';
121 +    dest[pos] = '\0';
123 +    return dest;
126 +char *expand_path(char *file_name)
128 +    char       *path = NULL;
130 +    if (file_name[0] == '~' && file_name[1] == '/')
131 +       file_name += 2;
133 +    path = expand_save_text(file_name);
134 +    if (!path)
135 +       return NULL;
137      return path;