"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "libedit/prompt.c" between
tnftp-20151004.tar.gz and tnftp-20200705.tar.gz

About: tnftp is an enhanced ftp client (prior name "lukemftp").

prompt.c  (tnftp-20151004):prompt.c  (tnftp-20200705)
/* $NetBSD: prompt.c,v 1.5 2005/06/09 16:48:58 lukem Exp $ */ /* $NetBSD: prompt.c,v 1.8 2020/07/04 13:43:21 lukem Exp $ */
/* from NetBSD: prompt.c,v 1.11 2003/08/07 16:44:32 agc Exp */ /* from NetBSD: prompt.c,v 1.27 2017/06/27 23:25:13 christos Exp *
/
/*- /*-
* Copyright (c) 1992, 1993 * Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved. * The Regents of the University of California. All rights reserved.
* *
* This code is derived from software contributed to Berkeley by * This code is derived from software contributed to Berkeley by
* Christos Zoulas of Cornell University. * Christos Zoulas of Cornell University.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
skipping to change at line 36 skipping to change at line 36
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
#include "tnftp.h" #include "config.h"
#include "sys.h"
#if 0 /* tnftp */
#if !defined(lint) && !defined(SCCSID)
#if 0
static char sccsid[] = "@(#)prompt.c 8.1 (Berkeley) 6/4/93";
#else
__RCSID(" NetBSD: prompt.c,v 1.27 2017/06/27 23:25:13 christos Exp ");
#endif
#endif /* not lint && not SCCSID */
#endif /* tnftp */
/* /*
* prompt.c: Prompt printing functions * prompt.c: Prompt printing functions
*/ */
#if 0 /* tnftp */
#include <stdio.h> #include <stdio.h>
#endif /* tnftp */
#include "el.h" #include "el.h"
private char *prompt_default(EditLine *); static wchar_t *prompt_default(EditLine *);
private char *prompt_default_r(EditLine *); static wchar_t *prompt_default_r(EditLine *);
/* prompt_default(): /* prompt_default():
* Just a default prompt, in case the user did not provide one * Just a default prompt, in case the user did not provide one
*/ */
private char * static wchar_t *
/*ARGSUSED*/ /*ARGSUSED*/
prompt_default(EditLine *el __attribute__((__unused__))) prompt_default(EditLine *el __attribute__((__unused__)))
{ {
static char a[3] = {'?', ' ', '\0'}; static wchar_t a[3] = L"? ";
return (a); return a;
} }
/* prompt_default_r(): /* prompt_default_r():
* Just a default rprompt, in case the user did not provide one * Just a default rprompt, in case the user did not provide one
*/ */
private char * static wchar_t *
/*ARGSUSED*/ /*ARGSUSED*/
prompt_default_r(EditLine *el __attribute__((__unused__))) prompt_default_r(EditLine *el __attribute__((__unused__)))
{ {
static char a[1] = {'\0'}; static wchar_t a[1] = L"";
return (a); return a;
} }
/* prompt_print(): /* prompt_print():
* Print the prompt and update the prompt position. * Print the prompt and update the prompt position.
* We use an array of integers in case we want to pass
* literal escape sequences in the prompt and we want a
* bit to flag them
*/ */
protected void libedit_private void
prompt_print(EditLine *el, int op) prompt_print(EditLine *el, int op)
{ {
el_prompt_t *elp; el_prompt_t *elp;
char *p; wchar_t *p;
if (op == EL_PROMPT) if (op == EL_PROMPT)
elp = &el->el_prompt; elp = &el->el_prompt;
else else
elp = &el->el_rprompt; elp = &el->el_rprompt;
p = (elp->p_func) (el);
while (*p) if (elp->p_wide)
re_putc(el, *p++, 1); p = (*elp->p_func)(el);
else
p = ct_decode_string((char *)(void *)(*elp->p_func)(el),
&el->el_scratch);
for (; *p; p++) {
if (elp->p_ignore == *p) {
wchar_t *litstart = ++p;
while (*p && *p != elp->p_ignore)
p++;
if (!*p || !p[1]) {
// XXX: We lose the last literal
break;
}
re_putliteral(el, litstart, p++);
continue;
}
re_putc(el, *p, 1);
}
elp->p_pos.v = el->el_refresh.r_cursor.v; elp->p_pos.v = el->el_refresh.r_cursor.v;
elp->p_pos.h = el->el_refresh.r_cursor.h; elp->p_pos.h = el->el_refresh.r_cursor.h;
} }
/* prompt_init(): /* prompt_init():
* Initialize the prompt stuff * Initialize the prompt stuff
*/ */
protected int libedit_private int
prompt_init(EditLine *el) prompt_init(EditLine *el)
{ {
el->el_prompt.p_func = prompt_default; el->el_prompt.p_func = prompt_default;
el->el_prompt.p_pos.v = 0; el->el_prompt.p_pos.v = 0;
el->el_prompt.p_pos.h = 0; el->el_prompt.p_pos.h = 0;
el->el_prompt.p_ignore = '\0';
el->el_rprompt.p_func = prompt_default_r; el->el_rprompt.p_func = prompt_default_r;
el->el_rprompt.p_pos.v = 0; el->el_rprompt.p_pos.v = 0;
el->el_rprompt.p_pos.h = 0; el->el_rprompt.p_pos.h = 0;
return (0); el->el_rprompt.p_ignore = '\0';
return 0;
} }
/* prompt_end(): /* prompt_end():
* Clean up the prompt stuff * Clean up the prompt stuff
*/ */
protected void libedit_private void
/*ARGSUSED*/ /*ARGSUSED*/
prompt_end(EditLine *el __attribute__((__unused__))) prompt_end(EditLine *el __attribute__((__unused__)))
{ {
} }
/* prompt_set(): /* prompt_set():
* Install a prompt printing function * Install a prompt printing function
*/ */
protected int libedit_private int
prompt_set(EditLine *el, el_pfunc_t prf, int op) prompt_set(EditLine *el, el_pfunc_t prf, wchar_t c, int op, int wide)
{ {
el_prompt_t *p; el_prompt_t *p;
if (op == EL_PROMPT) if (op == EL_PROMPT || op == EL_PROMPT_ESC)
p = &el->el_prompt; p = &el->el_prompt;
else else
p = &el->el_rprompt; p = &el->el_rprompt;
if (prf == NULL) { if (prf == NULL) {
if (op == EL_PROMPT) if (op == EL_PROMPT || op == EL_PROMPT_ESC)
p->p_func = prompt_default; p->p_func = prompt_default;
else else
p->p_func = prompt_default_r; p->p_func = prompt_default_r;
} else } else {
p->p_func = prf; p->p_func = prf;
}
p->p_ignore = c;
p->p_pos.v = 0; p->p_pos.v = 0;
p->p_pos.h = 0; p->p_pos.h = 0;
return (0); p->p_wide = wide;
return 0;
} }
/* prompt_get(): /* prompt_get():
* Retrieve the prompt printing function * Retrieve the prompt printing function
*/ */
protected int libedit_private int
prompt_get(EditLine *el, el_pfunc_t *prf, int op) prompt_get(EditLine *el, el_pfunc_t *prf, wchar_t *c, int op)
{ {
el_prompt_t *p;
if (prf == NULL) if (prf == NULL)
return (-1); return -1;
if (op == EL_PROMPT) if (op == EL_PROMPT)
*prf = el->el_prompt.p_func; p = &el->el_prompt;
else else
*prf = el->el_rprompt.p_func; p = &el->el_rprompt;
return (0);
if (prf)
*prf = p->p_func;
if (c)
*c = p->p_ignore;
return 0;
} }
 End of changes. 31 change blocks. 
35 lines changed or deleted 80 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)