Skip to content

Commit

Permalink
Change gets() to fgets() in user prompts (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
dey4ss authored Mar 14, 2024
1 parent a60ba27 commit c2cebff
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
25 changes: 14 additions & 11 deletions bm_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,20 @@ yes_no(char *prompt)
#pragma warning(default:4127)
#endif
printf("%s [Y/N]: ", prompt);
gets(reply);
switch (*reply)
// HYRISE: Replace gets() with fgets(). Add if.
if (fgets(reply, sizeof(reply), stdin) != NULL)
{
case 'y':
case 'Y':
return (1);
case 'n':
case 'N':
return (0);
default:
printf("Please answer 'yes' or 'no'.\n");
switch (*reply)
{
case 'y':
case 'Y':
return (1);
case 'n':
case 'N':
return (0);
default:
printf("Please answer 'yes' or 'no'.\n");
}
}
}
}
Expand Down Expand Up @@ -577,7 +580,7 @@ set_state(int table, long sf, long procs, long step, long *extra_rows)
if (step > procs) /* moving to the end to generate updates */
{
// HYRISE: The following line raises a compilation error when adding function prototypes the the tdef gen_seed
// member, as they epxect two arguments. All seed generators passed in driver.c (L 230-249) take either two
// member, as they expect two arguments. All seed generators passed in driver.c (L 230-249) take either two
// parameters or are simply 0. Thus, calling this line would always lead to an error. With this assumption, we
// simply ensure we fail if this should ever be called (did not happen after generating tables for multiple
// scale factors).
Expand Down
3 changes: 3 additions & 0 deletions config.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@
#endif /* LINUX */

#ifdef MAC
// HYRISE: Only define if not already defined.
#ifndef _POSIX_SOURCE
#define _POSIX_SOURCE
#endif /* _POSIX_SOURCE */
#define STDLIB_HAS_GETOPT
#endif /* MAC */

Expand Down
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ WORKLOAD =SSBM
# add -EDTERABYTE if orderkey will execeed 32 bits (SF >= 300)
# and make the appropriate change in gen_schema() of runit.sh
# HYRISE: Change -O to -O3. Add -Wno-dangling-else, -Wno-int-to-void-pointer-cast, and -Wno-void-pointer-to-int-cast because they are all over the codebase.
CFLAGS = -O3 -DDBNAME=\"dss\" -D$(MACHINE) -D$(DATABASE) -D$(WORKLOAD) -Wno-dangling-else -Wno-int-to-void-pointer-cast -Wno-void-pointer-to-int-cast
CFLAGS = -O3 -DDBNAME=\"dss\" -D$(MACHINE) -D$(DATABASE) -D$(WORKLOAD) -Wno-dangling-else -Wno-int-to-void-pointer-cast -Wno-void-pointer-to-int-cast -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast
LDFLAGS = -O3
# The OBJ,EXE and LIB macros will need to be changed for compilation under
# Windows NT
Expand Down
4 changes: 2 additions & 2 deletions varsub.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ varsub(int qnum, int vnum, int flags)
break;
case 6:
tmp_date = UnifInt(93,97,qnum);
sprintf(param[1], "19%d-01-01", tmp_date);
// HYRISE: Change format specifier.
sprintf(param[1], "19%d-01-01", tmp_date);
// HYRISE: Change format specifier.
sprintf(param[2], "0.0%ld", UnifInt(2, 9, qnum));
sprintf(param[3], "%ld", UnifInt((long)24, (long)25, (long)qnum));
param[4][0] = '\0';
Expand Down

0 comments on commit c2cebff

Please sign in to comment.