Index: tclreadline.c ================================================================== --- tclreadline.c +++ tclreadline.c @@ -1,14 +1,14 @@ - /* ================================================================== - FILE: tclreadline.c - $Id$ - --- - tclreadline -- gnu readline for tcl - http://www.zellner.org/tclreadline/ - Copyright (c) 1998 - 2014, Johannes Zellner - This software is copyright under the BSD license. - ================================================================== */ + /* ================================================================== * + * FILE: tclreadline.c + * $Id$ + * --- + * tclreadline -- gnu readline for tcl + * http://www.zellner.org/tclreadline/ + * Copyright (c) 1998 - 2014, Johannes Zellner + * This software is copyright under the BSD license. + * ================================================================== */ #ifdef HAVE_CONFIG_H # include "config.h" #endif @@ -48,12 +48,12 @@ #define MALLOC(size) malloc(size) #define FREE(ptr) free(ptr); ptr = NULL enum { - _CMD_SET = (1 << 0), - _CMD_GET = (1 << 1) + _CMD_SET = (1 << 0), + _CMD_GET = (1 << 1) }; typedef struct cmds_t { struct cmds_t* prev; @@ -62,45 +62,47 @@ } cmds_t; #define ISWHITE(c) ((' ' == c) || ('\t' == c) || ('\n' == c)) -/* forward declarations. */ -static char* stripleft(char* in); -static char* stripright(char* in); -static char* stripwhite(char* in); -static int TclReadlineLineComplete(void); -static void TclReadlineTerminate(int state); -static char* TclReadlineQuote(char* text, char* quotechars); -static int TclReadlineCmd(ClientData clientData, Tcl_Interp *interp, int objc, - Tcl_Obj *CONST objv[]); -static void TclReadlineReadHandler(ClientData clientData, int mask); -static void TclReadlineLineCompleteHandler(char* ptr); -static int TclReadlineInitialize(Tcl_Interp* interp, char* historyfile); -static int blank_line(char* str); +/** + * forward declarations + */ +static char* stripleft(char* in); +static char* stripright(char* in); +static char* stripwhite(char* in); +static int TclReadlineLineComplete(void); +static void TclReadlineTerminate(int state); +static char* TclReadlineQuote(char* text, char* quotechars); +static int TclReadlineCmd(ClientData clientData, Tcl_Interp *interp, int objc, + Tcl_Obj *CONST objv[]); +static void TclReadlineReadHandler(ClientData clientData, int mask); +static void TclReadlineLineCompleteHandler(char* ptr); +static int TclReadlineInitialize(Tcl_Interp* interp, char* historyfile); +static int blank_line(char* str); static char** TclReadlineCompletion(char* text, int start, int end); -static char* TclReadline0generator(char* text, int state); -static char* TclReadlineKnownCommands(char* text, int state, int mode); -static int TclReadlineParse(char** args, int maxargs, char* buf); +static char* TclReadline0generator(char* text, int state); +static char* TclReadlineKnownCommands(char* text, int state, int mode); +static int TclReadlineParse(char** args, int maxargs, char* buf); enum { - LINE_PENDING = -1, - LINE_EOF = (1 << 8), + LINE_PENDING = -1, + LINE_EOF = (1 << 8), LINE_COMPLETE = (1 << 9) }; /** * global variables */ -static int tclrl_state = TCL_OK; -static char* tclrl_eof_string = (char*) NULL; -static char* tclrl_custom_completer = (char*) NULL; -static char* tclrl_last_line = (char*) NULL; -static int tclrl_use_builtin_completer = 1; -static int tclrl_history_length = -1; -Tcl_Interp* tclrl_interp = (Tcl_Interp*) NULL; +static int tclrl_state = TCL_OK; +static char* tclrl_eof_string = (char*) NULL; +static char* tclrl_custom_completer = (char*) NULL; +static char* tclrl_last_line = (char*) NULL; +static int tclrl_use_builtin_completer = 1; +static int tclrl_history_length = -1; +Tcl_Interp* tclrl_interp = (Tcl_Interp*) NULL; static char* tclrl_license = " Copyright (c) 1998 - 2000, Johannes Zellner \n" " All rights reserved.\n" " \n" Index: tclreadline.h.in ================================================================== --- tclreadline.h.in +++ tclreadline.h.in @@ -1,14 +1,14 @@ - /* ================================================================== - FILE: tclreadline.h.in - $Id$ - --- - tclreadline -- gnu readline for tcl - http://www.zellner.org/tclreadline/ - Copyright (c) 1998 - 2014, Johannes Zellner - This software is copyright under the BSD license. - ================================================================== */ + /* ================================================================== * + * FILE: tclreadline.h.in + * $Id$ + * --- + * tclreadline -- gnu readline for tcl + * http://www.zellner.org/tclreadline/ + * Copyright (c) 1998 - 2014, Johannes Zellner + * This software is copyright under the BSD license. + * ================================================================== */ #ifndef TCLREADLINE_H_ #define TCLREADLINE_H_ #include Index: tclshrl.c ================================================================== --- tclshrl.c +++ tclshrl.c @@ -1,59 +1,53 @@ - /* ================================================================== - FILE: tclshrl.c - $Id$ - --- - tclreadline -- gnu readline for tcl - http://www.zellner.org/tclreadline/ - Copyright (c) 1998 - 2014, Johannes Zellner - This software is copyright under the BSD license. - ================================================================== */ + /* ================================================================== * + * FILE: tclshrl.c + * $Id$ + * --- + * tclreadline -- gnu readline for tcl + * http://www.zellner.org/tclreadline/ + * Copyright (c) 1998 - 2014, Johannes Zellner + * This software is copyright under the BSD license. + * ================================================================== */ #ifdef HAVE_CONFIG_H -# include "config.h" +# include "config.h" #endif +#include #include #include -#if 0 -#include -#endif - extern int Tclreadline_Init(Tcl_Interp *interp); extern int Tclreadline_SafeInit(Tcl_Interp *interp); int TclreadlineAppInit(Tcl_Interp* interp) { char file[0xff]; int status; -#if 0 - assert(Tcl_InitStubs(interp, TCL_VERSION, 0)); -#endif if (TCL_ERROR == Tcl_Init(interp)) { return TCL_ERROR; } if (TCL_ERROR == Tclreadline_Init(interp)) { return TCL_ERROR; } Tcl_StaticPackage(interp, "tclreadline", - Tclreadline_Init, Tclreadline_SafeInit); + Tclreadline_Init, Tclreadline_SafeInit); #if (TCL_MAJOR_VERSION == 7) && (TCL_MINOR_VERSION == 4) tcl_RcFileName = "~/.tclshrc"; #else Tcl_SetVar(interp, "tcl_rcFileName", "~/.tclshrc", TCL_GLOBAL_ONLY); #endif sprintf(file, "%s/tclreadlineInit.tcl", TCLRL_LIBRARY); if ((status = Tcl_EvalFile(interp, file))) { fprintf(stderr, "(TclreadlineAppInit) unable to eval %s\n", file); - exit (1); + exit (EXIT_FAILURE); } return TCL_OK; } int main(int argc, char *argv[]) { Tcl_Main(argc, argv, TclreadlineAppInit); - return 0; + return EXIT_SUCCESS; } Index: wishrl.c ================================================================== --- wishrl.c +++ wishrl.c @@ -1,19 +1,20 @@ - /* ================================================================== - FILE: wishrl.c - $Id$ - --- - tclreadline -- gnu readline for tcl - http://www.zellner.org/tclreadline/ - Copyright (c) 1998 - 2014, Johannes Zellner - This software is copyright under the BSD license. - ================================================================== */ + /* ================================================================== * + * FILE: wishrl.c + * $Id$ + * --- + * tclreadline -- gnu readline for tcl + * http://www.zellner.org/tclreadline/ + * Copyright (c) 1998 - 2014, Johannes Zellner + * This software is copyright under the BSD license. + * ================================================================== */ #ifdef HAVE_CONFIG_H -# include "config.h" +# include "config.h" #endif +#include #include #include #include extern int Tclreadline_Init(Tcl_Interp *interp); @@ -42,16 +43,16 @@ Tcl_SetVar(interp, "tcl_rcFileName", "~/.wishrc", TCL_GLOBAL_ONLY); #endif sprintf(file, "%s/tclreadlineInit.tcl", TCLRL_LIBRARY); if ((status = Tcl_EvalFile(interp, file))) { fprintf(stderr, "(TclreadlineAppInit) unable to eval %s\n", file); - exit (1); + exit (EXIT_FAILURE); } return TCL_OK; } int main(int argc, char *argv[]) { Tk_Main(argc, argv, TclreadlineAppInit); - return 0; + return EXIT_SUCCESS; }