Skip to content

Commit e52bf14

Browse files
committed
Replace setjmp-longjmp's by try_catch-throw
modified: storage/connect/CMakeLists.txt modified: storage/connect/array.cpp modified: storage/connect/blkfil.cpp modified: storage/connect/colblk.cpp modified: storage/connect/connect.cc modified: storage/connect/filamtxt.cpp modified: storage/connect/filamvct.cpp modified: storage/connect/filter.cpp modified: storage/connect/global.h modified: storage/connect/ha_connect.cc modified: storage/connect/jdbconn.cpp modified: storage/connect/json.cpp modified: storage/connect/jsonudf.cpp modified: storage/connect/odbconn.cpp modified: storage/connect/osutil.c modified: storage/connect/plgdbutl.cpp deleted: storage/connect/plugutil.c added: storage/connect/plugutil.cpp modified: storage/connect/tabdos.cpp modified: storage/connect/tabfix.cpp modified: storage/connect/tabfmt.cpp modified: storage/connect/tabjdbc.cpp modified: storage/connect/tabjdbc.h modified: storage/connect/tabjson.cpp modified: storage/connect/tabmul.cpp modified: storage/connect/tabmul.h modified: storage/connect/tabmysql.cpp modified: storage/connect/tabodbc.cpp modified: storage/connect/tabodbc.h modified: storage/connect/tabpivot.cpp modified: storage/connect/tabsys.cpp modified: storage/connect/tabvct.cpp modified: storage/connect/tabvir.cpp modified: storage/connect/tabxml.cpp modified: storage/connect/valblk.cpp modified: storage/connect/value.cpp modified: storage/connect/xindex.cpp modified: storage/connect/xobject.cpp
1 parent 180fe61 commit e52bf14

37 files changed

+1669
-1503
lines changed

storage/connect/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ SET(CONNECT_PLUGIN_DYNAMIC "connect")
1818

1919
SET(CONNECT_SOURCES
2020
ha_connect.cc connect.cc user_connect.cc mycat.cc
21-
fmdlex.c osutil.c plugutil.c rcmsg.c rcmsg.h
21+
fmdlex.c osutil.c rcmsg.c rcmsg.h
2222
array.cpp blkfil.cpp colblk.cpp csort.cpp
23-
filamap.cpp filamdbf.cpp filamfix.cpp filamgz.cpp filamtxt.cpp
24-
filter.cpp json.cpp jsonudf.cpp maputil.cpp myconn.cpp myutil.cpp plgdbutl.cpp
23+
filamap.cpp filamdbf.cpp filamfix.cpp filamgz.cpp filamtxt.cpp filter.cpp
24+
json.cpp jsonudf.cpp maputil.cpp myconn.cpp myutil.cpp plgdbutl.cpp plugutil.cpp
2525
reldef.cpp tabcol.cpp tabdos.cpp tabext.cpp tabfix.cpp tabfmt.cpp tabjson.cpp
2626
table.cpp tabmul.cpp tabmysql.cpp taboccur.cpp tabpivot.cpp tabsys.cpp tabtbl.cpp
2727
tabutil.cpp tabvir.cpp tabxcl.cpp valblk.cpp value.cpp xindex.cpp xobject.cpp

storage/connect/array.cpp

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -518,8 +518,12 @@ bool ARRAY::FilTest(PGLOBAL g, PVAL valp, OPVAL opc, int opm)
518518
vp = valp;
519519

520520
} else if (opc != OP_EXIST) {
521-
sprintf(g->Message, MSG(MISSING_ARG), opc);
522-
longjmp(g->jumper[g->jump_level], TYPE_ARRAY);
521+
sprintf(g->Message, MSG(MISSING_ARG), opc);
522+
#if defined(USE_TRY)
523+
throw TYPE_ARRAY;
524+
#else // !USE_TRY
525+
longjmp(g->jumper[g->jump_level], TYPE_ARRAY);
526+
#endif // !USE_TRY
523527
} else // OP_EXIST
524528
return Nval > 0;
525529

@@ -681,15 +685,23 @@ void ARRAY::SetPrecision(PGLOBAL g, int p)
681685
{
682686
if (Vblp == NULL) {
683687
strcpy(g->Message, MSG(PREC_VBLP_NULL));
684-
longjmp(g->jumper[g->jump_level], TYPE_ARRAY);
688+
#if defined(USE_TRY)
689+
throw TYPE_ARRAY;
690+
#else // !USE_TRY
691+
longjmp(g->jumper[g->jump_level], TYPE_ARRAY);
692+
#endif // !USE_TRY
685693
} // endif Vblp
686694

687695
bool was = Vblp->IsCi();
688696

689697
if (was && !p) {
690698
strcpy(g->Message, MSG(BAD_SET_CASE));
691-
longjmp(g->jumper[g->jump_level], TYPE_ARRAY);
692-
} // endif Vblp
699+
#if defined(USE_TRY)
700+
throw TYPE_ARRAY;
701+
#else // !USE_TRY
702+
longjmp(g->jumper[g->jump_level], TYPE_ARRAY);
703+
#endif // !USE_TRY
704+
} // endif Vblp
693705

