Commit 8bee9c86c9c9324fef253d8f4f321bc53510844a

Authored by Perry Werneck
1 parent ad7f27cd

Cleaning up unused code.

src/core/html.c
@@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
18 * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin 18 * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
19 * St, Fifth Floor, Boston, MA 02110-1301 USA 19 * St, Fifth Floor, Boston, MA 02110-1301 USA
20 * 20 *
21 - * Este programa está nomeado como html.c e possui - linhas de código. 21 + * Este programa está nomeado como util.c e possui - linhas de código.
22 * 22 *
23 * Contatos: 23 * Contatos:
24 * 24 *
src/core/resources.c
@@ -40,13 +40,14 @@ @@ -40,13 +40,14 @@
40 40
41 extern String fallbacks[]; 41 extern String fallbacks[];
42 42
43 -/* s3270 substitute Xt resource database. */  
44 -  
45 -#if defined(C3270) /*[*/  
46 /* 43 /*
47 - * These should be properly #ifdef'd in X3270.xad, but it would turn it into  
48 - * spaghetti.  
49 - */ 44 +// s3270 substitute Xt resource database.
  45 +
  46 +#if defined(C3270)
  47 +//
  48 +// These should be properly #ifdef'd in X3270.xad, but it would turn it into
  49 +// spaghetti.
  50 +//
