correct a few protos and comments

saves 4 .text bytes and my nerves
This commit is contained in:
tg 2006-11-10 03:45:57 +00:00
parent f8e7fdbb71
commit d10dd31b9a
3 changed files with 27 additions and 44 deletions

12
funcs.c
View File

@ -5,7 +5,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.32 2006/11/09 23:19:52 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.33 2006/11/10 03:45:56 tg Exp $");
int
c_cd(char **wp)
@ -178,13 +178,9 @@ c_pwd(char **wp)
NULL;
if (p && eaccess(p, R_OK) < 0)
p = NULL;
if (!p) {
p = ksh_get_wd(NULL, 0);
if (!p) {
bi_errorf("can't get current directory - %s",
strerror(errno));
return 1;
}
if (!p && !(p = ksh_get_wd(NULL))) {
bi_errorf("can't get current directory - %s", strerror(errno));
return 1;
}
shprintf("%s\n", p);
return 0;

51
misc.c
View File

@ -3,7 +3,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.29 2006/11/10 03:23:50 tg Exp $\t"
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.30 2006/11/10 03:45:57 tg Exp $\t"
MKSH_SH_H_ID);
unsigned char chtypes[UCHAR_MAX + 1]; /* type bits for unsigned char */
@ -747,7 +747,7 @@ xstrcmp(const void *p1, const void *p2)
return (strcmp(*(const char **)p1, *(const char **)p2));
}
/* Initialize a Getopt structure */
/* Initialise a Getopt structure */
void
ksh_getopt_reset(Getopt *go, int flags)
{
@ -962,7 +962,7 @@ print_columns(struct shf *shf, int n, char *(*func) (void *, int, char *, int),
}
/* Strip any nul bytes from buf - returns new length (nbytes - # of nuls) */
int
void
strip_nuls(char *buf, int nbytes)
{
char *dst;
@ -985,9 +985,7 @@ strip_nuls(char *buf, int nbytes)
dst += q - p;
}
*dst = '\0';
return dst - buf;
}
return nbytes;
}
/* Like read(2), but if read fails due to non-blocking flag, resets flag
@ -1001,12 +999,11 @@ blocking_read(int fd, char *buf, int nbytes)
while ((ret = read(fd, buf, nbytes)) < 0) {
if (!tried_reset && errno == EAGAIN) {
int oerrno = errno;
if (reset_nonblock(fd) > 0) {
tried_reset = 1;
continue;
}
errno = oerrno;
errno = EAGAIN;
}
break;
}
@ -1035,29 +1032,18 @@ reset_nonblock(int fd)
/* Like getcwd(), except bsize is ignored if buf is 0 (PATH_MAX is used) */
char *
ksh_get_wd(char *buf, int bsize)
ksh_get_wd(size_t *dlen)
{
char *b;
char *ret;
char *ret, *b;
size_t len = 0;
/* Note: we could just use plain getcwd(), but then we'd had to
* inject possibly allocated space into the ATEMP area. */
/* Assume getcwd() available */
if (!buf) {
bsize = PATH_MAX;
b = alloc(PATH_MAX + 1, ATEMP);
} else
b = buf;
ret = getcwd(b, bsize);
if (!buf) {
if (ret)
ret = aresize(b, strlen(b) + 1, ATEMP);
else
afree(b, ATEMP);
}
if ((ret = getcwd((b = alloc(PATH_MAX + 1, ATEMP)), PATH_MAX)))
ret = aresize(b, len = (strlen(b) + 1), ATEMP);
else
afree(b, ATEMP);
if (dlen)
*dlen = len;
return ret;
}
@ -1221,13 +1207,14 @@ simplify_path(char *pathl)
void
set_current_wd(char *pathl)
{
int len;
size_t len = 1;
char *p = pathl;
if (!p && !(p = ksh_get_wd(NULL, 0)))
p = null;
len = strlen(p) + 1;
if (p == NULL) {
if ((p = ksh_get_wd(&len)) == NULL)
p = null;
} else
len = strlen(p) + 1;
if (len > current_wd_size)
current_wd = aresize(current_wd, current_wd_size = len, APERM);

8
sh.h
View File

@ -8,7 +8,7 @@
/* $OpenBSD: c_test.h,v 1.4 2004/12/20 11:34:26 otto Exp $ */
/* $OpenBSD: tty.h,v 1.5 2004/12/20 11:34:26 otto Exp $ */
#define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.72 2006/11/10 03:23:50 tg Exp $"
#define MKSH_SH_H_ID "$MirOS: src/bin/mksh/sh.h,v 1.73 2006/11/10 03:45:57 tg Exp $"
#define MKSH_VERSION "R29 2006/11/10"
#if HAVE_SYS_PARAM_H
@ -454,7 +454,7 @@ EXTERN Tflag builtin_flag; /* flags of called builtin (SPEC_BI, etc.) */
/* current working directory, and size of memory allocated for same */
EXTERN char *current_wd;
EXTERN int current_wd_size;
EXTERN size_t current_wd_size;
/* Minimum required space to work with on a line - if the prompt leaves less
* space than this on a line, the prompt is truncated.
@ -1237,10 +1237,10 @@ int ksh_getopt(char **, Getopt *, const char *);
void print_value_quoted(const char *);
void print_columns(struct shf *, int, char *(*)(void *, int, char *, int),
void *, int, int prefcol);
int strip_nuls(char *, int);
void strip_nuls(char *, int);
int blocking_read(int, char *, int);
int reset_nonblock(int);
char *ksh_get_wd(char *, int);
char *ksh_get_wd(size_t *);
int make_path(const char *, const char *, char **, XString *, int *);
void simplify_path(char *);
char *get_phys_path(const char *);