Skip to content

Commit be4da0c

Browse files
committed
cleaned up OS test macros
1 parent a5b41c7 commit be4da0c

File tree

12 files changed

+64
-53
lines changed

12 files changed

+64
-53
lines changed

COPYING.LIB

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -488,9 +488,9 @@ notice is found.
488488
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
489489
Lesser General Public License for more details.
490490

491-
You should have received a copy of the GNU Lesser General Public
492-
License along with this library; if not, write to the Free Software
493-
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
491+
You should have received a copy of the GNU Library General Public
492+
License along with this library; if not, see
493+
<http://www.gnu.org/licenses/>.
494494

495495
Also add information on how to contact you by electronic and paper mail.
496496

LICENSE

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -483,10 +483,9 @@ convey the exclusion of warranty; and each file should have at least the
483483
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
484484
Lesser General Public License for more details.
485485

486-
You should have received a copy of the GNU Lesser General Public
487-
License along with this library; if not, write to the Free Software
488-
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
489-
USA
486+
You should have received a copy of the GNU Library General Public
487+
License along with this library; if not, see
488+
<http://www.gnu.org/licenses/>.
490489

491490
Also add information on how to contact you by electronic and paper mail.
492491

lib/libconfig.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,14 @@
5656
/* ------------------------------------------------------------------------- */
5757

5858
#ifndef LIBCONFIG_STATIC
59-
#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) \
60-
|| defined(WIN64) || defined(_WIN64) || defined(__WIN64__))
59+
#ifdef LIBCONFIG_WINDOWS_OS
6160

6261
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
6362
{
6463
return(TRUE);
6564
}
6665

67-
#endif /* WIN32 || WIN64 */
66+
#endif /* LIBCONFIG_WINDOWS_OS */
6867
#endif /* LIBCONFIG_STATIC */
6968

7069
/* ------------------------------------------------------------------------- */
@@ -100,8 +99,7 @@ static void __config_assert(const char *function, const char *expr)
10099