50 static struct { 51 static struct {
51 char *name; 52 char *name;
52 char *value; 53 char *value;
@@ -96,12 +97,12 @@ static struct { @@ -96,12 +97,12 @@ static struct {
96 { "message.terminalName", "Terminal name:" }, 97 { "message.terminalName", "Terminal name:" },
97 { "message.tn3270eNoOpts", "No TN3270E options" }, 98 { "message.tn3270eNoOpts", "No TN3270E options" },
98 { "message.tn3270eOpts", "TN3270E options:" }, 99 { "message.tn3270eOpts", "TN3270E options:" },
99 -#if defined(_WIN32) /*[*/ 100 +#if defined(_WIN32)
100 { "message.windowsCodePage", "Windows code page:" }, 101 { "message.windowsCodePage", "Windows code page:" },
101 -#endif /*][*/ 102 +#endif
102 { NULL, NULL } 103 { NULL, NULL }
103 }; 104 };
104 -#endif /*]*/ 105 +#endif
105 106
106 static struct dresource { 107 static struct dresource {
107 struct dresource *next; 108 struct dresource *next;
@@ -127,7 +128,6 @@ void add_resource(const char *name, const char *value) @@ -127,7 +128,6 @@ void add_resource(const char *name, const char *value)
127 drdb_next = &d->next; 128 drdb_next = &d->next;
128 } 129 }
129 130
130 -  
131 const char * get_resource(H3270 *hSession, const char *name) 131 const char * get_resource(H3270 *hSession, const char *name)
132 { 132 {
133 struct dresource *d; 133 struct dresource *d;
@@ -165,7 +165,7 @@ const char * get_resource(H3270 *hSession, const char *name) @@ -165,7 +165,7 @@ const char * get_resource(H3270 *hSession, const char *name)
165 return NULL; 165 return NULL;
166 } 166 }
167 167
168 -/* A version of get_resource that accepts sprintf arguments. */ 168 +/// @brief A version of get_resource that accepts sprintf arguments.
169 const char * get_fresource(H3270 *hSession, const char *fmt, ...) 169 const char * get_fresource(H3270 *hSession, const char *fmt, ...)
170 { 170 {
171 va_list args; 171 va_list args;
@@ -180,3 +180,5 @@ const char * get_fresource(H3270 *hSession, const char *fmt, ...) @@ -180,3 +180,5 @@ const char * get_fresource(H3270 *hSession, const char *fmt, ...)
180 return r; 180 return r;
181 } 181 }
182 182
  183 +*/
  184 +
src/core/util.c
@@ -138,18 +138,18 @@ xs_error(const char *fmt, ...) @@ -138,18 +138,18 @@ xs_error(const char *fmt, ...)
138 lib3270_free(r); 138 lib3270_free(r);
139 } 139 }
140 140
141 -  
142 -/**  
143 - * @brief Definition resource splitter.  
144 - *  
145 - * Definition resource splitter, for resources of the repeating form:  
146 - * left: right\n  
147 - *  
148 - * Can be called iteratively to parse a list.  
149 - * Returns 1 for success, 0 for EOF, -1 for error.  
150 - *  
151 - * Note: Modifies the input string.  
152 - */ 141 +/*
  142 +///
  143 +/// @brief Definition resource splitter.
  144 +///
  145 +/// Definition resource splitter, for resources of the repeating form:
  146 +/// left: right\n
  147 +///
  148 +/// Can be called iteratively to parse a list.
  149 +/// Returns 1 for success, 0 for EOF, -1 for error.
  150 +///
  151 +/// Note: Modifies the input string.
  152 +///
153 int 153 int
154 split_dresource(char **st, char **left, char **right) 154 split_dresource(char **st, char **left, char **right)
155 { 155 {
@@ -157,19 +157,19 @@ split_dresource(char **st, char **left, char **right) @@ -157,19 +157,19 @@ split_dresource(char **st, char **left, char **right)
157 char *t; 157 char *t;
158 Boolean quote; 158 Boolean quote;
159 159
160 - /* Skip leading white space. */ 160 + // Skip leading white space.
161 while (my_isspace(*s)) 161 while (my_isspace(*s))
162 s++; 162 s++;
163 163
164 - /* If nothing left, EOF. */ 164 + // If nothing left, EOF.
165 if (!*s) 165 if (!*s)
166 return 0; 166 return 0;
167 167
168 - /* There must be a left-hand side. */ 168 + // There must be a left-hand side.
169 if (*s == ':') 169 if (*s == ':')
170 return -1; 170 return -1;
171 171
172 - /* Scan until an unquoted colon is found. */ 172 + // Scan until an unquoted colon is found.
173 *left = s; 173 *left = s;
174 for (; *s && *s != ':' && *s != '\n'; s++) 174 for (; *s && *s != ':' && *s != '\n'; s++)
175 if (*s == '\\' && *(s+1) == ':') 175 if (*s == '\\' && *(s+1) == ':')
@@ -177,34 +177,34 @@ split_dresource(char **st, char **left, char **right) @@ -177,34 +177,34 @@ split_dresource(char **st, char **left, char **right)
177 if (*s != ':') 177 if (*s != ':')
178 return -1; 178 return -1;
179 179
180 - /* Stip white space before the colon. */ 180 + // Stip white space before the colon.
181 for (t = s-1; my_isspace(*t); t--) 181 for (t = s-1; my_isspace(*t); t--)
182 *t = '\0'; 182 *t = '\0';
183 183
184 - /* Terminate the left-hand side. */ 184 + // Terminate the left-hand side.
185 *(s++) = '\0'; 185 *(s++) = '\0';
186 186
187 - /* Skip white space after the colon. */ 187 + // Skip white space after the colon.
188 while (*s != '\n' && my_isspace(*s)) 188 while (*s != '\n' && my_isspace(*s))
189 s++; 189 s++;
190 190
191 - /* There must be a right-hand side. */ 191 + // There must be a right-hand side.
192 if (!*s || *s == '\n') 192 if (!*s || *s == '\n')
193 return -1; 193 return -1;
194 194
195 - /* Scan until an unquoted newline is found. */ 195 + // Scan until an unquoted newline is found.
196 *right = s; 196 *right = s;
197 quote = False; 197 quote = False;
198 for (; *s; s++) { 198 for (; *s; s++) {
199 if (*s == '\\' && *(s+1) == '"') 199 if (*s == '\\' && *(s+1) == '"')
200 s++; 200 s++;
201 - else if (*s == '"') 201 + else if (*s == '"')split_dresource
202 quote = !quote; 202 quote = !quote;
203 else if (!quote && *s == '\n') 203 else if (!quote && *s == '\n')
204 break; 204 break;
205 } 205 }
206 206
207 - /* Strip white space before the newline. */ 207 + // Strip white space before the newline.
208 if (*s) { 208 if (*s) {
209 t = s; 209 t = s;
210 *st = s+1; 210 *st = s+1;
@@ -215,27 +215,29 @@ split_dresource(char **st, char **left, char **right) @@ -215,27 +215,29 @@ split_dresource(char **st, char **left, char **right)
215 while (my_isspace(*t)) 215 while (my_isspace(*t))
216 *t-- = '\0'; 216 *t-- = '\0';
217 217
218 - /* Done. */ 218 + // Done.
219 return 1; 219 return 1;
220 } 220 }
  221 +*/
