Ticket #32858: tclreadline.patch
File tclreadline.patch, 3.2 KB (added by gustafn, 13 years ago) |
---|
-
tclreadline.
old new 49 49 static const char* tclrl_version_str = TCLRL_VERSION_STR; 50 50 static const char* tclrl_patchlevel_str = TCLRL_PATCHLEVEL_STR; 51 51 52 #define MALLOC(size) Tcl_Alloc((int) size)53 #define FREE(ptr) if (ptr) { Tcl_Free((char*) ptr); ptr = 0; }54 55 52 enum { 56 53 _CMD_SET = (1 << 0), 57 54 _CMD_GET = (1 << 1) … … 343 340 return TCL_ERROR; 344 341 } else if (3 == objc) { 345 342 if (tclrl_custom_completer) 346 FREE(tclrl_custom_completer);343 free(tclrl_custom_completer); 347 344 if (!blank_line(Tcl_GetStringFromObj(objv[2], 0))) 348 345 tclrl_custom_completer = 349 346 stripwhite(strdup(Tcl_GetStringFromObj(objv[2], 0))); … … 378 375 return TCL_ERROR; 379 376 } else if (3 == objc) { 380 377 if (tclrl_eof_string) 381 FREE(tclrl_eof_string);378 free(tclrl_eof_string); 382 379 if (!blank_line(Tcl_GetStringFromObj(objv[2], 0))) 383 380 tclrl_eof_string = 384 381 stripwhite(strdup(Tcl_GetStringFromObj(objv[2], 0))); … … 544 541 * tell the calling routines to terminate. 545 542 */ 546 543 TclReadlineTerminate(LINE_COMPLETE); 547 FREE(ptr);548 FREE(expansion);544 free(ptr); 545 free(expansion); 549 546 } 550 547 } 551 548 … … 673 670 strcpy(rl_line_buffer, expansion); 674 671 rl_end = strlen(expansion); 675 672 rl_point += strlen(expansion) - oldlen; 676 FREE(expansion);673 free(expansion); 677 674 /* 678 675 * TODO: 679 676 * because we return 0 == matches, … … 682 679 */ 683 680 return matches; 684 681 } 685 FREE(expansion);682 free(expansion); 686 683 } 687 684 688 685 if (tclrl_custom_completer) { … … 699 696 state = Tcl_VarEval(tclrl_interp, tclrl_custom_completer, 700 697 " \"", quoted_text, "\" ", start_s, " ", end_s, 701 698 " \"", quoted_rl_line_buffer, "\"", (char*) NULL); 702 FREE(quoted_text);703 FREE(quoted_rl_line_buffer);699 free(quoted_text); 700 free(quoted_rl_line_buffer); 704 701 if (TCL_OK != state) { 705 702 Tcl_AppendResult (tclrl_interp, " `", tclrl_custom_completer, 706 703 " \"", quoted_text, "\" ", start_s, " ", end_s, … … 715 712 716 713 if (objc) { 717 714 int i, length; 718 matches = (char**) MALLOC(sizeof(char*) * (objc + 1));715 matches = (char**) malloc(sizeof(char*) * (objc + 1)); 719 716 for (i = 0; i < objc; i++) { 720 717 matches[i] = strdup(Tcl_GetStringFromObj(objv[i], &length)); 721 718 if (1 == objc && !strlen(matches[i])) { 722 FREE(matches[i]);723 FREE(matches);719 free(matches[i]); 720 free(matches); 724 721 Tcl_ResetResult(tclrl_interp); /* clear result space */ 725 722 return (char**) NULL; 726 723 } … … 735 732 */ 736 733 if (2 == objc && !strlen(matches[1])) { 737 734 i--; 738 FREE(matches[1]);735 free(matches[1]); 739 736 rl_completion_append_character = '\0'; 740 737 } 741 738 … … 775 772 776 773 case _CMD_SET: 777 774 778 new = (cmds_t *) MALLOC(sizeof(cmds_t));775 new = (cmds_t *) malloc(sizeof(cmds_t)); 779 776 new->next = (cmds_t *) NULL; 780 777 781 778 if (!cmds) { … … 790 787 tmp = strdup(text); 791 788 argc = TclReadlineParse(args, sizeof(args), tmp); 792 789 793 new->cmd = (char**) MALLOC(sizeof(char*) * (argc + 1));790 new->cmd = (char**) malloc(sizeof(char*) * (argc + 1)); 794 791 795 792 for (i = 0; i < argc; i++) 796 793 new->cmd[i] = args[i];