diff options
author | mike <mike@FreeBSD.org> | 2001-08-06 22:01:31 +0000 |
---|---|---|
committer | mike <mike@FreeBSD.org> | 2001-08-06 22:01:31 +0000 |
commit | eced21209cdad6cf4ff64c6008b71b45a226d905 (patch) | |
tree | 0469fc49295a48c1140722bbff569214e2135f58 /bin/ed/buf.c | |
parent | e7f429490d285f94132046b59db80b6d1fe253c4 (diff) | |
download | FreeBSD-src-eced21209cdad6cf4ff64c6008b71b45a226d905.zip FreeBSD-src-eced21209cdad6cf4ff64c6008b71b45a226d905.tar.gz |
o Correctly define rcsid.
o Add consts where appropriate.
o Rename some variables that were shadowing global declarations.
o Remove register storage-classes.
o Make errmsg a const, so we can just set error messages instead
of using sprintf/strcpy.
o Set WARNS=2
Reviewed by: bde, des
Diffstat (limited to 'bin/ed/buf.c')
-rw-r--r-- | bin/ed/buf.c | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/bin/ed/buf.c b/bin/ed/buf.c index 4e24796..fb23e5a 100644 --- a/bin/ed/buf.c +++ b/bin/ed/buf.c @@ -27,12 +27,8 @@ */ #ifndef lint -#if 0 -static char * const rcsid = "@(#)buf.c,v 1.4 1994/02/01 00:34:35 alm Exp"; -#else -static char * const rcsid = +static const char rcsid[] = "$FreeBSD$"; -#endif #endif /* not lint */ #include <sys/file.h> @@ -65,7 +61,7 @@ get_sbuf_line(lp) sfseek = lp->seek; if (fseek(sfp, sfseek, SEEK_SET) < 0) { fprintf(stderr, "%s\n", strerror(errno)); - sprintf(errmsg, "cannot seek temp file"); + errmsg = "cannot seek temp file"; return NULL; } } @@ -73,7 +69,7 @@ get_sbuf_line(lp) REALLOC(sfbuf, sfbufsz, len + 1, NULL); if ((ct = fread(sfbuf, sizeof(char), len, sfp)) < 0 || ct != len) { fprintf(stderr, "%s\n", strerror(errno)); - sprintf(errmsg, "cannot read temp file"); + errmsg = "cannot read temp file"; return NULL; } sfseek += len; /* update file position */ @@ -84,24 +80,24 @@ get_sbuf_line(lp) /* put_sbuf_line: write a line of text to the scratch file and add a line node to the editor buffer; return a pointer to the end of the text */ -char * +const char * put_sbuf_line(cs) - char *cs; + const char *cs; { line_t *lp; int len, ct; - char *s; + const char *s; if ((lp = (line_t *) malloc(sizeof(line_t))) == NULL) { fprintf(stderr, "%s\n", strerror(errno)); - sprintf(errmsg, "out of memory"); + errmsg = "out of memory"; return NULL; } /* assert: cs is '\n' terminated */ for (s = cs; *s != '\n'; s++) ; if (s - cs >= LINECHARS) { - sprintf(errmsg, "line too long"); + errmsg = "line too long"; return NULL; } len = s - cs; @@ -109,7 +105,7 @@ put_sbuf_line(cs) if (seek_write) { if (fseek(sfp, 0L, SEEK_END) < 0) { fprintf(stderr, "%s\n", strerror(errno)); - sprintf(errmsg, "cannot seek temp file"); + errmsg = "cannot seek temp file"; return NULL; } sfseek = ftell(sfp); @@ -119,7 +115,7 @@ put_sbuf_line(cs) if ((ct = fwrite(cs, sizeof(char), len, sfp)) < 0 || ct != len) { sfseek = -1; fprintf(stderr, "%s\n", strerror(errno)); - sprintf(errmsg, "cannot write temp file"); + errmsg = "cannot write temp file"; return NULL; } lp->len = len; @@ -155,7 +151,7 @@ get_line_node_addr(lp) while (cp != lp && (cp = cp->q_forw) != &buffer_head) n++; if (n && cp == &buffer_head) { - sprintf(errmsg, "invalid address"); + errmsg = "invalid address"; return ERR; } return n; @@ -213,7 +209,7 @@ open_sbuf() if (fd != -1) close(fd); perror(sfn); - strcpy(errmsg, "cannot open temp file"); + errmsg = "cannot open temp file"; umask(u); return ERR; } @@ -229,7 +225,7 @@ close_sbuf() if (sfp) { if (fclose(sfp) < 0) { fprintf(stderr, "%s: %s\n", sfn, strerror(errno)); - sprintf(errmsg, "cannot close temp file"); + errmsg = "cannot close temp file"; return ERR; } sfp = NULL; |