221 222
222 -/**  
223 - * @brief Split a DBCS resource into its parts.  
224 - *  
225 - * Returns the number of parts found:  
226 - * -1 error (empty sub-field)  
227 - * 0 nothing found  
228 - * 1 one and just one thing found  
229 - * 2 two things found  
230 - * 3 more than two things found  
231 - */ 223 +/*
  224 +///
  225 +/// @brief Split a DBCS resource into its parts.
  226 +///
  227 +/// Returns the number of parts found:
  228 +/// -1 error (empty sub-field)
  229 +/// 0 nothing found
  230 +/// 1 one and just one thing found
  231 +/// 2 two things found
  232 +/// 3 more than two things found
  233 +///
232 int 234 int
233 split_dbcs_resource(const char *value, char sep, char **part1, char **part2) 235 split_dbcs_resource(const char *value, char sep, char **part1, char **part2)
234 { 236 {
235 int n_parts = 0; 237 int n_parts = 0;
236 const char *s = value; 238 const char *s = value;
237 - const char *f_start = CN; /* start of sub-field */  
238 - const char *f_end = CN; /* end of sub-field */ 239 + const char *f_start = CN; // start of sub-field
  240 + const char *f_end = CN; // end of sub-field
239 char c; 241 char c;
240 char **rp; 242 char **rp;
241 243
@@ -292,14 +294,16 @@ split_dbcs_resource(const char *value, char sep, char **part1, char **part2) @@ -292,14 +294,16 @@ split_dbcs_resource(const char *value, char sep, char **part1, char **part2)
292 s++; 294 s++;
293 } 295 }
294 } 296 }
  297 +*/
295 298
296 -#if defined(X3270_DISPLAY) /*[*/  
297 -/**  
298 - * @brief List resource splitter, for lists of elements speparated by newlines.  
299 - *  
300 - * Can be called iteratively.  
301 - * Returns 1 for success, 0 for EOF, -1 for error.  
302 - */ 299 +/*
  300 +#if defined(X3270_DISPLAY)
  301 +///
  302 +/// @brief List resource splitter, for lists of elements speparated by newlines.
  303 +///
  304 +/// Can be called iteratively.
  305 +/// Returns 1 for success, 0 for EOF, -1 for error.
  306 +///
303 int 307 int
304 split_lresource(char **st, char **value) 308 split_lresource(char **st, char **value)
305 { 309 {
@@ -307,18 +311,18 @@ split_lresource(char **st, char **value) @@ -307,18 +311,18 @@ split_lresource(char **st, char **value)
307 char *t; 311 char *t;
308 Boolean quote; 312 Boolean quote;
309 313
310 - /* Skip leading white space. */ 314 + // Skip leading white space.
311 while (my_isspace(*s)) 315 while (my_isspace(*s))
312 s++; 316 s++;
313 317
314 - /* If nothing left, EOF. */ 318 + // If nothing left, EOF.
315 if (!*s) 319 if (!*s)
316 return 0; 320 return 0;
317 321
318 - /* Save starting point. */ 322 + // Save starting point.
319 *value = s; 323 *value = s;
320 324
321 - /* Scan until an unquoted newline is found. */ 325 + // Scan until an unquoted newline is found.
322 quote = False; 326 quote = False;
323 for (; *s; s++) { 327 for (; *s; s++) {
324 if (*s == '\\' && *(s+1) == '"') 328 if (*s == '\\' && *(s+1) == '"')
@@ -329,7 +333,7 @@ split_lresource(char **st, char **value) @@ -329,7 +333,7 @@ split_lresource(char **st, char **value)
329 break; 333 break;
330 } 334 }
331 335
332 - /* Strip white space before the newline. */ 336 + // Strip white space before the newline.
333 if (*s) { 337 if (*s) {
334 t = s; 338 t = s;
335 *st = s+1; 339 *st = s+1;
@@ -340,10 +344,11 @@ split_lresource(char **st, char **value) @@ -340,10 +344,11 @@ split_lresource(char **st, char **value)
340 while (my_isspace(*t)) 344 while (my_isspace(*t))
341 *t-- = '\0'; 345 *t-- = '\0';
342 346
343 - /* Done. */ 347 + // Done.
344 return 1; 348 return 1;
345 } 349 }
346 -#endif /*]*/ 350 +#endif
  351 +*/
