util.c (26500) | util.c (35489) |
---|---|
1/* util.c -- readline utility functions */ 2 3/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc. 4 5 This file is part of the GNU Readline Library, a library for 6 reading lines of text with interactive input and history editing. 7 8 The GNU Readline Library is free software; you can redistribute it --- 152 unchanged lines hidden (view full) --- 161 { 162 rl_line_buffer_len += DEFAULT_BUFFER_SIZE; 163 rl_line_buffer = xrealloc (rl_line_buffer, rl_line_buffer_len); 164 } 165 166 _rl_set_the_line (); 167} 168 | 1/* util.c -- readline utility functions */ 2 3/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc. 4 5 This file is part of the GNU Readline Library, a library for 6 reading lines of text with interactive input and history editing. 7 8 The GNU Readline Library is free software; you can redistribute it --- 152 unchanged lines hidden (view full) --- 161 { 162 rl_line_buffer_len += DEFAULT_BUFFER_SIZE; 163 rl_line_buffer = xrealloc (rl_line_buffer, rl_line_buffer_len); 164 } 165 166 _rl_set_the_line (); 167} 168 |
169 170/* A function for simple tilde expansion. */ 171int 172rl_tilde_expand (ignore, key) 173 int ignore, key; 174{ 175 register int start, end; 176 char *homedir, *temp; 177 int len; 178 179 end = rl_point; 180 start = end - 1; 181 182 if (rl_point == rl_end && rl_line_buffer[rl_point] == '~') 183 { 184 homedir = tilde_expand ("~"); 185 _rl_replace_text (homedir, start, end); 186 return (0); 187 } 188 else if (rl_line_buffer[start] != '~') 189 { 190 for (; !whitespace (rl_line_buffer[start]) && start >= 0; start--) 191 ; 192 start++; 193 } 194 195 end = start; 196 do 197 end++; 198 while (whitespace (rl_line_buffer[end]) == 0 && end < rl_end); 199 200 if (whitespace (rl_line_buffer[end]) || end >= rl_end) 201 end--; 202 203 /* If the first character of the current word is a tilde, perform 204 tilde expansion and insert the result. If not a tilde, do 205 nothing. */ 206 if (rl_line_buffer[start] == '~') 207 { 208 len = end - start + 1; 209 temp = xmalloc (len + 1); 210 strncpy (temp, rl_line_buffer + start, len); 211 temp[len] = '\0'; 212 homedir = tilde_expand (temp); 213 free (temp); 214 215 _rl_replace_text (homedir, start, end); 216 } 217 218 return (0); 219} 220 |
|
169/* **************************************************************** */ 170/* */ 171/* String Utility Functions */ 172/* */ 173/* **************************************************************** */ 174 175/* Determine if s2 occurs in s1. If so, return a pointer to the 176 match in s1. The compare is case insensitive. */ --- 118 unchanged lines hidden (view full) --- 295 296#undef _rl_digit_value 297int 298_rl_digit_value (c) 299 int c; 300{ 301 return (isdigit (c) ? c - '0' : c); 302} | 221/* **************************************************************** */ 222/* */ 223/* String Utility Functions */ 224/* */ 225/* **************************************************************** */ 226 227/* Determine if s2 occurs in s1. If so, return a pointer to the 228 match in s1. The compare is case insensitive. */ --- 118 unchanged lines hidden (view full) --- 347 348#undef _rl_digit_value 349int 350_rl_digit_value (c) 351 int c; 352{ 353 return (isdigit (c) ? c - '0' : c); 354} |
355 356/* Backwards compatibility, now that savestring has been removed from 357 all `public' readline header files. */ 358#undef _rl_savestring 359char * 360_rl_savestring (s) 361 char *s; 362{ 363 return ((char *)strcpy (xmalloc (1 + (int)strlen (s)), (s))); 364} |
|