static int TclPrintLocation(ClientData clientData,
Tcl_Interp *interp,
int argc,
- char *argv[]);
+ const char *argv[]);
static int DefaultOutputString(ClientData clientData,
Tcl_Interp *interp,
int argc,
- char *argv[]);
+ const char *argv[]);
static int CompareI18NStrings(ClientData clientData,
Tcl_Interp *interp,
int argc,
- char *argv[]);
+ const char *argv[]);
static int TclReadLocaleStrings(ClientData clientData,
Tcl_Interp *interp,
int argc,
- char *argv[]);
+ const char *argv[]);
char *GetOutFileBaseName();
char *
static int DefaultOutputString(ClientData clientData,
Tcl_Interp *interp,
int argc,
- char *argv[])
+ const char *argv[])
{
-#define LOCAL_BUFFER_LENGTH 128
- char *string, *pString, *pArgv;
- char localBuffer[LOCAL_BUFFER_LENGTH];
- int retCode, stringLength;
+ char *string = NULL, *pString = NULL;
+ const char *pArgv = NULL;
+ int retCode = 0, stringLength = 0;
if (argc < 2) {
Tcl_SetResult(interpreter, "Missing string to output", TCL_VOLATILE);
pArgv = argv[1];
stringLength = (2 * strlen(pArgv)) + 3;
- /* try to use automatic buffer; use malloc if string is too large */
- if (stringLength <= LOCAL_BUFFER_LENGTH) {
- string = localBuffer;
- } else {
- string = malloc(stringLength);
- }
+ string = malloc(stringLength);
+ memset(string, 0, stringLength);
pString = string;
/* put the string to the output */
retCode = Tcl_VarEval(interpreter, "puts -nonewline ", string, 0);
- /* free the string if we're not using the automatic buffer */
- if (string != localBuffer) {
- free(string);
- }
+ free(string);
/* and ripple up any error code we got from the "puts" */
return retCode;
static int CompareI18NStrings(ClientData clientData,
Tcl_Interp *interp,
int argc,
- char *argv[])
+ const char *argv[])
{
int ret_val, len;
char *ret_string, *cp;
static int TclPrintLocation(ClientData clientData,
Tcl_Interp *interp,
int argc,
- char *argv[])
+ const char *argv[])
{
if (argc > 1) {
Tcl_SetResult(interpreter, "Too many arguments", TCL_VOLATILE);
static char *
ReadLocaleStrings(char *file_name, int *ret_code) {
-int fd;
-char *pBuf;
-char *i18nBuf;
-off_t size;
-struct stat stat_buf;
+ int fd;
+ char *pBuf;
+ char *i18nBuf;
+ off_t size;
+ struct stat stat_buf;
fd = open(file_name, O_RDONLY);
if (fd == -1) {
*ret_code = 1;
- return "";
+ return NULL;
}
fstat(fd, &stat_buf);
size = stat_buf.st_size;
- pBuf = malloc(size+1);
- pBuf[size] = 0;
+ pBuf = Tcl_Alloc(size+1);
+ memset(pBuf, 0, size+1);
if (read(fd, pBuf, size) != size) {
*ret_code = 2;
- return "";
+ return NULL;
}
i18nBuf = EscapeI18NChars(pBuf);
static int TclReadLocaleStrings(ClientData clientData,
Tcl_Interp *interp,
int argc,
- char *argv[]) {
-char *pBuf;
-int ret_code;
-char errorBuf[512];
+ const char *argv[]) {
+ char *pBuf;
+ int ret_code;
+ char errorBuf[512];
if (argc > 2) {
Tcl_SetResult(interpreter, "Too many arguments", TCL_VOLATILE);
int track_pos
)
{
- char c, *sdata, *cp;
+ char c = 0, *sdata, *cp;
static int char_pos; /* remembers our character position */
static int interp_pos; /* like char_pos but when output is to interp */
int *ppos; /* points to appropriate line position var */
*/
int FFlush(FILE *stream)
{
-if (stream) return fflush(stream);
-return 0;
+ if (stream) return fflush(stream);
+ return 0;
}
if (result != TCL_OK) {
fprintf(stderr,
"interpreter error \"%s\" at line %d executing:\n",
- interpreter->result,
- interpreter->errorLine);
+ Tcl_GetStringResult(interpreter),
+ Tcl_GetErrorLine(interpreter));
fprintf(stderr, "\"%s\"\n", commandBuf);
return EOF;
}
if (result != TCL_OK) {
fprintf(stderr,
"interpreter error \"%s\" at line %d executing:\n",
- interpreter->result,
- interpreter->errorLine);
+ Tcl_GetStringResult(interpreter),
+ Tcl_GetErrorLine(interpreter));
fprintf(stderr, "\"%s\"\n", pBuff);
if (pBuff != commandBuf) free(pBuff);
return EOF;