347 352
348 353
349 /** 354 /**
@@ -375,9 +380,8 @@ ctl_see(int c) @@ -375,9 +380,8 @@ ctl_see(int c)
375 return buf; 380 return buf;
376 } 381 }
377 382
378 -/**  
379 - * @brief Whitespace stripper.  
380 - */ 383 +/*
  384 +/// @brief Whitespace stripper.
381 char * 385 char *
382 strip_whitespace(const char *s) 386 strip_whitespace(const char *s)
383 { 387 {
@@ -394,10 +398,12 @@ strip_whitespace(const char *s) @@ -394,10 +398,12 @@ strip_whitespace(const char *s)
394 } 398 }
395 return t; 399 return t;
396 } 400 }
  401 +*/
397 402
398 -/**  
399 - * @brief Hierarchy (a>b>c) splitter.  
400 - */ 403 +/*
  404 +///
  405 +/// @brief Hierarchy (a>b>c) splitter.
  406 +///
401 Boolean 407 Boolean
402 split_hier(char *label, char **base, char ***parents) 408 split_hier(char *label, char **base, char ***parents)
403 { 409 {
@@ -429,14 +435,14 @@ split_hier(char *label, char **base, char ***parents) @@ -429,14 +435,14 @@ split_hier(char *label, char **base, char ***parents)
429 } 435 }
430 return True; 436 return True;
431 } 437 }
  438 +*/
