Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove #undef ERR from H5private.h #4346

Merged
merged 1 commit into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions src/H5private.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,14 +288,6 @@
#define SUCCEED 0
#define FAIL (-1)

/* The HDF5 library uses the symbol `ERR` frequently. So do
* header files for libraries such as curses(3), terminfo(3), etc.
* Remove its definition here to avoid clashes with HDF5.
*/
#ifdef ERR
#undef ERR
#endif

/* number of members in an array */
#ifndef NELMTS
#define NELMTS(X) (sizeof(X) / sizeof(X[0]))
Expand Down
10 changes: 5 additions & 5 deletions tools/src/h5import/h5import.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ main(int argc, char *argv[])
* parse the command line
*/
for (i = 1; i < argc; i++) {
if ((token = gtoken(argv[i])) == ERR) {
if ((token = gtoken(argv[i])) == INVALID_TOKEN) {
usage(argv[0]);
goto err;
}
Expand Down Expand Up @@ -220,7 +220,7 @@ main(int argc, char *argv[])
in->outputSize = in->inputSize;
break;

case ERR: /* command syntax error */
case INVALID_TOKEN: /* command syntax error */
default:
(void)fprintf(stderr, "%s", err2);
usage(argv[0]);
Expand Down Expand Up @@ -279,7 +279,7 @@ static int
gtoken(char *s)
{
size_t len;
int token = ERR;
int token = INVALID_TOKEN;

const char *err1 = "Illegal argument: %s.\n";

Expand Down Expand Up @@ -324,11 +324,11 @@ gtoken(char *s)
token = OPT_s;
break;
default:
token = ERR; /* not a supported option tag */
token = INVALID_TOKEN; /* not a supported option tag */
break;
}

if (token == ERR)
if (token == INVALID_TOKEN)
(void)fprintf(stderr, err1, s);
}
else { /* filename */
Expand Down
52 changes: 30 additions & 22 deletions tools/src/h5import/h5import.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
/* filename */
#define OPT_o 1
/* output filename */
#define OPT_c 2 /* configuration filename */
#define OPT_h 3 /* request for explanation */
#define OPT_d 4 /* dimensions */
#define OPT_p 5 /* pathname */
#define OPT_t 6 /* data type */
#define OPT_s 7 /* data size */
#define ERR 20 /* invalid token */
#define OPT_c 2 /* configuration filename */
#define OPT_h 3 /* request for explanation */
#define OPT_d 4 /* dimensions */
#define OPT_p 5 /* pathname */
#define OPT_t 6 /* data type */
#define OPT_s 7 /* data size */
#define INVALID_TOKEN 20 /* invalid token */

#define MAX_GROUPS_IN_PATH 20
#define MAX_PATH_NAME_LENGTH 255
Expand Down Expand Up @@ -130,49 +130,57 @@ static int state_table[15][8] = {
/* token ordering: FILNAME OPT_o OPT_c OPT_h OPT_d OPT_p OPT_t OPT_s */

/* state 0: start */
{1, ERR, ERR, 6, ERR, ERR, ERR, ERR},
{1, INVALID_TOKEN, INVALID_TOKEN, 6, INVALID_TOKEN, INVALID_TOKEN, INVALID_TOKEN, INVALID_TOKEN},

/* state 1: input files */
{ERR, ERR, 2, ERR, 7, ERR, ERR, ERR},
{INVALID_TOKEN, INVALID_TOKEN, 2, INVALID_TOKEN, 7, INVALID_TOKEN, INVALID_TOKEN, INVALID_TOKEN},

/* state 2: -c[onfigfile] */
{3, ERR, ERR, ERR, ERR, ERR, ERR, ERR},
{3, INVALID_TOKEN, INVALID_TOKEN, INVALID_TOKEN, INVALID_TOKEN, INVALID_TOKEN, INVALID_TOKEN,
INVALID_TOKEN},

/* state 3: configfile */
{1, 4, ERR, ERR, ERR, ERR, ERR, ERR},
{1, 4, INVALID_TOKEN, INVALID_TOKEN, INVALID_TOKEN, INVALID_TOKEN, INVALID_TOKEN, INVALID_TOKEN},

/* state 4: -o[utfile] */
{5, ERR, ERR, ERR, ERR, ERR, ERR, ERR},
{5, INVALID_TOKEN, INVALID_TOKEN, INVALID_TOKEN, INVALID_TOKEN, INVALID_TOKEN, INVALID_TOKEN,
INVALID_TOKEN},

/* state 5: outfile */
{ERR, ERR, ERR, ERR, ERR, ERR, ERR, ERR},
{INVALID_TOKEN, INVALID_TOKEN, INVALID_TOKEN, INVALID_TOKEN, INVALID_TOKEN, INVALID_TOKEN, INVALID_TOKEN,
INVALID_TOKEN},

/* state 6: -h[elp] */
{ERR, ERR, ERR, ERR, ERR, ERR, ERR, ERR},
{INVALID_TOKEN, INVALID_TOKEN, INVALID_TOKEN, INVALID_TOKEN, INVALID_TOKEN, INVALID_TOKEN, INVALID_TOKEN,
INVALID_TOKEN},

/* state 7: -d[ims] */
{8, ERR, ERR, ERR, ERR, ERR, ERR, ERR},
{8, INVALID_TOKEN, INVALID_TOKEN, INVALID_TOKEN, INVALID_TOKEN, INVALID_TOKEN, INVALID_TOKEN,
INVALID_TOKEN},

/* state 8: dimensions */
{1, 4, ERR, ERR, ERR, 9, 11, 13},
{1, 4, INVALID_TOKEN, INVALID_TOKEN, INVALID_TOKEN, 9, 11, 13},

/* state 9: -p[ath] */
{10, ERR, ERR, ERR, ERR, ERR, ERR, ERR},
{10, INVALID_TOKEN, INVALID_TOKEN, INVALID_TOKEN, INVALID_TOKEN, INVALID_TOKEN, INVALID_TOKEN,
INVALID_TOKEN},

/* state 10: path name */
{1, 4, ERR, ERR, ERR, ERR, 11, 13},
{1, 4, INVALID_TOKEN, INVALID_TOKEN, INVALID_TOKEN, INVALID_TOKEN, 11, 13},

/* state 11: -t[ype] */
{12, ERR, ERR, ERR, ERR, ERR, ERR, ERR},
{12, INVALID_TOKEN, INVALID_TOKEN, INVALID_TOKEN, INVALID_TOKEN, INVALID_TOKEN, INVALID_TOKEN,
INVALID_TOKEN},

/* state 12: data type */
{1, 4, ERR, ERR, ERR, ERR, ERR, 13},
{1, 4, INVALID_TOKEN, INVALID_TOKEN, INVALID_TOKEN, INVALID_TOKEN, INVALID_TOKEN, 13},

/* state 13: -s[ize] */
{14, ERR, ERR, ERR, ERR, ERR, ERR, ERR},
{14, INVALID_TOKEN, INVALID_TOKEN, INVALID_TOKEN, INVALID_TOKEN, INVALID_TOKEN, INVALID_TOKEN,
INVALID_TOKEN},

/* state 14: data size */
{1, 4, ERR, ERR, ERR, ERR, ERR, ERR}
{1, 4, INVALID_TOKEN, INVALID_TOKEN, INVALID_TOKEN, INVALID_TOKEN, INVALID_TOKEN, INVALID_TOKEN}

};

Expand Down
Loading