Skip to content

Commit fda7513

Browse files
authored
fixed all clang warnings
1 parent a3d13f5 commit fda7513

File tree

1 file changed

+28
-25
lines changed

1 file changed

+28
-25
lines changed

Bman.c

+28-25
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,21 @@
118118
* Format msg and save it for the next screen refreshing.
119119
*/
120120

121+
#include <stdlib.h>
122+
#include <string.h>
123+
121124
#include "s.h"
122125

123126
/* buffer operations */
124127
#define DELETE 1
125128
#define INSERT 2
126129
#define REPLACE 3
127130

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+
128136
static int
129137
b_count = 0, /* number of lines in the buffer */
130138
changed, /* did last command change the buffer? */
@@ -146,17 +154,14 @@ static struct mod_rec
146154
*curr_recs, /* mod recs for current user command */
147155
*prev_recs; /* mod recs for previous user change */
148156

149-
static add_rec();
150-
static free_recs();
151-
152157
/* b_changed - tell if last command changed the buffer */
153158
int b_changed()
154159
{
155160
return(changed);
156161
}
157162

158163
/* b_delete - manage deletion of buffer lines */
159-
b_delete(from, to)
164+
void b_delete(from, to)
160165
int from, to;
161166
{
162167
int count, line;
@@ -178,21 +183,21 @@ int from, to;
178183
}
179184

180185
/* b_free - manage freeing of temporary buffer storage */
181-
b_free()
186+
void b_free()
182187
{
183188
buf_free();
184189
}
185190

186191
/* b_getcur - get the cursor location */
187-
b_getcur(line_ptr, pos_ptr)
192+
void b_getcur(line_ptr, pos_ptr)
188193
int *line_ptr, *pos_ptr;
189194
{
190195
*line_ptr = cur_line;
191196
*pos_ptr = cur_pos;
192197
}
193198

194199
/* b_getmark - get the mark's location */
195-
b_getmark(line_ptr, pos_ptr)
200+
void b_getmark(line_ptr, pos_ptr)
196201
int *line_ptr, *pos_ptr;
197202
{
198203
int line;
@@ -207,12 +212,10 @@ int *line_ptr, *pos_ptr;
207212
}
208213

209214
/* b_gets - manage retrieval of a buffer line */
210-
b_gets(k, s)
215+
void b_gets(k, s)
211216
int k;
212217
char *s;
213218
{
214-
char *strcpy();
215-
216219
if (k < 1 || k > b_count) {
217220
s_errmsg("b_gets(): improper line number %d", k);
218221
strcpy(s, "");
@@ -221,7 +224,7 @@ char *s;
221224
}
222225

223226
/* b_init - manage buffer initialization */
224-
b_init()
227+
void b_init()
225228
{
226229
buf_init();
227230
}
@@ -259,7 +262,7 @@ int b_modified()
259262
}
260263

261264
/* b_newcmd - record the start of a command */
262-
b_newcmd(keyboard)
265+
void b_newcmd(keyboard)
263266
int keyboard;
264267
{
265268
changed = 0; /* even if command was pushed back on input */
@@ -287,7 +290,7 @@ int keyboard;
287290
}
288291

289292
/* b_replace - manage replacement of a buffer line */
290-
b_replace(k, s)
293+
void b_replace(k, s)
291294
int k;
292295
char *s;
293296
{
@@ -301,7 +304,7 @@ char *s;
301304
}
302305

303306
/* b_setcur - set buffer's record of the cursor location */
304-
b_setcur(line, pos)
307+
void b_setcur(line, pos)
305308
int line, pos;
306309
{
307310
if (line < 1 || line > b_count)
@@ -316,7 +319,7 @@ int line, pos;
316319
}
317320

318321
/* b_setline - set cursor to first nonwhite character of line */
319-
b_setline(line)
322+
void b_setline(line)
320323
int line;
321324
{
322325
int pos;
@@ -331,7 +334,7 @@ int line;
331334
}
332335

333336
/* b_setmark - set buffer's mark to the cursor location */
334-
b_setmark()
337+
void b_setmark()
335338
{
336339
mark_id = b_lineid(cur_line);
337340
mark_pos = cur_pos;
@@ -344,13 +347,13 @@ int b_size()
344347
}
345348

346349
/* b_unmod - record that the buffer matches the external file */
347-
b_unmod()
350+
void b_unmod()
348351
{
349352
modified = 0;
350353
}
351354

352355
/* undo - undo the last user command that changed the buffer */
353-
undo()
356+
void undo()
354357
{
355358
struct mod_rec *m;
356359

@@ -397,28 +400,28 @@ undo()
397400
}
398401

399402
/* 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)
401404
int type, line;
402405
char *del_text;
403406
{
404407
struct mod_rec *new;
405408
static int nospace = 0; /* are we out of memory? */
406-
char *malloc(), *p, *strcpy();
409+
char *p;
407410

408411
changed = modified = 1;
409412

410413
/* 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))
413416
return;
414417

415418
/* do nothing if space has been exhausted */
416419
if (nospace)
417420
return;
418421

419422
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)) {
422425
nospace = 1;
423426
free_recs(curr_recs);
424427
curr_recs = NULL;
@@ -433,7 +436,7 @@ char *del_text;
433436
}
434437

435438
/* free_recs - free storage for modification records */
436-
static free_recs(m)
439+
static void free_recs(m)
437440
struct mod_rec *m;
438441
{
439442
struct mod_rec *a;

0 commit comments

Comments
 (0)