diff options
author | 2013-12-23 14:58:16 +0000 | |
---|---|---|
committer | 2013-12-23 14:58:16 +0000 | |
commit | 40e8b10552d3969c821f1c625bfd0cc56075d60b (patch) | |
tree | 5d42de8389e261ad4a9dc5d8ba3dc9533986ac13 | |
parent | Sync Makefile with what other platforms do; makes dependency tracking actually (diff) | |
download | wireguard-openbsd-40e8b10552d3969c821f1c625bfd0cc56075d60b.tar.xz wireguard-openbsd-40e8b10552d3969c821f1c625bfd0cc56075d60b.zip |
Move findbuffer() to buffer.c.
ok florian@
-rw-r--r-- | usr.bin/mg/buffer.c | 29 | ||||
-rw-r--r-- | usr.bin/mg/def.h | 4 | ||||
-rw-r--r-- | usr.bin/mg/file.c | 29 |
3 files changed, 31 insertions, 31 deletions
diff --git a/usr.bin/mg/buffer.c b/usr.bin/mg/buffer.c index 162db4ed950..f6f432b8655 100644 --- a/usr.bin/mg/buffer.c +++ b/usr.bin/mg/buffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: buffer.c,v 1.91 2013/06/02 10:09:21 lum Exp $ */ +/* $OpenBSD: buffer.c,v 1.92 2013/12/23 14:58:16 lum Exp $ */ /* This file is in the public domain. */ @@ -1002,3 +1002,30 @@ diffbuffer(int f, int n) free(text); return (ret); } + +/* + * Given a file name, either find the buffer it uses, or create a new + * empty buffer to put it in. + */ +struct buffer * +findbuffer(char *fn) +{ + struct buffer *bp; + char bname[NBUFN], fname[NBUFN]; + + if (strlcpy(fname, fn, sizeof(fname)) >= sizeof(fname)) { + ewprintf("filename too long"); + return (NULL); + } + + for (bp = bheadp; bp != NULL; bp = bp->b_bufp) { + if (strcmp(bp->b_fname, fname) == 0) + return (bp); + } + /* Not found. Create a new one, adjusting name first */ + if (augbname(bname, fname, sizeof(bname)) == FALSE) + return (NULL); + + bp = bfind(bname, TRUE); + return (bp); +} diff --git a/usr.bin/mg/def.h b/usr.bin/mg/def.h index 1ef0edc399a..87635275339 100644 --- a/usr.bin/mg/def.h +++ b/usr.bin/mg/def.h @@ -1,4 +1,4 @@ -/* $OpenBSD: def.h,v 1.138 2013/05/31 18:03:43 lum Exp $ */ +/* $OpenBSD: def.h,v 1.139 2013/12/23 14:58:16 lum Exp $ */ /* This file is in the public domain. */ @@ -347,7 +347,6 @@ int filevisit(int, int); int filevisitalt(int, int); int filevisitro(int, int); int poptofile(int, int); -struct buffer *findbuffer(char *); int readin(char *); int insertfile(char *, char *, int); int filewrite(int, int); @@ -419,6 +418,7 @@ int checkdirty(struct buffer *); int revertbuffer(int, int); int dorevert(void); int diffbuffer(int, int); +struct buffer *findbuffer(char *); /* display.c */ int vtresize(int, int, int); diff --git a/usr.bin/mg/file.c b/usr.bin/mg/file.c index 3b26ada1c86..eb5639fbe85 100644 --- a/usr.bin/mg/file.c +++ b/usr.bin/mg/file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: file.c,v 1.89 2013/10/22 09:54:16 florian Exp $ */ +/* $OpenBSD: file.c,v 1.90 2013/12/23 14:58:16 lum Exp $ */ /* This file is in the public domain. */ @@ -171,33 +171,6 @@ poptofile(int f, int n) } /* - * Given a file name, either find the buffer it uses, or create a new - * empty buffer to put it in. - */ -struct buffer * -findbuffer(char *fn) -{ - struct buffer *bp; - char bname[NBUFN], fname[NBUFN]; - - if (strlcpy(fname, fn, sizeof(fname)) >= sizeof(fname)) { - ewprintf("filename too long"); - return (NULL); - } - - for (bp = bheadp; bp != NULL; bp = bp->b_bufp) { - if (strcmp(bp->b_fname, fname) == 0) - return (bp); - } - /* Not found. Create a new one, adjusting name first */ - if (augbname(bname, fname, sizeof(bname)) == FALSE) - return (NULL); - - bp = bfind(bname, TRUE); - return (bp); -} - -/* * Read the file "fname" into the current buffer. Make all of the text * in the buffer go away, after checking for unsaved changes. This is * called by the "read" command, the "visit" command, and the mainline |