Style fixes in preparation of code rewritting

This commit is contained in:
Andrey A. Chernov 2002-08-07 16:45:23 +00:00
parent ffe4fbf0fd
commit ecc4c62066
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=101470
4 changed files with 43 additions and 34 deletions

View File

@ -53,18 +53,18 @@ __part_load_locale(const char *name,
int locale_buf_size_min,
const char **dst_localebuf)
{
static char locale_buf_C[] = "C";
static int num_lines;
int saverr;
int fd;
char *lbuf;
char *p;
const char *plim;
char filename[PATH_MAX];
struct stat st;
size_t namesize;
size_t bufsize;
int save_using_locale;
static char locale_buf_C[] = "C";
static int num_lines;
int saverr;
int fd;
char *lbuf;
char *p;
const char *plim;
char filename[PATH_MAX];
struct stat st;
size_t namesize;
size_t bufsize;
int save_using_locale;
save_using_locale = *using_locale;
*using_locale = 0;
@ -112,7 +112,7 @@ __part_load_locale(const char *name,
malloc(bufsize) : reallocf(lbuf, bufsize);
if (lbuf == NULL)
goto bad_locale;
(void) strcpy(lbuf, name);
(void)strcpy(lbuf, name);
p = lbuf + namesize;
plim = p + st.st_size;
if (_read(fd, p, (size_t) st.st_size) != st.st_size)
@ -142,30 +142,36 @@ __part_load_locale(const char *name,
locale_buf = lbuf;
*using_locale = 1;
return 0;
reset_locale:
locale_buf = locale_buf_C;
save_using_locale = 0;
bad_lbuf:
saverr = errno; free(lbuf); errno = saverr;
saverr = errno;
free(lbuf);
errno = saverr;
bad_locale:
saverr = errno; (void)_close(fd); errno = saverr;
saverr = errno;
(void)_close(fd);
errno = saverr;
no_locale:
*using_locale = save_using_locale;
return -1;
}
static int
split_lines(char *p, const char *plim) {
split_lines(char *p, const char *plim)
{
int i;
for (i = 0; p < plim; i++) {
p = strchr(p, '\n');
*p++ = '\0';
}
return i;
return (i);
}
static void

View File

@ -50,8 +50,8 @@ static int _messages_using_locale;
static char *_messages_locale_buf;
int
__messages_load_locale(const char *name) {
__messages_load_locale(const char *name)
{
/*
* Propose that we can have incomplete locale file (w/o "{yes,no}str").
* Initialize them before loading. In case of complete locale, they'll
@ -67,8 +67,8 @@ __messages_load_locale(const char *name) {
}
struct lc_messages_T *
__get_current_messages_locale(void) {
__get_current_messages_locale(void)
{
return (_messages_using_locale
? &_messages_locale
: (struct lc_messages_T *)&_C_messages_locale);

View File

@ -63,17 +63,20 @@ static int _monetary_using_locale;
static char *_monetary_locale_buf;
static char
cnv(const char *str) {
cnv(const char *str)
{
int i = strtol(str, NULL, 10);
if (i == -1)
i = CHAR_MAX;
return (char)i;
return ((char)i);
}
int
__monetary_load_locale(const char *name) {
__monetary_load_locale(const char *name)
{
int ret;
__mlocale_changed = 1;
ret = __part_load_locale(name, &_monetary_using_locale,
_monetary_locale_buf, "LC_MONETARY",
@ -95,12 +98,12 @@ __monetary_load_locale(const char *name) {
M_ASSIGN_CHAR(p_sign_posn);
M_ASSIGN_CHAR(n_sign_posn);
}
return ret;
return (ret);
}
struct lc_monetary_T *
__get_current_monetary_locale(void) {
__get_current_monetary_locale(void)
{
return (_monetary_using_locale
? &_monetary_locale
: (struct lc_monetary_T *)&_C_monetary_locale);

View File

@ -49,8 +49,8 @@ static int _numeric_using_locale;
static char *_numeric_locale_buf;
int
__numeric_load_locale(const char *name) {
__numeric_load_locale(const char *name)
{
int ret;
__nlocale_changed = 1;
@ -61,12 +61,12 @@ __numeric_load_locale(const char *name) {
if (ret == 0 && _numeric_using_locale)
_numeric_locale.grouping =
__fix_locale_grouping_str(_numeric_locale.grouping);
return ret;
return (ret);
}
struct lc_numeric_T *
__get_current_numeric_locale(void) {
__get_current_numeric_locale(void)
{
return (_numeric_using_locale
? &_numeric_locale
: (struct lc_numeric_T *)&_C_numeric_locale);