mirror of
https://salsa.debian.org/dskoll/remind.git
synced 2026-04-16 06:18:47 +02:00
Simplify HAS_DATE and HAS_TIME macros by making type values into bitmasks.
All checks were successful
Remind unit tests / tests (push) Successful in 34s
All checks were successful
Remind unit tests / tests (push) Successful in 34s
This commit is contained in:
@@ -210,8 +210,8 @@ static int CacheHebYear, CacheHebMon, CacheHebDay;
|
||||
/* Macro for getting time part of a time or datetime value */
|
||||
#define TIMEPART(x) ((x).type == TIME_TYPE ? (x).v.val : ((x).v.val % MINUTES_PER_DAY))
|
||||
|
||||
#define HASDATE(x) ((x).type == DATE_TYPE || (x).type == DATETIME_TYPE)
|
||||
#define HASTIME(x) ((x).type == TIME_TYPE || (x).type == DATETIME_TYPE)
|
||||
#define HASDATE(x) ((x).type & DATE_TYPE)
|
||||
#define HASTIME(x) ((x).type & TIME_TYPE)
|
||||
|
||||
/* Macro for copying a value while destroying original copy */
|
||||
#define DCOPYVAL(x, y) ( (x) = (y), (y).type = ERR_TYPE )
|
||||
|
||||
21
src/types.h
21
src/types.h
@@ -15,15 +15,18 @@
|
||||
|
||||
typedef struct udf_struct UserFunc;
|
||||
|
||||
/* Define the types of values */
|
||||
#define ERR_TYPE 0
|
||||
#define INT_TYPE 1
|
||||
#define TIME_TYPE 2
|
||||
#define DATE_TYPE 3
|
||||
#define STR_TYPE 4
|
||||
#define DATETIME_TYPE 5
|
||||
#define SPECIAL_TYPE 6 /* Only for system variables */
|
||||
#define CONST_INT_TYPE 7 /* Only for system variables */
|
||||
/* Define the types of values. We use bitmasks so we can define
|
||||
DATETIME_TYPE as a combo of DATE_TYPE and TIME_TYPE */
|
||||
|
||||
#define ERR_TYPE 0x0
|
||||
#define INT_TYPE 0x1
|
||||
#define TIME_TYPE 0x2
|
||||
#define DATE_TYPE 0x4
|
||||
/* DATETIME_TYPE has both DATE and TIME bits turned on */
|
||||
#define DATETIME_TYPE (TIME_TYPE | DATE_TYPE)
|
||||
#define STR_TYPE 0x8
|
||||
#define SPECIAL_TYPE 0x10 /* Only for system variables */
|
||||
#define CONST_INT_TYPE 0x20 /* Only for system variables */
|
||||
|
||||
#define BEG_OF_EXPR '['
|
||||
#define END_OF_EXPR ']'
|
||||
|
||||
Reference in New Issue
Block a user