[sac-dev] [patch] Use a pager to show the help files

Brian Savage savage at uri.edu
Sun Sep 14 09:04:13 PDT 2008


Kuang He

Looking over the patches I have a couple of suggestions/comments.

Could we use ANSI C syntax rather than K&R for function declarations.   
This would allow for the easy creation of header files by copying and  
it is a current/standard notation.

Pager use: We need to check the system for the less command on  
compilation.  In fact we could check for less, then more, then  
fallback to the original code in sac.  A change like this might allow  
for syntax highlighting in the help files.  This would mean the  
current paging code needs to be made into a seperate function.  The  
pager value could always be checked for to override the default.

Cheers
Brian

On Sep 14, 2008, at 3:41 AM, "Kuang He" <icrazy at gmail.com> wrote:

> Hi all,
>
> Attached is a patch (against v101.2) to make SAC use a pager specified
> by environment variable $PAGER, instead of the current home-grown tool
> similar to ``more'', to show the help files. The good thing is that in
> this way, people get to use their favorite pager when viewing the help
> files. I personally use ``less'', and its biggest advantage over
> ``more'' is that it can support scrolling backwards using hotkeys like
> Up Arrow, PageDown, Ctrl+U, k, etc. Plus, I get to scroll either way
> by a few lines or by half a page, i.e. not necessarily by a whole
> page.
>
> Known caveat:
>
> - When the user have an unreasonable setting of $PAGER, the error
> message of not being able to load the pager might be a bit mysterious
> to the users.
>
> $ export PAGER=xxx
> $ sac
> SAC> h fg
> sh: xxx: not found
>
> - I did not check the return value of malloc() in my code, since I was
> hoping someone could come up with a uniform way of reporting malloc()
> errors so that we could all stick to it. One possible way is to have a
> warpper function to malloc(), and use that instead of malloc() all the
> time. And yes, I am aware that there are SO MANY malloc()'s in the
> code, whose return values have not been checked!
>
> void *
> xmalloc(size_t size)
> {
>    void *p;
>
>    if ((p = malloc(size)) == NULL)
>        fprintf(stderr, "Malloc failed: %s", strerror(errno));
>    return (p);
> }
>
>
> Best regards,
>
> -- 
> Kuang He
> Department of Physics
> University of Connecticut
> Storrs, CT 06269-3046
>
> Tel: +1.860.486.4919
> Web: http://www.phys.uconn.edu/~he/
> <pager-help-file.diff>
> _______________________________________________
> sac-dev mailing list
> sac-dev at iris.washington.edu
> http://www.iris.washington.edu/mailman/listinfo/sac-dev


More information about the sac-dev mailing list