1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2024-12-12 10:04:14 +02:00

Centralize String and Buffer constants in stringz.h.

It's not clear how useful single-character zero-terminated constants are or if we want propagate them through the code, but it at least makes sense to centralize the constants used by the Buffer and String objects.
This commit is contained in:
David Steele 2020-05-04 19:05:38 -04:00
parent 47aa765375
commit d04c21ca83
4 changed files with 40 additions and 22 deletions

View File

@ -13,16 +13,16 @@ Buffer Handler
/***********************************************************************************************************************************
Constant buffers that are generally useful
***********************************************************************************************************************************/
BUFFER_STRDEF_EXTERN(BRACEL_BUF, "{");
BUFFER_STRDEF_EXTERN(BRACER_BUF, "}");
BUFFER_STRDEF_EXTERN(BRACKETL_BUF, "[");
BUFFER_STRDEF_EXTERN(BRACKETR_BUF, "]");
BUFFER_STRDEF_EXTERN(COMMA_BUF, ",");
BUFFER_STRDEF_EXTERN(CR_BUF, "\r");
BUFFER_STRDEF_EXTERN(DOT_BUF, ".");
BUFFER_STRDEF_EXTERN(EQ_BUF, "=");
BUFFER_STRDEF_EXTERN(LF_BUF, "\n");
BUFFER_STRDEF_EXTERN(QUOTED_BUF, "\"");
BUFFER_STRDEF_EXTERN(BRACEL_BUF, BRACEL_Z);
BUFFER_STRDEF_EXTERN(BRACER_BUF, BRACER_Z);
BUFFER_STRDEF_EXTERN(BRACKETL_BUF, BRACKETL_Z);
BUFFER_STRDEF_EXTERN(BRACKETR_BUF, BRACKETR_Z);
BUFFER_STRDEF_EXTERN(COMMA_BUF, COMMA_Z);
BUFFER_STRDEF_EXTERN(CR_BUF, CR_Z);
BUFFER_STRDEF_EXTERN(DOT_BUF, DOT_Z);
BUFFER_STRDEF_EXTERN(EQ_BUF, EQ_Z);
BUFFER_STRDEF_EXTERN(LF_BUF, LF_Z);
BUFFER_STRDEF_EXTERN(QUOTED_BUF, QUOTED_Z);
/***********************************************************************************************************************************
Contains information about the buffer

View File

@ -19,23 +19,24 @@ String Handler
/***********************************************************************************************************************************
Constant strings that are generally useful
***********************************************************************************************************************************/
STRING_EXTERN(BRACKETL_STR, "[");
STRING_EXTERN(BRACKETR_STR, "]");
STRING_EXTERN(BRACKETL_STR, BRACKETL_Z);
STRING_EXTERN(BRACKETR_STR, BRACKETR_Z);
STRING_EXTERN(COLON_STR, COLON_Z);
STRING_EXTERN(CR_STR, "\r");
STRING_EXTERN(CR_STR, CR_Z);
STRING_EXTERN(DASH_STR, DASH_Z);
STRING_EXTERN(DOT_STR, ".");
STRING_EXTERN(DOTDOT_STR, "..");
STRING_EXTERN(EMPTY_STR, "");
STRING_EXTERN(EQ_STR, "=");
STRING_EXTERN(DOT_STR, DOT_Z);
STRING_EXTERN(DOTDOT_STR, DOTDOT_Z);
STRING_EXTERN(EMPTY_STR, EMPTY_Z);
STRING_EXTERN(EQ_STR, EQ_Z);
STRING_EXTERN(FALSE_STR, FALSE_Z);
STRING_EXTERN(FSLASH_STR, "/");
STRING_EXTERN(LF_STR, "\n");
STRING_EXTERN(N_STR, "n");
STRING_EXTERN(FSLASH_STR, FSLASH_Z);
STRING_EXTERN(LF_STR, LF_Z);
STRING_EXTERN(N_STR, N_Z);
STRING_EXTERN(NULL_STR, NULL_Z);
STRING_EXTERN(QUOTED_STR, QUOTED_Z);
STRING_EXTERN(TRUE_STR, TRUE_Z);
STRING_EXTERN(Y_STR, "y");
STRING_EXTERN(ZERO_STR, "0");
STRING_EXTERN(Y_STR, Y_Z);
STRING_EXTERN(ZERO_STR, ZERO_Z);
/***********************************************************************************************************************************
Maximum size of a string

View File

@ -212,6 +212,7 @@ STRING_DECLARE(FSLASH_STR);
STRING_DECLARE(LF_STR);
STRING_DECLARE(N_STR);
STRING_DECLARE(NULL_STR);
STRING_DECLARE(QUOTED_STR);
STRING_DECLARE(TRUE_STR);
STRING_DECLARE(Y_STR);
STRING_DECLARE(ZERO_STR);

View File

@ -7,10 +7,26 @@ Zero-Terminated String Handler
/***********************************************************************************************************************************
Zero-terminated strings that are generally useful
***********************************************************************************************************************************/
#define BRACEL_Z "{"
#define BRACER_Z "}"
#define BRACKETL_Z "["
#define BRACKETR_Z "]"
#define COLON_Z ":"
#define COMMA_Z ","
#define CR_Z "\r"
#define DASH_Z "-"
#define DOT_Z "."
#define DOTDOT_Z ".."
#define EMPTY_Z ""
#define EQ_Z "="
#define FALSE_Z "false"
#define FSLASH_Z "/"
#define LF_Z "\n"
#define N_Z "n"
#define NULL_Z "null"
#define QUOTED_Z "\""
#define TRUE_Z "true"
#define Y_Z "y"
#define ZERO_Z "0"
#endif