Menu

#1734 'help lo' doesn't have 'logscale' in its list

None
closed-accepted
nobody
None
2016-02-24
2016-02-01
Dan Sebald
No

It took me quite a few minutes to figure out what the keyword is for controling the logarithmic scale of an axis. Of course, 'logscale' is pretty obvious. However, the keyword doesn't show up anywhere common, and 'help log' displays no list because 'log' is a keyword. However, shouldn't 'logscale' be in the following list?:

gnuplot> help lo
Ambiguous request 'lo'; possible matches:
    load
    locale
    log
    lower

Discussion

  • Dan Sebald

    Dan Sebald - 2016-02-01

    I just noticed another, 'timefmt' doesn't show up:

    gnuplot> help ti
    Ambiguous request 'ti'; possible matches:
        tics
        tikz
        time
        tips
        title
    

    but

    gnuplot> help timefmt
     This command applies to timeseries where data are composed of dates/times.
     It has no meaning unless the command `set *data time` is given also.
    

    Is it that these have simply been overlooked in the gnuplot.doc file? Or is there something in the 'help' algorithm code that overlooks them because there is another keyword that is a precursor sub word of those longer keywords?

     
  • Ethan Merritt

    Ethan Merritt - 2016-02-01

    Beats me. Both 'timefmt' and 'logscale' are fully present in gnuplot.doc so far as I can see. So I guess the oddness is in the code rather than in the doc file.

     
  • Dan Sebald

    Dan Sebald - 2016-02-01

    It is probably this hunk of code in help.c that prints out the list:

            /* So this key matches the first one, up to len.
             * But is it different enough from the previous one
             * to bother printing it as a separate choice?
             */
            sublen = strcspn(prev + len, " ");
            if (strncmp(key->key, prev, len + sublen) != 0) {
            /* yup, this is different up to the next space */
            if (!status) {
    

    That comment sort of explains why it is weeding out some ambiguous options, but I think the algorithm isn't quite matching the underlying logic. I haven't investigated, but I suspect that the "log", "logscale" test with strcspn comes out as "sublen" of 0 so that the next strncmp() indicates no difference. I don't think that is the proper thing to do. (BTW, given it is only comparing against the previous, I assume this list of keywords is first sorted alphabetically.)

     

    Last edit: Dan Sebald 2016-02-01
  • Dan Sebald

    Dan Sebald - 2016-02-03

    I took a look at this a little while ago. Attached is a one line change where the length to the next whitespace is gotten from the current key, not the previous. I'm assuming these keys are first sorted so that the shorter key comes ahead of the longer key. I don't know quite what the thought was for the way it was programmed, but definitely don't want to rule out so many conceptually unique keys just because there is a key that is a pre-cursor. Perhaps the idea was to catch things like "find" and "find needle".

    Anyway, here is the behavior prior to the patch:

    gnuplot> help lo
    Ambiguous request 'lo'; possible matches:
        load
        locale
        log
        lower
    

    and behavior after the patch:

    gnuplot> help lo
    Ambiguous request 'lo'; possible matches:
        load
        loadpath
        locale
        log
        log10
        logscale
        lower
    
     
  • Ethan Merritt

    Ethan Merritt - 2016-02-04
    • status: open --> pending-accepted
    • Group: -->
    • Priority: -->
     
  • Ethan Merritt

    Ethan Merritt - 2016-02-04

    OK. Let's try it. If people run into problems I guess we'll eventually hear about it.

     
  • Ethan Merritt

    Ethan Merritt - 2016-02-24
    • status: pending-accepted --> closed-accepted
     

Log in to post a comment.