101100
static void __config_locale_override(void)
102101
{
103-
#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__)) \
104-
&& ! defined(__MINGW32__)
102+
#if defined(LIBCONFIG_WINDOWS_OS) && !defined(LIBCONFIG_MINGW_OS)
105103

106104
_configthreadlocale(_ENABLE_PER_THREAD_LOCALE);
107105
setlocale(LC_NUMERIC, "C");
@@ -127,8 +125,7 @@ static void __config_locale_override(void)
127125

128126
static void __config_locale_restore(void)
129127
{
130-
#if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__)) \
131-
&& ! defined(__MINGW32__)
128+
#if defined(LIBCONFIG_WINDOWS_OS) && !defined(LIBCONFIG_MINGW_OS)
132129

133130
_configthreadlocale(_DISABLE_PER_THREAD_LOCALE);
134131

@@ -164,7 +161,7 @@ static void __config_write_value(const config_t *config,
164161
const config_value_t *value, int type,
165162
int format, int depth, FILE *stream)
166163
{
167-
// Long enough for 64-bit binary value + NULL terminator.
164+
/* Long enough for 64-bit binary value + NULL terminator. */
168165
char temp_buf[(sizeof(int64_t) * BITS_IN_BYTE) + 1];
169166

170167
switch(type)
@@ -214,7 +211,7 @@ static void __config_write_value(const config_t *config,
214211
break;
215212

216213
case CONFIG_FORMAT_OCT:
217-
fprintf(stream, "0o%llo", value->llval);
214+
fprintf(stream, "0o%lloL", value->llval);
218215
break;
219216

220217
case CONFIG_FORMAT_DEFAULT:
@@ -686,13 +683,13 @@ int config_read_file(config_t *config, const char *filename)
686683
stream = fopen(filename, "rt");
687684
if(stream != NULL)
688685
{
689-
// On some operating systems, fopen() succeeds on a directory.
686+
/* On some operating systems, fopen() succeeds on a directory. */
690687
int fd = posix_fileno(stream);
691688
struct stat statbuf;
692689

693690
if(fstat(fd, &statbuf) == 0)
694691
{
695-
// Only proceed if this is not a directory.
692+
/* Only proceed if this is not a directory. */
696693
if(!S_ISDIR(statbuf.st_mode))
697694
ok = 1;
698695
}
@@ -800,7 +797,7 @@ unsigned short config_get_tab_width(const config_t *config)
800797
{
801798
config_assert(config != NULL);
802799

803-
return config->tab_width;
800+
return(config->tab_width);
804801
}
805802

806803
/* ------------------------------------------------------------------------- */
@@ -818,7 +815,7 @@ unsigned short config_get_float_precision(const config_t *config)
818815
{
819816
config_assert(config != NULL);
820817

821-
return config->float_precision;
818+
return(config->float_precision);
822819
}
823820

824821
/* ------------------------------------------------------------------------- */
@@ -889,7 +886,8 @@ void config_set_hook(config_t *config, void *hook)
889886

890887
/* ------------------------------------------------------------------------- */
891888

892-
void config_set_fatal_error_func(config_fatal_error_fn_t func) {
889+
void config_set_fatal_error_func(config_fatal_error_fn_t func)
890+
{
893891
libconfig_set_fatal_error_func(func);
894892
}
895893

@@ -1028,7 +1026,7 @@ int config_setting_get_int64_safe(const config_setting_t *setting,
10281026
config_assert(setting != NULL);
10291027
config_assert(value != NULL);
10301028

1031-
return __config_setting_get_int64(setting, value);
1029+
return(__config_setting_get_int64(setting, value));
10321030
}
10331031

10341032
/* ------------------------------------------------------------------------- */
@@ -1373,6 +1371,7 @@ int config_setting_set_string(config_setting_t *setting, const char *value)
13731371
__delete(setting->value.sval);
13741372

13751373
setting->value.sval = (value == NULL) ? NULL : strdup(value);
1374+
13761375
return(CONFIG_TRUE);
13771376
}
13781377

@@ -1575,6 +1574,7 @@ int config_lookup_bool(const config_t *config, const char *path, int *value)
15751574
return(CONFIG_FALSE);
15761575

15771576
*value = config_setting_get_bool(s);
1577+
15781578
return(CONFIG_TRUE);
15791579
}
15801580

lib/libconfig.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,18 @@
2727
extern "C" {
2828
#endif /* __cplusplus */
2929

30-
#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
30+
#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) \
31+
|| defined(_WIN64) || defined(__WIN64__) || defined(WIN64)
3132
#if defined(LIBCONFIG_STATIC)
3233
#define LIBCONFIG_API
3334
#elif defined(LIBCONFIG_EXPORTS)
3435
#define LIBCONFIG_API __declspec(dllexport)
3536
#else /* ! LIBCONFIG_EXPORTS */
3637
#define LIBCONFIG_API __declspec(dllimport)
3738
#endif /* LIBCONFIG_STATIC */
38-
#else /* ! WIN32 */
39+
#else /* ! WIN32/64 */
3940
#define LIBCONFIG_API
40-
#endif /* WIN32 */
41+
#endif /* WIN32/64 */
4142

4243
#define LIBCONFIG_VER_MAJOR 1
4344
#define LIBCONFIG_VER_MINOR 8

lib/libconfig.hh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1515
Lesser General Public License for more details.
1616
17-
You should have received a copy of the GNU Lesser General Public
18-
License along with this library; if not, write to the Free Software
19-
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17+
You should have received a copy of the GNU Library General Public
18+
License along with this library; if not, see
19+
<http://www.gnu.org/licenses/>.
2020
----------------------------------------------------------------------------
2121
*/
2222

lib/libconfigcpp.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1515
Lesser General Public License for more details.
1616
17-
You should have received a copy of the GNU Lesser General Public
18-
License along with this library; if not, write to the Free Software
19-
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17+
You should have received a copy of the GNU Library General Public
18+
License along with this library; if not, see
19+
<http://www.gnu.org/licenses/>.
2020
----------------------------------------------------------------------------
2121
*/
2222

lib/scanner.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,7 @@ static const flex_int32_t yy_rule_can_match_eol[49] =
929929
#include "wincompat.h"
930930
#include "util.h"
931931

932-
#define YY_NO_INPUT // Suppress generation of useless input() function
932+
#define YY_NO_INPUT /* Suppress generation of useless input() function */
933933

934934
#line 935 "scanner.c"
935935

lib/scanner.l

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
#include "wincompat.h"
5252
#include "util.h"
5353

54-
#define YY_NO_INPUT // Suppress generation of useless input() function
54+
#define YY_NO_INPUT /* Suppress generation of useless input() function */
5555

5656
%}
5757

lib/util.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ long long libconfig_parse_integer(const char *s, int base, int *is_long,
100100
long long llval;
101101
char *endptr;
102102
int errsave = errno;
103-
103+
104104
errno = 0;
105105
llval = strtoll(s, &endptr, base);
106106

@@ -109,7 +109,7 @@ long long libconfig_parse_integer(const char *s, int base, int *is_long,
109109

110110
*is_long = ((llval < INT_MIN) || (llval > INT_MAX));
111111

112-
// See if we can ignore the L.
112+
/* Check for trailing L's */
113113
while(!errno && *endptr == 'L')
114114
{
115115
*is_long = 1;
@@ -123,7 +123,7 @@ long long libconfig_parse_integer(const char *s, int base, int *is_long,
123123
return(0); /* parse error */
124124
}
125125
errno = errsave;
126-
126+
127127
*ok = 1;
128128
return(llval);
129129
}
@@ -165,8 +165,11 @@ void libconfig_format_double(double val, int precision, int sci_ok, char *buf,
165165
/* ------------------------------------------------------------------------- */
166166

167167
#ifdef __GNUC__
168+
168169
#define clzl(x) __builtin_clzll(x)
169-
#else
170+
171+
#else /* __GNUC__ */
172+
170173
static int clzl(int64_t val)
171174
{
172175
int leading = 0;
@@ -178,7 +181,8 @@ static int clzl(int64_t val)
178181
}
179182
return leading;
180183
}
181-
#endif
184+
185+
#endif /* __GNUC__ */
182186

183187
/* ------------------------------------------------------------------------- */
184188

@@ -196,3 +200,5 @@ void libconfig_format_bin(int64_t val, char *buf, size_t buflen)
196200
}
197201
buf[i] = '\0';
198202
}
203+
204+
/* ------------------------------------------------------------------------- */

lib/wincompat.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222

2323
#include "wincompat.h"
2424

25-
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) \
26-
|| defined(WIN64) || defined(_WIN64) || defined(__WIN64__)
25+
#ifdef LIBCONFIG_WINDOWS_OS
2726

2827
#include <errno.h>
2928
#include <io.h>
@@ -58,4 +57,4 @@ int posix_fsync(int fd)
5857
return(0);
5958
}
6059

61-
#endif // WIN32 || WIN64
60+
#endif /* LIBCONFIG_WINDOWS_OS */

0 commit comments

Comments
 (0)