694706
if (was || !p)
695707
return;
@@ -699,7 +711,11 @@ void ARRAY::SetPrecision(PGLOBAL g, int p)
699711
if (!was && Type == TYPE_STRING)
700712
// Must be resorted to eliminate duplicate strings
701713
if (Sort(g))
702-
longjmp(g->jumper[g->jump_level], TYPE_ARRAY);
714+
#if defined(USE_TRY)
715+
throw TYPE_ARRAY;
716+
#else // !USE_TRY
717+
longjmp(g->jumper[g->jump_level], TYPE_ARRAY);
718+
#endif // !USE_TRY
703719

704720
} // end of SetPrecision
705721

storage/connect/blkfil.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/************* BlkFil C++ Program Source Code File (.CPP) **************/
22
/* PROGRAM NAME: BLKFIL */
33
/* ------------- */
4-
/* Version 2.5 */
4+
/* Version 2.6 */
55
/* */
66
/* COPYRIGHT: */
77
/* ---------- */
8-
/* (C) Copyright to the author Olivier BERTRAND 2004-2015 */
8+
/* (C) Copyright to the author Olivier BERTRAND 2004-2017 */
99
/* */
1010
/* WHAT THIS PROGRAM DOES: */
1111
/* ----------------------- */
@@ -595,8 +595,12 @@ BLKFILIN::BLKFILIN(PGLOBAL g, PTDBDOS tdbp, int op, int opm, PXOB *xp)
595595

596596
if (Colp->GetResultType() != Type) {
597597
sprintf(g->Message, "BLKFILIN: %s", MSG(VALTYPE_NOMATCH));
598-
longjmp(g->jumper[g->jump_level], 99);
599-
} else if (Colp->GetValue()->IsCi())
598+
#if defined(USE_TRY)
599+
throw g->Message;
600+
#else // !USE_TRY
601+
longjmp(g->jumper[g->jump_level], 99);
602+
#endif // !USE_TRY
603+
} else if (Colp->GetValue()->IsCi())
600604
Arap->SetPrecision(g, 1); // Case insensitive
601605

602606
Sorted = Colp->IsSorted() > 0;

storage/connect/colblk.cpp

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,12 @@ int COLBLK::GetLengthEx(void)
197197
void COLBLK::ReadColumn(PGLOBAL g)
198198
{
199199
sprintf(g->Message, MSG(UNDEFINED_AM), "ReadColumn");
200-
longjmp(g->jumper[g->jump_level], TYPE_COLBLK);
201-
} // end of ReadColumn
200+
#if defined(USE_TRY)
201+
throw TYPE_COLBLK;
202+
#else // !USE_TRY
203+
longjmp(g->jumper[g->jump_level], TYPE_COLBLK);
204+
#endif // !USE_TRY
205+
} // end of ReadColumn
202206

203207
/***********************************************************************/
204208
/* WriteColumn: what this routine does is to access the last line */
@@ -208,8 +212,12 @@ void COLBLK::ReadColumn(PGLOBAL g)
208212
void COLBLK::WriteColumn(PGLOBAL g)
209213
{
210214
sprintf(g->Message, MSG(UNDEFINED_AM), "WriteColumn");
211-
longjmp(g->jumper[g->jump_level], TYPE_COLBLK);
212-
} // end of WriteColumn
215+
#if defined(USE_TRY)
216+
throw TYPE_COLBLK;
217+
#else // !USE_TRY
218+
longjmp(g->jumper[g->jump_level], TYPE_COLBLK);
219+
#endif // !USE_TRY
220+
} // end of WriteColumn
213221

214222
/***********************************************************************/
215223
/* Make file output of a column descriptor block. */
@@ -262,8 +270,12 @@ SPCBLK::SPCBLK(PCOLUMN cp)
262270
void SPCBLK::WriteColumn(PGLOBAL g)
263271
{
264272
sprintf(g->Message, MSG(SPCOL_READONLY), Name);
265-
longjmp(g->jumper[g->jump_level], TYPE_COLBLK);
266-
} // end of WriteColumn
273+
#if defined(USE_TRY)
274+
throw TYPE_COLBLK;
275+
#else // !USE_TRY
276+
longjmp(g->jumper[g->jump_level], TYPE_COLBLK);
277+
#endif // !USE_TRY
278+
} // end of WriteColumn
267279

268280
/***********************************************************************/
269281
/* RIDBLK constructor for the ROWID special column. */

0 commit comments

Comments
 (0)