From 4f3bcae93d51a26709c12b51261c3d95af610cb2 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 26 Apr 2011 14:33:23 +0200 Subject: [PATCH] Avoid ctype.h . The ctype.h-functions depend on the LANG environment which might be set to something totally different than a server application assumes. We also do not need anything but ASCII based checks (HTTP protocol for one). isxxx functions also require an unsigned int and a cast. These casts can be avoided now. --- client/client.c | 7 +++---- client/fhistory.c | 1 - include/yaz/yaz-iconv.h | 9 +++++++++ src/advancegreek.c | 1 - src/atoin.c | 6 +++--- src/ccl_stop_words.c | 1 - src/cclptree.c | 6 +++--- src/cclstr.c | 7 +++++-- src/ccltoken.c | 5 ++--- src/comstack.c | 10 +++++----- src/cql.y | 4 ++-- src/cqltransform.c | 3 +-- src/grs1disp.c | 1 - src/http.c | 7 +++---- src/iconv_decode_danmarc.c | 1 - src/iconv_decode_iso5426.c | 1 - src/iconv_decode_marc8.c | 1 - src/iconv_encode_iso_8859_1.c | 1 - src/iconv_encode_marc8.c | 1 - src/iconv_encode_wchar.c | 1 - src/iso5428.c | 1 - src/log.c | 4 ++-- src/marc_read_iso2709.c | 3 +-- src/marc_read_line.c | 1 - src/marc_read_xml.c | 1 - src/marcdisp.c | 1 - src/match_glob.c | 1 - src/matchstr.c | 10 +++++----- src/mime.c | 1 - src/odr_util.c | 1 - src/oid_db.c | 1 - src/oid_util.c | 4 ++-- src/opacdisp.c | 1 - src/pquery.c | 3 +-- src/readconf.c | 1 - src/seshigh.c | 3 +-- src/siconv.c | 1 - src/solrtransform.c | 3 +-- src/statserv.c | 6 +++--- src/tokenizer.c | 1 - src/tpath.c | 1 - src/ucs4.c | 1 - src/utf8.c | 1 - src/yaz-ccl.c | 1 - test/test_file_glob.c | 1 - test/test_filepath.c | 1 - test/test_iconv.c | 1 - test/test_nmem.c | 1 - util/yaziconv.c | 1 - zoom/zoom-benchmark.c | 5 +++-- zoom/zoomsh.c | 1 - zoom/zoomtst3.c | 4 ++-- ztest/dummy-opac.c | 1 - ztest/gfs-example.c | 1 - ztest/read-grs.c | 5 ++--- ztest/read-marc.c | 1 - ztest/ztest.c | 5 ++--- 57 files changed, 61 insertions(+), 93 deletions(-) diff --git a/client/client.c b/client/client.c index 71432b4..42a56f0 100644 --- a/client/client.c +++ b/client/client.c @@ -13,7 +13,6 @@ #include #include #include -#include #ifndef WIN32 #include #endif @@ -3067,7 +3066,7 @@ static int parse_show_args(const char *arg_c, char *setstring, *start = start_position; if (*end_ptr == '\0') return 1; - while (isspace(*(unsigned char *)end_ptr)) + while (yaz_isspace(*end_ptr)) end_ptr++; if (*end_ptr != '+') { @@ -3084,7 +3083,7 @@ static int parse_show_args(const char *arg_c, char *setstring, } if (*end_ptr == '\0') return 1; - while (isspace(*(unsigned char *)end_ptr)) + while (yaz_isspace(*end_ptr)) end_ptr++; if (*end_ptr != '+') { @@ -5180,7 +5179,7 @@ static void process_cmd_line(char* line) for (; *p; ++p) { - if (!isspace(*(unsigned char *) p)) + if (!yaz_isspace(*p)) lastnonspace = p; } if (lastnonspace) diff --git a/client/fhistory.c b/client/fhistory.c index a34490a..cb92730 100644 --- a/client/fhistory.c +++ b/client/fhistory.c @@ -14,7 +14,6 @@ #include #include #include -#include #if HAVE_SYS_TYPES_H #include #endif diff --git a/include/yaz/yaz-iconv.h b/include/yaz/yaz-iconv.h index c0ebdd7..a1a2dc4 100644 --- a/include/yaz/yaz-iconv.h +++ b/include/yaz/yaz-iconv.h @@ -82,6 +82,15 @@ YAZ_EXPORT size_t yaz_write_UTF8_char(unsigned long x, char **outbuf, size_t *outbytesleft, int *error); +/* ctype.h macros ASCII based. That do not depend on LANG, nor require + unsigned int as argument */ +#define yaz_isdigit(x) ((x) >= '0' && (x) <= '9') +#define yaz_isspace(x) strchr(" \f\r\n\t\v", x) +#define yaz_toupper(x) ((x) + ('A' - 'a')) +#define yaz_isupper(x) ((x) >= 'A' && (x) <= 'Z') +#define yaz_tolower(x) ((x) + ('a' - 'A')) +#define yaz_islower(x) ((x) >= 'a' && (x) <= 'z') + YAZ_END_CDECL #endif diff --git a/src/advancegreek.c b/src/advancegreek.c index 463c595..e4fc0e4 100644 --- a/src/advancegreek.c +++ b/src/advancegreek.c @@ -14,7 +14,6 @@ #include #include #include -#include #include "iconv-p.h" diff --git a/src/atoin.c b/src/atoin.c index 50a8381..39af45f 100644 --- a/src/atoin.c +++ b/src/atoin.c @@ -13,8 +13,8 @@ #endif #include -#include #include +#include int atoi_n(const char *buf, int len) { @@ -22,7 +22,7 @@ int atoi_n(const char *buf, int len) while (--len >= 0) { - if (isdigit(*(const unsigned char *) buf)) + if (yaz_isdigit(*buf)) val = val*10 + (*buf - '0'); buf++; } @@ -33,7 +33,7 @@ int atoi_n_check(const char *buf, int size, int *val) { int i; for (i = 0; i < size; i++) - if (!isdigit(i[(const unsigned char *) buf])) + if (!yaz_isdigit(*buf)) return 0; *val = atoi_n(buf, size); return 1; diff --git a/src/ccl_stop_words.c b/src/ccl_stop_words.c index db0e16c..bf6a23a 100644 --- a/src/ccl_stop_words.c +++ b/src/ccl_stop_words.c @@ -12,7 +12,6 @@ #include #include -#include #include #include diff --git a/src/cclptree.c b/src/cclptree.c index 1bbcaad..3ceb487 100644 --- a/src/cclptree.c +++ b/src/cclptree.c @@ -15,9 +15,9 @@ #include #include -#include #include +#include #include static void ccl_pquery_indent(WRBUF w, struct ccl_rpn_node *p, int indent); @@ -45,7 +45,7 @@ static void ccl_pquery_complex(WRBUF w, struct ccl_rpn_node *p, int indent) if (*cp == '!') { /* word order specified */ - if (isdigit(((const unsigned char *) cp)[1])) + if (yaz_isdigit(cp[1])) wrbuf_printf(w, "@prox 0 %s 1 2 k 2", cp+1); else wrbuf_printf(w, "@prox 0 1 1 2 k 2"); @@ -53,7 +53,7 @@ static void ccl_pquery_complex(WRBUF w, struct ccl_rpn_node *p, int indent) else if (*cp == '%') { /* word order not specified */ - if (isdigit(((const unsigned char *) cp)[1])) + if (yaz_isdigit(cp[1])) wrbuf_printf(w, "@prox 0 %s 0 2 k 2", cp+1); else wrbuf_printf(w, "@prox 0 1 0 2 k 2"); diff --git a/src/cclstr.c b/src/cclstr.c index 7c1e3e9..a970643 100644 --- a/src/cclstr.c +++ b/src/cclstr.c @@ -9,7 +9,7 @@ #if HAVE_CONFIG_H #include #endif -#include +#include #include #include @@ -17,7 +17,10 @@ static int ccli_toupper (int c) { - return toupper (c); + if (yaz_islower(c)) + return yaz_toupper(c); + else + return c; } int (*ccl_toupper)(int c) = NULL; diff --git a/src/ccltoken.c b/src/ccltoken.c index db5d9c9..538cd56 100644 --- a/src/ccltoken.c +++ b/src/ccltoken.c @@ -12,8 +12,7 @@ #include #include -#include - +#include #include "cclp.h" /* @@ -105,7 +104,7 @@ struct ccl_token *ccl_parser_tokenize(CCL_parser cclp, const char *command) case '%': case '!': last->kind = CCL_TOK_PROX; - while (isdigit(*cp)) + while (yaz_isdigit(*cp)) { ++ last->len; cp++; diff --git a/src/comstack.c b/src/comstack.c index 496fe22..669117d 100644 --- a/src/comstack.c +++ b/src/comstack.c @@ -11,9 +11,9 @@ #endif #include -#include #include +#include #include #include #include @@ -234,13 +234,13 @@ static int cs_read_chunk(const char *buf, int i, int len) printf ("i=%d len=%d\n", i, len); #endif return 0; - } else if (isdigit(buf[i])) + } else if (yaz_isdigit(buf[i])) chunk_len = chunk_len * 16 + (buf[i++] - '0'); - else if (isupper(buf[i])) + else if (yaz_isupper(buf[i])) chunk_len = chunk_len * 16 + (buf[i++] - ('A'-10)); - else if (islower(buf[i])) + else if (yaz_islower(buf[i])) chunk_len = chunk_len * 16 + (buf[i++] - ('a'-10)); else @@ -345,7 +345,7 @@ static int cs_complete_http(const char *buf, int len, int head_only) while (buf[i] == ' ') i++; content_len = 0; - while (i <= len-4 && isdigit(buf[i])) + while (i <= len-4 && yaz_isdigit(buf[i])) content_len = content_len*10 + (buf[i++] - '0'); if (content_len < 0) /* prevent negative offsets */ content_len = 0; diff --git a/src/cql.y b/src/cql.y index 7bb83f8..d102a17 100644 --- a/src/cql.y +++ b/src/cql.y @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include #include @@ -266,7 +266,7 @@ int yylex(YYSTYPE *lval, void *vp) return 0; if (c == '\n') return 0; - } while (isspace(c)); + } while (yaz_isspace(c)); if (strchr("()=> #include #include -#include #include #include #include @@ -138,7 +137,7 @@ static int cql_transform_parse_tok_line(cql_transform_t ct, break; } value_str = yaz_tok_parse_string(tp); - if (isdigit(*value_str)) + if (yaz_isdigit(*value_str)) { elem->which = Z_AttributeValue_numeric; elem->value.numeric = diff --git a/src/grs1disp.c b/src/grs1disp.c index 29b6304..f01fab8 100644 --- a/src/grs1disp.c +++ b/src/grs1disp.c @@ -13,7 +13,6 @@ #include #include #include -#include #include #include diff --git a/src/http.c b/src/http.c index 0fb1434..3f8fb53 100644 --- a/src/http.c +++ b/src/http.c @@ -10,7 +10,6 @@ #include #endif -#include #include #include #include @@ -143,13 +142,13 @@ static int decode_headers_content(ODR o, int off, Z_HTTP_Header **headers, /* chunk length .. */ int chunk_len = 0; for (; i < o->size-2; i++) - if (isdigit(o->buf[i])) + if (yaz_isdigit(o->buf[i])) chunk_len = chunk_len * 16 + (o->buf[i] - '0'); - else if (isupper(o->buf[i])) + else if (yaz_isupper(o->buf[i])) chunk_len = chunk_len * 16 + (o->buf[i] - ('A'-10)); - else if (islower(o->buf[i])) + else if (yaz_islower(o->buf[i])) chunk_len = chunk_len * 16 + (o->buf[i] - ('a'-10)); else diff --git a/src/iconv_decode_danmarc.c b/src/iconv_decode_danmarc.c index 7e86c0d..aba40be 100644 --- a/src/iconv_decode_danmarc.c +++ b/src/iconv_decode_danmarc.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include diff --git a/src/iconv_decode_iso5426.c b/src/iconv_decode_iso5426.c index 33847bc..4938e51 100644 --- a/src/iconv_decode_iso5426.c +++ b/src/iconv_decode_iso5426.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include "iconv-p.h" diff --git a/src/iconv_decode_marc8.c b/src/iconv_decode_marc8.c index 7b31510..915a68c 100644 --- a/src/iconv_decode_marc8.c +++ b/src/iconv_decode_marc8.c @@ -17,7 +17,6 @@ #include #include #include -#include #include #include "iconv-p.h" diff --git a/src/iconv_encode_iso_8859_1.c b/src/iconv_encode_iso_8859_1.c index 20b6505..32befea 100644 --- a/src/iconv_encode_iso_8859_1.c +++ b/src/iconv_encode_iso_8859_1.c @@ -15,7 +15,6 @@ #include #include #include -#include #include #include "iconv-p.h" diff --git a/src/iconv_encode_marc8.c b/src/iconv_encode_marc8.c index 2d7b694..6e753f1 100644 --- a/src/iconv_encode_marc8.c +++ b/src/iconv_encode_marc8.c @@ -17,7 +17,6 @@ #include #include #include -#include #include #include diff --git a/src/iconv_encode_wchar.c b/src/iconv_encode_wchar.c index 41b4492..a39a36c 100644 --- a/src/iconv_encode_wchar.c +++ b/src/iconv_encode_wchar.c @@ -14,7 +14,6 @@ #include #include #include -#include #if HAVE_WCHAR_H #include #endif diff --git a/src/iso5428.c b/src/iso5428.c index 5f22b24..f357187 100644 --- a/src/iso5428.c +++ b/src/iso5428.c @@ -14,7 +14,6 @@ #include #include #include -#include #include "iconv-p.h" diff --git a/src/log.c b/src/log.c index b68e308..28ffba5 100644 --- a/src/log.c +++ b/src/log.c @@ -22,11 +22,11 @@ #endif #include #include -#include #include #include #include #include +#include #include #include #include @@ -575,7 +575,7 @@ int yaz_log_mask_str_x(const char *str, int level) negated = 1; str++; } - if (isdigit(*(unsigned char *) str)) + if (yaz_isdigit(*str)) { level = atoi(str); } diff --git a/src/marc_read_iso2709.c b/src/marc_read_iso2709.c index dd20fc8..608a1e4 100644 --- a/src/marc_read_iso2709.c +++ b/src/marc_read_iso2709.c @@ -18,7 +18,6 @@ #include #include -#include #include #include #include @@ -90,7 +89,7 @@ int yaz_marc_read_iso2709(yaz_marc_t mt, const char *buf, int bsize) } /* Check for digits in length+starting info */ while (--l >= 3) - if (!isdigit(*(const unsigned char *) (buf + entry_p+l))) + if (!yaz_isdigit(buf[entry_p + l])) break; if (l >= 3) { diff --git a/src/marc_read_line.c b/src/marc_read_line.c index 82f455f..2137197 100644 --- a/src/marc_read_line.c +++ b/src/marc_read_line.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include diff --git a/src/marc_read_xml.c b/src/marc_read_xml.c index a81e8c4..709c8a0 100644 --- a/src/marc_read_xml.c +++ b/src/marc_read_xml.c @@ -18,7 +18,6 @@ #include #include -#include #include #include #include diff --git a/src/marcdisp.c b/src/marcdisp.c index 00d1ed8..8f9bcc3 100644 --- a/src/marcdisp.c +++ b/src/marcdisp.c @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include diff --git a/src/match_glob.c b/src/match_glob.c index 8fe4a2e..696a4a8 100644 --- a/src/match_glob.c +++ b/src/match_glob.c @@ -12,7 +12,6 @@ #include #include -#include #include #include diff --git a/src/matchstr.c b/src/matchstr.c index 15296cc..ce9521c 100644 --- a/src/matchstr.c +++ b/src/matchstr.c @@ -14,8 +14,8 @@ #include #include -#include #include +#include #include int yaz_matchstr(const char *s1, const char *s2) @@ -35,10 +35,10 @@ int yaz_matchstr(const char *s1, const char *s2) break; if (c2 != '.') { - if (isupper(c1)) - c1 = tolower(c1); - if (isupper(c2)) - c2 = tolower(c2); + if (yaz_isupper(c1)) + c1 = yaz_tolower(c1); + if (yaz_isupper(c2)) + c2 = yaz_tolower(c2); if (c1 != c2) break; } diff --git a/src/mime.c b/src/mime.c index 88dee67..f2421d1 100644 --- a/src/mime.c +++ b/src/mime.c @@ -13,7 +13,6 @@ #include #include -#include #include #include "mime.h" diff --git a/src/odr_util.c b/src/odr_util.c index 238f1be..aea6a4a 100644 --- a/src/odr_util.c +++ b/src/odr_util.c @@ -12,7 +12,6 @@ #include #include -#include #include "odr-priv.h" #include diff --git a/src/oid_db.c b/src/oid_db.c index 5d9297e..3b27864 100644 --- a/src/oid_db.c +++ b/src/oid_db.c @@ -13,7 +13,6 @@ #include #include -#include #include #include diff --git a/src/oid_util.c b/src/oid_util.c index 58c3a35..6158d3c 100644 --- a/src/oid_util.c +++ b/src/oid_util.c @@ -14,8 +14,8 @@ #include #include -#include +#include #include #include @@ -76,7 +76,7 @@ int oid_dotstring_to_oid(const char *name, Odr_oid *oid) { int i = 0; int val = 0; - while (isdigit (*(unsigned char *) name)) + while (yaz_isdigit (*name)) { val = val*10 + (*name - '0'); name++; diff --git a/src/opacdisp.c b/src/opacdisp.c index 735d969..4700a35 100644 --- a/src/opacdisp.c +++ b/src/opacdisp.c @@ -13,7 +13,6 @@ #include #include #include -#include #include #include diff --git a/src/pquery.c b/src/pquery.c index 1a45b40..dceed33 100644 --- a/src/pquery.c +++ b/src/pquery.c @@ -13,7 +13,6 @@ #include #include #include -#include #include #include @@ -77,7 +76,7 @@ static int query_token(struct yaz_pqf_parser *li) } li->lex_buf = *qptr; - if (**qptr == li->escape_char && isdigit(((const unsigned char *) *qptr)[1])) + if (**qptr == li->escape_char && yaz_isdigit((*qptr)[1])) { ++(li->lex_len); ++(*qptr); diff --git a/src/readconf.c b/src/readconf.c index 7a9c282..4d9bd05 100644 --- a/src/readconf.c +++ b/src/readconf.c @@ -13,7 +13,6 @@ #endif #include -#include #include #include diff --git a/src/seshigh.c b/src/seshigh.c index 1d709aa..2afbb4b 100644 --- a/src/seshigh.c +++ b/src/seshigh.c @@ -33,7 +33,6 @@ #include #include #include -#include #if HAVE_SYS_TYPES_H #include @@ -1920,7 +1919,7 @@ static void process_http_request(association *assoc, request *req) int t; const char *alive = z_HTTP_header_lookup(hreq->headers, "Keep-Alive"); - if (alive && isdigit(*(const unsigned char *) alive)) + if (alive && yaz_isdigit(*(const unsigned char *) alive)) t = atoi(alive); else t = 15; diff --git a/src/siconv.c b/src/siconv.c index 6a2618c..9ae3c39 100644 --- a/src/siconv.c +++ b/src/siconv.c @@ -20,7 +20,6 @@ #include #include #include -#include #if HAVE_ICONV_H #include diff --git a/src/solrtransform.c b/src/solrtransform.c index d2732e5..4ce5a95 100644 --- a/src/solrtransform.c +++ b/src/solrtransform.c @@ -13,7 +13,6 @@ #include #include #include -#include #include #include #include @@ -160,7 +159,7 @@ static int solr_transform_parse_tok_line(solr_transform_t ct, break; } value_str = yaz_tok_parse_string(tp); - if (isdigit(*value_str)) + if (yaz_isdigit(*value_str)) { elem->which = Z_AttributeValue_numeric; elem->value.numeric = diff --git a/src/statserv.c b/src/statserv.c index 7560058..487153e 100644 --- a/src/statserv.c +++ b/src/statserv.c @@ -15,7 +15,6 @@ #include #include #include -#include #ifdef WIN32 #include @@ -64,6 +63,7 @@ #include "session.h" #include #include +#include static IOCHAN pListener = NULL; @@ -195,7 +195,7 @@ static char *nmem_dup_xml_content(NMEM n, xmlNodePtr ptr) cp = p->content; if (first) { - while(*cp && isspace(*cp)) + while(*cp && yaz_isspace(*cp)) cp++; if (*cp) first = 0; /* reset if we got non-whitespace out */ @@ -205,7 +205,7 @@ static char *nmem_dup_xml_content(NMEM n, xmlNodePtr ptr) } /* remove trailing whitespace */ cp = strlen((const char *)str) + str; - while (cp != str && isspace(cp[-1])) + while (cp != str && yaz_isspace(cp[-1])) cp--; *cp = '\0'; /* return resulting string */ diff --git a/src/tokenizer.c b/src/tokenizer.c index 108de00..5f783be 100644 --- a/src/tokenizer.c +++ b/src/tokenizer.c @@ -13,7 +13,6 @@ #include #include #include -#include #include #include #include diff --git a/src/tpath.c b/src/tpath.c index 67b823a..a58bb3a 100644 --- a/src/tpath.c +++ b/src/tpath.c @@ -14,7 +14,6 @@ #include #include -#include #include #include #if HAVE_SYS_TYPES_H diff --git a/src/ucs4.c b/src/ucs4.c index 1b10e30..3b50dec 100644 --- a/src/ucs4.c +++ b/src/ucs4.c @@ -14,7 +14,6 @@ #include #include #include -#include #include "iconv-p.h" diff --git a/src/utf8.c b/src/utf8.c index ea1a5b0..8911683 100644 --- a/src/utf8.c +++ b/src/utf8.c @@ -14,7 +14,6 @@ #include #include #include -#include #include "iconv-p.h" diff --git a/src/yaz-ccl.c b/src/yaz-ccl.c index ddac41d..ee7a098 100644 --- a/src/yaz-ccl.c +++ b/src/yaz-ccl.c @@ -13,7 +13,6 @@ #include #include #include -#include #include #include diff --git a/test/test_file_glob.c b/test/test_file_glob.c index 6812e38..1526dc8 100644 --- a/test/test_file_glob.c +++ b/test/test_file_glob.c @@ -10,7 +10,6 @@ #include #include #include -#include #include #include diff --git a/test/test_filepath.c b/test/test_filepath.c index c816034..71431e8 100644 --- a/test/test_filepath.c +++ b/test/test_filepath.c @@ -10,7 +10,6 @@ #include #include #include -#include #include #include diff --git a/test/test_iconv.c b/test/test_iconv.c index 3c730cf..2a533bb 100644 --- a/test/test_iconv.c +++ b/test/test_iconv.c @@ -9,7 +9,6 @@ #include #include #include -#include #include #include diff --git a/test/test_nmem.c b/test/test_nmem.c index cd47192..61c0739 100644 --- a/test/test_nmem.c +++ b/test/test_nmem.c @@ -10,7 +10,6 @@ #include #include #include -#include #include #include diff --git a/util/yaziconv.c b/util/yaziconv.c index 3d4a1f0..0d9d211 100644 --- a/util/yaziconv.c +++ b/util/yaziconv.c @@ -10,7 +10,6 @@ #include #include #include -#include #include diff --git a/zoom/zoom-benchmark.c b/zoom/zoom-benchmark.c index 25c6759..83020e6 100644 --- a/zoom/zoom-benchmark.c +++ b/zoom/zoom-benchmark.c @@ -2,18 +2,19 @@ * Copyright (C) 1995-2011 Index Data * See the file LICENSE for details. */ +#if HAVE_CONFIG_H +#include +#endif #include #include #include -#include #include #include #include #include - /* naming events */ static char* zoom_events[ZOOM_EVENT_MAX+1]; diff --git a/zoom/zoomsh.c b/zoom/zoomsh.c index 461e848..530e08e 100644 --- a/zoom/zoomsh.c +++ b/zoom/zoomsh.c @@ -12,7 +12,6 @@ #include #include #include -#include #include #include diff --git a/zoom/zoomtst3.c b/zoom/zoomtst3.c index 7c2f751..7366f94 100644 --- a/zoom/zoomtst3.c +++ b/zoom/zoomtst3.c @@ -6,7 +6,7 @@ #include #include #include -#include +#include #include @@ -27,7 +27,7 @@ int main(int argc, char **argv) "%s number target query\n", *argv, *argv); exit (1); } - if (argc == 4 && isdigit(argv[1][0]) && !strchr(argv[1],'.')) + if (argc == 4 && yaz_isdigit(argv[1][0]) && !strchr(argv[1],'.')) { no = atoi(argv[1]); same_target = 1; diff --git a/ztest/dummy-opac.c b/ztest/dummy-opac.c index 50af043..e3d96d0 100644 --- a/ztest/dummy-opac.c +++ b/ztest/dummy-opac.c @@ -9,7 +9,6 @@ #include #endif -#include #include #include #include diff --git a/ztest/gfs-example.c b/ztest/gfs-example.c index 2aa5d8e..55e0cb7 100644 --- a/ztest/gfs-example.c +++ b/ztest/gfs-example.c @@ -11,7 +11,6 @@ #include #include -#include #include #include diff --git a/ztest/read-grs.c b/ztest/read-grs.c index 162f9ab..2943782 100644 --- a/ztest/read-grs.c +++ b/ztest/read-grs.c @@ -10,7 +10,6 @@ #endif #include -#include #include #include @@ -34,7 +33,7 @@ static Z_GenericRecord *read_grs1(FILE *f, ODR o) while (fgets(buf = line, 512, f)) { - while (*buf && isspace(*(unsigned char *) buf)) + while (*buf && yaz_isspace(*buf)) buf++; if (!*buf || *buf == '#') continue; @@ -52,7 +51,7 @@ static Z_GenericRecord *read_grs1(FILE *f, ODR o) if (!(buf = strchr(buf, ')'))) return 0; buf++; - while (*buf && isspace(*(unsigned char *) buf)) + while (*buf && yaz_isspace(*buf)) buf++; if (!*buf) return 0; diff --git a/ztest/read-marc.c b/ztest/read-marc.c index 3737554..4767f78 100644 --- a/ztest/read-marc.c +++ b/ztest/read-marc.c @@ -9,7 +9,6 @@ #include #endif -#include #include #include #include diff --git a/ztest/ztest.c b/ztest/ztest.c index 88e0a21..3c96d91 100644 --- a/ztest/ztest.c +++ b/ztest/ztest.c @@ -13,7 +13,6 @@ #include #include #include -#include #if HAVE_SYS_TIME_H #include @@ -1010,8 +1009,8 @@ int ztest_scan(void *handle, bend_scan_rr *q) strcpy(term, "0"); for (p = term; *p; p++) - if (islower(*(unsigned char *) p)) - *p = toupper(*p); + if (yaz_islower(*p)) + *p = yaz_toupper(*p); fseek(f, 0, SEEK_SET); q->num_entries = 0; -- 1.7.10.4