Changeset 10 for trunk/txlib/txscript.c
- Timestamp:
- 02/22/06 13:03:35 (3 years ago)
- Files:
-
- 1 modified
-
trunk/txlib/txscript.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/txlib/txscript.c
r5 r10 50 50 #define TXSC_P_PROMPT ";;prompt" 51 51 #define TXSC_P_ERRORS ";;error" 52 53 #define TXSC_PARAMS 10 // substitutable parameters 52 54 53 55 static char *runhelp[] = … … 105 107 }; 106 108 #endif 107 108 109 // Substitute $n parameters in a string by supplied values; n = 0..9110 static ULONG txsSubstituteParams // RET nr of substitutions111 (112 char *string, // IN base string113 char **values, // IN values to substitute114 char *result // OUT substituted (MAXLIN)115 );116 109 117 110 … … 184 177 TxRepl( scrline, '\n', '\0'); 185 178 TxRepl( scrline, '\r', '\0'); // mainly for Linux/Unix ... 186 txsSubstituteParams( scrline, params, command); 179 txsSubstituteParams( scrline, params, TXSC_PARAMS, 180 TXMAXLN, command); 187 181 188 182 if ( (strlen( command) > 0) && // not empty, and … … 413 407 /*---------------------------------------------------------------------------*/ 414 408 415 /*****************************************************************************/ 416 // Substitute $n parameters in a string by supplied values; n = 0..9 417 /*****************************************************************************/ 418 static ULONG txsSubstituteParams // RET nr of substitutions 409 410 /*****************************************************************************/ 411 // Substitute $n parameters in a string by supplied values; n = 0..9 (maximum) 412 /*****************************************************************************/ 413 ULONG txsSubstituteParams // RET nr of substitutions 419 414 ( 420 415 char *string, // IN base string 421 416 char **values, // IN values to substitute 417 int count, // IN number of values 418 int size, // IN size of output buffer 422 419 char *result // OUT substituted (MAXLIN) 423 420 ) … … 438 435 bs++; // skip $ 439 436 si = (int) ((*bs) - '0'); // index 0..9 440 if (values[si] != NULL) // value available ? 437 if ((si < count) && 438 (values[si] != NULL)) // value available ? 441 439 { 442 440 rl += strlen( values[si]); 443 if (rl < TXMAXLN)// room to grow ?441 if (rl < size) // room to grow ? 444 442 { 445 443 strcpy( rs, values[si]); // copy value