Menu

#2504 Copypasting into wgnuplot

open
nobody
2023-07-27
2022-02-24
No

When a tab character is pasted into the wgnuplot terminal, it is marked with the hat symbol as "invalid character", and omitted. It used to trigger the tab autocompletion in earlier versions, and two pasted tabstops still trigger the autocompletion in gnuplot.exe.
So any nicely indented gnuplot script or tab separated dataset from the web first needs to go into an editor to replace the tabs by spaces.

And I recently noticed that unix LF line endings are silently swallowed on pasting, so everything ends up in one line.

Other characters with ascii code <32 might be similarly problematic, but normally don't occur in text.

The problem isn't exactly new. I understand that on windows, gnuplot by default is compiled using its own libreadline replacement, is that right?

Discussion

  • Karl Ratzsch

    Karl Ratzsch - 2022-07-18

    @markisch An error with tab completion upon pasting occured before https://sourceforge.net/p/gnuplot/bugs/1444/
    You wrote it was fixed at the time, but it seems to have crept back in after five years. ;)

     
  • Ethan Merritt

    Ethan Merritt - 2022-07-18

    Could this be related to the change I had to make for linux? The symptoms sound similar.
    The world seems to have decided that the input layer should "sanitize" the buffer used for copy/paste. I had to disable this in order to use readline 8, and maybe Windows needs an equivalent?

    commit 1e08023efd633bf74022e6c443536276ab69ab24
    Author: Ethan A Merritt <merritt@u.washington.edu>
    Date:   Wed Jan 19 22:12:22 2022 -0800
    
        readline:  disable bracketed paste mode on program entry
    
        Readline version 8.1 began enabling bracketed paste mode by default.
        This mode clobbers gnuplot's parsing of multi-line pasted input
        because it looks like a single long line, effectively removing all
        newlines. This mode can be disabled globally by placing a line
            set enable-bracketed-paste off
        in /etc/inputrc or (if INPUTRC is set appropriately) in ~/.inputrc.
        However both of these options require user or sysadmin intervention.
        Better to turn it off in gnuplot itself, immediately on entry.
    
     
  • Tatsuro MATSUOKA

    Sorry the late reply.

    I understand that on windows, gnuplot by default is compiled using its own libreadline replacement, is that right?

    Yes. In config/mingw/Makefile

    # Uncomment if console mode gnuplot should use GNU readline
    # (not recommended)
    #GNUREADLINE=1
    

    The gnuplot binary distributions have been built without the external readline (keeping the comment out)

    An Karl said, text editing on the wgnuplot console has a lot of problems and problems are not easy to fix.

     

    Last edit: Tatsuro MATSUOKA 2023-03-20
  • Ethan Merritt

    Ethan Merritt - 2023-07-27

    I think the attached patch would fix this by ignoring non-printing characters in the input.
    But it seems to me that this is treating the symptom rather than the problem.
    How is this strange character getting into the input buffer?

    diff --git a/src/scanner.c b/src/scanner.c
    index f22c0d7e8..a491d5cb2 100644
    --- a/src/scanner.c
    +++ b/src/scanner.c
    @@ -115,6 +115,11 @@ scanner(char **expressionp, size_t *expressionlenp)
         }
         if (isspace((unsigned char) expression[current]))
             continue;       /* skip the whitespace */
    +
    +    /* Ignore non-printing characters (Bug #2504) */
    +    if (((unsigned char)(expression[current]) & 0xF0) == 0x10)
    +        continue;
    +
         token[t_num].start_index = current;
         token[t_num].length = 1;
         token[t_num].is_token = TRUE;   /* to start with... */
    

    And here is a short script that tests it:

    print "Test insertion of a non-printing byte in the input command line"
    A = "A"
    do for [i=16:31] {
        command = sprintf("print 'testing insertion of 0x%0x before A, ', %c A", i, i)
        eval(command)
    }
    
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.