Deleted Added
full compact
util.c (58314) util.c (75409)
1/* $FreeBSD: head/contrib/libreadline/util.c 58314 2000-03-19 22:00:57Z ache $ */
1/* $FreeBSD: head/contrib/libreadline/util.c 75409 2001-04-11 03:15:56Z ache $ */
2/* util.c -- readline utility functions */
3
4/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc.
5
6 This file is part of the GNU Readline Library, a library for
7 reading lines of text with interactive input and history editing.
8
9 The GNU Readline Library is free software; you can redistribute it

--- 53 unchanged lines hidden (view full) ---

63/* Utility Functions */
64/* */
65/* **************************************************************** */
66
67/* Return 0 if C is not a member of the class of characters that belong
68 in words, or 1 if it is. */
69
70int _rl_allow_pathname_alphabetic_chars = 0;
2/* util.c -- readline utility functions */
3
4/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc.
5
6 This file is part of the GNU Readline Library, a library for
7 reading lines of text with interactive input and history editing.
8
9 The GNU Readline Library is free software; you can redistribute it

--- 53 unchanged lines hidden (view full) ---

63/* Utility Functions */
64/* */
65/* **************************************************************** */
66
67/* Return 0 if C is not a member of the class of characters that belong
68 in words, or 1 if it is. */
69
70int _rl_allow_pathname_alphabetic_chars = 0;
71static char *pathname_alphabetic_chars = "/-_=~.#$";
71static const char *pathname_alphabetic_chars = "/-_=~.#$";
72
73int
72
73int
74alphabetic (c)
74rl_alphabetic (c)
75 int c;
76{
77 if (ALPHABETIC (c))
78 return (1);
79
80 return (_rl_allow_pathname_alphabetic_chars &&
81 strchr (pathname_alphabetic_chars, c) != NULL);
82}
83
84/* How to abort things. */
85int
86_rl_abort_internal ()
87{
75 int c;
76{
77 if (ALPHABETIC (c))
78 return (1);
79
80 return (_rl_allow_pathname_alphabetic_chars &&
81 strchr (pathname_alphabetic_chars, c) != NULL);
82}
83
84/* How to abort things. */
85int
86_rl_abort_internal ()
87{
88 ding ();
88 rl_ding ();
89 rl_clear_message ();
90 _rl_init_argument ();
89 rl_clear_message ();
90 _rl_init_argument ();
91 rl_pending_input = 0;
91 rl_clear_pending_input ();
92
93 _rl_defining_kbd_macro = 0;
92
93 _rl_defining_kbd_macro = 0;
94 while (_rl_executing_macro)
94 while (rl_executing_macro)
95 _rl_pop_executing_macro ();
96
95 _rl_pop_executing_macro ();
96
97 rl_last_func = (Function *)NULL;
97 rl_last_func = (rl_command_func_t *)NULL;
98 longjmp (readline_top_level, 1);
99 return (0);
100}
101
102int
103rl_abort (count, key)
104 int count, key;
105{
106 return (_rl_abort_internal ());
107}
108
109int
110rl_tty_status (count, key)
111 int count, key;
112{
113#if defined (TIOCSTAT)
114 ioctl (1, TIOCSTAT, (char *)0);
115 rl_refresh_line (count, key);
116#else
98 longjmp (readline_top_level, 1);
99 return (0);
100}
101
102int
103rl_abort (count, key)
104 int count, key;
105{
106 return (_rl_abort_internal ());
107}
108
109int
110rl_tty_status (count, key)
111 int count, key;
112{
113#if defined (TIOCSTAT)
114 ioctl (1, TIOCSTAT, (char *)0);
115 rl_refresh_line (count, key);
116#else
117 ding ();
117 rl_ding ();
118#endif
119 return 0;
120}
121
122/* Return a copy of the string between FROM and TO.
123 FROM is inclusive, TO is not. */
124char *
125rl_copy_text (from, to)

--- 85 unchanged lines hidden (view full) ---

211/* String Utility Functions */
212/* */
213/* **************************************************************** */
214
215/* Determine if s2 occurs in s1. If so, return a pointer to the
216 match in s1. The compare is case insensitive. */
217char *
218_rl_strindex (s1, s2)
118#endif
119 return 0;
120}
121
122/* Return a copy of the string between FROM and TO.
123 FROM is inclusive, TO is not. */
124char *
125rl_copy_text (from, to)

--- 85 unchanged lines hidden (view full) ---

211/* String Utility Functions */
212/* */
213/* **************************************************************** */
214
215/* Determine if s2 occurs in s1. If so, return a pointer to the
216 match in s1. The compare is case insensitive. */
217char *
218_rl_strindex (s1, s2)
219 register char *s1, *s2;
219 register const char *s1, *s2;
220{
221 register int i, l, len;
222
223 for (i = 0, l = strlen (s2), len = strlen (s1); (len - i) >= l; i++)
224 if (_rl_strnicmp (s1 + i, s2, l) == 0)
220{
221 register int i, l, len;
222
223 for (i = 0, l = strlen (s2), len = strlen (s1); (len - i) >= l; i++)
224 if (_rl_strnicmp (s1 + i, s2, l) == 0)
225 return (s1 + i);
225 return ((char *) (s1 + i));
226 return ((char *)NULL);
227}
228
226 return ((char *)NULL);
227}
228
229/* Find the first occurrence in STRING1 of any character from STRING2.
230 Return a pointer to the character in STRING1. */
231char *
232_rl_strpbrk (string1, string2)
233 const char *string1, *string2;
234{
235 register const char *scan;
236
237 if (string2 == NULL)
238 return ((char *)NULL);
239
240 for (; *string1; string1++)
241 {
242 for (scan = string2; *scan; scan++)
243 {
244 if (*string1 == *scan)
245 return ((char *)string1);
246 }
247 }
248 return ((char *)NULL);
249}
250
229#if !defined (HAVE_STRCASECMP)
230/* Compare at most COUNT characters from string1 to string2. Case
231 doesn't matter. */
232int
233_rl_strnicmp (string1, string2, count)
234 char *string1, *string2;
235 int count;
236{

--- 104 unchanged lines hidden (view full) ---

341 return (isdigit (c) ? c - '0' : c);
342}
343
344/* Backwards compatibility, now that savestring has been removed from
345 all `public' readline header files. */
346#undef _rl_savestring
347char *
348_rl_savestring (s)
251#if !defined (HAVE_STRCASECMP)
252/* Compare at most COUNT characters from string1 to string2. Case
253 doesn't matter. */
254int
255_rl_strnicmp (string1, string2, count)
256 char *string1, *string2;
257 int count;
258{

--- 104 unchanged lines hidden (view full) ---

363 return (isdigit (c) ? c - '0' : c);
364}
365
366/* Backwards compatibility, now that savestring has been removed from
367 all `public' readline header files. */
368#undef _rl_savestring
369char *
370_rl_savestring (s)
349 char *s;
371 const char *s;
350{
372{
351 return ((char *)strcpy (xmalloc (1 + (int)strlen (s)), (s)));
373 return (strcpy (xmalloc (1 + (int)strlen (s)), (s)));
352}
374}