432 439
433 -/**  
434 - * @brief Incremental, reallocing version of snprintf.  
435 - */ 440 +/*
  441 +/// @brief Incremental, reallocing version of snprintf.
436 #define RPF_BLKSIZE 4096 442 #define RPF_BLKSIZE 4096
437 #define SP_TMP_LEN 16384 443 #define SP_TMP_LEN 16384
438 444
439 -/* Initialize an RPF structure. */ 445 +/// @brief Initialize an RPF structure.
440 void 446 void
441 rpf_init(rpf_t *r) 447 rpf_init(rpf_t *r)
442 { 448 {
@@ -445,18 +451,14 @@ rpf_init(rpf_t *r) @@ -445,18 +451,14 @@ rpf_init(rpf_t *r)
445 r->cur_len = 0; 451 r->cur_len = 0;
446 } 452 }
447 453
448 -/**  
449 - * @brief Reset an initialized RPF structure (re-use with length 0).  
450 - */ 454 +/// @brief Reset an initialized RPF structure (re-use with length 0).
451 void 455 void
452 rpf_reset(rpf_t *r) 456 rpf_reset(rpf_t *r)
453 { 457 {
454 r->cur_len = 0; 458 r->cur_len = 0;
455 } 459 }
456 460
457 -/**  
458 - * @brief Append a string to a dynamically-allocated buffer.  
459 - */ 461 +/// @brief Append a string to a dynamically-allocated buffer.
460 void 462 void
461 rpf(rpf_t *r, char *fmt, ...) 463 rpf(rpf_t *r, char *fmt, ...)
462 { 464 {
@@ -465,14 +467,14 @@ rpf(rpf_t *r, char *fmt, ...) @@ -465,14 +467,14 @@ rpf(rpf_t *r, char *fmt, ...)
465 int ns; 467 int ns;
466 char tbuf[SP_TMP_LEN]; 468 char tbuf[SP_TMP_LEN];
467 469
468 - /* Figure out how much space would be needed. */ 470 + // Figure out how much space would be needed.
469 va_start(a, fmt); 471 va_start(a, fmt);
470 - ns = vsprintf(tbuf, fmt, a); /* XXX: dangerous, but so is vsnprintf */ 472 + ns = vsprintf(tbuf, fmt, a); // XXX: dangerous, but so is vsnprintf
471 va_end(a); 473 va_end(a);
472 if (ns >= SP_TMP_LEN) 474 if (ns >= SP_TMP_LEN)
473 Error(NULL,"rpf overrun"); 475 Error(NULL,"rpf overrun");
474 476
475 - /* Make sure we have that. */ 477 + // Make sure we have that.
476 while (r->alloc_len - r->cur_len < ns + 1) { 478 while (r->alloc_len - r->cur_len < ns + 1) {
477 r->alloc_len += RPF_BLKSIZE; 479 r->alloc_len += RPF_BLKSIZE;
478 need_realloc = True; 480 need_realloc = True;
@@ -481,22 +483,20 @@ rpf(rpf_t *r, char *fmt, ...) @@ -481,22 +483,20 @@ rpf(rpf_t *r, char *fmt, ...)
481 r->buf = Realloc(r->buf, r->alloc_len); 483 r->buf = Realloc(r->buf, r->alloc_len);
482 } 484 }
483 485
484 - /* Scribble onto the end of that. */ 486 + // Scribble onto the end of that.
485 (void) strcpy(r->buf + r->cur_len, tbuf); 487 (void) strcpy(r->buf + r->cur_len, tbuf);
486 r->cur_len += ns; 488 r->cur_len += ns;
487 } 489 }
488 490
489 -/**  
490 - * @brief Free resources associated with an RPF.  
491 - */  
492 -void  
493 -rpf_free(rpf_t *r) 491 +/// @brief Free resources associated with an RPF.
  492 +void rpf_free(rpf_t *r)
494 { 493 {
495 lib3270_free(r->buf); 494 lib3270_free(r->buf);
496 r->buf = NULL; 495 r->buf = NULL;
497 r->alloc_len = 0; 496 r->alloc_len = 0;
498 r->cur_len = 0; 497 r->cur_len = 0;
499 } 498 }
  499 +*/
