Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libc/citrus From Henning Petersen in PR # 44641: C99 pri...
details: https://anonhg.NetBSD.org/src/rev/92eeb6c9eaf4
branches: trunk
changeset: 763656:92eeb6c9eaf4
user: jruoho <jruoho%NetBSD.org@localhost>
date: Wed Mar 30 08:22:01 2011 +0000
description:
>From Henning Petersen in PR # 44641: C99 primitive type 'bool' used
as a variable name. Also small KNF, as in FreeBSD.
diffstat:
lib/libc/citrus/citrus_iconv.c | 24 ++++++++++++++----------
lib/libc/citrus/citrus_prop.c | 36 ++++++++++++++++++++++++++----------
lib/libc/citrus/citrus_prop.h | 8 ++++----
3 files changed, 44 insertions(+), 24 deletions(-)
diffs (180 lines):
diff -r 60032f7fe9a3 -r 92eeb6c9eaf4 lib/libc/citrus/citrus_iconv.c
--- a/lib/libc/citrus/citrus_iconv.c Wed Mar 30 05:24:05 2011 +0000
+++ b/lib/libc/citrus/citrus_iconv.c Wed Mar 30 08:22:01 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: citrus_iconv.c,v 1.8 2009/09/05 06:44:27 dholland Exp $ */
+/* $NetBSD: citrus_iconv.c,v 1.9 2011/03/30 08:22:01 jruoho Exp $ */
/*-
* Copyright (c)2003 Citrus Project,
@@ -28,22 +28,25 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: citrus_iconv.c,v 1.8 2009/09/05 06:44:27 dholland Exp $");
+__RCSID("$NetBSD: citrus_iconv.c,v 1.9 2011/03/30 08:22:01 jruoho Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
#include "reentrant.h"
+
+#include <sys/types.h>
+#include <sys/queue.h>
+
#include <assert.h>
+#include <dirent.h>
+#include <errno.h>
+#include <limits.h>
+#include <paths.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <errno.h>
-#include <limits.h>
#include <unistd.h>
-#include <paths.h>
-#include <dirent.h>
-#include <sys/types.h>
-#include <sys/queue.h>
#include "citrus_namespace.h"
#include "citrus_bcs.h"
@@ -65,7 +68,8 @@
#ifdef _REENTRANT
static rwlock_t lock = RWLOCK_INITIALIZER;
#endif
-static int isinit = 0;
+
+static bool isinit = false;
static _CITRUS_HASH_HEAD(, _citrus_iconv_shared, CI_HASH_SIZE) shared_pool;
static TAILQ_HEAD(, _citrus_iconv_shared) shared_unused;
static int shared_num_unused, shared_max_reuse;
@@ -82,7 +86,7 @@
shared_max_reuse = atoi(getenv(CI_ENV_MAX_REUSE));
if (shared_max_reuse < 0)
shared_max_reuse = CI_INITIAL_MAX_REUSE;
- isinit = 1;
+ isinit = true;
}
rwlock_unlock(&lock);
}
diff -r 60032f7fe9a3 -r 92eeb6c9eaf4 lib/libc/citrus/citrus_prop.c
--- a/lib/libc/citrus/citrus_prop.c Wed Mar 30 05:24:05 2011 +0000
+++ b/lib/libc/citrus/citrus_prop.c Wed Mar 30 08:22:01 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: citrus_prop.c,v 1.3 2006/11/22 23:47:21 tnozaki Exp $ */
+/* $NetBSD: citrus_prop.c,v 1.4 2011/03/30 08:22:01 jruoho Exp $ */
/*-
* Copyright (c)2006 Citrus Project,
@@ -29,12 +29,13 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: citrus_prop.c,v 1.3 2006/11/22 23:47:21 tnozaki Exp $");
+__RCSID("$NetBSD: citrus_prop.c,v 1.4 2011/03/30 08:22:01 jruoho Exp $");
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
+#include <errno.h>
#include <limits.h>
-#include <errno.h>
+#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
#include <stdint.h>
@@ -51,7 +52,8 @@
_citrus_prop_type_t type;
union {
const char *str;
- int bool, chr;
+ int chr;
+ bool boolean;
uint64_t num;
} u;
} _citrus_prop_object_t;
@@ -228,7 +230,7 @@
if (_bcs_tolower(_memstream_getc(ms)) == 'r' &&
_bcs_tolower(_memstream_getc(ms)) == 'u' &&
_bcs_tolower(_memstream_getc(ms)) == 'e') {
- obj->u.bool = 1;
+ obj->u.boolean = true;
return 0;
}
break;
@@ -237,7 +239,7 @@
_bcs_tolower(_memstream_getc(ms)) == 'l' &&
_bcs_tolower(_memstream_getc(ms)) == 's' &&
_bcs_tolower(_memstream_getc(ms)) == 'e') {
- obj->u.bool = 0;
+ obj->u.boolean = false;
return 0;
}
}
@@ -406,11 +408,25 @@
errnum = (*hint->cb._func_.func)(context, \
hint->name, ostart.u._func_, oend.u._func_);\
} while (/*CONSTCOND*/0)
+
switch (hint->type) {
- case _CITRUS_PROP_BOOL: CALL0(bool); break;
- case _CITRUS_PROP_STR : CALL0( str); break;
- case _CITRUS_PROP_CHR : CALL1( chr); break;
- case _CITRUS_PROP_NUM : CALL1( num); break;
+
+ case _CITRUS_PROP_BOOL:
+ CALL0(boolean);
+ break;
+
+ case _CITRUS_PROP_STR:
+ CALL0(str);
+ break;
+
+ case _CITRUS_PROP_CHR:
+ CALL1(chr);
+ break;
+
+ case _CITRUS_PROP_NUM:
+ CALL1(num);
+ break;
+
default:
abort();
/*NOTREACHED*/
diff -r 60032f7fe9a3 -r 92eeb6c9eaf4 lib/libc/citrus/citrus_prop.h
--- a/lib/libc/citrus/citrus_prop.h Wed Mar 30 05:24:05 2011 +0000
+++ b/lib/libc/citrus/citrus_prop.h Wed Mar 30 08:22:01 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: citrus_prop.h,v 1.3 2006/11/23 13:59:03 tnozaki Exp $ */
+/* $NetBSD: citrus_prop.h,v 1.4 2011/03/30 08:22:01 jruoho Exp $ */
/*-
* Copyright (c)2006 Citrus Project,
@@ -45,7 +45,7 @@
typedef struct { \
_citrus_prop_##_func_##_cb_func_t func; \
} _citrus_prop_##_func_##_cb_t;
-_CITRUS_PROP_CB0_T(bool, int)
+_CITRUS_PROP_CB0_T(boolean, int)
_CITRUS_PROP_CB0_T(str, const char *)
#undef _CITRUS_PROP_CB0_T
@@ -65,7 +65,7 @@
#define _CITRUS_PROP_CB_T_OPS(_name_) \
_citrus_prop_##_name_##_cb_t _name_
union {
- _CITRUS_PROP_CB_T_OPS(bool);
+ _CITRUS_PROP_CB_T_OPS(boolean);
_CITRUS_PROP_CB_T_OPS(str);
_CITRUS_PROP_CB_T_OPS(chr);
_CITRUS_PROP_CB_T_OPS(num);
@@ -73,7 +73,7 @@
};
#define _CITRUS_PROP_HINT_BOOL(name, cb) \
- { name, _CITRUS_PROP_BOOL, { .bool = { cb } } }
+ { name, _CITRUS_PROP_BOOL, { .boolean = { cb } } }
#define _CITRUS_PROP_HINT_STR(name, cb) \
{ name, _CITRUS_PROP_STR, { .str = { cb } } }
#define _CITRUS_PROP_HINT_CHR(name, cb) \
Home |
Main Index |
Thread Index |
Old Index