118
118
* Format msg and save it for the next screen refreshing.
119
119
*/
120
120
121
+ #include <stdlib.h>
122
+ #include <string.h>
123
+
121
124
#include "s.h"
122
125
123
126
/* buffer operations */
124
127
#define DELETE 1
125
128
#define INSERT 2
126
129
#define REPLACE 3
127
130
131
+ extern void s_errmsg (), buf_gets (), buf_delete (), buf_free (), buf_init ();
132
+ extern void s_savemsg ();
133
+ extern int b_lineid (), buf_insert (), buf_id (), buf_replace ();
134
+ static void add_rec (), free_recs ();
135
+
128
136
static int
129
137
b_count = 0 , /* number of lines in the buffer */
130
138
changed , /* did last command change the buffer? */
@@ -146,17 +154,14 @@ static struct mod_rec
146
154
* curr_recs , /* mod recs for current user command */
147
155
* prev_recs ; /* mod recs for previous user change */
148
156
149
- static add_rec ();
150
- static free_recs ();
151
-
152
157
/* b_changed - tell if last command changed the buffer */
153
158
int b_changed ()
154
159
{
155
160
return (changed );
156
161
}
157
162
158
163
/* b_delete - manage deletion of buffer lines */
159
- b_delete (from , to )
164
+ void b_delete (from , to )
160
165
int from , to ;
161
166
{
162
167
int count , line ;
@@ -178,21 +183,21 @@ int from, to;
178
183
}
179
184
180
185
/* b_free - manage freeing of temporary buffer storage */
181
- b_free ()
186
+ void b_free ()
182
187
{
183
188
buf_free ();
184
189
}
185
190
186
191
/* b_getcur - get the cursor location */
187
- b_getcur (line_ptr , pos_ptr )
192
+ void b_getcur (line_ptr , pos_ptr )
188
193
int * line_ptr , * pos_ptr ;
189
194
{
190
195
* line_ptr = cur_line ;
191
196
* pos_ptr = cur_pos ;
192
197
}
193
198
194
199
/* b_getmark - get the mark's location */
195
- b_getmark (line_ptr , pos_ptr )
200
+ void b_getmark (line_ptr , pos_ptr )
196
201
int * line_ptr , * pos_ptr ;
197
202
{
198
203
int line ;
@@ -207,12 +212,10 @@ int *line_ptr, *pos_ptr;
207
212
}
208
213
209
214
/* b_gets - manage retrieval of a buffer line */
210
- b_gets (k , s )
215
+ void b_gets (k , s )
211
216
int k ;
212
217
char * s ;
213
218
{
214
- char * strcpy ();
215
-
216
219
if (k < 1 || k > b_count ) {
217
220
s_errmsg ("b_gets(): improper line number %d" , k );
218
221
strcpy (s , "" );
@@ -221,7 +224,7 @@ char *s;
221
224
}
222
225
223
226
/* b_init - manage buffer initialization */
224
- b_init ()
227
+ void b_init ()
225
228
{
226
229
buf_init ();
227
230
}
@@ -259,7 +262,7 @@ int b_modified()
259
262
}
260
263
261
264
/* b_newcmd - record the start of a command */
262
- b_newcmd (keyboard )
265
+ void b_newcmd (keyboard )
263
266
int keyboard ;
264
267
{
265
268
changed = 0 ; /* even if command was pushed back on input */
@@ -287,7 +290,7 @@ int keyboard;
287
290
}
288
291
289
292
/* b_replace - manage replacement of a buffer line */
290
- b_replace (k , s )
293
+ void b_replace (k , s )
291
294
int k ;
292
295
char * s ;
293
296
{
@@ -301,7 +304,7 @@ char *s;
301
304
}
302
305
303
306
/* b_setcur - set buffer's record of the cursor location */
304
- b_setcur (line , pos )
307
+ void b_setcur (line , pos )
305
308
int line , pos ;
306
309
{
307
310
if (line < 1 || line > b_count )
@@ -316,7 +319,7 @@ int line, pos;
316
319
}
317
320
318
321
/* b_setline - set cursor to first nonwhite character of line */
319
- b_setline (line )
322
+ void b_setline (line )
320
323
int line ;
321
324
{
322
325
int pos ;
@@ -331,7 +334,7 @@ int line;
331
334
}
332
335
333
336
/* b_setmark - set buffer's mark to the cursor location */
334
- b_setmark ()
337
+ void b_setmark ()
335
338
{
336
339
mark_id = b_lineid (cur_line );
337
340
mark_pos = cur_pos ;
@@ -344,13 +347,13 @@ int b_size()
344
347
}
345
348
346
349
/* b_unmod - record that the buffer matches the external file */
347
- b_unmod ()
350
+ void b_unmod ()
348
351
{
349
352
modified = 0 ;
350
353
}
351
354
352
355
/* undo - undo the last user command that changed the buffer */
353
- undo ()
356
+ void undo ()
354
357
{
355
358
struct mod_rec * m ;
356
359
@@ -397,28 +400,28 @@ undo()
397
400
}
398
401
399
402
/* add_rec - add to the list of current modification records */
400
- static add_rec (type , line , del_text )
403
+ static void add_rec (type , line , del_text )
401
404
int type , line ;
402
405
char * del_text ;
403
406
{
404
407
struct mod_rec * new ;
405
408
static int nospace = 0 ; /* are we out of memory? */
406
- char * malloc (), * p , * strcpy () ;
409
+ char * p ;
407
410
408
411
changed = modified = 1 ;
409
412
410
413
/* look for the possibility of collapsing modification records */
411
- if (curr_recs != NULL && curr_recs -> line == line
412
- && type == REPLACE && curr_recs -> type != DELETE )
414
+ if (( curr_recs != NULL ) && ( curr_recs -> line == line )
415
+ && ( type == REPLACE ) && ( curr_recs -> type != DELETE ) )
413
416
return ;
414
417
415
418
/* do nothing if space has been exhausted */
416
419
if (nospace )
417
420
return ;
418
421
419
422
new = (struct mod_rec * ) malloc (sizeof (struct mod_rec ));
420
- if (new == NULL || del_text != NULL &&
421
- ( p = malloc ((unsigned )strlen (del_text )+ 1 )) == NULL ) {
423
+ if (( new == NULL || del_text != NULL ) &&
424
+ (( p = malloc ((unsigned )strlen (del_text )+ 1 )) == NULL ) ) {
422
425
nospace = 1 ;
423
426
free_recs (curr_recs );
424
427
curr_recs = NULL ;
@@ -433,7 +436,7 @@ char *del_text;
433
436
}
434
437
435
438
/* free_recs - free storage for modification records */
436
- static free_recs (m )
439
+ static void free_recs (m )
437
440
struct mod_rec * m ;
438
441
{
439
442
struct mod_rec * a ;
0 commit comments