Skip to content

Commit 1c6d166

Browse files
committed
fix isxspace warnings.
default to assuming libintl.
1 parent ee3e475 commit 1c6d166

File tree

3 files changed

+22
-19
lines changed

3 files changed

+22
-19
lines changed

CMakeLists.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
cmake_minimum_required(VERSION 2.8)
1+
cmake_minimum_required(VERSION 2.8...3.20)
22
project (echeck C)
33

44
add_executable(echeck echeck.c unicode.c whereami.c)
55
add_executable(tests echeck.c unicode.c tests.c whereami.c CuTest.c)
66
target_compile_definitions (tests PRIVATE TESTING=1)
77

8+
if (MSVC)
9+
target_compile_definitions (echeck PRIVATE /Wx)
10+
endif (MSVC)
811
if (WIN32)
912
find_library(Intl_LIBRARY NAMES libintl intl
1013
DOC "libintl libraries (if not in the C library)")
@@ -17,12 +20,12 @@ find_package(Intl)
1720
include_directories(${Intl_INCLUDE_DIR})
1821

1922
if (Intl_FOUND)
20-
target_compile_definitions (echeck PRIVATE HAVE_GETTEXT=1)
21-
target_compile_definitions (tests PRIVATE HAVE_GETTEXT=1)
2223
target_link_libraries(echeck ${Intl_LIBRARIES})
2324
target_link_libraries(tests ${Intl_LIBRARIES})
2425
else (Intl_FOUND)
2526
message(STATUS "libintl not found")
27+
target_compile_definitions (echeck PRIVATE NO_GETTEXT=1)
28+
target_compile_definitions (tests PRIVATE NO_GETTEXT=1)
2629
endif (Intl_FOUND)
2730

2831
include("Localization.cmake")

echeck.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
#include "unicode.h"
4545
#include "whereami.h"
4646

47-
#ifdef HAVE_GETTEXT
47+
#ifndef NO_GETTEXT
4848
#include <libintl.h>
4949
#include <locale.h>
5050
#else
@@ -87,9 +87,9 @@ int AddTestSuites(CuSuite * suite, const char *names);
8787

8888
#include <string.h>
8989

90-
#define isxspace(c) (c==194 || c==160 || isspace(c))
90+
#define isxspace(c) ((c)==194 || (c)==160 || isspace(c))
9191

92-
static const char *echeck_version = "4.5.7";
92+
static const char *echeck_version = "4.5.8";
9393

9494
#define DEFAULT_PATH "."
9595

@@ -783,8 +783,9 @@ int Pow(int p)
783783

784784
#define iswxspace(c) (c==160 || iswspace(c))
785785

786-
char *eatwhite(char *ptr)
786+
char *eatwhite(char *input)
787787
{
788+
unsigned char *ptr = (unsigned char *)input;
788789
while (*ptr) {
789790
ucs4_t ucs;
790791
size_t size = 0;
@@ -1062,11 +1063,10 @@ void readskill(char *s)
10621063
}
10631064
sk->name = STRDUP(transliterate(buffer, sizeof(buffer), s));
10641065
if (x) {
1065-
s = (char *)(x + 1);
1066-
while (isxspace(*s))
1067-
s++;
1068-
if (*s)
1069-
sk->kosten = atoi(s);
1066+
unsigned char *p = (unsigned char *)(x + 1);
1067+
while (isxspace(*p)) ++p;
1068+
if (*p)
1069+
sk->kosten = atoi(p);
10701070
}
10711071
sk->next = skilldata;
10721072
skilldata = sk;
@@ -1310,7 +1310,7 @@ int parsefile(char *s, int typ)
13101310
if (!x)
13111311
return 0;
13121312
y = x + 1;
1313-
while (isxspace(*(x - 1)))
1313+
while (isxspace(*((unsigned char *)x - 1)))
13141314
x--;
13151315
*x = 0;
13161316
for (i = 1; i < UT_MAX; i++)
@@ -2115,15 +2115,15 @@ char *getbuf(void)
21152115
if (c > 0 && isxspace(c)) {
21162116
if (eatwhite) {
21172117
do {
2118-
c = *(++bp);
2118+
c = *(unsigned char *)++bp;
21192119
}
21202120
while (bp != lbuf + MAXLINE && isxspace(*bp));
21212121
if (!quote && !start)
21222122
*(cp++) = ' ';
21232123
} else {
21242124
do {
21252125
*(cp++) = SPACE_REPLACEMENT;
2126-
c = *(++bp);
2126+
c = *(unsigned char *)++bp;
21272127
}
21282128
while (cp != warn_buf + MAXLINE && bp != lbuf + MAXLINE
21292129
&& c > 0 && isxspace(c));
@@ -5020,7 +5020,7 @@ void process_order_file(int *faction_count, int *unit_count)
50205020
x = strchr(order_buf, ';');
50215021
if (x) {
50225022
x++;
5023-
while (isxspace(*x))
5023+
while (isxspace(*(unsigned char *)x))
50245024
x++;
50255025
if (r->name)
50265026
free(r->name);
@@ -5300,7 +5300,7 @@ void init(void)
53005300
filename = getenv("ECHECKOPTS");
53015301
}
53025302

5303-
#ifdef HAVE_GETTEXT
5303+
#ifndef NO_GETTEXT
53045304
#ifdef WIN32
53055305
#define PATH_SEP '\\'
53065306
#else
@@ -5351,7 +5351,7 @@ void init_intl(void)
53515351
int main(int argc, char *argv[])
53525352
{
53535353
int faction_count = 0, unit_count = 0, nextarg = 1, i;
5354-
#ifdef HAVE_GETTEXT
5354+
#ifndef NO_GETTEXT
53555355
init_intl();
53565356
#endif
53575357
#if macintosh

unicode.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ extern "C" {
2626
#include <wchar.h>
2727
#define USE_UNICODE
2828
typedef unsigned long ucs4_t;
29-
typedef char utf8_t;
29+
typedef unsigned char utf8_t;
3030

3131
extern int unicode_utf8_to_cp437(char *result, const utf8_t * utf8_string,
3232
size_t * length);

0 commit comments

Comments
 (0)