|
7 | 7 | *
|
8 | 8 | *
|
9 | 9 | * IDENTIFICATION
|
10 |
| - * $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclCmds.c,v 1.36 1998/10/01 01:45:38 tgl Exp $ |
| 10 | + * $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclCmds.c,v 1.37 1998/10/02 01:37:17 tgl Exp $ |
11 | 11 | *
|
12 | 12 | *-------------------------------------------------------------------------
|
13 | 13 | */
|
@@ -240,21 +240,23 @@ int
|
240 | 240 | Pg_conndefaults(ClientData cData, Tcl_Interp * interp, int argc, char **argv)
|
241 | 241 | {
|
242 | 242 | PQconninfoOption *option;
|
243 |
| - char buf[8192]; |
| 243 | + Tcl_DString result; |
| 244 | + char ibuf[32]; |
244 | 245 |
|
245 |
| - Tcl_ResetResult(interp); |
| 246 | + Tcl_DStringInit(&result); |
246 | 247 | for (option = PQconndefaults(); option->keyword != NULL; option++)
|
247 | 248 | {
|
248 |
| - if (option->val == NULL) |
249 |
| - option->val = ""; |
250 |
| - sprintf(buf, "{%s} {%s} {%s} %d {%s}", |
251 |
| - option->keyword, |
252 |
| - option->label, |
253 |
| - option->dispchar, |
254 |
| - option->dispsize, |
255 |
| - option->val); |
256 |
| - Tcl_AppendElement(interp, buf); |
257 |
| - } |
| 249 | + char * val = option->val ? option->val : ""; |
| 250 | + sprintf(ibuf, "%d", option->dispsize); |
| 251 | + Tcl_DStringStartSublist(&result); |
| 252 | + Tcl_DStringAppendElement(&result, option->keyword); |
| 253 | + Tcl_DStringAppendElement(&result, option->label); |
| 254 | + Tcl_DStringAppendElement(&result, option->dispchar); |
| 255 | + Tcl_DStringAppendElement(&result, ibuf); |
| 256 | + Tcl_DStringAppendElement(&result, val); |
| 257 | + Tcl_DStringEndSublist(&result); |
| 258 | + } |
| 259 | + Tcl_DStringResult(interp, &result); |
258 | 260 |
|
259 | 261 | return TCL_OK;
|
260 | 262 | }
|
|
0 commit comments