Skip to content

Commit 0649a06

Browse files
author
D. Richard Hipp
committed
Use macros for the default values for QRF limits in the CLI, rather than
hard-coded magic numbers.
1 parent e41c938 commit 0649a06

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

src/shell.c.in

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,6 +1506,19 @@ static const ModeInfo aModeInfo[] = {
15061506
#define SEP_Unit "\x1F"
15071507
#define SEP_Record "\x1E"
15081508

1509+
/*
1510+
** Default values for the various QRF limits
1511+
*/
1512+
#ifndef DFLT_CHAR_LIMIT
1513+
# define DFLT_CHAR_LIMIT 300
1514+
#endif
1515+
#ifndef DFLT_LINE_LIMIT
1516+
# define DFLT_LINE_LIMIT 5
1517+
#endif
1518+
#ifndef DFLT_TITLE_LIMIT
1519+
# define DFLT_TITLE_LIMIT 20
1520+
#endif
1521+
15091522
/*
15101523
** Limit input nesting via .read or any other input redirect.
15111524
** It's not too expensive, so a generous allowance can be made.
@@ -1626,10 +1639,10 @@ static void modeChange(ShellState *p, unsigned char eMode){
16261639
modeChange(p, MODE_QBox);
16271640
p->mode.bAutoScreenWidth = 1;
16281641
p->mode.spec.eText = QRF_TEXT_Relaxed;
1629-
p->mode.spec.nCharLimit = 300;
1630-
p->mode.spec.nLineLimit = 5;
1642+
p->mode.spec.nCharLimit = DFLT_CHAR_LIMIT;
1643+
p->mode.spec.nLineLimit = DFLT_LINE_LIMIT;
16311644
p->mode.spec.bTextJsonb = QRF_Yes;
1632-
p->mode.spec.nTitleLimit = 20;
1645+
p->mode.spec.nTitleLimit = DFLT_TITLE_LIMIT;
16331646
p->mode.mFlags = mFlags;
16341647
}
16351648
}
@@ -7855,11 +7868,13 @@ static int dotCmdMode(ShellState *p){
78557868
}
78567869
k = pickStr(azArg[i],0,"on","off","");
78577870
if( k==0 ){
7858-
p->mode.spec.nLineLimit = 5;
7859-
p->mode.spec.nCharLimit = 300;
7871+
p->mode.spec.nLineLimit = DFLT_LINE_LIMIT;
7872+
p->mode.spec.nCharLimit = DFLT_CHAR_LIMIT;
7873+
p->mode.spec.nTitleLimit = DFLT_TITLE_LIMIT;
78607874
}else if( k==1 ){
78617875
p->mode.spec.nLineLimit = 0;
78627876
p->mode.spec.nCharLimit = 0;
7877+
p->mode.spec.nTitleLimit = 0;
78637878
}else{
78647879
int L, C, T = 0;
78657880
int nNum = sscanf(azArg[i], "%d,%d,%d", &L, &C, &T);
@@ -8145,9 +8160,9 @@ static int dotCmdMode(ShellState *p){
81458160
&& p->mode.spec.nTitleLimit==0
81468161
){
81478162
sqlite3_str_appendf(pDesc, " --limits off");
8148-
}else if( p->mode.spec.nLineLimit==5
8149-
&& p->mode.spec.nCharLimit==300
8150-
&& p->mode.spec.nTitleLimit==20
8163+
}else if( p->mode.spec.nLineLimit==DFLT_LINE_LIMIT
8164+
&& p->mode.spec.nCharLimit==DFLT_CHAR_LIMIT
8165+
&& p->mode.spec.nTitleLimit==DFLT_TITLE_LIMIT
81518166
){
81528167
sqlite3_str_appendf(pDesc, " --limits on");
81538168
}else{

0 commit comments

Comments
 (0)