500 500
501 LIB3270_EXPORT void * lib3270_free(void *p) 501 LIB3270_EXPORT void * lib3270_free(void *p)
502 { 502 {
src/include/utilc.h
@@ -13,24 +13,22 @@ @@ -13,24 +13,22 @@
13 * for more details. 13 * for more details.
14 */ 14 */
15 15
16 -/*  
17 - * utilc.h  
18 - * Global declarations for util.c. 16 +/***
  17 + * @brief Global declarations for util.c.
19 */ 18 */
20 19
21 -LIB3270_INTERNAL void add_resource(const char *name, const char *value);  
22 LIB3270_INTERNAL char *ctl_see(int c); 20 LIB3270_INTERNAL char *ctl_see(int c);
23 -// LIB3270_INTERNAL char *do_subst(const char *s, Boolean do_vars, Boolean do_tilde);  
24 -// LIB3270_INTERNAL void fcatv(FILE *f, char *s); 21 +
  22 + /*
  23 +LIB3270_INTERNAL void add_resource(const char *name, const char *value);
25 LIB3270_INTERNAL const char *get_message(const char *key); 24 LIB3270_INTERNAL const char *get_message(const char *key);
26 LIB3270_INTERNAL const char *get_fresource(H3270 *hSession, const char *fmt, ...) LIB3270_GNUC_FORMAT(2, 3); 25 LIB3270_INTERNAL const char *get_fresource(H3270 *hSession, const char *fmt, ...) LIB3270_GNUC_FORMAT(2, 3);
27 LIB3270_INTERNAL const char *get_resource(H3270 *hSession, const char *name); 26 LIB3270_INTERNAL const char *get_resource(H3270 *hSession, const char *name);
28 -// LIB3270_INTERNAL char *scatv(const char *s, char *buf, size_t len);  
29 -LIB3270_INTERNAL int split_dbcs_resource(const char *value, char sep, char **part1,  
30 - char **part2); 27 +LIB3270_INTERNAL int split_dbcs_resource(const char *value, char sep, char **part1, char **part2);
31 LIB3270_INTERNAL int split_dresource(char **st, char **left, char **right); 28 LIB3270_INTERNAL int split_dresource(char **st, char **left, char **right);
32 LIB3270_INTERNAL int split_lresource(char **st, char **value); 29 LIB3270_INTERNAL int split_lresource(char **st, char **value);
33 LIB3270_INTERNAL char *strip_whitespace(const char *s); 30 LIB3270_INTERNAL char *strip_whitespace(const char *s);
  31 +*/
34 32
35 LIB3270_INTERNAL char *xs_buffer(const char *fmt, ...) LIB3270_GNUC_FORMAT(1, 2); 33 LIB3270_INTERNAL char *xs_buffer(const char *fmt, ...) LIB3270_GNUC_FORMAT(1, 2);
36 LIB3270_INTERNAL void xs_error(const char *fmt, ...) LIB3270_GNUC_FORMAT(1, 2); 34 LIB3270_INTERNAL void xs_error(const char *fmt, ...) LIB3270_GNUC_FORMAT(1, 2);
@@ -44,11 +42,12 @@ LIB3270_INTERNAL void RemoveSource(H3270 *session, void *cookie); @@ -44,11 +42,12 @@ LIB3270_INTERNAL void RemoveSource(H3270 *session, void *cookie);
44 LIB3270_INTERNAL void * AddTimer(unsigned long msec, H3270 *session, int (*fn)(H3270 *session)); 42 LIB3270_INTERNAL void * AddTimer(unsigned long msec, H3270 *session, int (*fn)(H3270 *session));
45 LIB3270_INTERNAL void RemoveTimer(H3270 *session, void *cookie); 43 LIB3270_INTERNAL void RemoveTimer(H3270 *session, void *cookie);
46 44
47 -LIB3270_INTERNAL const char * KeysymToString(KeySym k); 45 +// LIB3270_INTERNAL const char * KeysymToString(KeySym k);
48 46
49 // LIB3270_INTERNAL int read_resource_file(const char *filename, Boolean fatal); 47 // LIB3270_INTERNAL int read_resource_file(const char *filename, Boolean fatal);
50 -LIB3270_INTERNAL Boolean split_hier(char *label, char **base, char ***parents); 48 +// LIB3270_INTERNAL Boolean split_hier(char *label, char **base, char ***parents);
51 49
  50 +/*
52 typedef struct { 51 typedef struct {
53 char *buf; 52 char *buf;
54 int alloc_len; 53 int alloc_len;
@@ -59,6 +58,7 @@ LIB3270_INTERNAL void rpf_init(rpf_t *r); @@ -59,6 +58,7 @@ LIB3270_INTERNAL void rpf_init(rpf_t *r);
59 LIB3270_INTERNAL void rpf_reset(rpf_t *r); 58 LIB3270_INTERNAL void rpf_reset(rpf_t *r);
60 LIB3270_INTERNAL void rpf(rpf_t *r, char *fmt, ...) LIB3270_GNUC_FORMAT(2, 3); 59 LIB3270_INTERNAL void rpf(rpf_t *r, char *fmt, ...) LIB3270_GNUC_FORMAT(2, 3);
61 LIB3270_INTERNAL void rpf_free(rpf_t *r); 60 LIB3270_INTERNAL void rpf_free(rpf_t *r);
  61 +*/
62 62
63 /** 63 /**
64 * @brief "unescape" text (Replaces %value for corresponding character). 64 * @brief "unescape" text (Replaces %value for corresponding character).