On Tue, Oct 02, 2001 at 10:22:59AM +0400, Alexander V. Lukyanov wrote:
> What's the purpose of this?
> + ArgV arg(argc, argv);
Er, it doesn't seem to have one. Delete it.
> > misc.cc code to do the real work. (This could possibly be improved
> > to make it usable for the main tokenizer.)
>
> I don't think main tokenizer can use that. It has to handle
> redirections, pipes and other things.
That's what I mean by improving it; making it parse "xx&&yy" into three
tokens, handle escapes and quotes, etc.
> BTW, this tokenize function does not handle multiple spaces between words.
> Where do you plan to use this tokenizer?
Currently it's only used for parsing cls and completion options, which
have defaults in two config variables.
> fd can be -1 for some time, until the file is actually opened.
> So isatty should return one of yes/no/don't know yet. Fortunately
> lftp does not open terminal devices unless user does not specify one,
> so probably this does not matter much. Anyway, use getfd() and check
> for fd==-1. The same applies to width().
Well, width() is a bit more code; if you don't want it in FDStream, I'd
recommend something like (untested)
int FdWidth(int fd)
{
if(fd == -1) return -1;
#ifdef TIOCGWINSZ
struct winsize sz;
sz.ws_col=sz.ws_row=0;
ioctl(fd,TIOCGWINSZ,&sz);
if(sz.ws_col==0)
sz.ws_col=80;
return(sz.ws_col);
#else /* !TIOCGWINSZ */
return 80;
#endif
}
in misc.cc. (This could be folded into StatusLine.cc.) Drop isatty()
if you want, it's just a convenience function.
> BTW, you have added this comment in CmdExec::MakePrompt:
> + /* Er, this is what the code was doing, but I don't think the extra \001
> + * should be there ... */
> + StartIgn[0] = '\001';
> + StartIgn[1] = RL_PROMPT_START_IGNORE;
> + StartIgn[2] = 0;
> + EndIgn[0] = '\001';
> + EndIgn[1] = RL_PROMPT_END_IGNORE;
> + EndIgn[2] = 0;
>
> The extra \001 is added because so does bash. If it is a bug, bash should
> be fixed too.
Well, RL_PROMPT_START_IGNORE *is* '\001' itself, so it might be some
kind of workaround; perhaps some older readlines choked on
RL_PROMPT_END_IGNORE without a preceeding RL_PROMPT_START_IGNORE or
something. Doubt it can do any harm.
Want to apply the rest, and nuke the things above (extra ArgV line,
isatty(), width(), and that comment if you want)? It'd take me a while
to reedit that patch. (diff doesn't like letting me edit the content
of patches other than to delete hunks ...)
Oh, and I found a couple bugs in tokenize() while bashing on it today;
fixes forthcoming.
--
Glenn Maynard