Ticket #56381: macports_append_history.patch

File macports_append_history.patch, 3.0 KB (added by ylluminarious (George Plymale II), 6 years ago)

First draft of a patch to fix this issue

  • src/pextlib1.0/readline.c

    diff --git a/src/pextlib1.0/readline.c b/src/pextlib1.0/readline.c
    index e955f8e7..ed9a6b50 100644
    a b int ReadlineCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl_ 
    267267                add line
    268268                read filename
    269269                write filename
     270                append filename
    270271                stifle max
    271272                unstifle
    272273*/
    int RLHistoryCmd(ClientData clientData UNUSED, Tcl_Interp *interp, int objc, Tcl 
    309310                }
    310311                s = Tcl_GetString(objv[2]);
    311312                write_history(s);
     313        }  else if (0 == strcmp("append", action)) {
     314                if (objc != 3) {
     315                        Tcl_WrongNumArgs(interp, 1, objv, "append filename");
     316                        return TCL_ERROR;
     317                }
     318                s = Tcl_GetString(objv[2]);
     319
     320                /* FYI: `append_history' _could_ write more than 1 item at a time here,
     321                 * but that is not necessary for our present usage in src/port/port.tcl.
     322                 * It would also require some different handling of the arg count in
     323                 * this function. */
     324
     325                append_history(1, s);
    312326        } else if (0 == strcmp("stifle", action)) {
    313327                if (objc != 3) {
    314328                        Tcl_WrongNumArgs(interp, 1, objv, "stifle maxlines");
  • src/port/port.tcl

    diff --git a/src/port/port.tcl b/src/port/port.tcl
    old mode 100644
    new mode 100755
    index a71f2cbe..7fb8170a
    a b proc get_next_cmdline { in out use_readline prompt linename } { 
    48444844        set line [string trim $line]
    48454845
    48464846        if { $use_readline && $line ne "" } {
     4847            # Create macports user directory if it does not exist yet
     4848            if {![file isdirectory $macports::macports_user_dir]} {
     4849                file mkdir $macports::macports_user_dir
     4850            }
     4851
     4852            # Add history item to memory...
    48474853            rl_history add $line
     4854            # ... and then append that item to the history file
     4855            rl_history append $history_file
     4856            puts "history is supposed to be written here"
    48484857        }
    48494858    }
    48504859
    proc process_command_file { in } { 
    48644873    if {$use_readline && [file isdirectory $macports::macports_user_dir]} {
    48654874        rl_history read $history_file
    48664875        rl_history stifle 100
     4876        puts "history is supposed to be read here"
    48674877    }
    48684878
    48694879    # Be noisy, if appropriate
    proc process_command_file { in } { 
    48734883        puts "Entering shell mode... (\"help\" for help, \"quit\" to quit)"
    48744884    }
    48754885
     4886    if {$use_readline} {
     4887        puts "this ought to be printed"
     4888    }
     4889
    48764890    # Main command loop
    48774891    set exit_status 0
    48784892    while { $exit_status == 0 || $isstdin || [macports::ui_isset ports_processall] } {
    proc process_command_file { in } { 
    49014915        }
    49024916    }
    49034917
    4904     # Create macports user directory if it does not exist yet
    4905     if {$use_readline && ![file isdirectory $macports::macports_user_dir]} {
    4906         file mkdir $macports::macports_user_dir
    4907     }
    4908     # Save readine history
    4909     if {$use_readline && [file isdirectory $macports::macports_user_dir]} {
    4910         rl_history write $history_file
    4911     }
    4912 
    49134918    # Say goodbye
    49144919    if { $noisy } {
    49154920        puts "Goodbye"