history.c (136644) | history.c (157184) |
---|---|
1/* history.c -- standalone history library */ 2 | 1/* history.c -- standalone history library */ 2 |
3/* Copyright (C) 1989-2003 Free Software Foundation, Inc. | 3/* Copyright (C) 1989-2005 Free Software Foundation, Inc. |
4 5 This file contains the GNU History Library (the Library), a set of 6 routines for managing the text of previously typed lines. 7 8 The Library is free software; you can redistribute it and/or modify 9 it under the terms of the GNU General Public License as published by 10 the Free Software Foundation; either version 2, or (at your option) 11 any later version. --- 187 unchanged lines hidden (view full) --- 199 OFFSET is relative to history_base. */ 200HIST_ENTRY * 201history_get (offset) 202 int offset; 203{ 204 int local_index; 205 206 local_index = offset - history_base; | 4 5 This file contains the GNU History Library (the Library), a set of 6 routines for managing the text of previously typed lines. 7 8 The Library is free software; you can redistribute it and/or modify 9 it under the terms of the GNU General Public License as published by 10 the Free Software Foundation; either version 2, or (at your option) 11 any later version. --- 187 unchanged lines hidden (view full) --- 199 OFFSET is relative to history_base. */ 200HIST_ENTRY * 201history_get (offset) 202 int offset; 203{ 204 int local_index; 205 206 local_index = offset - history_base; |
207 return (local_index >= history_length || local_index < 0 || !the_history) | 207 return (local_index >= history_length || local_index < 0 || the_history == 0) |
208 ? (HIST_ENTRY *)NULL 209 : the_history[local_index]; 210} 211 212time_t 213history_get_time (hist) 214 HIST_ENTRY *hist; 215{ --- 119 unchanged lines hidden (view full) --- 335HIST_ENTRY * 336replace_history_entry (which, line, data) 337 int which; 338 const char *line; 339 histdata_t data; 340{ 341 HIST_ENTRY *temp, *old_value; 342 | 208 ? (HIST_ENTRY *)NULL 209 : the_history[local_index]; 210} 211 212time_t 213history_get_time (hist) 214 HIST_ENTRY *hist; 215{ --- 119 unchanged lines hidden (view full) --- 335HIST_ENTRY * 336replace_history_entry (which, line, data) 337 int which; 338 const char *line; 339 histdata_t data; 340{ 341 HIST_ENTRY *temp, *old_value; 342 |
343 if (which >= history_length) | 343 if (which < 0 || which >= history_length) |
344 return ((HIST_ENTRY *)NULL); 345 346 temp = (HIST_ENTRY *)xmalloc (sizeof (HIST_ENTRY)); 347 old_value = the_history[which]; 348 349 temp->line = savestring (line); 350 temp->data = data; 351 temp->timestamp = savestring (old_value->timestamp); --- 7 unchanged lines hidden (view full) --- 359 and containing structure. */ 360HIST_ENTRY * 361remove_history (which) 362 int which; 363{ 364 HIST_ENTRY *return_value; 365 register int i; 366 | 344 return ((HIST_ENTRY *)NULL); 345 346 temp = (HIST_ENTRY *)xmalloc (sizeof (HIST_ENTRY)); 347 old_value = the_history[which]; 348 349 temp->line = savestring (line); 350 temp->data = data; 351 temp->timestamp = savestring (old_value->timestamp); --- 7 unchanged lines hidden (view full) --- 359 and containing structure. */ 360HIST_ENTRY * 361remove_history (which) 362 int which; 363{ 364 HIST_ENTRY *return_value; 365 register int i; 366 |
367 if (which >= history_length || !history_length) 368 return_value = (HIST_ENTRY *)NULL; 369 else 370 { 371 return_value = the_history[which]; | 367 if (which < 0 || which >= history_length || history_length == 0 || the_history == 0) 368 return ((HIST_ENTRY *)NULL); |
372 | 369 |
373 for (i = which; i < history_length; i++) 374 the_history[i] = the_history[i + 1]; | 370 return_value = the_history[which]; |
375 | 371 |
376 history_length--; 377 } | 372 for (i = which; i < history_length; i++) 373 the_history[i] = the_history[i + 1]; |
378 | 374 |
375 history_length--; 376 |
|
379 return (return_value); 380} 381 382/* Stifle the history list, remembering only MAX number of lines. */ 383void 384stifle_history (max) 385 int max; 386{ --- 57 unchanged lines hidden --- | 377 return (return_value); 378} 379 380/* Stifle the history list, remembering only MAX number of lines. */ 381void 382stifle_history (max) 383 int max; 384{ --- 57 unchanged lines hidden --- |