On Mon, Oct 02, 2023 at 04:35:47PM +0800, Qian Yun wrote:
> In HyperDoc, when using search functionality, for example:
> click "Browse" -> type "Integer" in search bar -> click "Reference"
> The result page is sorting matching count by only 1 digit:
> 
> The underlying shell command is:
> 
>     $FRICAS/lib/hthits Integer $FRICAS/share/hypertex/pages/ht.db  | sort -r
> -n -k 1.22

AFAICS this is "off by one" error, sort command should be
                                                                               
    sort -r -n -k 1.23

<snip>

> This can be fixed by following patch.
> 
> - Qian
> 
> 
> diff --git a/src/hyper/htsearch b/src/hyper/htsearch
> index 8958c89b..24e67d38 100755
> --- a/src/hyper/htsearch
> +++ b/src/hyper/htsearch
> @@ -8,5 +8,5 @@ if test -z "$1"
>  then
>          echo ""|$htbindir/presea use_case=1 -
>  else
> -( cd $htpagedir; $htbindir/hthits "$1" $htpagedir/ht.db |sort -r -n -k 1.22
> |$htbindir/presea use_case=0 expr="$1" -)
> +( cd $htpagedir; $htbindir/hthits "$1" $htpagedir/ht.db |sort -r -n -t { -k
> 2 |$htbindir/presea use_case=0 expr="$1" -)
>  fi

You propose to use 'sort -r -n -t { -k 2'.  Assuming that this works           
as intended it shoud be independent of count of characters, which is           
good.  However, Posix contains the following definition of '-t':               
                                                                               
   -t  char                                                                    
          Use char as the field separator character; char shall not be         
          considered to be part of a field (although it can be included        
          in a sort key). Each occurrence of char shall be significant         
                                                                               
The phrase "although it can be included in a sort key" suggests that           
some implementations of 'sort' include separator char as part of the           
field, this would defeat the purpose.  Given the spec using counts             
looks safer.

-- 
                              Waldek Hebisch

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to fricas-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/fricas-devel/ZSK9zKSQC9JAisue%40fricas.org.

Reply via email to