8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 04:43:03 +01:00

Remove trailing spaces (.cpp files)

This commit is contained in:
asfernandes 2008-12-05 01:20:14 +00:00
parent d41d1b40d1
commit 8fbf0e8e8c
231 changed files with 7278 additions and 7278 deletions

View File

@ -83,20 +83,20 @@ int EXE_action(const TEXT* database, const ULONG switches)
buildDpb(dpb, switches); buildDpb(dpb, switches);
FB_API_HANDLE handle = 0; FB_API_HANDLE handle = 0;
isc_attach_database(tdgbl->status, 0, database, &handle, isc_attach_database(tdgbl->status, 0, database, &handle,
dpb.getBufferLength(), dpb.getBufferLength(),
reinterpret_cast<const SCHAR*>(dpb.getBuffer())); reinterpret_cast<const SCHAR*>(dpb.getBuffer()));
tdgbl->uSvc->started(); tdgbl->uSvc->started();
if (tdgbl->status[1] && if (tdgbl->status[1] &&
// Ignore isc_shutdown error produced when we switch to full shutdown mode. It is expected. // Ignore isc_shutdown error produced when we switch to full shutdown mode. It is expected.
(tdgbl->status[1] != isc_shutdown || !(switches & sw_shut) || tdgbl->ALICE_data.ua_shutdown_mode != SHUT_FULL) (tdgbl->status[1] != isc_shutdown || !(switches & sw_shut) || tdgbl->ALICE_data.ua_shutdown_mode != SHUT_FULL)
) )
{ {
error = true; error = true;
} }
if (tdgbl->status[2] == isc_arg_warning) if (tdgbl->status[2] == isc_arg_warning)
{ {
tdgbl->uSvc->makePermanentVector(tdgbl->status); tdgbl->uSvc->makePermanentVector(tdgbl->status);
@ -107,7 +107,7 @@ int EXE_action(const TEXT* database, const ULONG switches)
tdgbl->uSvc->makePermanentVector(tdgbl->status); tdgbl->uSvc->makePermanentVector(tdgbl->status);
} }
if (handle != 0) if (handle != 0)
{ {
UCHAR error_string[128]; UCHAR error_string[128];
if ((switches & sw_validate) && (tdgbl->status[1] != isc_bug_check)) if ((switches & sw_validate) && (tdgbl->status[1] != isc_bug_check))
@ -156,7 +156,7 @@ int EXE_two_phase(const TEXT* database, const ULONG switches)
FB_API_HANDLE handle = 0; FB_API_HANDLE handle = 0;
isc_attach_database(tdgbl->status, 0, database, &handle, isc_attach_database(tdgbl->status, 0, database, &handle,
dpb.getBufferLength(), dpb.getBufferLength(),
reinterpret_cast<const SCHAR*>(dpb.getBuffer())); reinterpret_cast<const SCHAR*>(dpb.getBuffer()));
tdgbl->uSvc->started(); tdgbl->uSvc->started();
@ -223,13 +223,13 @@ static void buildDpb(Firebird::ClumpletWriter& dpb, const ULONG switches)
dpb.insertByte(isc_dpb_verify, b); dpb.insertByte(isc_dpb_verify, b);
} }
else if (switches & sw_housekeeping) { else if (switches & sw_housekeeping) {
dpb.insertInt(isc_dpb_sweep_interval, dpb.insertInt(isc_dpb_sweep_interval,
tdgbl->ALICE_data.ua_sweep_interval); tdgbl->ALICE_data.ua_sweep_interval);
} }
/* /*
else if (switches & sw_begin_log) { else if (switches & sw_begin_log) {
dpb.insertString(isc_dpb_begin_log, dpb.insertString(isc_dpb_begin_log,
tdgbl->ALICE_data.ua_log_file, tdgbl->ALICE_data.ua_log_file,
strlen(tdgbl->ALICE_data.ua_log_file)); strlen(tdgbl->ALICE_data.ua_log_file));
} }
else if (switches & sw_quit_log) { else if (switches & sw_quit_log) {
@ -237,18 +237,18 @@ static void buildDpb(Firebird::ClumpletWriter& dpb, const ULONG switches)
} }
*/ */
else if (switches & sw_buffers) { else if (switches & sw_buffers) {
dpb.insertInt(isc_dpb_set_page_buffers, dpb.insertInt(isc_dpb_set_page_buffers,
tdgbl->ALICE_data.ua_page_buffers); tdgbl->ALICE_data.ua_page_buffers);
} }
else if (switches & sw_kill) { else if (switches & sw_kill) {
dpb.insertTag(isc_dpb_delete_shadow); dpb.insertTag(isc_dpb_delete_shadow);
} }
else if (switches & sw_write) { else if (switches & sw_write) {
dpb.insertByte(isc_dpb_force_write, dpb.insertByte(isc_dpb_force_write,
tdgbl->ALICE_data.ua_force ? 1 : 0); tdgbl->ALICE_data.ua_force ? 1 : 0);
} }
else if (switches & sw_no_reserve) { else if (switches & sw_no_reserve) {
dpb.insertByte(isc_dpb_no_reserve, dpb.insertByte(isc_dpb_no_reserve,
tdgbl->ALICE_data.ua_no_reserve ? 1 : 0); tdgbl->ALICE_data.ua_no_reserve ? 1 : 0);
} }
else if (switches & sw_mode) { else if (switches & sw_mode) {
@ -278,7 +278,7 @@ static void buildDpb(Firebird::ClumpletWriter& dpb, const ULONG switches)
case SHUT_FULL: case SHUT_FULL:
b |= isc_dpb_shut_full; b |= isc_dpb_shut_full;
break; break;
default: default:
break; break;
} }
dpb.insertByte(isc_dpb_shutdown, b); dpb.insertByte(isc_dpb_shutdown, b);
@ -318,24 +318,24 @@ static void buildDpb(Firebird::ClumpletWriter& dpb, const ULONG switches)
dpb.insertTag(isc_dpb_no_garbage_collect); dpb.insertTag(isc_dpb_no_garbage_collect);
} }
else if (switches & sw_set_db_dialect) { else if (switches & sw_set_db_dialect) {
dpb.insertInt(isc_dpb_set_db_sql_dialect, dpb.insertInt(isc_dpb_set_db_sql_dialect,
tdgbl->ALICE_data.ua_db_SQL_dialect); tdgbl->ALICE_data.ua_db_SQL_dialect);
} }
if (tdgbl->ALICE_data.ua_user) { if (tdgbl->ALICE_data.ua_user) {
dpb.insertString(isc_dpb_user_name, dpb.insertString(isc_dpb_user_name,
tdgbl->ALICE_data.ua_user, tdgbl->ALICE_data.ua_user,
strlen(tdgbl->ALICE_data.ua_user)); strlen(tdgbl->ALICE_data.ua_user));
} }
if (tdgbl->ALICE_data.ua_password) { if (tdgbl->ALICE_data.ua_password) {
dpb.insertString(tdgbl->uSvc->isService() ? isc_dpb_password_enc : dpb.insertString(tdgbl->uSvc->isService() ? isc_dpb_password_enc :
isc_dpb_password, isc_dpb_password,
tdgbl->ALICE_data.ua_password, tdgbl->ALICE_data.ua_password,
strlen(tdgbl->ALICE_data.ua_password)); strlen(tdgbl->ALICE_data.ua_password));
} }
if (tdgbl->ALICE_data.ua_tr_user) { if (tdgbl->ALICE_data.ua_tr_user) {
tdgbl->uSvc->checkService(); tdgbl->uSvc->checkService();
dpb.insertString(isc_dpb_trusted_auth, dpb.insertString(isc_dpb_trusted_auth,
tdgbl->ALICE_data.ua_tr_user, tdgbl->ALICE_data.ua_tr_user,
strlen(tdgbl->ALICE_data.ua_tr_user)); strlen(tdgbl->ALICE_data.ua_tr_user));
} }
@ -371,9 +371,9 @@ static void extract_db_info(const UCHAR* db_info_buffer, size_t buf_size)
const SLONG length = gds__vax_integer(p, 2); const SLONG length = gds__vax_integer(p, 2);
p += 2; p += 2;
// TMN: Here we should really have the following assert // TMN: Here we should really have the following assert
// fb_assert(length <= MAX_SSHORT); // fb_assert(length <= MAX_SSHORT);
// for all cases that use 'length' as input to 'gds__vax_integer' // for all cases that use 'length' as input to 'gds__vax_integer'
// Remember to keep this list in sync with the val_errors array. // Remember to keep this list in sync with the val_errors array.
switch (item) switch (item)
{ {

View File

@ -195,19 +195,19 @@ bool TDR_attach_database(ISC_STATUS* status_vector,
dpb.insertTag(isc_dpb_gfix_attach); dpb.insertTag(isc_dpb_gfix_attach);
tdgbl->uSvc->getAddressPath(dpb); tdgbl->uSvc->getAddressPath(dpb);
if (tdgbl->ALICE_data.ua_user) { if (tdgbl->ALICE_data.ua_user) {
dpb.insertString(isc_dpb_user_name, dpb.insertString(isc_dpb_user_name,
tdgbl->ALICE_data.ua_user, tdgbl->ALICE_data.ua_user,
strlen(tdgbl->ALICE_data.ua_user)); strlen(tdgbl->ALICE_data.ua_user));
} }
if (tdgbl->ALICE_data.ua_password) { if (tdgbl->ALICE_data.ua_password) {
dpb.insertString(tdgbl->uSvc->isService() ? isc_dpb_password_enc : dpb.insertString(tdgbl->uSvc->isService() ? isc_dpb_password_enc :
isc_dpb_password, isc_dpb_password,
tdgbl->ALICE_data.ua_password, tdgbl->ALICE_data.ua_password,
strlen(tdgbl->ALICE_data.ua_password)); strlen(tdgbl->ALICE_data.ua_password));
} }
if (tdgbl->ALICE_data.ua_tr_user) { if (tdgbl->ALICE_data.ua_tr_user) {
tdgbl->uSvc->checkService(); tdgbl->uSvc->checkService();
dpb.insertString(isc_dpb_trusted_auth, dpb.insertString(isc_dpb_trusted_auth,
tdgbl->ALICE_data.ua_tr_user, tdgbl->ALICE_data.ua_tr_user,
strlen(reinterpret_cast<const char*>(tdgbl->ALICE_data.ua_tr_user))); strlen(reinterpret_cast<const char*>(tdgbl->ALICE_data.ua_tr_user)));
} }
@ -323,7 +323,7 @@ void TDR_list_limbo(FB_API_HANDLE handle, const TEXT* name, const ULONG switches
ALICE_print(71, SafeArg() << id); ALICE_print(71, SafeArg() << id);
// msg 71: Transaction %d is in limbo. // msg 71: Transaction %d is in limbo.
} }
if (trans = MET_get_transaction(status_vector, handle, id)) if (trans = MET_get_transaction(status_vector, handle, id))
{ {
tdgbl->uSvc->putSLong(isc_spb_multi_tra_id, id); tdgbl->uSvc->putSLong(isc_spb_multi_tra_id, id);
reattach_databases(trans); reattach_databases(trans);
@ -331,7 +331,7 @@ void TDR_list_limbo(FB_API_HANDLE handle, const TEXT* name, const ULONG switches
TDR_shutdown_databases(trans); TDR_shutdown_databases(trans);
print_description(trans); print_description(trans);
} }
else else
{ {
tdgbl->uSvc->putSLong(isc_spb_single_tra_id, id); tdgbl->uSvc->putSLong(isc_spb_single_tra_id, id);
} }
@ -770,7 +770,7 @@ static void reattach_database(TDR trans)
ALICE_exit(FINI_ERROR, tdgbl); ALICE_exit(FINI_ERROR, tdgbl);
} }
for (;;) for (;;)
{ {
ALICE_print(88); // msg 88: Enter a valid path: ALICE_print(88); // msg 88: Enter a valid path:
char* p = buffer; char* p = buffer;

View File

@ -1,7 +1,7 @@
/* /*
* PROGRAM: JRD Backup and Restore Program * PROGRAM: JRD Backup and Restore Program
* MODULE: canonical.cpp * MODULE: canonical.cpp
* DESCRIPTION: * DESCRIPTION:
* *
* The contents of this file are subject to the Interbase Public * The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file * License Version 1.0 (the "License"); you may not use this file
@ -200,7 +200,7 @@ ULONG CAN_encode_decode(burp_rel* relation,
} }
} }
// Next, get null flags // Next, get null flags
for (field = relation->rel_fields; field; field = field->fld_next) for (field = relation->rel_fields; field; field = field->fld_next)
{ {
@ -442,7 +442,7 @@ static bool_t expand_buffer(XDR* xdrs)
* *
* Functional description * Functional description
* Allocate a new, larger buffer, copy * Allocate a new, larger buffer, copy
* everything we've got, and release the * everything we've got, and release the
* old one. * old one.
* *
**************************************/ **************************************/
@ -654,7 +654,7 @@ static bool_t xdr_slice(XDR* xdrs,
if (!xdr_long(xdrs, reinterpret_cast<SLONG*>(&slice->lstr_length))) if (!xdr_long(xdrs, reinterpret_cast<SLONG*>(&slice->lstr_length)))
return FALSE; return FALSE;
// Handle operation specific stuff, particularly memory allocation/deallocation // Handle operation specific stuff, particularly memory allocation/deallocation
switch (xdrs->x_op) switch (xdrs->x_op)
{ {
@ -692,7 +692,7 @@ static bool_t xdr_slice(XDR* xdrs,
return FALSE; return FALSE;
} }
// Get descriptor of array element // Get descriptor of array element
ISC_STATUS_ARRAY status_vector; ISC_STATUS_ARRAY status_vector;
sdl_info info; sdl_info info;

View File

@ -48,7 +48,7 @@ UCHAR *MISC_alloc_burp(ULONG size)
BurpGlobals* tdgbl = BurpGlobals::getSpecific(); BurpGlobals* tdgbl = BurpGlobals::getSpecific();
// Add some header space to store a list of blocks allocated for this gbak // Add some header space to store a list of blocks allocated for this gbak
size += ROUNDUP(sizeof(UCHAR *), FB_ALIGNMENT); size += ROUNDUP(sizeof(UCHAR *), FB_ALIGNMENT);
UCHAR* block = (UCHAR*)gds__alloc(size); UCHAR* block = (UCHAR*)gds__alloc(size);
@ -57,14 +57,14 @@ UCHAR *MISC_alloc_burp(ULONG size)
/* NOMEM: message & abort FREE: all items freed at gbak exit */ /* NOMEM: message & abort FREE: all items freed at gbak exit */
{ {
BURP_error(238, true); BURP_error(238, true);
// msg 238: System memory exhaused // msg 238: System memory exhaused
return NULL; return NULL;
} }
memset(block, 0, size); memset(block, 0, size);
/* FREE: We keep a linked list of all gbak memory allocations, which /* FREE: We keep a linked list of all gbak memory allocations, which
* are then freed when gbak exits. This is important for * are then freed when gbak exits. This is important for
* NETWARE in particular. * NETWARE in particular.
*/ */
*((UCHAR **) block) = tdgbl->head_of_mem_list; *((UCHAR **) block) = tdgbl->head_of_mem_list;
@ -89,26 +89,26 @@ void MISC_free_burp( void *free)
BurpGlobals* tdgbl = BurpGlobals::getSpecific(); BurpGlobals* tdgbl = BurpGlobals::getSpecific();
if (free != NULL) { if (free != NULL) {
// Point at the head of the allocated block // Point at the head of the allocated block
UCHAR **block = UCHAR **block =
(UCHAR **) ((UCHAR *) free - ROUNDUP(sizeof(UCHAR *), FB_ALIGNMENT)); (UCHAR **) ((UCHAR *) free - ROUNDUP(sizeof(UCHAR *), FB_ALIGNMENT));
// Scan for this block in the list of blocks // Scan for this block in the list of blocks
for (UCHAR **ptr = &tdgbl->head_of_mem_list; *ptr; ptr = (UCHAR **) *ptr) for (UCHAR **ptr = &tdgbl->head_of_mem_list; *ptr; ptr = (UCHAR **) *ptr)
{ {
if (*ptr == (UCHAR *) block) { if (*ptr == (UCHAR *) block) {
// Found it - remove it from the list // Found it - remove it from the list
*ptr = *block; *ptr = *block;
// and free it // and free it
gds__free((SLONG *) block); gds__free((SLONG *) block);
return; return;
} }
} }
// We should always find the block in the list // We should always find the block in the list
BURP_error(238, true); BURP_error(238, true);
// msg 238: System memory exhausted // msg 238: System memory exhausted
// (too lazy to add a better message) // (too lazy to add a better message)
} }
} }

View File

@ -1,7 +1,7 @@
/* /*
* PROGRAM: JRD Backup and Restore Program * PROGRAM: JRD Backup and Restore Program
* MODULE: multivol.cpp * MODULE: multivol.cpp
* DESCRIPTION: * DESCRIPTION:
* *
* The contents of this file are subject to the Interbase Public * The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file * License Version 1.0 (the "License"); you may not use this file
@ -84,7 +84,7 @@ static inline void put(BurpGlobals* tdgbl, UCHAR c)
} }
#ifdef DEBUG #ifdef DEBUG
static UCHAR debug_on = 0; // able to turn this on in debug mode static UCHAR debug_on = 0; // able to turn this on in debug mode
#endif #endif
const int burp_msg_fac = 12; const int burp_msg_fac = 12;
@ -253,7 +253,7 @@ void MVOL_init_write(const char* database_name, // unused?
if (tdgbl->action->act_action == ACT_backup_split) if (tdgbl->action->act_action == ACT_backup_split)
{ {
BURP_error(269, true, tdgbl->action->act_file->fil_name.c_str()); BURP_error(269, true, tdgbl->action->act_file->fil_name.c_str());
// msg 269 can't write a header record to file %s // msg 269 can't write a header record to file %s
} }
tdgbl->file_desc = next_volume(tdgbl->file_desc, MODE_WRITE, false); tdgbl->file_desc = next_volume(tdgbl->file_desc, MODE_WRITE, false);
} }
@ -299,12 +299,12 @@ int MVOL_read(int* cnt, UCHAR** ptr)
if (cnt) if (cnt)
{ {
BURP_error_redirect(0, 220); BURP_error_redirect(0, 220);
// msg 220 Unexpected I/O error while reading from backup file // msg 220 Unexpected I/O error while reading from backup file
} }
else else
{ {
BURP_error_redirect(0, 50); BURP_error_redirect(0, 50);
// msg 50 unexpected end of file on backup file // msg 50 unexpected end of file on backup file
} }
} }
} }
@ -349,10 +349,10 @@ int MVOL_read(int* cnt, UCHAR** ptr)
{ {
if (cnt) if (cnt)
BURP_error_redirect(NULL, 220); BURP_error_redirect(NULL, 220);
// msg 220 Unexpected I/O error while reading from backup file // msg 220 Unexpected I/O error while reading from backup file
else else
BURP_error_redirect(NULL, 50); BURP_error_redirect(NULL, 50);
// msg 50 unexpected end of file on backup file // msg 50 unexpected end of file on backup file
} }
} }
@ -364,7 +364,7 @@ int MVOL_read(int* cnt, UCHAR** ptr)
return *(tdgbl->mvol_io_ptr); return *(tdgbl->mvol_io_ptr);
} }
#endif // !WIN_NT #endif // !WIN_NT
//____________________________________________________________ //____________________________________________________________
@ -380,23 +380,23 @@ UCHAR* MVOL_read_block(BurpGlobals* tdgbl, UCHAR* ptr, ULONG count)
while (count) while (count)
{ {
// If buffer empty, reload it // If buffer empty, reload it
if (tdgbl->io_cnt <= 0) if (tdgbl->io_cnt <= 0)
{ {
*ptr++ = MVOL_read(&tdgbl->io_cnt, &tdgbl->io_ptr); *ptr++ = MVOL_read(&tdgbl->io_cnt, &tdgbl->io_ptr);
// One byte was "read" by MVOL_read // One byte was "read" by MVOL_read
count--; count--;
} }
const ULONG n = MIN(count, (ULONG) tdgbl->io_cnt); const ULONG n = MIN(count, (ULONG) tdgbl->io_cnt);
// Copy data from the IO buffer // Copy data from the IO buffer
memcpy(ptr, tdgbl->io_ptr, n); memcpy(ptr, tdgbl->io_ptr, n);
ptr += n; ptr += n;
// Skip ahead in current buffer // Skip ahead in current buffer
count -= n; count -= n;
tdgbl->io_cnt -= n; tdgbl->io_cnt -= n;
@ -420,18 +420,18 @@ void MVOL_skip_block( BurpGlobals* tdgbl, ULONG count)
while (count) while (count)
{ {
// If buffer empty, reload it // If buffer empty, reload it
if (tdgbl->io_cnt <= 0) if (tdgbl->io_cnt <= 0)
{ {
MVOL_read(&tdgbl->io_cnt, &tdgbl->io_ptr); MVOL_read(&tdgbl->io_cnt, &tdgbl->io_ptr);
// One byte was "read" by MVOL_read // One byte was "read" by MVOL_read
count--; count--;
} }
const ULONG n = MIN(count, (ULONG) tdgbl->io_cnt); const ULONG n = MIN(count, (ULONG) tdgbl->io_cnt);
// Skip ahead in current buffer // Skip ahead in current buffer
count -= n; count -= n;
tdgbl->io_cnt -= n; tdgbl->io_cnt -= n;
@ -462,11 +462,11 @@ DESC MVOL_open(const char* name, ULONG mode, ULONG create)
} }
else else
{ {
// it's a tape device // it's a tape device
// Note: we *want* to open the tape in Read-only mode or in // Note: we *want* to open the tape in Read-only mode or in
// write-only mode, but it turns out that on NT SetTapePosition // write-only mode, but it turns out that on NT SetTapePosition
// will fail (thereby not rewinding the tape) if the tape is // will fail (thereby not rewinding the tape) if the tape is
// opened write-only, so we will make sure that we always have // opened write-only, so we will make sure that we always have
// read access. So much for standards! // read access. So much for standards!
// Ain't Windows wonderful??? // Ain't Windows wonderful???
// //
@ -482,16 +482,16 @@ DESC MVOL_open(const char* name, ULONG mode, ULONG create)
{ {
// emulate UNIX rewinding the tape on open: // emulate UNIX rewinding the tape on open:
// This MUST be done since Windows does NOT have anything // This MUST be done since Windows does NOT have anything
// like mt to allow the user to do tape management. The // like mt to allow the user to do tape management. The
// implication here is that we will be able to write ONLY // implication here is that we will be able to write ONLY
// one (1) database per tape. This is bad if the user wishes to // one (1) database per tape. This is bad if the user wishes to
// backup several small databases. // backup several small databases.
// Note: We are intentionally NOT trapping for errors during // Note: We are intentionally NOT trapping for errors during
// rewind, since if we can not rewind, we are either a non-rewind // rewind, since if we can not rewind, we are either a non-rewind
// device (then it is user controlled) or we have a problem with // device (then it is user controlled) or we have a problem with
// the physical media. In the latter case I would rather wait for // the physical media. In the latter case I would rather wait for
// the write to fail so that we can loop and prompt the user for // the write to fail so that we can loop and prompt the user for
// a different file/device. // a different file/device.
// //
SetTapePosition(handle, TAPE_REWIND, 0, 0, 0, FALSE); SetTapePosition(handle, TAPE_REWIND, 0, 0, 0, FALSE);
if (GetTapeParameters(handle, GET_TAPE_MEDIA_INFORMATION, &size, if (GetTapeParameters(handle, GET_TAPE_MEDIA_INFORMATION, &size,
@ -503,7 +503,7 @@ DESC MVOL_open(const char* name, ULONG mode, ULONG create)
} }
return handle; return handle;
} }
#endif // WIN_NT #endif // WIN_NT
//____________________________________________________________ //____________________________________________________________
@ -558,7 +558,7 @@ UCHAR MVOL_write(const UCHAR c, int* io_cnt, UCHAR** io_ptr)
(tdgbl->action->act_action == ACT_backup_split && (tdgbl->action->act_action == ACT_backup_split &&
(tdgbl->action->act_file->fil_length < left) ? (tdgbl->action->act_file->fil_length < left) ?
tdgbl->action->act_file->fil_length : left); tdgbl->action->act_file->fil_length : left);
DWORD err = 0; DWORD err = 0;
// Assumes DWORD <==> ULONG // Assumes DWORD <==> ULONG
if (!WriteFile(tdgbl->file_desc, ptr, nBytesToWrite, if (!WriteFile(tdgbl->file_desc, ptr, nBytesToWrite,
@ -566,7 +566,7 @@ UCHAR MVOL_write(const UCHAR c, int* io_cnt, UCHAR** io_ptr)
{ {
err = GetLastError(); err = GetLastError();
} }
#endif // !WIN_NT #endif // !WIN_NT
tdgbl->mvol_io_buffer = tdgbl->mvol_io_data; tdgbl->mvol_io_buffer = tdgbl->mvol_io_data;
if (cnt > 0) if (cnt > 0)
{ {
@ -588,7 +588,7 @@ UCHAR MVOL_write(const UCHAR c, int* io_cnt, UCHAR** io_ptr)
errno == EFBIG) errno == EFBIG)
#else #else
err == ERROR_DISK_FULL || err == ERROR_HANDLE_DISK_FULL) err == ERROR_DISK_FULL || err == ERROR_HANDLE_DISK_FULL)
#endif // !WIN_NT #endif // !WIN_NT
{ {
if (tdgbl->action->act_action == ACT_backup_split) if (tdgbl->action->act_action == ACT_backup_split)
{ {
@ -604,7 +604,7 @@ UCHAR MVOL_write(const UCHAR c, int* io_cnt, UCHAR** io_ptr)
if (file->fil_fd == tdgbl->file_desc) if (file->fil_fd == tdgbl->file_desc)
file->fil_fd = INVALID_HANDLE_VALUE; file->fil_fd = INVALID_HANDLE_VALUE;
} }
tdgbl->action->act_file->fil_fd = INVALID_HANDLE_VALUE; tdgbl->action->act_file->fil_fd = INVALID_HANDLE_VALUE;
BURP_print(272, SafeArg() << BURP_print(272, SafeArg() <<
tdgbl->action->act_file->fil_name.c_str() << tdgbl->action->act_file->fil_name.c_str() <<
@ -621,7 +621,7 @@ UCHAR MVOL_write(const UCHAR c, int* io_cnt, UCHAR** io_ptr)
else else
{ {
BURP_error(270, true); BURP_error(270, true);
// msg 270 free disk space exhausted // msg 270 free disk space exhausted
} }
cnt = 0; cnt = 0;
continue; continue;
@ -639,7 +639,7 @@ UCHAR MVOL_write(const UCHAR c, int* io_cnt, UCHAR** io_ptr)
if (left != size_to_write) if (left != size_to_write)
{ {
// Wrote some, move remainder up in buffer. // Wrote some, move remainder up in buffer.
// NOTE: We should NOT use memcpy here. We're moving overlapped // NOTE: We should NOT use memcpy here. We're moving overlapped
// data and memcpy does not guanantee the order the data // data and memcpy does not guanantee the order the data
@ -652,7 +652,7 @@ UCHAR MVOL_write(const UCHAR c, int* io_cnt, UCHAR** io_ptr)
full_buffer = true; full_buffer = true;
else else
full_buffer = false; full_buffer = false;
tdgbl->file_desc = next_volume(tdgbl->file_desc, MODE_WRITE, tdgbl->file_desc = next_volume(tdgbl->file_desc, MODE_WRITE,
full_buffer); full_buffer);
if (full_buffer) if (full_buffer)
{ {
@ -670,7 +670,7 @@ UCHAR MVOL_write(const UCHAR c, int* io_cnt, UCHAR** io_ptr)
else if (!SYSCALL_INTERRUPTED(errno)) else if (!SYSCALL_INTERRUPTED(errno))
{ {
BURP_error_redirect(0, 221); BURP_error_redirect(0, 221);
// msg 221 Unexpected I/O error while writing to backup file // msg 221 Unexpected I/O error while writing to backup file
} }
} }
if (left < cnt) { // this is impossible, but... if (left < cnt) { // this is impossible, but...
@ -755,7 +755,7 @@ static void bad_attribute(int attribute, USHORT type)
static const SafeArg dummy; static const SafeArg dummy;
fb_msg_format(NULL, burp_msg_fac, type, sizeof(name), name, dummy); fb_msg_format(NULL, burp_msg_fac, type, sizeof(name), name, dummy);
BURP_print(80, SafeArg() << name << attribute); BURP_print(80, SafeArg() << name << attribute);
// msg 80 don't recognize %s attribute %ld -- continuing // msg 80 don't recognize %s attribute %ld -- continuing
for (int l = get(tdgbl); l; --l) for (int l = get(tdgbl); l; --l)
get(tdgbl); get(tdgbl);
} }
@ -832,7 +832,7 @@ static DESC next_volume( DESC handle, ULONG mode, bool full_buffer)
if (handle != INVALID_HANDLE_VALUE) if (handle != INVALID_HANDLE_VALUE)
#else #else
if (handle > -1) if (handle > -1)
#endif // WIN_NT #endif // WIN_NT
{ {
close_platf(handle); close_platf(handle);
} }
@ -858,20 +858,20 @@ static DESC next_volume( DESC handle, ULONG mode, bool full_buffer)
tdgbl->mvol_empty_file = TRUE; tdgbl->mvol_empty_file = TRUE;
// Loop until we have opened a file successfully // Loop until we have opened a file successfully
SCHAR new_file[MAX_FILE_NAME_SIZE]; SCHAR new_file[MAX_FILE_NAME_SIZE];
DESC new_desc = INVALID_HANDLE_VALUE; DESC new_desc = INVALID_HANDLE_VALUE;
for (;;) for (;;)
{ {
// We aim to keep our descriptors clean // We aim to keep our descriptors clean
if (new_desc != INVALID_HANDLE_VALUE) { if (new_desc != INVALID_HANDLE_VALUE) {
close_platf(new_desc); close_platf(new_desc);
new_desc = INVALID_HANDLE_VALUE; new_desc = INVALID_HANDLE_VALUE;
} }
// Get file name to try // Get file name to try
prompt_for_name(new_file, sizeof(new_file)); prompt_for_name(new_file, sizeof(new_file));
@ -881,20 +881,20 @@ static DESC next_volume( DESC handle, ULONG mode, bool full_buffer)
#else #else
new_desc = open(new_file, mode, open_mask); new_desc = open(new_file, mode, open_mask);
if (new_desc < 0) if (new_desc < 0)
#endif // WIN_NT #endif // WIN_NT
{ {
BURP_print(222, new_file); BURP_print(222, new_file);
// msg 222 \n\nCould not open file name \"%s\"\n // msg 222 \n\nCould not open file name \"%s\"\n
continue; continue;
} }
// If the file is to be writable, probe it, and make sure it is... // If the file is to be writable, probe it, and make sure it is...
#ifdef WIN_NT #ifdef WIN_NT
if (mode == MODE_WRITE) if (mode == MODE_WRITE)
#else #else
if ((O_WRONLY == (mode & O_WRONLY)) || (O_RDWR == (mode & O_RDWR))) if ((O_WRONLY == (mode & O_WRONLY)) || (O_RDWR == (mode & O_RDWR)))
#endif // WIN_NT #endif // WIN_NT
{ {
if (!write_header(new_desc, 0L, full_buffer)) if (!write_header(new_desc, 0L, full_buffer))
{ {
@ -905,13 +905,13 @@ static DESC next_volume( DESC handle, ULONG mode, bool full_buffer)
else else
{ {
BURP_msg_put(261, SafeArg() << tdgbl->mvol_volume_count << new_file); BURP_msg_put(261, SafeArg() << tdgbl->mvol_volume_count << new_file);
// Starting with volume #vol_count, new_file // Starting with volume #vol_count, new_file
BURP_verbose(75, new_file); // msg 75 creating file %s BURP_verbose(75, new_file); // msg 75 creating file %s
} }
} }
else else
{ {
// File is open for read only. Read the header. // File is open for read only. Read the header.
ULONG temp_buffer_size; ULONG temp_buffer_size;
USHORT format; USHORT format;
@ -923,7 +923,7 @@ static DESC next_volume( DESC handle, ULONG mode, bool full_buffer)
else else
{ {
BURP_msg_put(261, SafeArg() << tdgbl->mvol_volume_count << new_file); BURP_msg_put(261, SafeArg() << tdgbl->mvol_volume_count << new_file);
// Starting with volume #vol_count, new_file // Starting with volume #vol_count, new_file
BURP_verbose(100, new_file); // msg 100 opened file %s BURP_verbose(100, new_file); // msg 100 opened file %s
} }
} }
@ -961,11 +961,11 @@ static void prompt_for_name(SCHAR* name, int length)
term_in = stdin; term_in = stdin;
} }
// Loop until we have a file name to try // Loop until we have a file name to try
for (;;) for (;;)
{ {
// If there was an old file name, use that prompt // If there was an old file name, use that prompt
if (strlen(tdgbl->mvol_old_file) > 0) if (strlen(tdgbl->mvol_old_file) > 0)
{ {
@ -973,14 +973,14 @@ static void prompt_for_name(SCHAR* name, int length)
tdgbl->mvol_old_file); tdgbl->mvol_old_file);
fprintf(term_out, msg); fprintf(term_out, msg);
BURP_msg_get(226, msg); BURP_msg_get(226, msg);
// \tPress return to reopen that file, or type a new\n\tname // \tPress return to reopen that file, or type a new\n\tname
// followed by return to open a different file.\n // followed by return to open a different file.\n
fprintf(term_out, msg); fprintf(term_out, msg);
} }
else // First volume else // First volume
{ {
BURP_msg_get(227, msg); BURP_msg_get(227, msg);
// Type a file name to open and hit return // Type a file name to open and hit return
fprintf(term_out, msg); fprintf(term_out, msg);
} }
BURP_msg_get(228, msg); // " Name: " BURP_msg_get(228, msg); // " Name: "
@ -1005,11 +1005,11 @@ static void prompt_for_name(SCHAR* name, int length)
strcpy(name, tdgbl->mvol_old_file); strcpy(name, tdgbl->mvol_old_file);
break; break;
} }
else // reprompt else // reprompt
continue; continue;
} }
// OK, its a file name, strip the carriage return // OK, its a file name, strip the carriage return
SCHAR* name_ptr = name; SCHAR* name_ptr = name;
while (*name_ptr && *name_ptr != '\n') while (*name_ptr && *name_ptr != '\n')
@ -1089,12 +1089,12 @@ static bool read_header(DESC handle,
BurpGlobals* tdgbl = BurpGlobals::getSpecific(); BurpGlobals* tdgbl = BurpGlobals::getSpecific();
// Headers are a version number, and a volume number // Headers are a version number, and a volume number
// CVC: Nobody does an explicit check for the read operation, assuming // CVC: Nobody does an explicit check for the read operation, assuming
// that GET_ATTRIBUTE() != rec_burp will provide an implicit test. // that GET_ATTRIBUTE() != rec_burp will provide an implicit test.
#ifndef WIN_NT #ifndef WIN_NT
tdgbl->mvol_io_cnt = read(handle, tdgbl->mvol_io_buffer, tdgbl->mvol_io_cnt = read(handle, tdgbl->mvol_io_buffer,
tdgbl->mvol_actual_buffer_size); tdgbl->mvol_actual_buffer_size);
#else #else
ReadFile(handle, tdgbl->mvol_io_buffer, tdgbl->mvol_actual_buffer_size, ReadFile(handle, tdgbl->mvol_io_buffer, tdgbl->mvol_actual_buffer_size,
@ -1105,7 +1105,7 @@ static bool read_header(DESC handle,
int attribute = get(tdgbl); int attribute = get(tdgbl);
if (attribute != rec_burp) if (attribute != rec_burp)
BURP_error_redirect(0, 45); BURP_error_redirect(0, 45);
// msg 45 expected backup description record // msg 45 expected backup description record
int l, maxlen; int l, maxlen;
int temp; int temp;
@ -1294,7 +1294,7 @@ static bool write_header(DESC handle,
#else #else
ULONG bytes_written = write(handle, tdgbl->mvol_io_header, ULONG bytes_written = write(handle, tdgbl->mvol_io_header,
tdgbl->mvol_io_buffer_size); tdgbl->mvol_io_buffer_size);
#endif // WIN_NT #endif // WIN_NT
if (bytes_written != tdgbl->mvol_io_buffer_size) if (bytes_written != tdgbl->mvol_io_buffer_size)
{ {
@ -1349,7 +1349,7 @@ bool MVOL_split_hdr_write(void)
#else #else
ULONG bytes_written = ULONG bytes_written =
write(tdgbl->action->act_file->fil_fd, buffer, HDR_SPLIT_SIZE); write(tdgbl->action->act_file->fil_fd, buffer, HDR_SPLIT_SIZE);
#endif // WIN_NT #endif // WIN_NT
if (bytes_written != HDR_SPLIT_SIZE) { if (bytes_written != HDR_SPLIT_SIZE) {
return false; return false;

View File

@ -62,7 +62,7 @@ StatusVector::ImplStatusVector::ImplStatusVector(const ISC_STATUS* s) throw() :
StatusVector::StatusVector(ISC_STATUS k, ISC_STATUS c) : StatusVector::StatusVector(ISC_STATUS k, ISC_STATUS c) :
Base(FB_NEW(*getDefaultMemoryPool()) ImplStatusVector(k, c)) Base(FB_NEW(*getDefaultMemoryPool()) ImplStatusVector(k, c))
{ {
operator<<(*(static_cast<Base*>(this))); operator<<(*(static_cast<Base*>(this)));
} }
@ -71,7 +71,7 @@ StatusVector::StatusVector(const ISC_STATUS* s) :
{ {
} }
StatusVector::StatusVector() : StatusVector::StatusVector() :
Base(FB_NEW(*getDefaultMemoryPool()) ImplStatusVector(0, 0)) Base(FB_NEW(*getDefaultMemoryPool()) ImplStatusVector(0, 0))
{ {
} }
@ -95,21 +95,21 @@ void StatusVector::ImplStatusVector::append(const StatusVector& v) throw()
newVector.appendWarnings(v.implementation); newVector.appendWarnings(v.implementation);
} }
} }
*this = newVector; *this = newVector;
} }
bool StatusVector::ImplStatusVector::appendErrors(const ImplBase* const v) throw() bool StatusVector::ImplStatusVector::appendErrors(const ImplBase* const v) throw()
{ {
return append(v->value(), v->firstWarning() ? v->firstWarning() : v->length()); return append(v->value(), v->firstWarning() ? v->firstWarning() : v->length());
} }
bool StatusVector::ImplStatusVector::appendWarnings(const ImplBase* const v) throw() bool StatusVector::ImplStatusVector::appendWarnings(const ImplBase* const v) throw()
{ {
if (! v->firstWarning()) if (! v->firstWarning())
return true; return true;
return append(v->value() + v->firstWarning(), v->length() - v->firstWarning()); return append(v->value() + v->firstWarning(), v->length() - v->firstWarning());
} }
bool StatusVector::ImplStatusVector::append(const ISC_STATUS* const from, const int count) throw() bool StatusVector::ImplStatusVector::append(const ISC_STATUS* const from, const int count) throw()
{ {
@ -193,43 +193,43 @@ ISC_STATUS StatusVector::ImplStatusVector::copyTo(ISC_STATUS* dest) const throw(
return dest[1]; return dest[1];
} }
Gds::Gds(ISC_STATUS s) throw() : Gds::Gds(ISC_STATUS s) throw() :
StatusVector(isc_arg_gds, s) { } StatusVector(isc_arg_gds, s) { }
Num::Num(ISC_STATUS s) throw() : Num::Num(ISC_STATUS s) throw() :
Base(isc_arg_number, s) { } Base(isc_arg_number, s) { }
Interpreted::Interpreted(const char* text) throw() : Interpreted::Interpreted(const char* text) throw() :
StatusVector(isc_arg_interpreted, (ISC_STATUS)(IPTR) text) { } StatusVector(isc_arg_interpreted, (ISC_STATUS)(IPTR) text) { }
Interpreted::Interpreted(const AbstractString& text) throw() : Interpreted::Interpreted(const AbstractString& text) throw() :
StatusVector(isc_arg_interpreted, (ISC_STATUS)(IPTR) text.c_str()) { } StatusVector(isc_arg_interpreted, (ISC_STATUS)(IPTR) text.c_str()) { }
Unix::Unix(ISC_STATUS s) throw() : Unix::Unix(ISC_STATUS s) throw() :
Base(isc_arg_unix, s) { } Base(isc_arg_unix, s) { }
Windows::Windows(ISC_STATUS s) throw() : Windows::Windows(ISC_STATUS s) throw() :
Base(isc_arg_win32, s) { } Base(isc_arg_win32, s) { }
Warning::Warning(ISC_STATUS s) throw() : Warning::Warning(ISC_STATUS s) throw() :
StatusVector(isc_arg_warning, s) { } StatusVector(isc_arg_warning, s) { }
Str::Str(const char* text) throw() : Str::Str(const char* text) throw() :
Base(isc_arg_string, (ISC_STATUS)(IPTR) text) { } Base(isc_arg_string, (ISC_STATUS)(IPTR) text) { }
Str::Str(const AbstractString& text) throw() : Str::Str(const AbstractString& text) throw() :
Base(isc_arg_string, (ISC_STATUS)(IPTR) text.c_str()) { } Base(isc_arg_string, (ISC_STATUS)(IPTR) text.c_str()) { }
Str::Str(const MetaName& text) throw() : Str::Str(const MetaName& text) throw() :
Base(isc_arg_string, (ISC_STATUS)(IPTR) text.c_str()) { } Base(isc_arg_string, (ISC_STATUS)(IPTR) text.c_str()) { }
SqlState::SqlState(const char* text) throw() : SqlState::SqlState(const char* text) throw() :
Base(isc_arg_sql_state, (ISC_STATUS)(IPTR) text) { } Base(isc_arg_sql_state, (ISC_STATUS)(IPTR) text) { }
SqlState::SqlState(const AbstractString& text) throw() : SqlState::SqlState(const AbstractString& text) throw() :
Base(isc_arg_sql_state, (ISC_STATUS)(IPTR) text.c_str()) { } Base(isc_arg_sql_state, (ISC_STATUS)(IPTR) text.c_str()) { }
OsError::OsError() throw() : OsError::OsError() throw() :
#ifdef WIN_NT #ifdef WIN_NT
Base(isc_arg_win32, GetLastError()) { } Base(isc_arg_win32, GetLastError()) { }
#else #else

View File

@ -1,7 +1,7 @@
/* /*
* PROGRAM: Firebird exceptions classes * PROGRAM: Firebird exceptions classes
* MODULE: StatusHolder.cpp * MODULE: StatusHolder.cpp
* DESCRIPTION: Firebird's exception classes * DESCRIPTION: Firebird's exception classes
* *
* The contents of this file are subject to the Initial * The contents of this file are subject to the Initial
* Developer's Public License Version 1.0 (the "License"); * Developer's Public License Version 1.0 (the "License");
@ -42,14 +42,14 @@ ISC_STATUS StatusHolder::save(const ISC_STATUS* status)
const ISC_STATUS *from = status; const ISC_STATUS *from = status;
ISC_STATUS *to = m_status_vector; ISC_STATUS *to = m_status_vector;
while (true) while (true)
{ {
const ISC_STATUS type = *to++ = *from++; const ISC_STATUS type = *to++ = *from++;
if (type == isc_arg_end) if (type == isc_arg_end)
break; break;
switch (type) { switch (type) {
case isc_arg_cstring: case isc_arg_cstring:
{ {
const size_t len = *to++ = *from++; const size_t len = *to++ = *from++;
char *string = FB_NEW(*getDefaultMemoryPool()) char[len]; char *string = FB_NEW(*getDefaultMemoryPool()) char[len];
@ -64,7 +64,7 @@ ISC_STATUS StatusHolder::save(const ISC_STATUS* status)
case isc_arg_sql_state: case isc_arg_sql_state:
{ {
const char* temp = reinterpret_cast<const char*>(*from++); const char* temp = reinterpret_cast<const char*>(*from++);
const size_t len = strlen(temp); const size_t len = strlen(temp);
char* string = FB_NEW(*getDefaultMemoryPool()) char[len + 1]; char* string = FB_NEW(*getDefaultMemoryPool()) char[len + 1];
memcpy(string, temp, len + 1); memcpy(string, temp, len + 1);
@ -84,7 +84,7 @@ ISC_STATUS StatusHolder::save(const ISC_STATUS* status)
void StatusHolder::clear() void StatusHolder::clear()
{ {
ISC_STATUS *ptr = m_status_vector; ISC_STATUS *ptr = m_status_vector;
while (true) while (true)
{ {
const ISC_STATUS type = *ptr++; const ISC_STATUS type = *ptr++;
if (type == isc_arg_end) if (type == isc_arg_end)
@ -105,18 +105,18 @@ void StatusHolder::clear()
default: default:
ptr++; ptr++;
break; break;
} }
} }
memset(m_status_vector, 0, sizeof(m_status_vector)); memset(m_status_vector, 0, sizeof(m_status_vector));
m_raised = false; m_raised = false;
} }
void StatusHolder::raise() void StatusHolder::raise()
{ {
if (getError()) if (getError())
{ {
m_raised = true; m_raised = true;
throw status_exception(m_status_vector, true); throw status_exception(m_status_vector, true);
} }
} }

View File

@ -1,7 +1,7 @@
/* /*
* PROGRAM: Firebird utilities interface * PROGRAM: Firebird utilities interface
* MODULE: UtilSvc.cpp * MODULE: UtilSvc.cpp
* DESCRIPTION: Interface making it possible to use same code * DESCRIPTION: Interface making it possible to use same code
* as both utility or service * as both utility or service
* *
* The contents of this file are subject to the Initial * The contents of this file are subject to the Initial
@ -49,7 +49,7 @@ public:
} }
} }
virtual void printf(const SCHAR* format, ...) virtual void printf(const SCHAR* format, ...)
{ {
va_list arglist; va_list arglist;
va_start(arglist, format); va_start(arglist, format);
@ -90,7 +90,7 @@ public:
{ {
StringsBuffer::makeEnginePermanentVector(s); StringsBuffer::makeEnginePermanentVector(s);
} }
// do nothing for non-service // do nothing for non-service
virtual void finish() { } virtual void finish() { }
virtual void started() { } virtual void started() { }

View File

@ -92,9 +92,9 @@ int StringStream::write(const void* str, unsigned int n)
} }
else else
m_current_pos += avail; m_current_pos += avail;
m_current_pos[0] = 0; m_current_pos[0] = 0;
return avail; return avail;
} }

View File

@ -58,12 +58,12 @@ public:
return t2; return t2;
} }
protected: protected:
virtual void usage_mistake(const char* what) const virtual void usage_mistake(const char* what) const
{ {
fatal_exception::raiseFmt( fatal_exception::raiseFmt(
"Internal error when using clumplet API: %s", what); "Internal error when using clumplet API: %s", what);
} }
virtual void invalid_structure(const char* what) const virtual void invalid_structure(const char* what) const
{ {
fatal_exception::raiseFmt( fatal_exception::raiseFmt(
"Invalid clumplet buffer structure: %s", what); "Invalid clumplet buffer structure: %s", what);
@ -80,7 +80,7 @@ void ClumpletReader::dump() const
return; return;
} }
dmp++; dmp++;
try { try {
ClumpletDump d(kind, getBuffer(), getBufferLength()); ClumpletDump d(kind, getBuffer(), getBufferLength());
int t = (kind == SpbStart || kind == UnTagged || kind == WideUnTagged) ? -1 : d.getBufferTag(); int t = (kind == SpbStart || kind == UnTagged || kind == WideUnTagged) ? -1 : d.getBufferTag();
@ -107,13 +107,13 @@ void ClumpletReader::dump() const
namespace Firebird { namespace Firebird {
ClumpletReader::ClumpletReader(Kind k, const UCHAR* buffer, size_t buffLen) : ClumpletReader::ClumpletReader(Kind k, const UCHAR* buffer, size_t buffLen) :
kind(k), static_buffer(buffer), static_buffer_end(buffer + buffLen) kind(k), static_buffer(buffer), static_buffer_end(buffer + buffLen)
{ {
rewind(); // this will set cur_offset and spbState rewind(); // this will set cur_offset and spbState
} }
ClumpletReader::ClumpletReader(MemoryPool& pool, Kind k, const UCHAR* buffer, size_t buffLen) : ClumpletReader::ClumpletReader(MemoryPool& pool, Kind k, const UCHAR* buffer, size_t buffLen) :
AutoStorage(pool), kind(k), static_buffer(buffer), static_buffer_end(buffer + buffLen) AutoStorage(pool), kind(k), static_buffer(buffer), static_buffer_end(buffer + buffLen)
{ {
rewind(); // this will set cur_offset and spbState rewind(); // this will set cur_offset and spbState
} }
@ -140,13 +140,13 @@ UCHAR ClumpletReader::getBufferTag() const
{ {
const UCHAR* const buffer_end = getBufferEnd(); const UCHAR* const buffer_end = getBufferEnd();
const UCHAR* buffer_start = getBuffer(); const UCHAR* buffer_start = getBuffer();
switch (kind) switch (kind)
{ {
case Tpb: case Tpb:
case Tagged: case Tagged:
case WideTagged: case WideTagged:
if (buffer_end - buffer_start == 0) if (buffer_end - buffer_start == 0)
{ {
invalid_structure("empty buffer"); invalid_structure("empty buffer");
return 0; return 0;
@ -159,7 +159,7 @@ UCHAR ClumpletReader::getBufferTag() const
usage_mistake("buffer is not tagged"); usage_mistake("buffer is not tagged");
return 0; return 0;
case SpbAttach: case SpbAttach:
if (buffer_end - buffer_start == 0) if (buffer_end - buffer_start == 0)
{ {
invalid_structure("empty buffer"); invalid_structure("empty buffer");
return 0; return 0;
@ -167,12 +167,12 @@ UCHAR ClumpletReader::getBufferTag() const
switch (buffer_start[0]) switch (buffer_start[0])
{ {
case isc_spb_version1: case isc_spb_version1:
// This is old SPB format, it's almost like DPB - // This is old SPB format, it's almost like DPB -
// buffer's tag is the first byte. // buffer's tag is the first byte.
return buffer_start[0]; return buffer_start[0];
case isc_spb_version: case isc_spb_version:
// Buffer's tag is the second byte // Buffer's tag is the second byte
if (buffer_end - buffer_start == 1) if (buffer_end - buffer_start == 1)
{ {
invalid_structure("buffer too short (1 byte)"); invalid_structure("buffer too short (1 byte)");
return 0; return 0;
@ -215,7 +215,7 @@ ClumpletReader::ClumpletType ClumpletReader::getClumpletType(UCHAR tag) const
return SingleTpb; return SingleTpb;
case isc_action_svc_backup: case isc_action_svc_backup:
case isc_action_svc_restore: case isc_action_svc_restore:
switch (tag) switch (tag)
{ {
case isc_spb_bkp_file: case isc_spb_bkp_file:
case isc_spb_dbname: case isc_spb_dbname:
@ -235,7 +235,7 @@ ClumpletReader::ClumpletType ClumpletReader::getClumpletType(UCHAR tag) const
invalid_structure("unknown parameter for backup/restore"); invalid_structure("unknown parameter for backup/restore");
break; break;
case isc_action_svc_repair: case isc_action_svc_repair:
switch (tag) switch (tag)
{ {
case isc_spb_dbname: case isc_spb_dbname:
return StringSpb; return StringSpb;
@ -247,11 +247,11 @@ ClumpletReader::ClumpletType ClumpletReader::getClumpletType(UCHAR tag) const
} }
invalid_structure("unknown parameter for repair"); invalid_structure("unknown parameter for repair");
break; break;
case isc_action_svc_add_user: case isc_action_svc_add_user:
case isc_action_svc_delete_user: case isc_action_svc_delete_user:
case isc_action_svc_modify_user: case isc_action_svc_modify_user:
case isc_action_svc_display_user: case isc_action_svc_display_user:
switch (tag) switch (tag)
{ {
case isc_spb_dbname: case isc_spb_dbname:
case isc_spb_sql_role_name: case isc_spb_sql_role_name:
@ -269,7 +269,7 @@ ClumpletReader::ClumpletType ClumpletReader::getClumpletType(UCHAR tag) const
invalid_structure("unknown parameter for security database operation"); invalid_structure("unknown parameter for security database operation");
break; break;
case isc_action_svc_properties: case isc_action_svc_properties:
switch (tag) switch (tag)
{ {
case isc_spb_dbname: case isc_spb_dbname:
return StringSpb; return StringSpb;
@ -296,7 +296,7 @@ ClumpletReader::ClumpletType ClumpletReader::getClumpletType(UCHAR tag) const
// case isc_action_svc_add_license: // case isc_action_svc_add_license:
// case isc_action_svc_remove_license: // case isc_action_svc_remove_license:
case isc_action_svc_db_stats: case isc_action_svc_db_stats:
switch (tag) switch (tag)
{ {
case isc_spb_dbname: case isc_spb_dbname:
case isc_spb_command_line: case isc_spb_command_line:
@ -311,7 +311,7 @@ ClumpletReader::ClumpletType ClumpletReader::getClumpletType(UCHAR tag) const
break; break;
case isc_action_svc_nbak: case isc_action_svc_nbak:
case isc_action_svc_nrest: case isc_action_svc_nrest:
switch (tag) switch (tag)
{ {
case isc_spb_nbk_file: case isc_spb_nbk_file:
case isc_spb_dbname: case isc_spb_dbname:
@ -358,7 +358,7 @@ size_t ClumpletReader::getClumpletSize(bool wTag, bool wLength, bool wData) cons
size_t rc = wTag ? 1 : 0; size_t rc = wTag ? 1 : 0;
size_t lengthSize = 0; size_t lengthSize = 0;
size_t dataSize = 0; size_t dataSize = 0;
switch (getClumpletType(clumplet[0])) switch (getClumpletType(clumplet[0]))
{ {
@ -455,7 +455,7 @@ void ClumpletReader::rewind()
} }
if (kind == UnTagged || kind == WideUnTagged || kind == SpbStart || kind == SpbItems) if (kind == UnTagged || kind == WideUnTagged || kind == SpbStart || kind == SpbItems)
cur_offset = 0; cur_offset = 0;
else if (kind == SpbAttach && getBufferLength() > 0 else if (kind == SpbAttach && getBufferLength() > 0
&& getBuffer()[0] != isc_spb_version1) && getBuffer()[0] != isc_spb_version1)
cur_offset = 2; cur_offset = 2;
else else

View File

@ -36,20 +36,20 @@
namespace Firebird { namespace Firebird {
ClumpletWriter::ClumpletWriter(Kind k, size_t limit, UCHAR tag) : ClumpletWriter::ClumpletWriter(Kind k, size_t limit, UCHAR tag) :
ClumpletReader(k, NULL, 0), sizeLimit(limit), dynamic_buffer(getPool()) ClumpletReader(k, NULL, 0), sizeLimit(limit), dynamic_buffer(getPool())
{ {
initNewBuffer(tag); initNewBuffer(tag);
rewind(); rewind();
} }
ClumpletWriter::ClumpletWriter(MemoryPool& given_pool, Kind k, size_t limit, UCHAR tag) : ClumpletWriter::ClumpletWriter(MemoryPool& given_pool, Kind k, size_t limit, UCHAR tag) :
ClumpletReader(given_pool, k, NULL, 0), sizeLimit(limit), dynamic_buffer(getPool()) ClumpletReader(given_pool, k, NULL, 0), sizeLimit(limit), dynamic_buffer(getPool())
{ {
initNewBuffer(tag); initNewBuffer(tag);
rewind(); rewind();
} }
void ClumpletWriter::initNewBuffer(UCHAR tag) void ClumpletWriter::initNewBuffer(UCHAR tag)
{ {
switch (kind) switch (kind)
@ -72,7 +72,7 @@ void ClumpletWriter::initNewBuffer(UCHAR tag)
} }
ClumpletWriter::ClumpletWriter(Kind k, size_t limit, const UCHAR* buffer, size_t buffLen, UCHAR tag) : ClumpletWriter::ClumpletWriter(Kind k, size_t limit, const UCHAR* buffer, size_t buffLen, UCHAR tag) :
ClumpletReader(k, NULL, 0), sizeLimit(limit), dynamic_buffer(getPool()) ClumpletReader(k, NULL, 0), sizeLimit(limit), dynamic_buffer(getPool())
{ {
if (buffer && buffLen) { if (buffer && buffLen) {
dynamic_buffer.push(buffer, buffLen); dynamic_buffer.push(buffer, buffLen);
@ -85,7 +85,7 @@ ClumpletWriter::ClumpletWriter(Kind k, size_t limit, const UCHAR* buffer, size_t
ClumpletWriter::ClumpletWriter(MemoryPool& given_pool, Kind k, size_t limit, ClumpletWriter::ClumpletWriter(MemoryPool& given_pool, Kind k, size_t limit,
const UCHAR* buffer, size_t buffLen, UCHAR tag) : const UCHAR* buffer, size_t buffLen, UCHAR tag) :
ClumpletReader(given_pool, k, NULL, 0), sizeLimit(limit), dynamic_buffer(getPool()) ClumpletReader(given_pool, k, NULL, 0), sizeLimit(limit), dynamic_buffer(getPool())
{ {
if (buffer && buffLen) { if (buffer && buffLen) {
dynamic_buffer.push(buffer, buffLen); dynamic_buffer.push(buffer, buffLen);
@ -203,7 +203,7 @@ void ClumpletWriter::insertBytesLengthCheck(UCHAR tag, const UCHAR* bytes, const
usage_mistake("write past EOF"); usage_mistake("write past EOF");
return; return;
} }
// Check length according to clumplet type // Check length according to clumplet type
const ClumpletType t = getClumpletType(tag); const ClumpletType t = getClumpletType(tag);
UCHAR lenSize = 0; UCHAR lenSize = 0;
@ -344,7 +344,7 @@ void ClumpletWriter::deleteClumplet()
if (buffer_end - clumplet < 2) { if (buffer_end - clumplet < 2) {
// It appears we're erasing EOF marker // It appears we're erasing EOF marker
dynamic_buffer.shrink(cur_offset); dynamic_buffer.shrink(cur_offset);
} }
else { else {
dynamic_buffer.removeCount(cur_offset, getClumpletSize(true, true, true)); dynamic_buffer.removeCount(cur_offset, getClumpletSize(true, true, true));
} }

View File

@ -25,7 +25,7 @@
* *
* *
*/ */
#include "firebird.h" #include "firebird.h"
#include <stdarg.h> #include <stdarg.h>
@ -49,7 +49,7 @@ namespace Firebird {
return *this; return *this;
} }
int MetaName::compare(const char* s, size_t l) const int MetaName::compare(const char* s, size_t l) const
{ {
if (s) if (s)
{ {
@ -83,7 +83,7 @@ namespace Firebird {
void MetaName::upper7() void MetaName::upper7()
{ {
for (char* p = data; *p; p++) for (char* p = data; *p; p++)
{ {
*p = UPPER7(*p); *p = UPPER7(*p);
} }
@ -91,7 +91,7 @@ namespace Firebird {
void MetaName::lower7() void MetaName::lower7()
{ {
for (char* p = data; *p; p++) for (char* p = data; *p; p++)
{ {
*p = LOWWER7(*p); *p = LOWWER7(*p);
} }

View File

@ -216,7 +216,7 @@ int MsgPrintHelper(BaseStream& out_stream, const safe_cell& item)
size_t n = strlen(s); size_t n = strlen(s);
if (n > MAX_STRING) if (n > MAX_STRING)
n = MAX_STRING; n = MAX_STRING;
return out_stream.write(s, n); return out_stream.write(s, n);
} }
case safe_cell::at_ptr: case safe_cell::at_ptr:
@ -293,7 +293,7 @@ int MsgPrint(const char* format, const SafeArg& arg)
int MsgPrint(const char* format) int MsgPrint(const char* format)
{ {
static const SafeArg dummy; static const SafeArg dummy;
StdioStream st(stdout); StdioStream st(stdout);
return MsgPrint(st, format, dummy); return MsgPrint(st, format, dummy);
} }

View File

@ -25,7 +25,7 @@
* *
*/ */
// Localized messages type-safe printing facility. // Localized messages type-safe printing facility.
#include "firebird.h" #include "firebird.h"
@ -311,10 +311,10 @@ void SafeArg::dump(const TEXT* target[], size_t v_size) const
const safe_cell& SafeArg::getCell(size_t index) const const safe_cell& SafeArg::getCell(size_t index) const
{ {
static safe_cell aux_cell = {safe_cell::at_none, {0}}; static safe_cell aux_cell = {safe_cell::at_none, {0}};
if (index < m_count) if (index < m_count)
return m_arguments[index]; return m_arguments[index];
return aux_cell; return aux_cell;
} }

View File

@ -52,7 +52,7 @@
// Const definitions // Const definitions
static const char* ENV_VAR = "FIREBIRD_TMP"; static const char* ENV_VAR = "FIREBIRD_TMP";
static const char* DEFAULT_PATH = static const char* DEFAULT_PATH =
#if defined(UNIX) #if defined(UNIX)
"/tmp/"; "/tmp/";
#elif defined(WIN_NT) #elif defined(WIN_NT)
@ -234,7 +234,7 @@ void TempFile::seek(const offset_t offset)
{ {
if (position == offset) if (position == offset)
return; return;
#if defined(WIN_NT) #if defined(WIN_NT)
LARGE_INTEGER liOffset; LARGE_INTEGER liOffset;
liOffset.QuadPart = offset; liOffset.QuadPart = offset;

View File

@ -53,7 +53,7 @@
#define FREE_PATTERN 0xDEADBEEF #define FREE_PATTERN 0xDEADBEEF
#define ALLOC_PATTERN 0xFEEDABED #define ALLOC_PATTERN 0xFEEDABED
#ifdef DEBUG_GDS_ALLOC #ifdef DEBUG_GDS_ALLOC
inline void PATTERN_FILL(void* ptr, size_t size, unsigned int pattern) inline void PATTERN_FILL(void* ptr, size_t size, unsigned int pattern)
{ {
for (size_t i = 0; i < size / sizeof(unsigned int); i++) for (size_t i = 0; i < size / sizeof(unsigned int); i++)
{ {
@ -90,13 +90,13 @@ inline static void mem_assert(bool value)
// Returns redirect list for given memory block // Returns redirect list for given memory block
inline MemoryRedirectList* block_list_small(MemoryBlock* block) inline MemoryRedirectList* block_list_small(MemoryBlock* block)
{ {
return (MemoryRedirectList*)((char*)block + MEM_ALIGN(sizeof(MemoryBlock)) + return (MemoryRedirectList*)((char*)block + MEM_ALIGN(sizeof(MemoryBlock)) +
block->mbk_small.mbk_length - MEM_ALIGN(sizeof(MemoryRedirectList))); block->mbk_small.mbk_length - MEM_ALIGN(sizeof(MemoryRedirectList)));
} }
inline MemoryRedirectList* block_list_large(MemoryBlock* block) inline MemoryRedirectList* block_list_large(MemoryBlock* block)
{ {
return (MemoryRedirectList*)((char*)block + MEM_ALIGN(sizeof(MemoryBlock)) + return (MemoryRedirectList*)((char*)block + MEM_ALIGN(sizeof(MemoryBlock)) +
block->mbk_large_length - MEM_ALIGN(sizeof(MemoryRedirectList))); block->mbk_large_length - MEM_ALIGN(sizeof(MemoryRedirectList)));
} }
@ -167,7 +167,7 @@ int dev_zero_fd = -1; /* Cached file descriptor for /dev/zero. */
#if defined(WIN_NT) || defined(HAVE_MMAP) #if defined(WIN_NT) || defined(HAVE_MMAP)
// Extents cache is not used when DEBUG_GDS_ALLOC or USE_VALGRIND is enabled. // Extents cache is not used when DEBUG_GDS_ALLOC or USE_VALGRIND is enabled.
// This slows down things a little due to frequent syscalls mapping/unmapping // This slows down things a little due to frequent syscalls mapping/unmapping
// memory but allows to detect more allocation errors // memory but allows to detect more allocation errors
Vector<void*, MAP_CACHE_SIZE> extents_cache; Vector<void*, MAP_CACHE_SIZE> extents_cache;
Mutex* cache_mutex; // Will be initialized manually in MemoryPool::init Mutex* cache_mutex; // Will be initialized manually in MemoryPool::init
@ -177,7 +177,7 @@ size_t map_page_size = 0;
inline size_t get_map_page_size() inline size_t get_map_page_size()
{ {
if (! map_page_size) if (! map_page_size)
{ {
map_page_size = get_page_size(); map_page_size = get_page_size();
} }
@ -258,7 +258,7 @@ MemoryPool* MemoryPool::setContextPool(MemoryPool* newPool)
TLS_SET(contextPool, newPool); TLS_SET(contextPool, newPool);
return old; return old;
} }
MemoryPool* MemoryPool::getContextPool() MemoryPool* MemoryPool::getContextPool()
{ {
return TLS_GET(contextPool); return TLS_GET(contextPool);
@ -269,7 +269,7 @@ MemoryStats* MemoryPool::default_stats_group = NULL;
MemoryPool* MemoryPool::processMemoryPool = NULL; MemoryPool* MemoryPool::processMemoryPool = NULL;
// Initialize process memory pool (called from InstanceControl). // Initialize process memory pool (called from InstanceControl).
// At this point also set contextMemoryPool for main thread // At this point also set contextMemoryPool for main thread
// (or all process in case of no threading). // (or all process in case of no threading).
void MemoryPool::init() void MemoryPool::init()
@ -311,7 +311,7 @@ void MemoryPool::setStatsGroup(MemoryStats& statsL)
// to be safe // to be safe
if (parent) if (parent)
parent->lock.enter(); parent->lock.enter();
lock.enter(); lock.enter();
const size_t sav_used_memory = used_memory.value(); const size_t sav_used_memory = used_memory.value();
const size_t sav_mapped_memory = mapped_memory; const size_t sav_mapped_memory = mapped_memory;
@ -319,18 +319,18 @@ void MemoryPool::setStatsGroup(MemoryStats& statsL)
decrement_usage(sav_used_memory); decrement_usage(sav_used_memory);
this->stats = &statsL; this->stats = &statsL;
increment_mapping(sav_mapped_memory); increment_mapping(sav_mapped_memory);
increment_usage(sav_used_memory); increment_usage(sav_used_memory);
lock.leave(); lock.leave();
if (parent) if (parent)
parent->lock.leave(); parent->lock.leave();
} }
MemoryPool::MemoryPool(MemoryPool* parentL, MemoryPool::MemoryPool(MemoryPool* parentL,
MemoryStats &statsL, void *first_extent, void *root_page MemoryStats &statsL, void *first_extent, void *root_page
) : ) :
parent_redirect(parentL != NULL), parent_redirect(parentL != NULL),
freeBlocks((InternalAllocator*)this, root_page), freeBlocks((InternalAllocator*)this, root_page),
extents((MemoryExtent *)first_extent), extents((MemoryExtent *)first_extent),
needSpare(false), needSpare(false),
pendingFree(NULL), pendingFree(NULL),
used_memory(0), used_memory(0),
@ -379,7 +379,7 @@ void MemoryPool::updateSpare()
// Blocks added with tree_deallocate may require merging with nearby ones // Blocks added with tree_deallocate may require merging with nearby ones
// This is why we do internal_deallocate // This is why we do internal_deallocate
internal_deallocate(temp); // Note that this method may change pendingFree! internal_deallocate(temp); // Note that this method may change pendingFree!
if (needSpare) if (needSpare)
break; // New pages were added to tree. Loop again break; // New pages were added to tree. Loop again
} }
@ -394,7 +394,7 @@ void* MemoryPool::external_alloc(size_t &size)
{ {
// This method is assumed to return NULL in case it cannot alloc // This method is assumed to return NULL in case it cannot alloc
size = FB_ALIGN(size, get_map_page_size()); size = FB_ALIGN(size, get_map_page_size());
void *result = mmap(NULL, size, PROT_READ | PROT_WRITE, void *result = mmap(NULL, size, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
// Let Valgrind forget that block was zero-initialized // Let Valgrind forget that block was zero-initialized
VALGRIND_DISCARD( VALGRIND_DISCARD(
@ -478,7 +478,7 @@ void* MemoryPool::external_alloc(size_t &size)
# endif # endif
# if defined WIN_NT # if defined WIN_NT
size = FB_ALIGN(size, get_map_page_size()); size = FB_ALIGN(size, get_map_page_size());
return VirtualAlloc(NULL, size, MEM_COMMIT, return VirtualAlloc(NULL, size, MEM_COMMIT,
PAGE_READWRITE); PAGE_READWRITE);
# elif defined (HAVE_MMAP) && !defined(SOLARIS) # elif defined (HAVE_MMAP) && !defined(SOLARIS)
@ -489,16 +489,16 @@ void* MemoryPool::external_alloc(size_t &size)
size = FB_ALIGN(size, get_map_page_size()); size = FB_ALIGN(size, get_map_page_size());
void* result = NULL; void* result = NULL;
# ifdef MAP_ANONYMOUS # ifdef MAP_ANONYMOUS
result = mmap(NULL, size, PROT_READ | PROT_WRITE, result = mmap(NULL, size, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
# else # else
// This code is needed for Solaris 2.6, AFAIK (only?) // This code is needed for Solaris 2.6, AFAIK (only?)
if (dev_zero_fd < 0) if (dev_zero_fd < 0)
dev_zero_fd = open("/dev/zero", O_RDWR); dev_zero_fd = open("/dev/zero", O_RDWR);
result = mmap(NULL, size, PROT_READ | PROT_WRITE, result = mmap(NULL, size, PROT_READ | PROT_WRITE,
MAP_PRIVATE, dev_zero_fd, 0); MAP_PRIVATE, dev_zero_fd, 0);
# endif //MAP_ANONYMOUS # endif //MAP_ANONYMOUS
return result == MAP_FAILED ? NULL : result; return result == MAP_FAILED ? NULL : result;
# elif defined(SOLARIS) # elif defined(SOLARIS)
// No successful return from mmap() will return the value MAP_FAILED. // No successful return from mmap() will return the value MAP_FAILED.
@ -510,33 +510,33 @@ void* MemoryPool::external_alloc(size_t &size)
void *result = NULL; void *result = NULL;
# ifdef MAP_ANONYMOUS # ifdef MAP_ANONYMOUS
result = mmap(0, size, PROT_READ | PROT_WRITE, result = mmap(0, size, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANON , -1, 0); MAP_PRIVATE | MAP_ANON , -1, 0);
if (result == MAP_FAILED) { if (result == MAP_FAILED) {
// failure happens! // failure happens!
return NULL; return NULL;
} }
else { else {
return result; return result;
} }
# else # else
// This code is needed for Solaris 2.6, AFAIK // This code is needed for Solaris 2.6, AFAIK
if (dev_zero_fd < 0) if (dev_zero_fd < 0)
dev_zero_fd = open("/dev/zero", O_RDWR); dev_zero_fd = open("/dev/zero", O_RDWR);
result = mmap(NULL, size, PROT_READ | PROT_WRITE, result = mmap(NULL, size, PROT_READ | PROT_WRITE,
MAP_PRIVATE, dev_zero_fd, 0); MAP_PRIVATE, dev_zero_fd, 0);
if (result == MAP_FAILED) { if (result == MAP_FAILED) {
return NULL; return NULL;
} }
else { else {
return result; return result;
} }
# endif //MAP_ANONYMOUS # endif //MAP_ANONYMOUS
# else # else
return malloc(size); return malloc(size);
# endif # endif
} }
void MemoryPool::external_free(void *blk, size_t &size, bool pool_destroying) void MemoryPool::external_free(void *blk, size_t &size, bool pool_destroying)
{ {
# if !defined(DEBUG_GDS_ALLOC) && (defined(WIN_NT) || defined(HAVE_MMAP)) # if !defined(DEBUG_GDS_ALLOC) && (defined(WIN_NT) || defined(HAVE_MMAP))
@ -558,7 +558,7 @@ void MemoryPool::external_free(void *blk, size_t &size, bool pool_destroying)
if (munmap((caddr_t) blk, size)) if (munmap((caddr_t) blk, size))
system_call_failed::raise("munmap"); system_call_failed::raise("munmap");
# else # else
if (munmap(blk, size)) if (munmap(blk, size))
system_call_failed::raise("munmap"); system_call_failed::raise("munmap");
# endif /*Solaris*/ # endif /*Solaris*/
@ -573,8 +573,8 @@ void* MemoryPool::tree_alloc(size_t size)
{ {
if (size == sizeof(FreeBlocksTree::ItemList)) if (size == sizeof(FreeBlocksTree::ItemList))
// This condition is to handle case when nodelist and itemlist have equal size // This condition is to handle case when nodelist and itemlist have equal size
if (sizeof(FreeBlocksTree::ItemList) != sizeof(FreeBlocksTree::NodeList) || if (sizeof(FreeBlocksTree::ItemList) != sizeof(FreeBlocksTree::NodeList) ||
spareLeafs.getCount()) spareLeafs.getCount())
{ {
if (!spareLeafs.getCount()) if (!spareLeafs.getCount())
Firebird::BadAlloc::raise(); Firebird::BadAlloc::raise();
@ -623,7 +623,7 @@ void* MemoryPool::allocate_nothrow(size_t size
if (parent_redirect) if (parent_redirect)
{ {
// We do not synchronize redirect_amount here. In the worst case we redirect slightly // We do not synchronize redirect_amount here. In the worst case we redirect slightly
// more allocations to parent than we wanted. This shouldn't cause problems // more allocations to parent than we wanted. This shouldn't cause problems
if (redirect_amount + size < REDIRECT_THRESHOLD) if (redirect_amount + size < REDIRECT_THRESHOLD)
{ {
@ -667,7 +667,7 @@ void* MemoryPool::allocate_nothrow(size_t size
{ // It may have changed while we were taking the lock { // It may have changed while we were taking the lock
parent_redirect = false; parent_redirect = false;
// Do some hard manual work to initialize first extent // Do some hard manual work to initialize first extent
// This is the exact initial layout of memory pool in the first extent // // This is the exact initial layout of memory pool in the first extent //
// MemoryExtent // MemoryExtent
// MemoryBlock // MemoryBlock
@ -726,7 +726,7 @@ void* MemoryPool::allocate_nothrow(size_t size
lock.enter(); lock.enter();
// If block cannot fit into extent then allocate it from OS directly // If block cannot fit into extent then allocate it from OS directly
if (size > EXTENT_SIZE - MEM_ALIGN(sizeof(MemoryBlock)) - MEM_ALIGN(sizeof(MemoryExtent))) { if (size > EXTENT_SIZE - MEM_ALIGN(sizeof(MemoryBlock)) - MEM_ALIGN(sizeof(MemoryExtent))) {
size_t ext_size = MEM_ALIGN(sizeof(MemoryBlock)) + size + size_t ext_size = MEM_ALIGN(sizeof(MemoryBlock)) + size +
MEM_ALIGN(sizeof(MemoryRedirectList)); MEM_ALIGN(sizeof(MemoryRedirectList));
MemoryBlock *blk = (MemoryBlock*) external_alloc(ext_size); MemoryBlock *blk = (MemoryBlock*) external_alloc(ext_size);
if (!blk) { if (!blk) {
@ -759,7 +759,7 @@ void* MemoryPool::allocate_nothrow(size_t size
//VALGRIND_MAKE_NOACCESS((char*)result - VALGRIND_REDZONE, VALGRIND_REDZONE); //VALGRIND_MAKE_NOACCESS((char*)result - VALGRIND_REDZONE, VALGRIND_REDZONE);
//VALGRIND_MAKE_WRITABLE(result, requested_size); //VALGRIND_MAKE_WRITABLE(result, requested_size);
//VALGRIND_MAKE_NOACCESS((char*)result + requested_size, VALGRIND_REDZONE); //VALGRIND_MAKE_NOACCESS((char*)result + requested_size, VALGRIND_REDZONE);
#endif #endif
return result; return result;
} }
// Otherwise use conventional allocator // Otherwise use conventional allocator
@ -780,7 +780,7 @@ void* MemoryPool::allocate_nothrow(size_t size
//VALGRIND_MAKE_NOACCESS((char*)result - VALGRIND_REDZONE, VALGRIND_REDZONE); //VALGRIND_MAKE_NOACCESS((char*)result - VALGRIND_REDZONE, VALGRIND_REDZONE);
//VALGRIND_MAKE_WRITABLE(result, requested_size); //VALGRIND_MAKE_WRITABLE(result, requested_size);
//VALGRIND_MAKE_NOACCESS((char*)result + requested_size, VALGRIND_REDZONE); //VALGRIND_MAKE_NOACCESS((char*)result + requested_size, VALGRIND_REDZONE);
#endif #endif
return result; return result;
} }
@ -802,22 +802,22 @@ void* MemoryPool::allocate(size_t size
bool MemoryPool::verify_pool(bool fast_checks_only) bool MemoryPool::verify_pool(bool fast_checks_only)
{ {
lock.enter(); lock.enter();
mem_assert(!pendingFree || needSpare); // needSpare flag should be set if we are in mem_assert(!pendingFree || needSpare); // needSpare flag should be set if we are in
// a critically low memory condition // a critically low memory condition
size_t blk_used_memory = 0; size_t blk_used_memory = 0;
size_t blk_mapped_memory = 0; size_t blk_mapped_memory = 0;
// Verify that free blocks tree is consistent and indeed contains free memory blocks // Verify that free blocks tree is consistent and indeed contains free memory blocks
if (freeBlocks.getFirst()) if (freeBlocks.getFirst())
do { do {
BlockInfo *current = &freeBlocks.current(); BlockInfo *current = &freeBlocks.current();
// Verify that head of free blocks list set correctly // Verify that head of free blocks list set correctly
mem_assert(current->bli_fragments); mem_assert(current->bli_fragments);
mem_assert(ptrToBlock(current->bli_fragments)->mbk_prev_fragment == NULL); mem_assert(ptrToBlock(current->bli_fragments)->mbk_prev_fragment == NULL);
// Look over all blocks in list checking that things look kosher // Look over all blocks in list checking that things look kosher
for (FreeMemoryBlock *fragment = current->bli_fragments; for (FreeMemoryBlock *fragment = current->bli_fragments;
fragment; fragment = fragment->fbk_next_fragment) fragment; fragment = fragment->fbk_next_fragment)
{ {
// Make sure that list is actually doubly linked // Make sure that list is actually doubly linked
@ -847,11 +847,11 @@ bool MemoryPool::verify_pool(bool fast_checks_only)
blk_mapped_memory += EXTENT_SIZE; blk_mapped_memory += EXTENT_SIZE;
USHORT prev_length = 0; USHORT prev_length = 0;
for (MemoryBlock *blk = (MemoryBlock *)((char*)extent + MEM_ALIGN(sizeof(MemoryExtent))); for (MemoryBlock *blk = (MemoryBlock *)((char*)extent + MEM_ALIGN(sizeof(MemoryExtent)));
; ;
blk = next_block(blk)) blk = next_block(blk))
{ {
// Verify block flags, large blocks are not allowed here // Verify block flags, large blocks are not allowed here
mem_assert(!(blk->mbk_flags & mem_assert(!(blk->mbk_flags &
~(MBK_USED | MBK_LAST | MBK_PARENT | MBK_DELAYED))); ~(MBK_USED | MBK_LAST | MBK_PARENT | MBK_DELAYED)));
// Check that if block is marked as delayed free it is still accounted as used // Check that if block is marked as delayed free it is still accounted as used
@ -866,8 +866,8 @@ bool MemoryPool::verify_pool(bool fast_checks_only)
} }
// Calculate memory usage // Calculate memory usage
if ((blk->mbk_flags & MBK_USED) && !(blk->mbk_flags & MBK_PARENT) && if ((blk->mbk_flags & MBK_USED) && !(blk->mbk_flags & MBK_PARENT) &&
!(blk->mbk_flags & MBK_DELAYED) && (blk->mbk_type >= 0)) !(blk->mbk_flags & MBK_DELAYED) && (blk->mbk_type >= 0))
{ {
blk_used_memory += blk->mbk_small.mbk_length; blk_used_memory += blk->mbk_small.mbk_length;
} }
@ -897,7 +897,7 @@ bool MemoryPool::verify_pool(bool fast_checks_only)
mem_assert(foundPending || ptrToBlock(freeBlocks.current().bli_fragments) == blk); mem_assert(foundPending || ptrToBlock(freeBlocks.current().bli_fragments) == blk);
} }
// See if next fragment seems kosher // See if next fragment seems kosher
// (note that FreeMemoryBlock has the same structure as PendingFreeBlock so we can do this check) // (note that FreeMemoryBlock has the same structure as PendingFreeBlock so we can do this check)
FreeMemoryBlock *next_fragment = blockToPtr<FreeMemoryBlock*>(blk)->fbk_next_fragment; FreeMemoryBlock *next_fragment = blockToPtr<FreeMemoryBlock*>(blk)->fbk_next_fragment;
if (next_fragment) { if (next_fragment) {
@ -909,9 +909,9 @@ bool MemoryPool::verify_pool(bool fast_checks_only)
} }
if (fast_checks_only) { if (fast_checks_only) {
foundTree = !(blk->mbk_flags & MBK_USED) && foundTree = !(blk->mbk_flags & MBK_USED) &&
(blk->mbk_prev_fragment || ptrToBlock(freeBlocks.current().bli_fragments) == blk); (blk->mbk_prev_fragment || ptrToBlock(freeBlocks.current().bli_fragments) == blk);
} }
else { else {
for (FreeMemoryBlock* freeBlk = freeBlocks.current().bli_fragments; freeBlk; freeBlk = freeBlk->fbk_next_fragment) for (FreeMemoryBlock* freeBlk = freeBlocks.current().bli_fragments; freeBlk; freeBlk = freeBlk->fbk_next_fragment)
{ {
@ -1009,7 +1009,7 @@ bool MemoryPool::verify_pool(bool fast_checks_only)
else { else {
mem_assert(blk_used_memory == (size_t) used_memory.value()); mem_assert(blk_used_memory == (size_t) used_memory.value());
} }
return true; return true;
} }
@ -1017,8 +1017,8 @@ static void print_block(FILE *file, MemoryBlock *blk, bool used_only,
const char* filter_path, const size_t filter_len) const char* filter_path, const size_t filter_len)
{ {
void *mem = blockToPtr<void*>(blk); void *mem = blockToPtr<void*>(blk);
if (((blk->mbk_flags & MBK_USED) && if (((blk->mbk_flags & MBK_USED) &&
!(blk->mbk_flags & MBK_DELAYED) && blk->mbk_type >= 0) || !used_only) !(blk->mbk_flags & MBK_DELAYED) && blk->mbk_type >= 0) || !used_only)
{ {
char flags[100]; char flags[100];
flags[0] = 0; flags[0] = 0;
@ -1068,7 +1068,7 @@ void MemoryPool::print_contents(FILE *file, bool used_only,
const char* filter_path) const char* filter_path)
{ {
lock.enter(); lock.enter();
fprintf(file, "********* Printing contents of pool %p used=%ld mapped=%ld:\n", fprintf(file, "********* Printing contents of pool %p used=%ld mapped=%ld:\n",
this, (long)used_memory.value(), (long)mapped_memory); this, (long)used_memory.value(), (long)mapped_memory);
const size_t filter_len = filter_path ? strlen(filter_path) : 0; const size_t filter_len = filter_path ? strlen(filter_path) : 0;
@ -1077,7 +1077,7 @@ void MemoryPool::print_contents(FILE *file, bool used_only,
if (!used_only) if (!used_only)
fprintf(file, "EXTENT %p:\n", extent); fprintf(file, "EXTENT %p:\n", extent);
for (MemoryBlock *blk = (MemoryBlock *)((char*)extent + MEM_ALIGN(sizeof(MemoryExtent))); for (MemoryBlock *blk = (MemoryBlock *)((char*)extent + MEM_ALIGN(sizeof(MemoryExtent)));
; ;
blk = next_block(blk)) blk = next_block(blk))
{ {
print_block(file, blk, used_only, filter_path, filter_len); print_block(file, blk, used_only, filter_path, filter_len);
@ -1103,12 +1103,12 @@ void MemoryPool::print_contents(FILE *file, bool used_only,
fprintf(file, "********* End of output for pool %p.\n", this); fprintf(file, "********* End of output for pool %p.\n", this);
} }
MemoryPool* MemoryPool::createPool(MemoryPool* parent, MemoryStats &stats) MemoryPool* MemoryPool::createPool(MemoryPool* parent, MemoryStats &stats)
{ {
MemoryPool *pool; MemoryPool *pool;
#ifndef USE_VALGRIND #ifndef USE_VALGRIND
// If pool has a parent things are simplified. // If pool has a parent things are simplified.
// Note we do not use parent redirection when using Valgrind because it is // Note we do not use parent redirection when using Valgrind because it is
// difficult to make memory pass through any delayed free list in this case // difficult to make memory pass through any delayed free list in this case
if (parent) { if (parent) {
parent->lock.enter(); parent->lock.enter();
@ -1130,7 +1130,7 @@ MemoryPool* MemoryPool::createPool(MemoryPool* parent, MemoryStats &stats)
pool->parent_redirected = blk; pool->parent_redirected = blk;
parent->lock.leave(); parent->lock.leave();
} }
else else
#endif #endif
{ {
@ -1157,11 +1157,11 @@ MemoryPool* MemoryPool::createPool(MemoryPool* parent, MemoryStats &stats)
pool = new(mem + pool = new(mem +
MEM_ALIGN(sizeof(MemoryExtent)) + MEM_ALIGN(sizeof(MemoryExtent)) +
MEM_ALIGN(sizeof(MemoryBlock))) MEM_ALIGN(sizeof(MemoryBlock)))
MemoryPool(NULL, stats, mem, mem + MemoryPool(NULL, stats, mem, mem +
MEM_ALIGN(sizeof(MemoryExtent)) + MEM_ALIGN(sizeof(MemoryExtent)) +
MEM_ALIGN(sizeof(MemoryBlock)) + MEM_ALIGN(sizeof(MemoryBlock)) +
MEM_ALIGN(sizeof(MemoryPool)) + MEM_ALIGN(sizeof(MemoryPool)) +
MEM_ALIGN(sizeof(MemoryBlock))); MEM_ALIGN(sizeof(MemoryBlock)));
pool->increment_mapping(EXTENT_SIZE); pool->increment_mapping(EXTENT_SIZE);
@ -1257,13 +1257,13 @@ void MemoryPool::deletePool(MemoryPool* pool)
MemoryExtent *next = extent->mxt_next; MemoryExtent *next = extent->mxt_next;
size_t ext_size = EXTENT_SIZE; size_t ext_size = EXTENT_SIZE;
external_free(extent, ext_size, true); external_free(extent, ext_size, true);
fb_assert(ext_size == EXTENT_SIZE); // Make sure exent size is a multiply of page size fb_assert(ext_size == EXTENT_SIZE); // Make sure exent size is a multiply of page size
extent = next; extent = next;
} }
// Deallocate blocks redirected to parent // Deallocate blocks redirected to parent
// IF parent is set then pool was allocated from it and is not deleted at this point yet // IF parent is set then pool was allocated from it and is not deleted at this point yet
if (parent) { if (parent) {
parent->lock.enter(); parent->lock.enter();
MemoryBlock *redirected = pool->parent_redirected; MemoryBlock *redirected = pool->parent_redirected;
while (redirected) { while (redirected) {
@ -1276,10 +1276,10 @@ void MemoryPool::deletePool(MemoryPool* pool)
// Remove protection from red zones of memory block or block as whole if it is // Remove protection from red zones of memory block or block as whole if it is
// in delayed free queue. Since this code makes pointers to deallocated memory // in delayed free queue. Since this code makes pointers to deallocated memory
// immediately valid we disable parent redirection in USE_VALGRIND mode. Code is // immediately valid we disable parent redirection in USE_VALGRIND mode. Code is
// here for case if you want to debug something with parent redirection enabled. // here for case if you want to debug something with parent redirection enabled.
VALGRIND_DISCARD( VALGRIND_DISCARD(
VALGRIND_MAKE_WRITABLE((char*)redirected + MEM_ALIGN(sizeof(MemoryBlock)) - VALGRIND_REDZONE, VALGRIND_MAKE_WRITABLE((char*)redirected + MEM_ALIGN(sizeof(MemoryBlock)) - VALGRIND_REDZONE,
(redirected->mbk_flags & MBK_LARGE ? redirected->mbk_large_length: redirected->mbk_small.mbk_length) - (redirected->mbk_flags & MBK_LARGE ? redirected->mbk_large_length: redirected->mbk_small.mbk_length) -
(redirected->mbk_flags & (MBK_LARGE | MBK_PARENT) ? MEM_ALIGN(sizeof(MemoryRedirectList)) : 0) + (redirected->mbk_flags & (MBK_LARGE | MBK_PARENT) ? MEM_ALIGN(sizeof(MemoryRedirectList)) : 0) +
VALGRIND_REDZONE) VALGRIND_REDZONE)
@ -1352,20 +1352,20 @@ void* MemoryPool::internal_alloc(size_t size, SSHORT type
FreeMemoryBlock *next_free = current->bli_fragments->fbk_next_fragment; FreeMemoryBlock *next_free = current->bli_fragments->fbk_next_fragment;
if (next_free) { if (next_free) {
// Moderately cheap case. Quite possibly we only need to tweak doubly // Moderately cheap case. Quite possibly we only need to tweak doubly
// linked lists a little // linked lists a little
ptrToBlock(next_free)->mbk_prev_fragment = NULL; ptrToBlock(next_free)->mbk_prev_fragment = NULL;
current->bli_fragments = next_free; current->bli_fragments = next_free;
addFreeBlock(current_block); addFreeBlock(current_block);
} }
else { else {
// This is special handling of case when we have single large fragment and // This is special handling of case when we have single large fragment and
// cut off small pieces from it. This is common and we avoid modification // cut off small pieces from it. This is common and we avoid modification
// of free blocks tree in this case. // of free blocks tree in this case.
bool get_prev_succeeded = freeBlocks.getPrev(); bool get_prev_succeeded = freeBlocks.getPrev();
if (!get_prev_succeeded || freeBlocks.current().bli_length < current_block->mbk_small.mbk_length) { if (!get_prev_succeeded || freeBlocks.current().bli_length < current_block->mbk_small.mbk_length) {
current->bli_length = current_block->mbk_small.mbk_length; current->bli_length = current_block->mbk_small.mbk_length;
} }
else { else {
// Moderately expensive case. We need to modify tree for sure // Moderately expensive case. We need to modify tree for sure
if (get_prev_succeeded) { if (get_prev_succeeded) {
@ -1406,7 +1406,7 @@ void* MemoryPool::internal_alloc(size_t size, SSHORT type
if (prev) if (prev)
prev->next = itr->next; prev->next = itr->next;
else else
pendingFree = itr->next; pendingFree = itr->next;
PATTERN_FILL(itr, size, ALLOC_PATTERN); PATTERN_FILL(itr, size, ALLOC_PATTERN);
return itr; return itr;
@ -1460,8 +1460,8 @@ void* MemoryPool::internal_alloc(size_t size, SSHORT type
blk->mbk_line = line; blk->mbk_line = line;
#endif #endif
blk->mbk_small.mbk_prev_length = 0; blk->mbk_small.mbk_prev_length = 0;
if (EXTENT_SIZE - size - MEM_ALIGN(sizeof(MemoryExtent)) - MEM_ALIGN(sizeof(MemoryBlock)) if (EXTENT_SIZE - size - MEM_ALIGN(sizeof(MemoryExtent)) - MEM_ALIGN(sizeof(MemoryBlock))
< MEM_ALIGN(sizeof(MemoryBlock)) + ALLOC_ALIGNMENT) < MEM_ALIGN(sizeof(MemoryBlock)) + ALLOC_ALIGNMENT)
{ {
// Block is small enough to be returned AS IS // Block is small enough to be returned AS IS
blk->mbk_flags |= MBK_LAST; blk->mbk_flags |= MBK_LAST;
@ -1475,7 +1475,7 @@ void* MemoryPool::internal_alloc(size_t size, SSHORT type
// Will be initialized (to NULL) by addFreeBlock code // Will be initialized (to NULL) by addFreeBlock code
// rest->mbk_pool = this; // rest->mbk_pool = this;
rest->mbk_flags = MBK_LAST; rest->mbk_flags = MBK_LAST;
rest->mbk_small.mbk_length = EXTENT_SIZE - MEM_ALIGN(sizeof(MemoryExtent)) - rest->mbk_small.mbk_length = EXTENT_SIZE - MEM_ALIGN(sizeof(MemoryExtent)) -
MEM_ALIGN(sizeof(MemoryBlock)) - size - MEM_ALIGN(sizeof(MemoryBlock)); MEM_ALIGN(sizeof(MemoryBlock)) - size - MEM_ALIGN(sizeof(MemoryBlock));
rest->mbk_small.mbk_prev_length = blk->mbk_small.mbk_length; rest->mbk_small.mbk_prev_length = blk->mbk_small.mbk_length;
addFreeBlock(rest); addFreeBlock(rest);
@ -1516,10 +1516,10 @@ inline void MemoryPool::addFreeBlock(MemoryBlock *blk)
// NOTE! Items placed into pendingFree queue have mbk_prev_fragment equal to ZERO. // NOTE! Items placed into pendingFree queue have mbk_prev_fragment equal to ZERO.
} }
} }
void MemoryPool::removeFreeBlock(MemoryBlock *blk) void MemoryPool::removeFreeBlock(MemoryBlock *blk)
{ {
// NOTE! We signal items placed into pendingFree queue via setting their // NOTE! We signal items placed into pendingFree queue via setting their
// mbk_prev_fragment to ZERO. // mbk_prev_fragment to ZERO.
FreeMemoryBlock *fragmentToRemove = blockToPtr<FreeMemoryBlock*>(blk); FreeMemoryBlock *fragmentToRemove = blockToPtr<FreeMemoryBlock*>(blk);
@ -1527,7 +1527,7 @@ void MemoryPool::removeFreeBlock(MemoryBlock *blk)
FreeMemoryBlock *next = fragmentToRemove->fbk_next_fragment; FreeMemoryBlock *next = fragmentToRemove->fbk_next_fragment;
if (prev) { if (prev) {
// Cheapest case. There is no need to touch B+ tree at all. // Cheapest case. There is no need to touch B+ tree at all.
// Simply remove item from a middle or end of doubly linked list // Simply remove item from a middle or end of doubly linked list
prev->fbk_next_fragment = next; prev->fbk_next_fragment = next;
if (next) if (next)
ptrToBlock(next)->mbk_prev_fragment = prev; ptrToBlock(next)->mbk_prev_fragment = prev;
@ -1536,8 +1536,8 @@ void MemoryPool::removeFreeBlock(MemoryBlock *blk)
// Need to locate item in tree // Need to locate item in tree
BlockInfo* current; BlockInfo* current;
if (freeBlocks.locate(blk->mbk_small.mbk_length) && if (freeBlocks.locate(blk->mbk_small.mbk_length) &&
(current = &freeBlocks.current())->bli_fragments == fragmentToRemove) (current = &freeBlocks.current())->bli_fragments == fragmentToRemove)
{ {
if (next) { if (next) {
// Still moderately fast case. All we need is to replace the head of fragments list // Still moderately fast case. All we need is to replace the head of fragments list
@ -1550,10 +1550,10 @@ void MemoryPool::removeFreeBlock(MemoryBlock *blk)
} }
} }
else { else {
// Our block could be in the pending free blocks list if we are in a // Our block could be in the pending free blocks list if we are in a
// critically-low memory condition or if tree_free placed it there. // critically-low memory condition or if tree_free placed it there.
// Find and remove it from there. // Find and remove it from there.
PendingFreeBlock *itr = pendingFree, PendingFreeBlock *itr = pendingFree,
*temp = blockToPtr<PendingFreeBlock*>(blk); *temp = blockToPtr<PendingFreeBlock*>(blk);
if (itr == temp) if (itr == temp)
pendingFree = itr->next; pendingFree = itr->next;
@ -1584,12 +1584,12 @@ void MemoryPool::free_blk_extent(MemoryBlock *blk)
if (extent->mxt_next) if (extent->mxt_next)
extent->mxt_next->mxt_prev = extent->mxt_prev; extent->mxt_next->mxt_prev = extent->mxt_prev;
fb_assert(blk->mbk_small.mbk_length + MEM_ALIGN(sizeof(MemoryBlock)) + fb_assert(blk->mbk_small.mbk_length + MEM_ALIGN(sizeof(MemoryBlock)) +
MEM_ALIGN(sizeof(MemoryExtent)) == EXTENT_SIZE); MEM_ALIGN(sizeof(MemoryExtent)) == EXTENT_SIZE);
size_t ext_size = EXTENT_SIZE; size_t ext_size = EXTENT_SIZE;
external_free(extent, ext_size, false); external_free(extent, ext_size, false);
fb_assert(ext_size == EXTENT_SIZE); // Make sure exent size is a multiply of page size fb_assert(ext_size == EXTENT_SIZE); // Make sure exent size is a multiply of page size
decrement_mapping(EXTENT_SIZE); decrement_mapping(EXTENT_SIZE);
} }
@ -1598,11 +1598,11 @@ void MemoryPool::internal_deallocate(void *block)
MemoryBlock *blk = ptrToBlock(block); MemoryBlock *blk = ptrToBlock(block);
// This method is normally called for used blocks from our pool. Also it may // This method is normally called for used blocks from our pool. Also it may
// be called for free blocks in pendingFree list by updateSpare routine. // be called for free blocks in pendingFree list by updateSpare routine.
// Such blocks must have mbk_prev_fragment equal to NULL. // Such blocks must have mbk_prev_fragment equal to NULL.
fb_assert( fb_assert(
blk->mbk_flags & MBK_USED ? blk->mbk_flags & MBK_USED ?
blk->mbk_pool == this : blk->mbk_pool == this :
blk->mbk_prev_fragment == NULL); blk->mbk_prev_fragment == NULL);
@ -1643,8 +1643,8 @@ void MemoryPool::internal_deallocate(void *block)
// Mark block as free // Mark block as free
blk->mbk_flags &= ~MBK_USED; blk->mbk_flags &= ~MBK_USED;
// Try to merge block with next free block // Try to merge block with next free block
if (!(blk->mbk_flags & MBK_LAST) && if (!(blk->mbk_flags & MBK_LAST) &&
!((next = next_block(blk))->mbk_flags & MBK_USED)) !((next = next_block(blk))->mbk_flags & MBK_USED))
{ {
removeFreeBlock(next); removeFreeBlock(next);
blk->mbk_small.mbk_length += next->mbk_small.mbk_length + MEM_ALIGN(sizeof(MemoryBlock)); blk->mbk_small.mbk_length += next->mbk_small.mbk_length + MEM_ALIGN(sizeof(MemoryBlock));
@ -1694,12 +1694,12 @@ void MemoryPool::deallocate(void *block)
VALGRIND_MEMPOOL_FREE(this, block); VALGRIND_MEMPOOL_FREE(this, block);
// Make it read and write protected // Make it read and write protected
int handle = int handle =
VALGRIND_MAKE_NOACCESS((char*)block - VALGRIND_REDZONE, VALGRIND_MAKE_NOACCESS((char*)block - VALGRIND_REDZONE,
(blk->mbk_flags & MBK_LARGE ? blk->mbk_large_length: blk->mbk_small.mbk_length) - (blk->mbk_flags & MBK_LARGE ? blk->mbk_large_length: blk->mbk_small.mbk_length) -
(blk->mbk_flags & (MBK_LARGE | MBK_PARENT) ? MEM_ALIGN(sizeof(MemoryRedirectList)) : 0) + (blk->mbk_flags & (MBK_LARGE | MBK_PARENT) ? MEM_ALIGN(sizeof(MemoryRedirectList)) : 0) +
VALGRIND_REDZONE); VALGRIND_REDZONE);
// Extend circular buffer if possible // Extend circular buffer if possible
if (delayedFreeCount < FB_NELEM(delayedFree)) { if (delayedFreeCount < FB_NELEM(delayedFree)) {
delayedFree[delayedFreeCount] = block; delayedFree[delayedFreeCount] = block;
@ -1723,7 +1723,7 @@ void MemoryPool::deallocate(void *block)
// Remove protection from memory block // Remove protection from memory block
VALGRIND_DISCARD( VALGRIND_DISCARD(
VALGRIND_MAKE_WRITABLE((char*)block - VALGRIND_REDZONE, VALGRIND_MAKE_WRITABLE((char*)block - VALGRIND_REDZONE,
(blk->mbk_flags & MBK_LARGE ? blk->mbk_large_length: blk->mbk_small.mbk_length) - (blk->mbk_flags & MBK_LARGE ? blk->mbk_large_length: blk->mbk_small.mbk_length) -
(blk->mbk_flags & (MBK_LARGE | MBK_PARENT) ? MEM_ALIGN(sizeof(MemoryRedirectList)) : 0) + (blk->mbk_flags & (MBK_LARGE | MBK_PARENT) ? MEM_ALIGN(sizeof(MemoryRedirectList)) : 0) +
VALGRIND_REDZONE) VALGRIND_REDZONE)
@ -1804,7 +1804,7 @@ void MemoryPool::deallocate(void *block)
} }
MemoryPool& AutoStorage::getAutoMemoryPool() MemoryPool& AutoStorage::getAutoMemoryPool()
{ {
#ifndef SUPERCLIENT #ifndef SUPERCLIENT
MemoryPool* p = MemoryPool::getContextPool(); MemoryPool* p = MemoryPool::getContextPool();
if (! p) if (! p)
@ -1815,15 +1815,15 @@ MemoryPool& AutoStorage::getAutoMemoryPool()
MemoryPool* p = getDefaultMemoryPool(); MemoryPool* p = getDefaultMemoryPool();
#endif //SUPERCLIENT #endif //SUPERCLIENT
fb_assert(p); fb_assert(p);
return *p; return *p;
} }
#if defined(DEV_BUILD) #if defined(DEV_BUILD)
void AutoStorage::ProbeStack() const void AutoStorage::ProbeStack() const
{ {
// //
// AutoStorage() default constructor can be used only // AutoStorage() default constructor can be used only
// for objects on the stack. ProbeStack() uses the // for objects on the stack. ProbeStack() uses the
// following assumptions to check it: // following assumptions to check it:
// 1. One and only one stack is used for all kind of variables. // 1. One and only one stack is used for all kind of variables.
// 2. Objects don't grow > 64K. // 2. Objects don't grow > 64K.

View File

@ -22,7 +22,7 @@
* *
* All Rights Reserved. * All Rights Reserved.
* Contributor(s): ______________________________________. * Contributor(s): ______________________________________.
* *
* *
*/ */
@ -43,7 +43,7 @@ const int TEST_ITEMS = 5000000;
void report(int scaleNode, int scaleTree) { void report(int scaleNode, int scaleTree) {
clock_t d = clock(); clock_t d = clock();
printf("Add+remove %d elements from tree of scale %d/%d took %d milliseconds. \n", printf("Add+remove %d elements from tree of scale %d/%d took %d milliseconds. \n",
TEST_ITEMS, scaleNode, scaleTree, (int)(d-t)*1000/CLOCKS_PER_SEC); TEST_ITEMS, scaleNode, scaleTree, (int)(d-t)*1000/CLOCKS_PER_SEC);
} }
@ -61,9 +61,9 @@ static void testTree() {
} }
printf(" DONE\n"); printf(" DONE\n");
MallocAllocator temp; MallocAllocator temp;
start(); start();
BePlusTree<int, int, MallocAllocator, DefaultKeyValue<int>, BePlusTree<int, int, MallocAllocator, DefaultKeyValue<int>,
DefaultComparator<int>, 30, 30> tree30(NULL); DefaultComparator<int>, 30, 30> tree30(NULL);
for (i=0; i<TEST_ITEMS;i++) for (i=0; i<TEST_ITEMS;i++)
tree30.add((*v)[i]); tree30.add((*v)[i]);
@ -74,7 +74,7 @@ static void testTree() {
report(30, 30); report(30, 30);
start(); start();
BePlusTree<int, int, MallocAllocator, DefaultKeyValue<int>, BePlusTree<int, int, MallocAllocator, DefaultKeyValue<int>,
DefaultComparator<int>, 50, 50> tree50(NULL); DefaultComparator<int>, 50, 50> tree50(NULL);
for (i=0; i<TEST_ITEMS;i++) for (i=0; i<TEST_ITEMS;i++)
tree50.add((*v)[i]); tree50.add((*v)[i]);
@ -83,9 +83,9 @@ static void testTree() {
tree50.fastRemove(); tree50.fastRemove();
} }
report(50, 50); report(50, 50);
start(); start();
BePlusTree<int, int, MallocAllocator, DefaultKeyValue<int>, BePlusTree<int, int, MallocAllocator, DefaultKeyValue<int>,
DefaultComparator<int>, 75, 75> tree75(NULL); DefaultComparator<int>, 75, 75> tree75(NULL);
for (i=0; i<TEST_ITEMS;i++) for (i=0; i<TEST_ITEMS;i++)
tree75.add((*v)[i]); tree75.add((*v)[i]);
@ -94,9 +94,9 @@ static void testTree() {
tree75.fastRemove(); tree75.fastRemove();
} }
report(75, 75); report(75, 75);
start(); start();
BePlusTree<int, int, MallocAllocator, DefaultKeyValue<int>, BePlusTree<int, int, MallocAllocator, DefaultKeyValue<int>,
DefaultComparator<int>, 100, 100> tree100(NULL); DefaultComparator<int>, 100, 100> tree100(NULL);
for (i=0; i<TEST_ITEMS;i++) for (i=0; i<TEST_ITEMS;i++)
tree100.add((*v)[i]); tree100.add((*v)[i]);
@ -107,7 +107,7 @@ static void testTree() {
report(100, 100); report(100, 100);
start(); start();
BePlusTree<int, int, MallocAllocator, DefaultKeyValue<int>, BePlusTree<int, int, MallocAllocator, DefaultKeyValue<int>,
DefaultComparator<int>, 100, 250> tree100_250(NULL); DefaultComparator<int>, 100, 250> tree100_250(NULL);
for (i=0; i<TEST_ITEMS;i++) for (i=0; i<TEST_ITEMS;i++)
tree100_250.add((*v)[i]); tree100_250.add((*v)[i]);
@ -116,9 +116,9 @@ static void testTree() {
tree100_250.fastRemove(); tree100_250.fastRemove();
} }
report(100, 250); report(100, 250);
start(); start();
BePlusTree<int, int, MallocAllocator, DefaultKeyValue<int>, BePlusTree<int, int, MallocAllocator, DefaultKeyValue<int>,
DefaultComparator<int>, 200, 200> tree200(NULL); DefaultComparator<int>, 200, 200> tree200(NULL);
for (i=0; i<TEST_ITEMS;i++) for (i=0; i<TEST_ITEMS;i++)
tree200.add((*v)[i]); tree200.add((*v)[i]);
@ -127,7 +127,7 @@ static void testTree() {
tree200.fastRemove(); tree200.fastRemove();
} }
report(250, 250); report(250, 250);
std::set<int> stlTree; std::set<int> stlTree;
start(); start();
for (i=0; i<TEST_ITEMS;i++) for (i=0; i<TEST_ITEMS;i++)
@ -135,7 +135,7 @@ static void testTree() {
for (i=0; i<TEST_ITEMS;i++) for (i=0; i<TEST_ITEMS;i++)
stlTree.erase((*v)[i]); stlTree.erase((*v)[i]);
clock_t d = clock(); clock_t d = clock();
printf("Just a reference: add+remove %d elements from STL tree took %d milliseconds. \n", printf("Just a reference: add+remove %d elements from STL tree took %d milliseconds. \n",
TEST_ITEMS, (int)(d-t)*1000/CLOCKS_PER_SEC); TEST_ITEMS, (int)(d-t)*1000/CLOCKS_PER_SEC);
} }
@ -177,7 +177,7 @@ static void testAllocatorOverhead() {
if (items.getFirst()) do { if (items.getFirst()) do {
items.current(); items.current();
n++; n++;
} while (n < ALLOC_ITEMS / 2 && items.getNext()); } while (n < ALLOC_ITEMS / 2 && items.getNext());
// Allocate big items // Allocate big items
for (i=0;i<BIG_ITEMS;i++) { for (i=0;i<BIG_ITEMS;i++) {
n = n * 47163 - 57412; n = n * 47163 - 57412;
@ -194,16 +194,16 @@ static void testAllocatorOverhead() {
} while (bigItems.getNext()); } while (bigItems.getNext());
report(); report();
} }
static void testAllocatorMemoryPool() { static void testAllocatorMemoryPool() {
printf("Test run for Firebird::MemoryPool...\n"); printf("Test run for Firebird::MemoryPool...\n");
start(); start();
Firebird::MemoryPool* pool = Firebird::MemoryPool::createPool(); Firebird::MemoryPool* pool = Firebird::MemoryPool::createPool();
MallocAllocator allocator; MallocAllocator allocator;
BePlusTree<AllocItem, AllocItem, MallocAllocator, DefaultKeyValue<AllocItem>, AllocItem> items(&allocator), BePlusTree<AllocItem, AllocItem, MallocAllocator, DefaultKeyValue<AllocItem>, AllocItem> items(&allocator),
bigItems(&allocator); bigItems(&allocator);
// Allocate small items // Allocate small items
int i, n = 0; int i, n = 0;
for (i=0;i<ALLOC_ITEMS;i++) { for (i=0;i<ALLOC_ITEMS;i++) {
n = n * 47163 - 57412; n = n * 47163 - 57412;
AllocItem temp = {n, pool->allocate((n % MAX_ITEM_SIZE + MAX_ITEM_SIZE) / 2 + 1)}; AllocItem temp = {n, pool->allocate((n % MAX_ITEM_SIZE + MAX_ITEM_SIZE) / 2 + 1)};
@ -214,7 +214,7 @@ static void testAllocatorMemoryPool() {
if (items.getFirst()) do { if (items.getFirst()) do {
pool->deallocate(items.current().item); pool->deallocate(items.current().item);
n++; n++;
} while (n < ALLOC_ITEMS / 2 && items.getNext()); } while (n < ALLOC_ITEMS / 2 && items.getNext());
// Allocate big items // Allocate big items
for (i=0;i<BIG_ITEMS;i++) { for (i=0;i<BIG_ITEMS;i++) {
n = n * 47163 - 57412; n = n * 47163 - 57412;
@ -251,7 +251,7 @@ static void testAllocatorMalloc() {
if (items.getFirst()) do { if (items.getFirst()) do {
free(items.current().item); free(items.current().item);
n++; n++;
} while (n < ALLOC_ITEMS / 2 && items.getNext()); } while (n < ALLOC_ITEMS / 2 && items.getNext());
// Allocate big items // Allocate big items
for (i=0;i<BIG_ITEMS;i++) { for (i=0;i<BIG_ITEMS;i++) {
n = n * 47163 - 57412; n = n * 47163 - 57412;
@ -289,7 +289,7 @@ static void testAllocatorMalloc() {
if (items.getFirst()) do { if (items.getFirst()) do {
pool->deallocate(items.current().item); pool->deallocate(items.current().item);
n++; n++;
} while (n < ALLOC_ITEMS / 2 && items.getNext()); } while (n < ALLOC_ITEMS / 2 && items.getNext());
// Allocate big items // Allocate big items
for (i=0;i<BIG_ITEMS;i++) { for (i=0;i<BIG_ITEMS;i++) {
n = n * 47163 - 57412; n = n * 47163 - 57412;

View File

@ -22,7 +22,7 @@
* *
* All Rights Reserved. * All Rights Reserved.
* Contributor(s): ______________________________________. * Contributor(s): ______________________________________.
* *
* *
* *
*/ */
@ -111,16 +111,16 @@ void testBitmap() {
printf(" DONE\n"); printf(" DONE\n");
printf("Verify CLEAR(V) operation for correctness"); printf("Verify CLEAR(V) operation for correctness");
for (i = 0; i < BITMAP_ITEMS; i++) { for (i = 0; i < BITMAP_ITEMS; i++) {
if (tree.locate(v1[i])) { if (tree.locate(v1[i])) {
bool result = bitmap.clear(v1[i]); bool result = bitmap.clear(v1[i]);
tree.fastRemove(); tree.fastRemove();
fb_assert(result == true); fb_assert(result == true);
} }
else { else {
bool result = bitmap.clear(v1[i]); bool result = bitmap.clear(v1[i]);
fb_assert(result == false); fb_assert(result == false);
} }
} }
printf(" DONE\n"); printf(" DONE\n");
@ -143,7 +143,7 @@ void testBitmap() {
else else
if (!tree2.getNext()) break; if (!tree2.getNext()) break;
} }
SparseBitmap<ULONG> *and_res = SparseBitmap<ULONG>::bit_and(&bitmap, &bitmap2); SparseBitmap<ULONG> *and_res = SparseBitmap<ULONG>::bit_and(&bitmap, &bitmap2);
bool has1 = tree2.getFirst(), has2 = and_res->getFirst(); bool has1 = tree2.getFirst(), has2 = and_res->getFirst();
@ -154,9 +154,9 @@ void testBitmap() {
has2 = and_res->getNext(); has2 = and_res->getNext();
fb_assert(has1 == has2); fb_assert(has1 == has2);
fb_assert((ULONG)tree2.current() == and_res->current()); fb_assert((ULONG)tree2.current() == and_res->current());
} }
printf(" DONE\n"); printf(" DONE\n");
printf("Verify OR operation for correctness (and backwards iterator)"); printf("Verify OR operation for correctness (and backwards iterator)");
tree.clear(); tree.clear();
@ -199,7 +199,7 @@ struct Test {
void testBePlusTree() { void testBePlusTree() {
MallocAllocator temp; MallocAllocator temp;
printf("Test Firebird::BePlusTree\n"); printf("Test Firebird::BePlusTree\n");
printf("Fill array with test data (%d items)...", (int)TEST_ITEMS); printf("Fill array with test data (%d items)...", (int)TEST_ITEMS);
Vector<int, TEST_ITEMS> v; Vector<int, TEST_ITEMS> v;
int n = 0; int n = 0;
@ -210,11 +210,11 @@ void testBePlusTree() {
v.add(((i + n) % TEST_ITEMS + TEST_ITEMS) / 2); v.add(((i + n) % TEST_ITEMS + TEST_ITEMS) / 2);
} }
printf(" DONE\n"); printf(" DONE\n");
printf("Create two trees one with factor 2 and one with factor 13 and fill them with test data: "); printf("Create two trees one with factor 2 and one with factor 13 and fill them with test data: ");
BePlusTree<Test, int, MallocAllocator, Test, BePlusTree<Test, int, MallocAllocator, Test,
DefaultComparator<int>, 2, 2> tree1(&temp); DefaultComparator<int>, 2, 2> tree1(&temp);
BePlusTree<Test, int, MallocAllocator, Test, BePlusTree<Test, int, MallocAllocator, Test,
DefaultComparator<int>, 13, 13> tree2(&temp); DefaultComparator<int>, 13, 13> tree2(&temp);
int cnt1 = 0, cnt2 = 0; int cnt1 = 0, cnt2 = 0;
for (i = 0; i < v.getCount(); i++) { for (i = 0; i < v.getCount(); i++) {
@ -237,10 +237,10 @@ void testBePlusTree() {
if (!tree2.add(t)) if (!tree2.add(t))
fb_assert(false); fb_assert(false);
cnt2++; cnt2++;
} }
} }
printf(" DONE\n"); printf(" DONE\n");
bool passed = true; bool passed = true;
printf("Empty trees verifying fastRemove() result: "); printf("Empty trees verifying fastRemove() result: ");
@ -277,7 +277,7 @@ void testBePlusTree() {
passed = false; passed = false;
printf(passed ? "PASSED\n" : "FAILED\n"); printf(passed ? "PASSED\n" : "FAILED\n");
passed = true; passed = true;
printf("Fill trees with data again: "); printf("Fill trees with data again: ");
cnt1 = 0; cnt2 = 0; cnt1 = 0; cnt2 = 0;
for (i = 0; i < v.getCount(); i++) { for (i = 0; i < v.getCount(); i++) {
@ -300,10 +300,10 @@ void testBePlusTree() {
if (!tree2.add(t)) if (!tree2.add(t))
fb_assert(false); fb_assert(false);
cnt2++; cnt2++;
} }
} }
printf(" DONE\n"); printf(" DONE\n");
printf("Check that tree(2) contains test data: "); printf("Check that tree(2) contains test data: ");
for (i = 0; i < v.getCount(); i++) { for (i = 0; i < v.getCount(); i++) {
if (!tree1.locate(locEqual, v[i])) if (!tree1.locate(locEqual, v[i]))
@ -311,27 +311,27 @@ void testBePlusTree() {
} }
printf(passed ? "PASSED\n" : "FAILED\n"); printf(passed ? "PASSED\n" : "FAILED\n");
passed = true; passed = true;
printf("Check that tree(13) contains test data: "); printf("Check that tree(13) contains test data: ");
for (i = 0; i < v.getCount(); i++) { for (i = 0; i < v.getCount(); i++) {
if (!tree2.locate(locEqual, v[i])) if (!tree2.locate(locEqual, v[i]))
passed = false; passed = false;
} }
printf(passed ? "PASSED\n" : "FAILED\n"); printf(passed ? "PASSED\n" : "FAILED\n");
passed = true; passed = true;
printf("Check that tree(2) contains data from the tree(13) and its count is correct: "); printf("Check that tree(2) contains data from the tree(13) and its count is correct: ");
n = 0; n = 0;
if (tree1.getFirst()) do { if (tree1.getFirst()) do {
n++; n++;
if (!tree2.locate(locEqual, tree1.current().value)) if (!tree2.locate(locEqual, tree1.current().value))
passed = false; passed = false;
} while (tree1.getNext()); } while (tree1.getNext());
if (n != cnt1 || cnt1 != cnt2) if (n != cnt1 || cnt1 != cnt2)
passed = false; passed = false;
printf(passed ? "PASSED\n" : "FAILED\n"); printf(passed ? "PASSED\n" : "FAILED\n");
printf("Check that tree(13) contains data from the tree(2) "\ printf("Check that tree(13) contains data from the tree(2) "\
"and its count is correct (check in reverse order): "); "and its count is correct (check in reverse order): ");
n = 0; n = 0;
@ -343,13 +343,13 @@ void testBePlusTree() {
if (n != cnt2) if (n != cnt2)
passed = false; passed = false;
printf(passed ? "PASSED\n" : "FAILED\n"); printf(passed ? "PASSED\n" : "FAILED\n");
printf("Remove half of data from the trees: "); printf("Remove half of data from the trees: ");
passed = true; passed = true;
while (v.getCount() > TEST_ITEMS / 2) { while (v.getCount() > TEST_ITEMS / 2) {
if (!tree1.locate(locEqual, v[v.getCount() - 1])) if (!tree1.locate(locEqual, v[v.getCount() - 1]))
fb_assert(false); fb_assert(false);
if (tree1.current().count > 1) if (tree1.current().count > 1)
tree1.current().count--; tree1.current().count--;
else { else {
int nextValue = -1; int nextValue = -1;
@ -360,7 +360,7 @@ void testBePlusTree() {
if (tree1.fastRemove()) { if (tree1.fastRemove()) {
if (tree1.current().value != nextValue) if (tree1.current().value != nextValue)
passed = false; passed = false;
} }
else { else {
if (nextValue >= 0) if (nextValue >= 0)
passed = false; passed = false;
@ -369,7 +369,7 @@ void testBePlusTree() {
} }
if (!tree2.locate(locEqual, v[v.getCount() - 1])) if (!tree2.locate(locEqual, v[v.getCount() - 1]))
fb_assert(false); fb_assert(false);
if (tree2.current().count > 1) if (tree2.current().count > 1)
tree2.current().count--; tree2.current().count--;
else { else {
int nextValue = -1; int nextValue = -1;
@ -380,7 +380,7 @@ void testBePlusTree() {
if (tree2.fastRemove()) { if (tree2.fastRemove()) {
if (tree2.current().value != nextValue) if (tree2.current().value != nextValue)
passed = false; passed = false;
} }
else { else {
if (nextValue >= 0) if (nextValue >= 0)
passed = false; passed = false;
@ -390,26 +390,26 @@ void testBePlusTree() {
v.shrink(v.getCount() - 1); v.shrink(v.getCount() - 1);
} }
printf(passed ? "PASSED\n" : "FAILED\n"); printf(passed ? "PASSED\n" : "FAILED\n");
passed = true; passed = true;
printf("Check that tree(2) contains test data: "); printf("Check that tree(2) contains test data: ");
for (i = 0; i < v.getCount(); i++) { for (i = 0; i < v.getCount(); i++) {
if (!tree1.locate(locEqual, v[i])) if (!tree1.locate(locEqual, v[i]))
passed = false; passed = false;
} }
printf(passed ? "PASSED\n" : "FAILED\n"); printf(passed ? "PASSED\n" : "FAILED\n");
passed = true; passed = true;
printf("Check that tree(13) contains test data: "); printf("Check that tree(13) contains test data: ");
for (i = 0; i < v.getCount(); i++) { for (i = 0; i < v.getCount(); i++) {
if (!tree2.locate(locEqual, v[i])) if (!tree2.locate(locEqual, v[i]))
passed = false; passed = false;
} }
printf(passed ? "PASSED\n" : "FAILED\n"); printf(passed ? "PASSED\n" : "FAILED\n");
passed = true; passed = true;
printf("Check that tree(2) contains data from the tree(13) and its count is correct: "); printf("Check that tree(2) contains data from the tree(13) and its count is correct: ");
n = 0; n = 0;
if (tree1.getFirst()) do { if (tree1.getFirst()) do {
@ -417,12 +417,12 @@ void testBePlusTree() {
if (!tree2.locate(locEqual, tree1.current().value)) if (!tree2.locate(locEqual, tree1.current().value))
passed = false; passed = false;
} while (tree1.getNext()); } while (tree1.getNext());
if (n != cnt1 || cnt1 != cnt2) if (n != cnt1 || cnt1 != cnt2)
passed = false; passed = false;
printf(passed ? "PASSED\n" : "FAILED\n"); printf(passed ? "PASSED\n" : "FAILED\n");
passed = true; passed = true;
printf("Check that tree(13) contains data from the tree(2) "\ printf("Check that tree(13) contains data from the tree(2) "\
"and its count is correct (check in reverse order): "); "and its count is correct (check in reverse order): ");
n = 0; n = 0;
@ -431,17 +431,17 @@ void testBePlusTree() {
if (!tree1.locate(locEqual, tree2.current().value)) if (!tree1.locate(locEqual, tree2.current().value))
passed = false; passed = false;
} while (tree2.getPrev()); } while (tree2.getPrev());
if (n != cnt2) if (n != cnt2)
passed = false; passed = false;
printf(passed ? "PASSED\n" : "FAILED\n"); printf(passed ? "PASSED\n" : "FAILED\n");
passed = true; passed = true;
printf("Remove the rest of data from the trees: "); printf("Remove the rest of data from the trees: ");
for (i = 0;i < v.getCount(); i++) { for (i = 0;i < v.getCount(); i++) {
if (!tree1.locate(locEqual, v[i])) if (!tree1.locate(locEqual, v[i]))
fb_assert(false); fb_assert(false);
if (tree1.current().count > 1) if (tree1.current().count > 1)
tree1.current().count--; tree1.current().count--;
else { else {
int nextValue = -1; int nextValue = -1;
@ -452,7 +452,7 @@ void testBePlusTree() {
if (tree1.fastRemove()) { if (tree1.fastRemove()) {
if (tree1.current().value != nextValue) if (tree1.current().value != nextValue)
passed = false; passed = false;
} }
else { else {
if (nextValue >= 0) if (nextValue >= 0)
passed = false; passed = false;
@ -472,7 +472,7 @@ void testBePlusTree() {
if (tree2.fastRemove()) { if (tree2.fastRemove()) {
if (tree2.current().value != nextValue) if (tree2.current().value != nextValue)
passed = false; passed = false;
} }
else { else {
if (nextValue >= 0) if (nextValue >= 0)
passed = false; passed = false;
@ -515,11 +515,11 @@ void testAllocator() {
printf("Test Firebird::MemoryPool\n"); printf("Test Firebird::MemoryPool\n");
MemoryPool* parent = getDefaultMemoryPool(); MemoryPool* parent = getDefaultMemoryPool();
MemoryPool* pool = MemoryPool::createPool(parent); MemoryPool* pool = MemoryPool::createPool(parent);
MallocAllocator allocator; MallocAllocator allocator;
BePlusTree<AllocItem, AllocItem, MallocAllocator, DefaultKeyValue<AllocItem>, AllocItem> items(&allocator), BePlusTree<AllocItem, AllocItem, MallocAllocator, DefaultKeyValue<AllocItem>, AllocItem> items(&allocator),
bigItems(&allocator); bigItems(&allocator);
Vector<void*, LARGE_ITEMS> la; Vector<void*, LARGE_ITEMS> la;
printf("Allocate %d large items: ", LARGE_ITEMS); printf("Allocate %d large items: ", LARGE_ITEMS);
int i; int i;
@ -529,7 +529,7 @@ void testAllocator() {
} }
VERIFY_POOL(pool); VERIFY_POOL(pool);
printf(" DONE\n"); printf(" DONE\n");
printf("Allocate %d items: ", ALLOC_ITEMS); printf("Allocate %d items: ", ALLOC_ITEMS);
int n = 0; int n = 0;
VERIFY_POOL(pool); VERIFY_POOL(pool);
@ -542,7 +542,7 @@ void testAllocator() {
printf(" DONE\n"); printf(" DONE\n");
VERIFY_POOL(pool); VERIFY_POOL(pool);
VERIFY_POOL(parent); VERIFY_POOL(parent);
printf("Deallocate half of items in quasi-random order: "); printf("Deallocate half of items in quasi-random order: ");
n = 0; n = 0;
if (items.getFirst()) do { if (items.getFirst()) do {
@ -552,7 +552,7 @@ void testAllocator() {
printf(" DONE\n"); printf(" DONE\n");
VERIFY_POOL(pool); VERIFY_POOL(pool);
VERIFY_POOL(parent); VERIFY_POOL(parent);
printf("Allocate %d big items: ", BIG_ITEMS); printf("Allocate %d big items: ", BIG_ITEMS);
n = 0; n = 0;
VERIFY_POOL(pool); VERIFY_POOL(pool);
@ -565,7 +565,7 @@ void testAllocator() {
printf(" DONE\n"); printf(" DONE\n");
VERIFY_POOL(pool); VERIFY_POOL(pool);
VERIFY_POOL(parent); VERIFY_POOL(parent);
printf("Deallocate the rest of small items in quasi-random order: "); printf("Deallocate the rest of small items in quasi-random order: ");
while (items.getNext()) { while (items.getNext()) {
pool->deallocate(items.current().item); pool->deallocate(items.current().item);
@ -573,26 +573,26 @@ void testAllocator() {
printf(" DONE\n"); printf(" DONE\n");
VERIFY_POOL(pool); VERIFY_POOL(pool);
VERIFY_POOL(parent); VERIFY_POOL(parent);
printf("Deallocate big items in quasi-random order: "); printf("Deallocate big items in quasi-random order: ");
if (bigItems.getFirst()) do { if (bigItems.getFirst()) do {
pool->deallocate(bigItems.current().item); pool->deallocate(bigItems.current().item);
} while (bigItems.getNext()); } while (bigItems.getNext());
printf(" DONE\n"); printf(" DONE\n");
printf("Deallocate %d large items: ", LARGE_ITEMS/2); printf("Deallocate %d large items: ", LARGE_ITEMS/2);
for (i = 0; i<LARGE_ITEMS/2; i++) for (i = 0; i<LARGE_ITEMS/2; i++)
pool->deallocate(la[i]); pool->deallocate(la[i]);
VERIFY_POOL(pool); VERIFY_POOL(pool);
printf(" DONE\n"); printf(" DONE\n");
// pool->verify_pool(); // pool->verify_pool();
// parent->verify_pool(); // parent->verify_pool();
pool->print_contents(stdout, false); pool->print_contents(stdout, false);
parent->print_contents(stdout, false); parent->print_contents(stdout, false);
MemoryPool::deletePool(pool); MemoryPool::deletePool(pool);
// parent->verify_pool(); // parent->verify_pool();
// TODO: // TODO:
// Test critically low memory conditions // Test critically low memory conditions
// Test that tree correctly recovers in low-memory conditions // Test that tree correctly recovers in low-memory conditions

View File

@ -2,7 +2,7 @@
* PROGRAM: string class definition * PROGRAM: string class definition
* MODULE: fb_string.cpp * MODULE: fb_string.cpp
* DESCRIPTION: Provides almost that same functionality, * DESCRIPTION: Provides almost that same functionality,
* that STL::basic_string<char> does, * that STL::basic_string<char> does,
* but behaves MemoryPools friendly. * but behaves MemoryPools friendly.
* *
* The contents of this file are subject to the Initial * The contents of this file are subject to the Initial
@ -115,7 +115,7 @@ namespace Firebird {
initialize(sizeL); initialize(sizeL);
memset(stringBuffer, c, sizeL); memset(stringBuffer, c, sizeL);
} }
void AbstractString::adjustRange(const size_type length, size_type& pos, size_type& n) void AbstractString::adjustRange(const size_type length, size_type& pos, size_type& n)
{ {
if (pos == npos) { if (pos == npos) {
@ -153,7 +153,7 @@ namespace Firebird {
return baseAppend(n); return baseAppend(n);
} }
reserveBuffer(stringLength + n); reserveBuffer(stringLength + n);
memmove(stringBuffer + p0 + n, stringBuffer + p0, memmove(stringBuffer + p0 + n, stringBuffer + p0,
stringLength - p0 + 1); // Do not forget to move null terminator too stringLength - p0 + 1); // Do not forget to move null terminator too
stringLength += n; stringLength += n;
return stringBuffer + p0; return stringBuffer + p0;
@ -162,7 +162,7 @@ namespace Firebird {
void AbstractString::baseErase(size_type p0, size_type n) void AbstractString::baseErase(size_type p0, size_type n)
{ {
adjustRange(length(), p0, n); adjustRange(length(), p0, n);
memmove(stringBuffer + p0, memmove(stringBuffer + p0,
stringBuffer + p0 + n, stringLength - (p0 + n) + 1); stringBuffer + p0 + n, stringLength - (p0 + n) + 1);
stringLength -= n; stringLength -= n;
shrinkBuffer(); shrinkBuffer();
@ -295,7 +295,7 @@ namespace Firebird {
baseErase(0, length()); baseErase(0, length());
if (! file) if (! file)
return false; return false;
bool rc = false; bool rc = false;
int c; int c;
while ((c = getc(file)) != EOF) { while ((c = getc(file)) != EOF) {
@ -423,7 +423,7 @@ extern "C" {
} }
} }
resize(l); resize(l);
return; return;
} }
temp[tempsize - 1] = 0; temp[tempsize - 1] = 0;
if (l < tempsize) { if (l < tempsize) {

View File

@ -1,7 +1,7 @@
/* /*
* PROGRAM: Client/Server Common Code * PROGRAM: Client/Server Common Code
* MODULE: locks.cpp * MODULE: locks.cpp
* DESCRIPTION: Win32 Mutex support compatible with * DESCRIPTION: Win32 Mutex support compatible with
* old OS versions (like Windows 95) * old OS versions (like Windows 95)
* *
* The contents of this file are subject to the Initial * The contents of this file are subject to the Initial
@ -46,7 +46,7 @@ TryEnterCS::TryEnterCS()
{ {
HMODULE kernel32 = GetModuleHandle("kernel32.dll"); HMODULE kernel32 = GetModuleHandle("kernel32.dll");
if (kernel32) { if (kernel32) {
m_funct = (tTryEnterCriticalSection*) m_funct = (tTryEnterCriticalSection*)
GetProcAddress(kernel32, "TryEnterCriticalSection"); GetProcAddress(kernel32, "TryEnterCriticalSection");
} }
} }
@ -68,7 +68,7 @@ void Spinlock::init()
SetCriticalSectionSpinCount = MISS_SPIN_COUNT; SetCriticalSectionSpinCount = MISS_SPIN_COUNT;
return; return;
} }
SetCriticalSectionSpinCount = SetCriticalSectionSpinCount =
(tSetCriticalSectionSpinCount *) GetProcAddress( (tSetCriticalSectionSpinCount *) GetProcAddress(
kernel32, "SetCriticalSectionSpinCount"); kernel32, "SetCriticalSectionSpinCount");
if (!SetCriticalSectionSpinCount) { if (!SetCriticalSectionSpinCount) {

View File

@ -33,7 +33,7 @@
/* /*
There is a problem with values returned by sem_open() in MacOS 10.5 and earlier. There is a problem with values returned by sem_open() in MacOS 10.5 and earlier.
They are not pointers. They are handles, in format of file handle (0,1,2,3,...), They are not pointers. They are handles, in format of file handle (0,1,2,3,...),
and worse - they share same space with actual file handles. And when we close and worse - they share same space with actual file handles. And when we close
unneeded file handles in divorce_terminal(), we kill all global semaphores. unneeded file handles in divorce_terminal(), we kill all global semaphores.
MIXED_SEMAPHORE_AND_FILE_HANDLE exists to avoid it. MIXED_SEMAPHORE_AND_FILE_HANDLE exists to avoid it.
*/ */

View File

@ -2,7 +2,7 @@ char lbl[] = "0123456789";
//#define CHECK_FATAL_RANGE_EXCEPTION //#define CHECK_FATAL_RANGE_EXCEPTION
//Don't modify 3 lines upper from this - they are used in file read test //Don't modify 3 lines upper from this - they are used in file read test
//If you plan to check range exception, you may uncomment it - //If you plan to check range exception, you may uncomment it -
//anyway file test should not happen //anyway file test should not happen
/* /*
@ -184,7 +184,7 @@ void test(void) {
} }
{ {
string a, b, c; string a, b, c;
a = "uuu"; a = "uuu";
b = lbl; b = lbl;
c = a + b; c = a + b;
@ -254,19 +254,19 @@ void test(void) {
{ {
string a, b; string a, b;
b = lbl; b = lbl;
a.assign(3, 'u'); a.assign(3, 'u');
validate(a, "uuu"); validate(a, "uuu");
a.assign(lbl); a.assign(lbl);
validate(a, lbl); validate(a, lbl);
a.assign(lbl, 2); a.assign(lbl, 2);
validate(a, "01"); validate(a, "01");
a.assign(b, 3, 3); a.assign(b, 3, 3);
validate(a, "345"); validate(a, "345");
a.assign(b); a.assign(b);
validate(a, lbl); validate(a, lbl);
@ -287,15 +287,15 @@ void test(void) {
a = lbl; a = lbl;
a.insert(3, lbl); a.insert(3, lbl);
validate(a, "01201234567893456789"); validate(a, "01201234567893456789");
a = lbl; a = lbl;
a.insert(4, lbl, 2); a.insert(4, lbl, 2);
validate(a, "012301456789"); validate(a, "012301456789");
a = lbl; a = lbl;
a.insert(5, b, 3, 3); a.insert(5, b, 3, 3);
validate(a, "0123434556789"); validate(a, "0123434556789");
a = lbl; a = lbl;
a.insert(5, b); a.insert(5, b);
validate(a, "01234012345678956789"); validate(a, "01234012345678956789");
@ -313,8 +313,8 @@ void test(void) {
a = lbl; a = lbl;
x = a.begin(); x = a.begin();
x += 2; x += 2;
string::iterator f = b.begin(); string::iterator f = b.begin();
string::iterator t = b.end(); string::iterator t = b.end();
f++; t--; f++; t--;
a.insert(x, f, t); a.insert(x, f, t);
validate(a, "011234567823456789"); validate(a, "011234567823456789");
@ -368,27 +368,27 @@ void test(void) {
a = lbl; a = lbl;
a.replace(3, 3, lbl); a.replace(3, 3, lbl);
validate(a, "01201234567896789"); validate(a, "01201234567896789");
a = lbl; a = lbl;
f0 = a.begin() + 3; f0 = a.begin() + 3;
t0 = f0 + 3; t0 = f0 + 3;
a.replace(f0, t0, lbl); a.replace(f0, t0, lbl);
validate(a, "01201234567896789"); validate(a, "01201234567896789");
a = lbl; a = lbl;
a.replace(4, 4, lbl, 2); a.replace(4, 4, lbl, 2);
validate(a, "01230189"); validate(a, "01230189");
a = lbl; a = lbl;
f0 = a.begin() + 4; f0 = a.begin() + 4;
t0 = f0 + 4; t0 = f0 + 4;
a.replace(f0, t0, lbl, 2); a.replace(f0, t0, lbl, 2);
validate(a, "01230189"); validate(a, "01230189");
a = lbl; a = lbl;
a.replace(5, 10, b, 3, 3); a.replace(5, 10, b, 3, 3);
validate(a, "01234345"); validate(a, "01234345");
a = lbl; a = lbl;
f0 = a.begin() + 5; f0 = a.begin() + 5;
t0 = f0 + 10; t0 = f0 + 10;
@ -396,7 +396,7 @@ void test(void) {
t = f + 3; t = f + 3;
a.replace(f0, t0, f, t); a.replace(f0, t0, f, t);
validate(a, "01234345"); validate(a, "01234345");
a = lbl; a = lbl;
a.replace(5, 0, b); a.replace(5, 0, b);
validate(a, "01234012345678956789"); validate(a, "01234012345678956789");
@ -406,7 +406,7 @@ void test(void) {
t0 = f0; t0 = f0;
a.replace(f0, t0, b); a.replace(f0, t0, b);
validate(a, "01234012345678956789"); validate(a, "01234012345678956789");
a = lbl; a = lbl;
a.replace(2, 1, "Something reaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaally long"); a.replace(2, 1, "Something reaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaally long");
validate(a, "01Something reaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaally long3456789"); validate(a, "01Something reaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaally long3456789");
@ -428,7 +428,7 @@ void test(void) {
// a.swap(b); // a.swap(b);
// validate(b, "3456789"); // validate(b, "3456789");
// validate(a, lbl); // validate(a, lbl);
} }
#ifdef DEV_BUILD #ifdef DEV_BUILD
@ -441,7 +441,7 @@ void test(void) {
string a = "012345uuu345678"; string a = "012345uuu345678";
// 9 // 9
string b = "345"; string b = "345";
check(a.find(b), 3); check(a.find(b), 3);
check(a.find("45"), 4); check(a.find("45"), 4);
check(a.find('5'), 5); check(a.find('5'), 5);
@ -561,7 +561,7 @@ void test(void) {
check(c.compare(d), 1); check(c.compare(d), 1);
check(c.compare(e), 1); check(c.compare(e), 1);
check(a.compare(1, 10, b), 1); check(a.compare(1, 10, b), 1);
check(a.compare(1, 10, b, 1, 10), 0); check(a.compare(1, 10, b, 1, 10), 0);
check(a.compare(lbl), 0); check(a.compare(lbl), 0);
@ -570,7 +570,7 @@ void test(void) {
#ifdef FULL_FIRE #ifdef FULL_FIRE
{ {
string a = " 011100 ", b; string a = " 011100 ", b;
b = a; b = a;
b.ltrim(); b.ltrim();
validate(b, "011100 "); validate(b, "011100 ");
@ -631,7 +631,7 @@ void start() {
void report() { void report() {
clock_t d = clock(); clock_t d = clock();
printf("Test of %d iterations with %s took %d milliseconds.\n", printf("Test of %d iterations with %s took %d milliseconds.\n",
TEST_ITEMS, NAME, (int)(d-t)*1000/CLOCKS_PER_SEC); TEST_ITEMS, NAME, (int)(d-t)*1000/CLOCKS_PER_SEC);
} }

View File

@ -53,7 +53,7 @@ TimeStamp TimeStamp::getCurrentTimeStamp()
// NS: We round generated timestamps to whole millisecond. // NS: We round generated timestamps to whole millisecond.
// Not many applications can deal with fractional milliseconds properly and // Not many applications can deal with fractional milliseconds properly and
// we do not use high resolution timers either so actual time granularity // we do not use high resolution timers either so actual time granularity
// is going to to be somewhere in range between 1 ms (like on UNIX/Risc) // is going to to be somewhere in range between 1 ms (like on UNIX/Risc)
// and 53 ms (such as Win9X) // and 53 ms (such as Win9X)
time_t seconds; // UTC time time_t seconds; // UTC time
@ -71,7 +71,7 @@ TimeStamp TimeStamp::getCurrentTimeStamp()
milliseconds = time_buffer.millitm; milliseconds = time_buffer.millitm;
#endif #endif
// NS: Current FB behavior of using server time zone is not appropriate for // NS: Current FB behavior of using server time zone is not appropriate for
// distributed applications. We should be storing UTC times everywhere and // distributed applications. We should be storing UTC times everywhere and
// convert timestamps to client timezone as necessary. Replace localtime stuff // convert timestamps to client timezone as necessary. Replace localtime stuff
// with these lines as soon as the appropriate functionality is implemented // with these lines as soon as the appropriate functionality is implemented
@ -255,12 +255,12 @@ void TimeStamp::round_time(ISC_TIME &ntime, const int precision)
{ {
const int scale = -ISC_TIME_SECONDS_PRECISION_SCALE - precision; const int scale = -ISC_TIME_SECONDS_PRECISION_SCALE - precision;
// for the moment, if greater precision was requested than we can // for the moment, if greater precision was requested than we can
// provide return what we have. // provide return what we have.
if (scale <= 0) if (scale <= 0)
return; return;
static const ISC_TIME pow10table[] = static const ISC_TIME pow10table[] =
{1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000}; {1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000};
fb_assert(scale < FB_NELEM(pow10table)); fb_assert(scale < FB_NELEM(pow10table));

View File

@ -135,7 +135,7 @@ static Firebird::InitInstance<ConfigImpl> sysConfig;
* Implementation interface * Implementation interface
*/ */
ConfigImpl::ConfigImpl(MemoryPool& p) : ConfigRoot(p) ConfigImpl::ConfigImpl(MemoryPool& p) : ConfigRoot(p)
{ {
/* Prepare some stuff */ /* Prepare some stuff */
@ -244,7 +244,7 @@ static Firebird::PathName* rootFromCommandLine = 0;
void Config::setRootDirectoryFromCommandLine(const Firebird::PathName& newRoot) void Config::setRootDirectoryFromCommandLine(const Firebird::PathName& newRoot)
{ {
delete rootFromCommandLine; delete rootFromCommandLine;
rootFromCommandLine = FB_NEW(*getDefaultMemoryPool()) rootFromCommandLine = FB_NEW(*getDefaultMemoryPool())
Firebird::PathName(*getDefaultMemoryPool(), newRoot); Firebird::PathName(*getDefaultMemoryPool(), newRoot);
} }

View File

@ -179,7 +179,7 @@ string ConfigFile::parseValueFrom(string inputLine, string::size_type initialPos
{ {
return inputLine.substr(startPos + 1, inputLine.length() - startPos - 2); return inputLine.substr(startPos + 1, inputLine.length() - startPos - 2);
} }
return inputLine.substr(startPos); return inputLine.substr(startPos);
} }

View File

@ -28,7 +28,7 @@
namespace Firebird { namespace Firebird {
void ParsedPath::parse(const PathName& path) void ParsedPath::parse(const PathName& path)
{ {
clear(); clear();
@ -46,7 +46,7 @@ void ParsedPath::parse(const PathName& path)
} while (oldpath.length() > 0); } while (oldpath.length() > 0);
} }
PathName ParsedPath::subPath(size_t n) const PathName ParsedPath::subPath(size_t n) const
{ {
PathName rc = (*this)[0]; PathName rc = (*this)[0];
if (PathUtils::isRelative(rc + PathUtils::dir_sep)) if (PathUtils::isRelative(rc + PathUtils::dir_sep))
@ -59,14 +59,14 @@ PathName ParsedPath::subPath(size_t n) const
return rc; return rc;
} }
ParsedPath::operator PathName() const ParsedPath::operator PathName() const
{ {
if (!getCount()) if (!getCount())
return ""; return "";
return subPath(getCount()); return subPath(getCount());
} }
bool ParsedPath::contains(const ParsedPath& pPath) const bool ParsedPath::contains(const ParsedPath& pPath) const
{ {
size_t nFullElem = getCount(); size_t nFullElem = getCount();
if (nFullElem > 1 && (*this)[nFullElem - 1].length() == 0) if (nFullElem > 1 && (*this)[nFullElem - 1].length() == 0)
@ -75,7 +75,7 @@ bool ParsedPath::contains(const ParsedPath& pPath) const
if (pPath.getCount() < nFullElem) { if (pPath.getCount() < nFullElem) {
return false; return false;
} }
size_t i; size_t i;
for (i = 0; i < nFullElem; i++) { for (i = 0; i < nFullElem; i++) {
if (pPath[i] != (*this)[i]) { if (pPath[i] != (*this)[i]) {
@ -92,10 +92,10 @@ bool ParsedPath::contains(const ParsedPath& pPath) const
} }
bool DirectoryList::keyword( bool DirectoryList::keyword(
const ListMode keyMode, const ListMode keyMode,
PathName& value, PathName& value,
PathName key, PathName key,
PathName next) PathName next)
{ {
if (value.length() < key.length()) { if (value.length() < key.length()) {
return false; return false;
@ -128,7 +128,7 @@ bool DirectoryList::keyword(
return true; return true;
} }
void DirectoryList::initialize(bool simple_mode) void DirectoryList::initialize(bool simple_mode)
{ {
if (mode != NotInitialized) if (mode != NotInitialized)
return; return;
@ -141,7 +141,7 @@ void DirectoryList::initialize(bool simple_mode)
mode = SimpleList; mode = SimpleList;
} }
else { else {
if (keyword(None, val, "None", "") || if (keyword(None, val, "None", "") ||
keyword(Full, val, "Full", "")) { keyword(Full, val, "Full", "")) {
return; return;
} }
@ -185,7 +185,7 @@ void DirectoryList::initialize(bool simple_mode)
add(ParsedPath(dir)); add(ParsedPath(dir));
} }
bool DirectoryList::isPathInList(const PathName& path) const bool DirectoryList::isPathInList(const PathName& path) const
{ {
#ifdef BOOT_BUILD #ifdef BOOT_BUILD
return true; return true;
@ -211,7 +211,7 @@ bool DirectoryList::isPathInList(const PathName& path) const
PathName varpath(path); PathName varpath(path);
if (PathUtils::isRelative(path)) { if (PathUtils::isRelative(path)) {
PathUtils::concatPath(varpath, PathUtils::concatPath(varpath,
PathName(Config::getRootDirectory()), path); PathName(Config::getRootDirectory()), path);
} }
@ -227,7 +227,7 @@ bool DirectoryList::isPathInList(const PathName& path) const
#endif //BOOT_BUILD #endif //BOOT_BUILD
} }
bool DirectoryList::expandFileName(PathName& path, const PathName& name) const bool DirectoryList::expandFileName(PathName& path, const PathName& name) const
{ {
fb_assert(mode != NotInitialized); fb_assert(mode != NotInitialized);
for (size_t i = 0; i < getCount(); i++) { for (size_t i = 0; i < getCount(); i++) {

View File

@ -297,7 +297,7 @@ static void integer_to_text(const dsc* from, dsc* to, Callbacks* cb)
************************************** **************************************
* *
* Functional description * Functional description
* Convert your basic binary number to * Convert your basic binary number to
* nice, formatted text. * nice, formatted text.
* *
**************************************/ **************************************/
@ -455,9 +455,9 @@ static void string_to_datetime(const dsc* desc,
* "today" Today's date 0:0:0.0 time * "today" Today's date 0:0:0.0 time
* "tomorrow" Tomorrow's date 0:0:0.0 time * "tomorrow" Tomorrow's date 0:0:0.0 time
* "yesterday" Yesterday's date 0:0:0.0 time * "yesterday" Yesterday's date 0:0:0.0 time
* YYYY-MM-DD [HH:[Min:[SS.[Thou]]]]] * YYYY-MM-DD [HH:[Min:[SS.[Thou]]]]]
* MM:DD[:YY [HH:[Min:[SS.[Thou]]]]] * MM:DD[:YY [HH:[Min:[SS.[Thou]]]]]
* DD.MM[:YY [HH:[Min:[SS.[Thou]]]]] * DD.MM[:YY [HH:[Min:[SS.[Thou]]]]]
* Where: * Where:
* DD = 1 .. 31 (Day of month) * DD = 1 .. 31 (Day of month)
* YY = 00 .. 99 2-digit years are converted to the nearest year * YY = 00 .. 99 2-digit years are converted to the nearest year
@ -476,7 +476,7 @@ static void string_to_datetime(const dsc* desc,
* 95 ==> 1995 * 95 ==> 1995
* If the current year is 1997, then 46 is converted * If the current year is 1997, then 46 is converted
* to 2046 (etc). * to 2046 (etc).
* = 100.. 5200 (Year) * = 100.. 5200 (Year)
* MM = 1 .. 12 (Month of year) * MM = 1 .. 12 (Month of year)
* = "JANUARY"... (etc) * = "JANUARY"... (etc)
* HH = 0 .. 23 (Hour of day) * HH = 0 .. 23 (Hour of day)
@ -512,7 +512,7 @@ static void string_to_datetime(const dsc* desc,
const char* p = NULL; const char* p = NULL;
const USHORT length = const USHORT length =
CVT_make_string(desc, ttype_ascii, &p, (vary*) buffer, sizeof(buffer), err); CVT_make_string(desc, ttype_ascii, &p, (vary*) buffer, sizeof(buffer), err);
const char* const end = p + length; const char* const end = p + length;
USHORT n, components[7]; USHORT n, components[7];
@ -526,7 +526,7 @@ static void string_to_datetime(const dsc* desc,
const int start_component = (expect_type == expect_sql_time) ? 3 : 0; const int start_component = (expect_type == expect_sql_time) ? 3 : 0;
int i; int i;
for (i = start_component; i < 7; i++) for (i = start_component; i < 7; i++)
{ {
// Skip leading blanks. If we run out of characters, we're done // Skip leading blanks. If we run out of characters, we're done
@ -927,7 +927,7 @@ SLONG CVT_get_long(const dsc* desc, SSHORT scale, ErrorFunction err)
else else
d -= 0.5 + eps; d -= 0.5 + eps;
/* make sure the cast will succeed - different machines /* make sure the cast will succeed - different machines
do different things if the value is larger than a long do different things if the value is larger than a long
can hold */ can hold */
/* If rounding would yield a legitimate value, permit it */ /* If rounding would yield a legitimate value, permit it */
@ -1129,7 +1129,7 @@ double CVT_get_double(const dsc* desc, ErrorFunction err)
exp = exp * 10 + *p - '0'; exp = exp * 10 + *p - '0';
/* The following is a 'safe' test to prevent overflow of /* The following is a 'safe' test to prevent overflow of
exp here and of scale below. A more precise test occurs exp here and of scale below. A more precise test occurs
later in this routine. */ later in this routine. */
if (exp >= SHORT_LIMIT) if (exp >= SHORT_LIMIT)
@ -1237,7 +1237,7 @@ void CVT_move_common(const dsc* from, dsc* to, Callbacks* cb)
const UCHAR* q = from->dsc_address; const UCHAR* q = from->dsc_address;
/* If the datatypes and lengths are identical, just move the /* If the datatypes and lengths are identical, just move the
stuff byte by byte. Although this may seem slower than stuff byte by byte. Although this may seem slower than
optimal, it would cost more to find the fast move than the optimal, it would cost more to find the fast move than the
fast move would gain. */ fast move would gain. */
@ -1358,7 +1358,7 @@ void CVT_move_common(const dsc* from, dsc* to, Callbacks* cb)
case dtype_cstring: case dtype_cstring:
case dtype_text: case dtype_text:
{ {
/* If we are within the engine, INTL_convert_string /* If we are within the engine, INTL_convert_string
* will convert the string between character sets * will convert the string between character sets
* (or die trying). * (or die trying).
* This module, however, can be called from outside * This module, however, can be called from outside
@ -1371,7 +1371,7 @@ void CVT_move_common(const dsc* from, dsc* to, Callbacks* cb)
* *
* a charset type binary is compatible with all other types. * a charset type binary is compatible with all other types.
* if a charset involved is ttype_dynamic, we must look up * if a charset involved is ttype_dynamic, we must look up
* the charset of the attachment (only if we are in the * the charset of the attachment (only if we are in the
* engine). If we are outside the engine, the * engine). If we are outside the engine, the
* assume that the engine has converted the values * assume that the engine has converted the values
* previously in the request. * previously in the request.
@ -1383,7 +1383,7 @@ void CVT_move_common(const dsc* from, dsc* to, Callbacks* cb)
CHARSET_ID charset2; CHARSET_ID charset2;
if (cb->transliterate(from, to, charset2, cb->err)) if (cb->transliterate(from, to, charset2, cb->err))
return; return;
{ // scope { // scope
USHORT strtype_unused; USHORT strtype_unused;
UCHAR *ptr; UCHAR *ptr;
@ -1756,7 +1756,7 @@ USHORT CVT_make_string(const dsc* desc,
{ {
/************************************** /**************************************
* *
* C V T _ m a k e _ s t r i n g * C V T _ m a k e _ s t r i n g
* *
************************************** **************************************
* *
@ -2198,7 +2198,7 @@ SQUAD CVT_get_quad(const dsc* desc, SSHORT scale, ErrorFunction err)
else else
d -= 0.5; d -= 0.5;
/* make sure the cast will succeed - different machines /* make sure the cast will succeed - different machines
do different things if the value is larger than a quad do different things if the value is larger than a quad
can hold */ can hold */
@ -2343,7 +2343,7 @@ SINT64 CVT_get_int64(const dsc* desc, SSHORT scale, ErrorFunction err)
else else
d -= 0.5 + eps; d -= 0.5 + eps;
/* make sure the cast will succeed - different machines /* make sure the cast will succeed - different machines
do different things if the value is larger than a quad do different things if the value is larger than a quad
can hold. can hold.
@ -2524,7 +2524,7 @@ void CVT_move(const dsc* from, dsc* to, ErrorFunction err)
* Move (and possible convert) something to something else. * Move (and possible convert) something to something else.
* *
**************************************/ **************************************/
Callbacks toCommon = {transliterate, getChid, err, getToCharset, Callbacks toCommon = {transliterate, getChid, err, getToCharset,
validateData, validateLength, getCurDate, isVersion4}; validateData, validateLength, getCurDate, isVersion4};
CVT_move_common(from, to, &toCommon); CVT_move_common(from, to, &toCommon);

View File

@ -22,7 +22,7 @@ class InterlockedStringsBuffer : public CircularBuffer
public: public:
explicit InterlockedStringsBuffer(Firebird::MemoryPool&) explicit InterlockedStringsBuffer(Firebird::MemoryPool&)
: CircularBuffer() { } : CircularBuffer() { }
virtual const char* alloc(const char* string, size_t& length) virtual const char* alloc(const char* string, size_t& length)
{ {
Firebird::MutexLockGuard guard(buffer_lock); Firebird::MutexLockGuard guard(buffer_lock);
return CircularBuffer::alloc(string, length); return CircularBuffer::alloc(string, length);
@ -47,15 +47,15 @@ ISC_STATUS dupStringTemp(const char* s)
void fill_status(ISC_STATUS* ptr, const ISC_STATUS* orig_status) void fill_status(ISC_STATUS* ptr, const ISC_STATUS* orig_status)
{ {
// Move in status and clone transient strings // Move in status and clone transient strings
while (true) while (true)
{ {
const ISC_STATUS type = *ptr++ = *orig_status++; const ISC_STATUS type = *ptr++ = *orig_status++;
if (type == isc_arg_end) if (type == isc_arg_end)
break; break;
switch (type) { switch (type) {
case isc_arg_cstring: case isc_arg_cstring:
{ {
const size_t len = *ptr++ = *orig_status++; const size_t len = *ptr++ = *orig_status++;
char *string = FB_NEW(*getDefaultMemoryPool()) char[len]; char *string = FB_NEW(*getDefaultMemoryPool()) char[len];
const char *temp = reinterpret_cast<char*>(*orig_status++); const char *temp = reinterpret_cast<char*>(*orig_status++);
@ -74,7 +74,7 @@ void fill_status(ISC_STATUS* ptr, const ISC_STATUS* orig_status)
*ptr++ = *orig_status++; *ptr++ = *orig_status++;
break; break;
} }
} }
} }
Firebird::GlobalPtr<InterlockedStringsBuffer> engine_failures; Firebird::GlobalPtr<InterlockedStringsBuffer> engine_failures;
@ -87,15 +87,15 @@ namespace Firebird {
void StringsBuffer::makePermanentVector(ISC_STATUS* perm, const ISC_STATUS* trans) void StringsBuffer::makePermanentVector(ISC_STATUS* perm, const ISC_STATUS* trans)
{ {
while (true) while (true)
{ {
const ISC_STATUS type = *perm++ = *trans++; const ISC_STATUS type = *perm++ = *trans++;
switch (type) { switch (type) {
case isc_arg_end: case isc_arg_end:
return; return;
case isc_arg_cstring: case isc_arg_cstring:
{ {
size_t len = *perm++ = *trans++; size_t len = *perm++ = *trans++;
const char* temp = reinterpret_cast<char*>(*trans++); const char* temp = reinterpret_cast<char*>(*trans++);
*perm++ = (ISC_STATUS)(IPTR) (alloc(temp, len)); *perm++ = (ISC_STATUS)(IPTR) (alloc(temp, len));
@ -125,7 +125,7 @@ void StringsBuffer::makeEnginePermanentVector(ISC_STATUS* v)
/********************************* status_exception *******************************/ /********************************* status_exception *******************************/
status_exception::status_exception() throw() : status_exception::status_exception() throw() :
m_strings_permanent(true) m_strings_permanent(true)
{ {
memset(m_status_vector, 0, sizeof(m_status_vector)); memset(m_status_vector, 0, sizeof(m_status_vector));
@ -138,10 +138,10 @@ status_exception::status_exception(const ISC_STATUS *status_vector, bool permane
if (status_vector) if (status_vector)
{ {
set_status(status_vector, permanent); set_status(status_vector, permanent);
} }
} }
void status_exception::set_status(const ISC_STATUS *new_vector, bool permanent) throw() void status_exception::set_status(const ISC_STATUS *new_vector, bool permanent) throw()
{ {
fb_assert(new_vector != 0); fb_assert(new_vector != 0);
@ -151,7 +151,7 @@ void status_exception::set_status(const ISC_STATUS *new_vector, bool permanent)
m_strings_permanent = permanent; m_strings_permanent = permanent;
ISC_STATUS *ptr = m_status_vector; ISC_STATUS *ptr = m_status_vector;
while (true) while (true)
{ {
const ISC_STATUS type = *ptr++ = *new_vector++; const ISC_STATUS type = *ptr++ = *new_vector++;
if (type == isc_arg_end) if (type == isc_arg_end)
@ -166,10 +166,10 @@ void status_exception::release_vector() throw()
{ {
if (m_strings_permanent) if (m_strings_permanent)
return; return;
// Free owned strings // Free owned strings
ISC_STATUS *ptr = m_status_vector; ISC_STATUS *ptr = m_status_vector;
while (true) while (true)
{ {
const ISC_STATUS type = *ptr++; const ISC_STATUS type = *ptr++;
if (type == isc_arg_end) if (type == isc_arg_end)
@ -188,18 +188,18 @@ void status_exception::release_vector() throw()
default: default:
ptr++; ptr++;
break; break;
} }
} }
} }
status_exception::~status_exception() throw() status_exception::~status_exception() throw()
{ {
release_vector(); release_vector();
} }
/********************************* fatal_exception *******************************/ /********************************* fatal_exception *******************************/
void fatal_exception::raiseFmt(const char* format, ...) void fatal_exception::raiseFmt(const char* format, ...)
{ {
va_list args; va_list args;
va_start(args, format); va_start(args, format);
@ -210,11 +210,11 @@ void fatal_exception::raiseFmt(const char* format, ...)
throw fatal_exception(buffer); throw fatal_exception(buffer);
} }
void status_exception::raise(const ISC_STATUS *status_vector) void status_exception::raise(const ISC_STATUS *status_vector)
{ {
throw status_exception(status_vector, true); throw status_exception(status_vector, true);
} }
void status_exception::raise(const Arg::StatusVector& statusVector) void status_exception::raise(const Arg::StatusVector& statusVector)
{ {
ISC_STATUS_ARRAY temp; ISC_STATUS_ARRAY temp;
@ -231,10 +231,10 @@ ISC_STATUS status_exception::stuff_exception(ISC_STATUS* const status_vector, St
sb = &engine_failures; sb = &engine_failures;
} }
if (strings_permanent()) if (strings_permanent())
{ {
// Copy status vector // Copy status vector
while (true) while (true)
{ {
const ISC_STATUS type = *sv++ = *ptr++; const ISC_STATUS type = *sv++ = *ptr++;
if (type == isc_arg_end) if (type == isc_arg_end)
@ -280,7 +280,7 @@ void LongJump::raise()
ISC_STATUS LongJump::stuff_exception(ISC_STATUS* const status_vector, StringsBuffer* sb) const throw() ISC_STATUS LongJump::stuff_exception(ISC_STATUS* const status_vector, StringsBuffer* sb) const throw()
{ {
/* /*
* Do nothing for a while - not all utilities are ready, * Do nothing for a while - not all utilities are ready,
* status_vector is passed in them by other means. * status_vector is passed in them by other means.
* Ideally status_exception should be always used for it, * Ideally status_exception should be always used for it,
* and we should activate the following code: * and we should activate the following code:
@ -290,7 +290,7 @@ ISC_STATUS LongJump::stuff_exception(ISC_STATUS* const status_vector, StringsBuf
{ {
sb = &engine_failures; sb = &engine_failures;
} }
const char *temp = "Unexpected Firebird::LongJump"; const char *temp = "Unexpected Firebird::LongJump";
*sv++ = isc_arg_gds; *sv++ = isc_arg_gds;
@ -299,14 +299,14 @@ ISC_STATUS LongJump::stuff_exception(ISC_STATUS* const status_vector, StringsBuf
*sv++ = (ISC_STATUS)(IPTR) (sb->alloc(temp, strlen(temp))); *sv++ = (ISC_STATUS)(IPTR) (sb->alloc(temp, strlen(temp)));
*sv++ = isc_arg_end; *sv++ = isc_arg_end;
*/ */
return status_vector[1]; return status_vector[1];
} }
/********************************* system_error ****************************/ /********************************* system_error ****************************/
system_error::system_error(const char* syscall, int error_code) : system_error::system_error(const char* syscall, int error_code) :
status_exception(0, false), errorCode(error_code) status_exception(0, false), errorCode(error_code)
{ {
Arg::Gds temp(isc_sys_request); Arg::Gds temp(isc_sys_request);
@ -336,11 +336,11 @@ int system_error::getSystemError()
/********************************* system_call_failed ****************************/ /********************************* system_call_failed ****************************/
system_call_failed::system_call_failed(const char* syscall, int error_code) : system_call_failed::system_call_failed(const char* syscall, int error_code) :
system_error(syscall, error_code) system_error(syscall, error_code)
{ {
#ifdef DEV_BUILD #ifdef DEV_BUILD
// raised failed system call exception in DEV_BUILD in 99.99% means // raised failed system call exception in DEV_BUILD in 99.99% means
// problems with the code - let's create memory dump now // problems with the code - let's create memory dump now
abort(); abort();
#endif #endif
@ -361,9 +361,9 @@ void system_call_failed::raise(const char* syscall)
fatal_exception::fatal_exception(const char* message) : fatal_exception::fatal_exception(const char* message) :
status_exception(0, false) status_exception(0, false)
{ {
ISC_STATUS temp[] = {isc_arg_gds, ISC_STATUS temp[] = {isc_arg_gds,
isc_random, isc_random,
isc_arg_string, dupStringTemp(message), isc_arg_string, dupStringTemp(message),
isc_arg_end}; isc_arg_end};
set_status(temp, false); set_status(temp, false);
} }

View File

@ -123,12 +123,12 @@ void THD_yield(void)
* *
**************************************/ **************************************/
#ifdef USE_POSIX_THREADS #ifdef USE_POSIX_THREADS
/* use sched_yield() instead of pthread_yield(). Because pthread_yield() /* use sched_yield() instead of pthread_yield(). Because pthread_yield()
is not part of the (final) POSIX 1003.1c standard. Several drafts of is not part of the (final) POSIX 1003.1c standard. Several drafts of
the standard contained pthread_yield(), but then the POSIX guys the standard contained pthread_yield(), but then the POSIX guys
discovered it was redundant with sched_yield() and dropped it. discovered it was redundant with sched_yield() and dropped it.
So, just use sched_yield() instead. POSIX systems on which So, just use sched_yield() instead. POSIX systems on which
sched_yield() is available define _POSIX_PRIORITY_SCHEDULING sched_yield() is available define _POSIX_PRIORITY_SCHEDULING
in <unistd.h>. Darwin defined _POSIX_THREAD_PRIORITY_SCHEDULING in <unistd.h>. Darwin defined _POSIX_THREAD_PRIORITY_SCHEDULING
instead of _POSIX_PRIORITY_SCHEDULING. instead of _POSIX_PRIORITY_SCHEDULING.
*/ */

View File

@ -722,7 +722,7 @@ namespace {
flagEcho = GetConsoleMode(handle, &dwMode) && (dwMode & ENABLE_ECHO_INPUT); flagEcho = GetConsoleMode(handle, &dwMode) && (dwMode & ENABLE_ECHO_INPUT);
if (flagEcho) if (flagEcho)
SetConsoleMode(handle, dwMode & ~ENABLE_ECHO_INPUT); SetConsoleMode(handle, dwMode & ~ENABLE_ECHO_INPUT);
#endif #endif
} }
} }
~InputFile() ~InputFile()
@ -738,7 +738,7 @@ namespace {
DWORD dwMode; DWORD dwMode;
if (GetConsoleMode(handle, &dwMode)) if (GetConsoleMode(handle, &dwMode))
SetConsoleMode(handle, dwMode | ENABLE_ECHO_INPUT); SetConsoleMode(handle, dwMode | ENABLE_ECHO_INPUT);
#endif #endif
} }
if (f && f != stdin) { if (f && f != stdin) {
fclose(f); fclose(f);

View File

@ -1,19 +1,19 @@
/* /*
*
* The contents of this file are subject to the Initial
* Developer's Public License Version 1.0 (the "License");
* you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
* http://www.ibphoenix.com/idpl.html.
* *
* Software distributed under the License is distributed on * The contents of this file are subject to the Initial
* an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either * Developer's Public License Version 1.0 (the "License");
* express or implied. See the License for the specific * you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
* http://www.ibphoenix.com/idpl.html.
*
* Software distributed under the License is distributed on
* an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
* express or implied. See the License for the specific
* language governing rights and limitations under the License. * language governing rights and limitations under the License.
* *
* The contents of this file or any work derived from this file * The contents of this file or any work derived from this file
* may not be distributed under any other license whatsoever * may not be distributed under any other license whatsoever
* without the express prior written permission of the original * without the express prior written permission of the original
* author. * author.
* *
* *

View File

@ -1,19 +1,19 @@
/* /*
*
* The contents of this file are subject to the Initial
* Developer's Public License Version 1.0 (the "License");
* you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
* http://www.ibphoenix.com/idpl.html.
* *
* Software distributed under the License is distributed on * The contents of this file are subject to the Initial
* an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either * Developer's Public License Version 1.0 (the "License");
* express or implied. See the License for the specific * you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
* http://www.ibphoenix.com/idpl.html.
*
* Software distributed under the License is distributed on
* an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
* express or implied. See the License for the specific
* language governing rights and limitations under the License. * language governing rights and limitations under the License.
* *
* The contents of this file or any work derived from this file * The contents of this file or any work derived from this file
* may not be distributed under any other license whatsoever * may not be distributed under any other license whatsoever
* without the express prior written permission of the original * without the express prior written permission of the original
* author. * author.
* *
* *

View File

@ -1,19 +1,19 @@
/* /*
*
* The contents of this file are subject to the Initial
* Developer's Public License Version 1.0 (the "License");
* you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
* http://www.ibphoenix.com/idpl.html.
* *
* Software distributed under the License is distributed on * The contents of this file are subject to the Initial
* an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either * Developer's Public License Version 1.0 (the "License");
* express or implied. See the License for the specific * you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
* http://www.ibphoenix.com/idpl.html.
*
* Software distributed under the License is distributed on
* an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
* express or implied. See the License for the specific
* language governing rights and limitations under the License. * language governing rights and limitations under the License.
* *
* The contents of this file or any work derived from this file * The contents of this file or any work derived from this file
* may not be distributed under any other license whatsoever * may not be distributed under any other license whatsoever
* without the express prior written permission of the original * without the express prior written permission of the original
* author. * author.
* *
* *
@ -53,7 +53,7 @@ ConfObject* Configuration::findObject(const char* objectType, const char* object
{ {
if (!configFile) if (!configFile)
loadConfigFile(); loadConfigFile();
return configFile->findObject (objectType, objectName); return configFile->findObject (objectType, objectName);
} }
@ -61,7 +61,7 @@ const char* Configuration::getRootDirectory()
{ {
if (!configFile) if (!configFile)
loadConfigFile(); loadConfigFile();
return configFile->getRootDirectory(); return configFile->getRootDirectory();
} }
@ -81,16 +81,16 @@ ConfObject* Configuration::getObject(const char* objectType)
{ {
if (!configFile) if (!configFile)
loadConfigFile(); loadConfigFile();
return configFile->getObject (objectType); return configFile->getObject (objectType);
} }
ConfObject* Configuration::getObject(const char* objectType, const char* objectName) ConfObject* Configuration::getObject(const char* objectType, const char* objectName)
{ {
ConfObject* object = findObject (objectType, objectName); ConfObject* object = findObject (objectType, objectName);
if (!object) if (!object)
object = getObject (objectType); object = getObject (objectType);
return object; return object;
} }

View File

@ -24,20 +24,20 @@ FileName::FileName(const Firebird::PathName& name) :
else if (*p == '.') else if (*p == '.')
dot = p; dot = p;
} }
if (slash) if (slash)
{ {
directory.assign (start, (int) (slash - rootName)); directory.assign (start, (int) (slash - rootName));
rootName = slash + 1; rootName = slash + 1;
} }
if (dot) if (dot)
{ {
extension = dot + 1; extension = dot + 1;
root.assign (rootName, (int) (dot - rootName)); root.assign (rootName, (int) (dot - rootName));
} }
else else
root = rootName; root = rootName;
} }
FileName::~FileName() FileName::~FileName()

View File

@ -1,19 +1,19 @@
/* /*
*
* The contents of this file are subject to the Initial
* Developer's Public License Version 1.0 (the "License");
* you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
* http://www.ibphoenix.com/idpl.html.
* *
* Software distributed under the License is distributed on * The contents of this file are subject to the Initial
* an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either * Developer's Public License Version 1.0 (the "License");
* express or implied. See the License for the specific * you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
* http://www.ibphoenix.com/idpl.html.
*
* Software distributed under the License is distributed on
* an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either
* express or implied. See the License for the specific
* language governing rights and limitations under the License. * language governing rights and limitations under the License.
* *
* The contents of this file or any work derived from this file * The contents of this file or any work derived from this file
* may not be distributed under any other license whatsoever * may not be distributed under any other license whatsoever
* without the express prior written permission of the original * without the express prior written permission of the original
* author. * author.
* *
* *

View File

@ -181,7 +181,7 @@ void Stream::setMinSegment(int length)
Stream::Segment* Stream::allocSegment(int tail) Stream::Segment* Stream::allocSegment(int tail)
{ {
fb_assert(tail >= 0); fb_assert(tail >= 0);
Segment *segment; Segment *segment;
int length = tail; int length = tail;

View File

@ -97,7 +97,7 @@ void StreamSegment::advance(int size)
char* StreamSegment::copy(void *target, int length) char* StreamSegment::copy(void *target, int length)
{ {
char* targ = static_cast<char*>(target); char* targ = static_cast<char*>(target);
for (int len = length; len;) for (int len = length; len;)
{ {
const int l = MIN (len, available); const int l = MIN (len, available);

View File

@ -161,7 +161,7 @@ jrd_nod* InAutonomousTransactionNode::execute(thread_db* tdbb, jrd_req* request)
EXE_execute_db_triggers(tdbb, request->req_transaction, EXE_execute_db_triggers(tdbb, request->req_transaction,
jrd_req::req_trigger_trans_commit); jrd_req::req_trigger_trans_commit);
} }
{ // scope { // scope
Firebird::AutoSetRestore2<jrd_req*, thread_db> autoNullifyRequest( Firebird::AutoSetRestore2<jrd_req*, thread_db> autoNullifyRequest(
tdbb, &thread_db::getRequest, &thread_db::setRequest, NULL); tdbb, &thread_db::getRequest, &thread_db::setRequest, NULL);

View File

@ -142,11 +142,11 @@ dsql_dbb::~dsql_dbb()
/** /**
DSQL_allocate_statement DSQL_allocate_statement
@brief Allocate a statement handle. @brief Allocate a statement handle.
@param tdbb @param tdbb
@param attachment @param attachment
@ -160,7 +160,7 @@ dsql_req* DSQL_allocate_statement(thread_db* tdbb,
dsql_dbb* const database = init(attachment); dsql_dbb* const database = init(attachment);
Jrd::ContextPoolHolder context(tdbb, database->createPool()); Jrd::ContextPoolHolder context(tdbb, database->createPool());
// allocate the request block // allocate the request block
MemoryPool& pool = *tdbb->getDefaultPool(); MemoryPool& pool = *tdbb->getDefaultPool();
dsql_req* const request = FB_NEW(pool) dsql_req(pool); dsql_req* const request = FB_NEW(pool) dsql_req(pool);
@ -171,11 +171,11 @@ dsql_req* DSQL_allocate_statement(thread_db* tdbb,
/** /**
DSQL_execute DSQL_execute
@brief Execute a non-SELECT dynamic SQL statement. @brief Execute a non-SELECT dynamic SQL statement.
@param tdbb @param tdbb
@param tra_handle @param tra_handle
@ -204,7 +204,7 @@ void DSQL_execute(thread_db* tdbb,
Jrd::ContextPoolHolder context(tdbb, &request->req_pool); Jrd::ContextPoolHolder context(tdbb, &request->req_pool);
if (request->req_flags & REQ_orphan) if (request->req_flags & REQ_orphan)
{ {
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-901) << ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-901) <<
Arg::Gds(isc_bad_req_handle)); Arg::Gds(isc_bad_req_handle));
@ -214,7 +214,7 @@ void DSQL_execute(thread_db* tdbb,
request->req_type = REQ_EMBED_SELECT; request->req_type = REQ_EMBED_SELECT;
} }
// Only allow NULL trans_handle if we're starting a transaction // Only allow NULL trans_handle if we're starting a transaction
if (!*tra_handle && request->req_type != REQ_START_TRANS) if (!*tra_handle && request->req_type != REQ_START_TRANS)
{ {
@ -226,7 +226,7 @@ void DSQL_execute(thread_db* tdbb,
Make sure the cursor is not already open. */ Make sure the cursor is not already open. */
if (request->req_type == REQ_SELECT || if (request->req_type == REQ_SELECT ||
request->req_type == REQ_EXEC_BLOCK || request->req_type == REQ_EXEC_BLOCK ||
request->req_type == REQ_SELECT_BLOCK || request->req_type == REQ_SELECT_BLOCK ||
request->req_type == REQ_SELECT_UPD || request->req_type == REQ_SELECT_UPD ||
request->req_type == REQ_EMBED_SELECT || request->req_type == REQ_EMBED_SELECT ||
@ -240,7 +240,7 @@ void DSQL_execute(thread_db* tdbb,
} }
} }
// A select with a non zero output length is a singleton select // A select with a non zero output length is a singleton select
bool singleton; bool singleton;
if (request->req_type == REQ_SELECT && out_msg_length != 0) { if (request->req_type == REQ_SELECT && out_msg_length != 0) {
singleton = true; singleton = true;
@ -270,7 +270,7 @@ void DSQL_execute(thread_db* tdbb,
* to the list of open cursors (it's not really open). * to the list of open cursors (it's not really open).
*/ */
if ((request->req_type == REQ_SELECT && out_msg_length == 0) || if ((request->req_type == REQ_SELECT && out_msg_length == 0) ||
(request->req_type == REQ_SELECT_BLOCK) || (request->req_type == REQ_SELECT_BLOCK) ||
request->req_type == REQ_SELECT_UPD || request->req_type == REQ_SELECT_UPD ||
request->req_type == REQ_EMBED_SELECT || request->req_type == REQ_EMBED_SELECT ||
request->req_type == REQ_GET_SEGMENT || request->req_type == REQ_GET_SEGMENT ||
@ -283,11 +283,11 @@ void DSQL_execute(thread_db* tdbb,
/** /**
DSQL_execute_immediate DSQL_execute_immediate
@brief Execute a non-SELECT dynamic SQL statement. @brief Execute a non-SELECT dynamic SQL statement.
@param tdbb @param tdbb
@param attachment @param attachment
@ -317,23 +317,23 @@ void DSQL_execute_immediate(thread_db* tdbb,
USHORT out_msg_type, USHORT out_msg_length, UCHAR* out_msg) USHORT out_msg_type, USHORT out_msg_length, UCHAR* out_msg)
{ {
execute_immediate(tdbb, attachment, tra_handle, length, execute_immediate(tdbb, attachment, tra_handle, length,
string, dialect, in_blr_length, string, dialect, in_blr_length,
in_blr, in_blr,
in_msg_type, in_msg_length, in_msg_type, in_msg_length,
in_msg, in_msg,
out_blr_length, out_blr_length,
out_blr, out_blr,
out_msg_type, out_msg_length, out_msg_type, out_msg_length,
out_msg); out_msg);
} }
/** /**
DSQL_fetch DSQL_fetch
@brief Fetch next record from a dynamic SQL cursor @brief Fetch next record from a dynamic SQL cursor
@param user_status @param user_status
@param req_handle @param req_handle
@ -359,7 +359,7 @@ ISC_STATUS DSQL_fetch(thread_db* tdbb,
Jrd::ContextPoolHolder context(tdbb, &request->req_pool); Jrd::ContextPoolHolder context(tdbb, &request->req_pool);
// if the cursor isn't open, we've got a problem // if the cursor isn't open, we've got a problem
if (!(request->req_flags & REQ_cursor_open)) if (!(request->req_flags & REQ_cursor_open))
{ {
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-504) << ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-504) <<
@ -518,11 +518,11 @@ ISC_STATUS DSQL_fetch(thread_db* tdbb,
/** /**
DSQL_free_statement DSQL_free_statement
@brief Release request for a dsql statement @brief Release request for a dsql statement
@param user_status @param user_status
@param req_handle @param req_handle
@ -558,11 +558,11 @@ void DSQL_free_statement(thread_db* tdbb,
/** /**
DSQL_insert DSQL_insert
@brief Insert next record into a dynamic SQL cursor @brief Insert next record into a dynamic SQL cursor
@param user_status @param user_status
@param req_handle @param req_handle
@ -582,13 +582,13 @@ void DSQL_insert(thread_db* tdbb,
Jrd::ContextPoolHolder context(tdbb, &request->req_pool); Jrd::ContextPoolHolder context(tdbb, &request->req_pool);
if (request->req_flags & REQ_orphan) if (request->req_flags & REQ_orphan)
{ {
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-901) << ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-901) <<
Arg::Gds(isc_bad_req_handle)); Arg::Gds(isc_bad_req_handle));
} }
// if the cursor isn't open, we've got a problem // if the cursor isn't open, we've got a problem
if (request->req_type == REQ_PUT_SEGMENT) if (request->req_type == REQ_PUT_SEGMENT)
{ {
@ -609,7 +609,7 @@ void DSQL_insert(thread_db* tdbb,
parse_blr(blr_length, blr, msg_length, message->msg_parameters); parse_blr(blr_length, blr, msg_length, message->msg_parameters);
if (request->req_type == REQ_PUT_SEGMENT) { if (request->req_type == REQ_PUT_SEGMENT) {
// For put segment, use the user buffer and indicator directly. // For put segment, use the user buffer and indicator directly.
dsql_par* parameter = request->req_blob->blb_segment; dsql_par* parameter = request->req_blob->blb_segment;
const UCHAR* buffer = dsql_msg_buf + (IPTR) parameter->par_user_desc.dsc_address; const UCHAR* buffer = dsql_msg_buf + (IPTR) parameter->par_user_desc.dsc_address;
@ -621,11 +621,11 @@ void DSQL_insert(thread_db* tdbb,
/** /**
DSQL_prepare DSQL_prepare
@brief Prepare a statement for execution. @brief Prepare a statement for execution.
@param user_status @param user_status
@param trans_handle @param trans_handle
@ -661,7 +661,7 @@ void DSQL_prepare(thread_db* tdbb,
Arg::Gds(isc_bad_req_handle)); Arg::Gds(isc_bad_req_handle));
} }
// check to see if old request has an open cursor // check to see if old request has an open cursor
if (old_request && (old_request->req_flags & REQ_cursor_open)) { if (old_request && (old_request->req_flags & REQ_cursor_open)) {
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-519) << ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-519) <<
@ -683,7 +683,7 @@ void DSQL_prepare(thread_db* tdbb,
try { try {
// Figure out which parser version to use // Figure out which parser version to use
/* Since the API to dsql8_prepare is public and can not be changed, there needs to /* Since the API to dsql8_prepare is public and can not be changed, there needs to
* be a way to send the parser version to DSQL so that the parser can compare the keyword * be a way to send the parser version to DSQL so that the parser can compare the keyword
* version to the parser version. To accomplish this, the parser version is combined with * version to the parser version. To accomplish this, the parser version is combined with
@ -735,7 +735,7 @@ void DSQL_prepare(thread_db* tdbb,
request->req_flags |= REQ_prepared; request->req_flags |= REQ_prepared;
// Now that we know that the new request exists, zap the old one. // Now that we know that the new request exists, zap the old one.
{ {
Jrd::ContextPoolHolder context(tdbb, &old_request->req_pool); Jrd::ContextPoolHolder context(tdbb, &old_request->req_pool);
@ -760,11 +760,11 @@ void DSQL_prepare(thread_db* tdbb,
/** /**
DSQL_set_cursor_name DSQL_set_cursor_name
@brief Set a cursor name for a dynamic request @brief Set a cursor name for a dynamic request
@param user_status @param user_status
@param req_handle @param req_handle
@ -790,7 +790,7 @@ void DSQL_set_cursor(thread_db* tdbb,
// Note that "" will be replaced with ". // Note that "" will be replaced with ".
// The code is very strange, because it doesn't check for "" really // The code is very strange, because it doesn't check for "" really
// and thus deletes one isolated " in the middle of the cursor. // and thus deletes one isolated " in the middle of the cursor.
for (Firebird::string::iterator i = cursor.begin(); for (Firebird::string::iterator i = cursor.begin();
i < cursor.end(); ++i) i < cursor.end(); ++i)
{ {
if (*i == '\"') { if (*i == '\"') {
@ -819,9 +819,9 @@ void DSQL_set_cursor(thread_db* tdbb,
} }
cursor.resize(length); cursor.resize(length);
// If there already is a different cursor by the same name, bitch // If there already is a different cursor by the same name, bitch
const dsql_sym* symbol = const dsql_sym* symbol =
HSHD_lookup(request->req_dbb, cursor.c_str(), length, SYM_cursor, 0); HSHD_lookup(request->req_dbb, cursor.c_str(), length, SYM_cursor, 0);
if (symbol) if (symbol)
{ {
@ -850,11 +850,11 @@ void DSQL_set_cursor(thread_db* tdbb,
/** /**
DSQL_sql_info DSQL_sql_info
@brief Provide information on dsql statement @brief Provide information on dsql statement
@param user_status @param user_status
@param req_handle @param req_handle
@ -878,11 +878,11 @@ void DSQL_sql_info(thread_db* tdbb,
/** /**
close_cursor close_cursor
@brief Close an open cursor. @brief Close an open cursor.
@param request @param request
@param tdbb @param tdbb
@ -917,12 +917,12 @@ static void close_cursor(thread_db* tdbb, dsql_req* request)
/** /**
convert convert
@brief Convert a number to VAX form -- least significant bytes first. @brief Convert a number to VAX form -- least significant bytes first.
Return the length. Return the length.
@param number @param number
@param buffer @param buffer
@ -956,11 +956,11 @@ static USHORT convert( SLONG number, UCHAR* buffer)
/** /**
execute_blob execute_blob
@brief Open or create a blob. @brief Open or create a blob.
@param tdbb @param tdbb
@param request @param request
@ -1043,11 +1043,11 @@ static void execute_blob(thread_db* tdbb,
/** /**
execute_immediate execute_immediate
@brief Common part of prepare and execute a statement. @brief Common part of prepare and execute a statement.
@param tdbb @param tdbb
@param attachment @param attachment
@ -1095,7 +1095,7 @@ static void execute_immediate(thread_db* tdbb,
try { try {
// Figure out which parser version to use // Figure out which parser version to use
/* Since the API to dsql8_execute_immediate is public and can not be changed, there needs to /* Since the API to dsql8_execute_immediate is public and can not be changed, there needs to
* be a way to send the parser version to DSQL so that the parser can compare the keyword * be a way to send the parser version to DSQL so that the parser can compare the keyword
* version to the parser version. To accomplish this, the parser version is combined with * version to the parser version. To accomplish this, the parser version is combined with
@ -1150,11 +1150,11 @@ static void execute_immediate(thread_db* tdbb,
/** /**
execute_request execute_request
@brief Execute a dynamic SQL statement. @brief Execute a dynamic SQL statement.
@param tdbb @param tdbb
@param request @param request
@ -1245,11 +1245,11 @@ static void execute_request(thread_db* tdbb,
break; break;
default: default:
// Catch invalid request types // Catch invalid request types
fb_assert(false); fb_assert(false);
} }
// If there is no data required, just start the request // If there is no data required, just start the request
dsql_msg* message = request->req_send; dsql_msg* message = request->req_send;
if (!message) if (!message)
@ -1286,7 +1286,7 @@ static void execute_request(thread_db* tdbb,
if (out_msg_length && out_blr_length) { if (out_msg_length && out_blr_length) {
parse_blr(out_blr_length, out_blr, out_msg_length, parse_blr(out_blr_length, out_blr, out_msg_length,
message->msg_parameters); message->msg_parameters);
} }
else if (!out_msg_length && isBlock) { else if (!out_msg_length && isBlock) {
message = &temp_msg; message = &temp_msg;
message->msg_number = 1; message->msg_number = 1;
@ -1300,7 +1300,7 @@ static void execute_request(thread_db* tdbb,
if (out_msg_length) if (out_msg_length)
map_in_out(NULL, message, 0, out_blr, out_msg_length, out_msg); map_in_out(NULL, message, 0, out_blr, out_msg_length, out_msg);
// if this is a singleton select, make sure there's in fact one record // if this is a singleton select, make sure there's in fact one record
if (singleton) if (singleton)
{ {
@ -1393,12 +1393,12 @@ static void execute_request(thread_db* tdbb,
} }
/** /**
filter_sub_type filter_sub_type
@brief Determine the sub_type to use in filtering @brief Determine the sub_type to use in filtering
a blob. a blob.
@param request @param request
@param node @param node
@ -1422,13 +1422,13 @@ static SSHORT filter_sub_type( dsql_req* request, const dsql_nod* node)
/** /**
get_indices get_indices
@brief Retrieve the indices from the index tree in @brief Retrieve the indices from the index tree in
the request info buffer (explain_ptr), and print them out the request info buffer (explain_ptr), and print them out
in the plan buffer. Return true on success and false on failure. in the plan buffer. Return true on success and false on failure.
@param explain_length_ptr @param explain_length_ptr
@param explain_ptr @param explain_ptr
@ -1468,7 +1468,7 @@ static bool get_indices(
explain_length--; explain_length--;
length = *explain++; length = *explain++;
// if this isn't the first index, put out a comma // if this isn't the first index, put out a comma
if (plan[-1] != '(' && plan[-1] != ' ') { if (plan[-1] != '(' && plan[-1] != ' ') {
plan_length -= 2; plan_length -= 2;
@ -1478,7 +1478,7 @@ static bool get_indices(
*plan++ = ' '; *plan++ = ' ';
} }
// now put out the index name // now put out the index name
if ((plan_length -= length) < 0) if ((plan_length -= length) < 0)
return false; return false;
@ -1501,13 +1501,13 @@ static bool get_indices(
/** /**
get_plan_info get_plan_info
@brief Get the access plan for the request and turn @brief Get the access plan for the request and turn
it into a textual representation suitable for it into a textual representation suitable for
human reading. human reading.
@param request @param request
@param buffer_length @param buffer_length
@ -1527,7 +1527,7 @@ static USHORT get_plan_info(thread_db* tdbb,
SCHAR* buffer_ptr = *out_buffer; SCHAR* buffer_ptr = *out_buffer;
// get the access path info for the underlying request from the engine // get the access path info for the underlying request from the engine
try try
{ {
@ -1573,12 +1573,12 @@ static USHORT get_plan_info(thread_db* tdbb,
at the begining of the function hence they had trash the second time. */ at the begining of the function hence they had trash the second time. */
USHORT join_count = 0, level = 0; USHORT join_count = 0, level = 0;
// keep going until we reach the end of the explain info // keep going until we reach the end of the explain info
while (explain_length > 0 && buffer_length > 0) while (explain_length > 0 && buffer_length > 0)
{ {
if (!get_rsb_item(&explain_length, &explain, &buffer_length, &plan, if (!get_rsb_item(&explain_length, &explain, &buffer_length, &plan,
&join_count, &level)) &join_count, &level))
{ {
// don't allocate buffer of the same length second time // don't allocate buffer of the same length second time
// and let user know plan is incomplete // and let user know plan is incomplete
@ -1592,7 +1592,7 @@ static USHORT get_plan_info(thread_db* tdbb,
break; break;
} }
// assume we have run out of room in the buffer, try again with a larger one // assume we have run out of room in the buffer, try again with a larger one
const size_t new_length = MAX_SSHORT; const size_t new_length = MAX_SSHORT;
char* const temp = static_cast<char*>(gds__alloc(new_length)); char* const temp = static_cast<char*>(gds__alloc(new_length));
if (!temp) { if (!temp) {
@ -1618,11 +1618,11 @@ static USHORT get_plan_info(thread_db* tdbb,
/** /**
get_request_info get_request_info
@brief Get the records updated/deleted for record @brief Get the records updated/deleted for record
@param request @param request
@param buffer_length @param buffer_length
@ -1637,7 +1637,7 @@ static USHORT get_request_info(thread_db* tdbb,
if (!request->req_request) // DDL if (!request->req_request) // DDL
return 0; return 0;
// get the info for the request from the engine // get the info for the request from the engine
try try
{ {
@ -1691,13 +1691,13 @@ static USHORT get_request_info(thread_db* tdbb,
/** /**
get_rsb_item get_rsb_item
@brief Use recursion to print out a reverse-polish @brief Use recursion to print out a reverse-polish
access plan of joins and join types. Return true on success access plan of joins and join types. Return true on success
and false on failure and false on failure
@param explain_length_ptr @param explain_length_ptr
@param explain_ptr @param explain_ptr
@ -1727,7 +1727,7 @@ static bool get_rsb_item(SSHORT* explain_length_ptr,
{ {
case isc_info_rsb_begin: case isc_info_rsb_begin:
if (!*level_ptr) { if (!*level_ptr) {
// put out the PLAN prefix // put out the PLAN prefix
p = "\nPLAN "; p = "\nPLAN ";
if ((plan_length -= strlen(p)) < 0) if ((plan_length -= strlen(p)) < 0)
@ -1757,7 +1757,7 @@ static bool get_rsb_item(SSHORT* explain_length_ptr,
*plan++ = '('; *plan++ = '(';
} }
// if this isn't the first relation, put out a comma // if this isn't the first relation, put out a comma
if (plan[-1] != '(') { if (plan[-1] != '(') {
plan_length -= 2; plan_length -= 2;
@ -1767,7 +1767,7 @@ static bool get_rsb_item(SSHORT* explain_length_ptr,
*plan++ = ' '; *plan++ = ' ';
} }
// put out the relation name // put out the relation name
{ // scope to keep length local. { // scope to keep length local.
explain_length--; explain_length--;
SSHORT length = (UCHAR) * explain++; SSHORT length = (UCHAR) * explain++;
@ -1790,7 +1790,7 @@ static bool get_rsb_item(SSHORT* explain_length_ptr,
case isc_info_rsb_union: case isc_info_rsb_union:
case isc_info_rsb_recursive: case isc_info_rsb_recursive:
// put out all the substreams of the join // put out all the substreams of the join
{ // scope to have union_count, union_level and union_join_count local. { // scope to have union_count, union_level and union_join_count local.
explain_length--; explain_length--;
USHORT union_count = (USHORT) * explain++ - 1; USHORT union_count = (USHORT) * explain++ - 1;
@ -1844,7 +1844,7 @@ static bool get_rsb_item(SSHORT* explain_length_ptr,
*plan++ = ' '; *plan++ = ' ';
} }
// put out the join type // put out the join type
if (rsb_type == isc_info_rsb_cross || if (rsb_type == isc_info_rsb_cross ||
rsb_type == isc_info_rsb_left_cross) rsb_type == isc_info_rsb_left_cross)
@ -1860,7 +1860,7 @@ static bool get_rsb_item(SSHORT* explain_length_ptr,
while (*p) while (*p)
*plan++ = *p++; *plan++ = *p++;
// put out all the substreams of the join // put out all the substreams of the join
explain_length--; explain_length--;
{ // scope to have join_count local. { // scope to have join_count local.
@ -1878,14 +1878,14 @@ static bool get_rsb_item(SSHORT* explain_length_ptr,
} }
} // scope } // scope
// put out the final parenthesis for the join // put out the final parenthesis for the join
if (--plan_length < 0) if (--plan_length < 0)
return false; return false;
else else
*plan++ = ')'; *plan++ = ')';
// this qualifies as a stream, so decrement the join count // this qualifies as a stream, so decrement the join count
if (*parent_join_count) if (*parent_join_count)
-- * parent_join_count; -- * parent_join_count;
@ -1915,7 +1915,7 @@ static bool get_rsb_item(SSHORT* explain_length_ptr,
while (*p) while (*p)
*plan++ = *p++; *plan++ = *p++;
// print out additional index information // print out additional index information
if (rsb_type == isc_info_rsb_indexed || if (rsb_type == isc_info_rsb_indexed ||
rsb_type == isc_info_rsb_navigate || rsb_type == isc_info_rsb_navigate ||
@ -1944,7 +1944,7 @@ static bool get_rsb_item(SSHORT* explain_length_ptr,
*plan++ = ')'; *plan++ = ')';
} }
// detect the end of a single relation and put out a final parenthesis // detect the end of a single relation and put out a final parenthesis
if (!*parent_join_count) if (!*parent_join_count)
if (--plan_length < 0) if (--plan_length < 0)
@ -1952,7 +1952,7 @@ static bool get_rsb_item(SSHORT* explain_length_ptr,
else else
*plan++ = ')'; *plan++ = ')';
// this also qualifies as a stream, so decrement the join count // this also qualifies as a stream, so decrement the join count
if (*parent_join_count) if (*parent_join_count)
-- * parent_join_count; -- * parent_join_count;
@ -1973,7 +1973,7 @@ static bool get_rsb_item(SSHORT* explain_length_ptr,
break; break;
} }
// if this isn't the first item in the list, put out a comma // if this isn't the first item in the list, put out a comma
if (*parent_join_count && plan[-1] != '(') { if (*parent_join_count && plan[-1] != '(') {
plan_length -= 2; plan_length -= 2;
@ -2030,11 +2030,11 @@ static bool get_rsb_item(SSHORT* explain_length_ptr,
/** /**
init init
@brief Initialize dynamic SQL. This is called only once. @brief Initialize dynamic SQL. This is called only once.
@param db_handle @param db_handle
@ -2126,12 +2126,12 @@ static dsql_dbb* init(Attachment* attachment)
/** /**
map_in_out map_in_out
@brief Map data from external world into message or @brief Map data from external world into message or
from message to external world. from message to external world.
@param request @param request
@param message @param message
@ -2162,7 +2162,7 @@ static void map_in_out( dsql_req* request,
{ {
if (parameter->par_index) if (parameter->par_index)
{ {
// Make sure the message given to us is long enough // Make sure the message given to us is long enough
DSC desc = parameter->par_user_desc; DSC desc = parameter->par_user_desc;
USHORT length = (IPTR) desc.dsc_address + desc.dsc_length; USHORT length = (IPTR) desc.dsc_address + desc.dsc_length;
@ -2252,11 +2252,11 @@ static void map_in_out( dsql_req* request,
/** /**
parse_blr parse_blr
@brief Parse the message of a blr request. @brief Parse the message of a blr request.
@param blr_length @param blr_length
@param blr @param blr
@ -2289,14 +2289,14 @@ static USHORT parse_blr(
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-804) << ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-804) <<
Arg::Gds(isc_dsql_sqlda_err)); Arg::Gds(isc_dsql_sqlda_err));
} }
blr++; // skip the blr_version blr++; // skip the blr_version
if (*blr++ != blr_begin || *blr++ != blr_message) if (*blr++ != blr_begin || *blr++ != blr_message)
{ {
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-804) << ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-804) <<
Arg::Gds(isc_dsql_sqlda_err)); Arg::Gds(isc_dsql_sqlda_err));
} }
++blr; // skip the message number ++blr; // skip the message number
USHORT count = *blr++; USHORT count = *blr++;
count += (*blr++) << 8; count += (*blr++) << 8;
count /= 2; count /= 2;
@ -2308,7 +2308,7 @@ static USHORT parse_blr(
desc.dsc_scale = 0; desc.dsc_scale = 0;
desc.dsc_sub_type = 0; desc.dsc_sub_type = 0;
desc.dsc_flags = 0; desc.dsc_flags = 0;
switch (*blr++) switch (*blr++)
{ {
case blr_text: case blr_text:
@ -2453,12 +2453,12 @@ static USHORT parse_blr(
/** /**
prepare prepare
@brief Prepare a statement for execution. Return SQL status @brief Prepare a statement for execution. Return SQL status
code. Note: caller is responsible for pool handling. code. Note: caller is responsible for pool handling.
@param request @param request
@param string_length @param string_length
@ -2503,7 +2503,7 @@ static dsql_req* prepare(thread_db* tdbb, dsql_dbb* database, jrd_tra* transacti
} }
} }
// allocate the statement block, then prepare the statement // allocate the statement block, then prepare the statement
Jrd::ContextPoolHolder context(tdbb, database->createPool()); Jrd::ContextPoolHolder context(tdbb, database->createPool());
@ -2515,7 +2515,7 @@ static dsql_req* prepare(thread_db* tdbb, dsql_dbb* database, jrd_tra* transacti
try { try {
// Parse the SQL statement. If it croaks, return // Parse the SQL statement. If it croaks, return
Parser parser(*tdbb->getDefaultPool(), client_dialect, statement->req_dbb->dbb_db_SQL_dialect, Parser parser(*tdbb->getDefaultPool(), client_dialect, statement->req_dbb->dbb_db_SQL_dialect,
parser_version, string, string_length, tdbb->getAttachment()->att_charset); parser_version, string, string_length, tdbb->getAttachment()->att_charset);
@ -2532,7 +2532,7 @@ static dsql_req* prepare(thread_db* tdbb, dsql_dbb* database, jrd_tra* transacti
Arg::Gds(isc_command_end_err)); Arg::Gds(isc_command_end_err));
} }
// allocate the send and receive messages // allocate the send and receive messages
statement->req_send = FB_NEW(pool) dsql_msg; statement->req_send = FB_NEW(pool) dsql_msg;
dsql_msg* message = FB_NEW(pool) dsql_msg; dsql_msg* message = FB_NEW(pool) dsql_msg;
@ -2563,7 +2563,7 @@ static dsql_req* prepare(thread_db* tdbb, dsql_dbb* database, jrd_tra* transacti
if (!node) if (!node)
return statement; return statement;
// stop here for statements not requiring code generation // stop here for statements not requiring code generation
if (statement->req_type == REQ_DDL && parser.isStmtAmbiguous() && if (statement->req_type == REQ_DDL && parser.isStmtAmbiguous() &&
statement->req_dbb->dbb_db_SQL_dialect != client_dialect) statement->req_dbb->dbb_db_SQL_dialect != client_dialect)
@ -2580,7 +2580,7 @@ static dsql_req* prepare(thread_db* tdbb, dsql_dbb* database, jrd_tra* transacti
return statement; return statement;
} }
// Work on blob segment statements // Work on blob segment statements
if (statement->req_type == REQ_GET_SEGMENT || if (statement->req_type == REQ_GET_SEGMENT ||
statement->req_type == REQ_PUT_SEGMENT) statement->req_type == REQ_PUT_SEGMENT)
@ -2591,7 +2591,7 @@ static dsql_req* prepare(thread_db* tdbb, dsql_dbb* database, jrd_tra* transacti
return statement; return statement;
} }
// Generate BLR, DDL or TPB for statement // Generate BLR, DDL or TPB for statement
// Start transactions takes parameters via a parameter block. // Start transactions takes parameters via a parameter block.
// The statement blr string is used for that // The statement blr string is used for that
@ -2608,8 +2608,8 @@ static dsql_req* prepare(thread_db* tdbb, dsql_dbb* database, jrd_tra* transacti
GEN_request(statement, node); GEN_request(statement, node);
const USHORT length = statement->req_blr_data.getCount(); const USHORT length = statement->req_blr_data.getCount();
// stop here for ddl statements // stop here for ddl statements
if (statement->req_type == REQ_CREATE_DB || if (statement->req_type == REQ_CREATE_DB ||
statement->req_type == REQ_DDL) statement->req_type == REQ_DDL)
@ -2617,7 +2617,7 @@ static dsql_req* prepare(thread_db* tdbb, dsql_dbb* database, jrd_tra* transacti
return statement; return statement;
} }
// have the access method compile the statement // have the access method compile the statement
#ifdef DSQL_DEBUG #ifdef DSQL_DEBUG
if (DSQL_debug & 64) { if (DSQL_debug & 64) {
@ -2630,9 +2630,9 @@ static dsql_req* prepare(thread_db* tdbb, dsql_dbb* database, jrd_tra* transacti
} }
#endif #endif
// check for warnings // check for warnings
if (tdbb->tdbb_status_vector[2] == isc_arg_warning) { if (tdbb->tdbb_status_vector[2] == isc_arg_warning) {
// save a status vector // save a status vector
memcpy(local_status, tdbb->tdbb_status_vector, sizeof(ISC_STATUS_ARRAY)); memcpy(local_status, tdbb->tdbb_status_vector, sizeof(ISC_STATUS_ARRAY));
} }
@ -2655,17 +2655,17 @@ static dsql_req* prepare(thread_db* tdbb, dsql_dbb* database, jrd_tra* transacti
status = tdbb->tdbb_status_vector[1]; status = tdbb->tdbb_status_vector[1];
} }
// restore warnings (if there are any) // restore warnings (if there are any)
if (local_status[2] == isc_arg_warning) if (local_status[2] == isc_arg_warning)
{ {
int indx, len, warning; int indx, len, warning;
// find end of a status vector // find end of a status vector
PARSE_STATUS(tdbb->tdbb_status_vector, indx, warning); PARSE_STATUS(tdbb->tdbb_status_vector, indx, warning);
if (indx) if (indx)
--indx; --indx;
// calculate length of saved warnings // calculate length of saved warnings
PARSE_STATUS(local_status, len, warning); PARSE_STATUS(local_status, len, warning);
len -= 2; len -= 2;
@ -2691,13 +2691,13 @@ static dsql_req* prepare(thread_db* tdbb, dsql_dbb* database, jrd_tra* transacti
/** /**
put_item put_item
@brief Put information item in output buffer if there is room, and @brief Put information item in output buffer if there is room, and
return an updated pointer. If there isn't room for the item, return an updated pointer. If there isn't room for the item,
indicate truncation and return NULL. indicate truncation and return NULL.
@param item @param item
@param length @param length
@ -2734,11 +2734,11 @@ static UCHAR* put_item( UCHAR item,
/** /**
release_request release_request
@brief Release a dynamic request. @brief Release a dynamic request.
@param request @param request
@param top_level @param top_level
@ -2747,7 +2747,7 @@ static UCHAR* put_item( UCHAR item,
static void release_request(thread_db* tdbb, dsql_req* request, bool drop) static void release_request(thread_db* tdbb, dsql_req* request, bool drop)
{ {
SET_TDBB(tdbb); SET_TDBB(tdbb);
// If request is parent, orphan the children and // If request is parent, orphan the children and
// release a portion of their requests // release a portion of their requests
@ -2848,7 +2848,7 @@ static void sql_info(thread_db* tdbb,
memset(buffer, 0, sizeof(buffer)); memset(buffer, 0, sizeof(buffer));
// Pre-initialize buffer. This is necessary because we don't want to transfer rubbish over the wire // Pre-initialize buffer. This is necessary because we don't want to transfer rubbish over the wire
memset(info, 0, info_length); memset(info, 0, info_length);
const UCHAR* const end_items = items + item_length; const UCHAR* const end_items = items + item_length;
const UCHAR* const end_info = info + info_length; const UCHAR* const end_info = info + info_length;
@ -2931,10 +2931,10 @@ static void sql_info(thread_db* tdbb,
case REQ_SAVEPOINT: case REQ_SAVEPOINT:
number = isc_info_sql_stmt_savepoint; number = isc_info_sql_stmt_savepoint;
break; break;
case REQ_EXEC_BLOCK: case REQ_EXEC_BLOCK:
number = isc_info_sql_stmt_exec_procedure; number = isc_info_sql_stmt_exec_procedure;
break; break;
case REQ_SELECT_BLOCK: case REQ_SELECT_BLOCK:
number = isc_info_sql_stmt_select; number = isc_info_sql_stmt_select;
break; break;
default: default:
@ -2965,7 +2965,7 @@ static void sql_info(thread_db* tdbb,
} }
else if (item == isc_info_sql_records) { else if (item == isc_info_sql_records) {
length = get_request_info(tdbb, request, (SSHORT) sizeof(buffer), buffer); length = get_request_info(tdbb, request, (SSHORT) sizeof(buffer), buffer);
if (length && !(info = put_item(item, length, buffer, info, end_info))) if (length && !(info = put_item(item, length, buffer, info, end_info)))
{ {
return; return;
} }
@ -3015,7 +3015,7 @@ static void sql_info(thread_db* tdbb,
const UCHAR* end_describe = items; const UCHAR* end_describe = items;
while (end_describe < end_items && while (end_describe < end_items &&
*end_describe != isc_info_end && *end_describe != isc_info_end &&
*end_describe != isc_info_sql_describe_end) *end_describe != isc_info_sql_describe_end)
{ {
end_describe++; end_describe++;
} }
@ -3050,11 +3050,11 @@ static void sql_info(thread_db* tdbb,
/** /**
var_info var_info
@brief Provide information on an internal message. @brief Provide information on an internal message.
@param message @param message
@param items @param items
@ -3068,8 +3068,8 @@ static UCHAR* var_info(
dsql_msg* message, dsql_msg* message,
const UCHAR* items, const UCHAR* items,
const UCHAR* const end_describe, const UCHAR* const end_describe,
UCHAR* info, UCHAR* info,
const UCHAR* const end, const UCHAR* const end,
USHORT first_index) USHORT first_index)
{ {
if (!message || !message->msg_index) if (!message || !message->msg_index)
@ -3102,7 +3102,7 @@ static UCHAR* var_info(
SLONG sql_sub_type = 0; SLONG sql_sub_type = 0;
SLONG sql_scale = 0; SLONG sql_scale = 0;
SLONG sql_type = 0; SLONG sql_type = 0;
switch (param->par_desc.dsc_dtype) switch (param->par_desc.dsc_dtype)
{ {
case dtype_real: case dtype_real:

View File

@ -19,7 +19,7 @@
* *
* All Rights Reserved. * All Rights Reserved.
* Contributor(s): ______________________________________. * Contributor(s): ______________________________________.
* *
* 27 Nov 2001 Ann W. Harrison - preserve string arguments in * 27 Nov 2001 Ann W. Harrison - preserve string arguments in
* ERRD_post_warning * ERRD_post_warning
* *
@ -42,7 +42,7 @@
#include "../dsql/utld_proto.h" #include "../dsql/utld_proto.h"
// This is the only one place in dsql code, where we need both // This is the only one place in dsql code, where we need both
// dsql.h and err_proto.h. // dsql.h and err_proto.h.
// To avoid warnings, undefine some macro's here // To avoid warnings, undefine some macro's here
//#undef BUGCHECK //#undef BUGCHECK
//#undef IBERROR //#undef IBERROR
@ -65,11 +65,11 @@ static void internal_post(const ISC_STATUS* status_vector);
#ifdef DEV_BUILD #ifdef DEV_BUILD
/** /**
ERRD_assert_msg ERRD_assert_msg
@brief Generate an assertion failure with a message @brief Generate an assertion failure with a message
@param msg @param msg
@param file @param file
@ -86,15 +86,15 @@ void ERRD_assert_msg(const char* msg, const char* file, ULONG lineno)
(msg ? msg : ""), (file ? file : ""), lineno); (msg ? msg : ""), (file ? file : ""), lineno);
ERRD_bugcheck(buffer); ERRD_bugcheck(buffer);
} }
#endif // DEV_BUILD #endif // DEV_BUILD
/** /**
ERRD_bugcheck ERRD_bugcheck
@brief Somebody has screwed up. Bugcheck. @brief Somebody has screwed up. Bugcheck.
@param text @param text
@ -108,16 +108,16 @@ void ERRD_bugcheck(const char* text)
/** /**
ERRD_error ERRD_error
@brief This routine should only be used by fatal @brief This routine should only be used by fatal
error messages, those that cannot use the error messages, those that cannot use the
normal error routines because something normal error routines because something
is very badly wrong. ERRD_post() should is very badly wrong. ERRD_post() should
be used by most error messages, especially be used by most error messages, especially
so that strings will be handled. so that strings will be handled.
@param code @param code
@param text @param text
@ -134,14 +134,14 @@ void ERRD_error(const char* text)
/** /**
ERRD_post_warning ERRD_post_warning
@brief Post a warning to the current status vector. @brief Post a warning to the current status vector.
@param status @param status
@param @param
**/ **/
bool ERRD_post_warning(const Firebird::Arg::StatusVector& v) bool ERRD_post_warning(const Firebird::Arg::StatusVector& v)
@ -155,7 +155,7 @@ bool ERRD_post_warning(const Firebird::Arg::StatusVector& v)
(status_vector[0] == isc_arg_gds && status_vector[1] == 0 && (status_vector[0] == isc_arg_gds && status_vector[1] == 0 &&
status_vector[2] != isc_arg_warning)) status_vector[2] != isc_arg_warning))
{ {
// this is a blank status vector // this is a blank status vector
status_vector[0] = isc_arg_gds; status_vector[0] = isc_arg_gds;
status_vector[1] = 0; status_vector[1] = 0;
status_vector[2] = isc_arg_end; status_vector[2] = isc_arg_end;
@ -163,7 +163,7 @@ bool ERRD_post_warning(const Firebird::Arg::StatusVector& v)
} }
else else
{ {
// find end of a status vector // find end of a status vector
int warning_indx = 0; int warning_indx = 0;
PARSE_STATUS(status_vector, indx, warning_indx); PARSE_STATUS(status_vector, indx, warning_indx);
if (indx) { if (indx) {
@ -178,21 +178,21 @@ bool ERRD_post_warning(const Firebird::Arg::StatusVector& v)
return true; return true;
} }
// not enough free space // not enough free space
return false; return false;
} }
/** /**
ERRD_post ERRD_post
@brief Post an error, copying any potentially @brief Post an error, copying any potentially
transient data before we punt. transient data before we punt.
@param statusVector @param statusVector
@param @param
**/ **/
void ERRD_post(const Firebird::Arg::StatusVector& v) void ERRD_post(const Firebird::Arg::StatusVector& v)
@ -204,22 +204,22 @@ void ERRD_post(const Firebird::Arg::StatusVector& v)
/** /**
internal_post internal_post
@brief Post an error, copying any potentially @brief Post an error, copying any potentially
transient data before we punt. transient data before we punt.
@param tmp_status @param tmp_status
@param @param
**/ **/
static void internal_post(const ISC_STATUS* tmp_status) static void internal_post(const ISC_STATUS* tmp_status)
{ {
ISC_STATUS* status_vector = JRD_get_thread_data()->tdbb_status_vector; ISC_STATUS* status_vector = JRD_get_thread_data()->tdbb_status_vector;
// calculate length of the status // calculate length of the status
int tmp_status_len = 0, warning_indx = 0; int tmp_status_len = 0, warning_indx = 0;
PARSE_STATUS(tmp_status, tmp_status_len, warning_indx); PARSE_STATUS(tmp_status, tmp_status_len, warning_indx);
fb_assert(warning_indx == 0); fb_assert(warning_indx == 0);
@ -228,7 +228,7 @@ static void internal_post(const ISC_STATUS* tmp_status)
(status_vector[0] == isc_arg_gds && status_vector[1] == 0 && (status_vector[0] == isc_arg_gds && status_vector[1] == 0 &&
status_vector[2] != isc_arg_warning)) status_vector[2] != isc_arg_warning))
{ {
// this is a blank status vector // this is a blank status vector
status_vector[0] = isc_arg_gds; status_vector[0] = isc_arg_gds;
status_vector[1] = isc_dsql_error; status_vector[1] = isc_dsql_error;
status_vector[2] = isc_arg_end; status_vector[2] = isc_arg_end;
@ -244,11 +244,11 @@ static void internal_post(const ISC_STATUS* tmp_status)
for (i = 0; i < ISC_STATUS_LENGTH; i++) for (i = 0; i < ISC_STATUS_LENGTH; i++)
{ {
if (status_vector[i] == isc_arg_end && i == status_len) { if (status_vector[i] == isc_arg_end && i == status_len) {
break; // end of argument list break; // end of argument list
} }
if (i && i == warning_indx) { if (i && i == warning_indx) {
break; // vector has no more errors break; // vector has no more errors
} }
if (status_vector[i] == tmp_status[1] && i && if (status_vector[i] == tmp_status[1] && i &&
@ -257,7 +257,7 @@ static void internal_post(const ISC_STATUS* tmp_status)
(memcmp(&status_vector[i], &tmp_status[1], (memcmp(&status_vector[i], &tmp_status[1],
sizeof(ISC_STATUS) * (tmp_status_len - 2)) == 0)) sizeof(ISC_STATUS) * (tmp_status_len - 2)) == 0))
{ {
// duplicate found // duplicate found
ERRD_punt(); ERRD_punt();
} }
} }
@ -272,7 +272,7 @@ static void internal_post(const ISC_STATUS* tmp_status)
ISC_STATUS_ARRAY warning_status; ISC_STATUS_ARRAY warning_status;
if (warning_indx) { if (warning_indx) {
// copy current warning(s) to a temp buffer // copy current warning(s) to a temp buffer
MOVE_CLEAR(warning_status, sizeof(warning_status)); MOVE_CLEAR(warning_status, sizeof(warning_status));
memcpy(warning_status, &status_vector[warning_indx], memcpy(warning_status, &status_vector[warning_indx],
sizeof(ISC_STATUS) * (ISC_STATUS_LENGTH - warning_indx)); sizeof(ISC_STATUS) * (ISC_STATUS_LENGTH - warning_indx));
@ -287,7 +287,7 @@ static void internal_post(const ISC_STATUS* tmp_status)
{ {
memcpy(&status_vector[err_status_len], tmp_status, sizeof(ISC_STATUS) * tmp_status_len); memcpy(&status_vector[err_status_len], tmp_status, sizeof(ISC_STATUS) * tmp_status_len);
ERR_make_permanent(&status_vector[err_status_len]); ERR_make_permanent(&status_vector[err_status_len]);
// copy current warning(s) to the status_vector // copy current warning(s) to the status_vector
if (warning_count && i + warning_count - 1 < ISC_STATUS_LENGTH) if (warning_count && i + warning_count - 1 < ISC_STATUS_LENGTH)
{ {
memcpy(&status_vector[i - 1], warning_status, memcpy(&status_vector[i - 1], warning_status,
@ -299,12 +299,12 @@ static void internal_post(const ISC_STATUS* tmp_status)
/** /**
ERRD_punt ERRD_punt
@brief Error stuff has been copied to @brief Error stuff has been copied to
status vector. Now punt. status vector. Now punt.
**/ **/
@ -317,11 +317,11 @@ void ERRD_punt(const ISC_STATUS* local)
UTLD_copy_status(local, tdbb->tdbb_status_vector); UTLD_copy_status(local, tdbb->tdbb_status_vector);
} }
// Save any strings in a permanent location // Save any strings in a permanent location
UTLD_save_status_strings(tdbb->tdbb_status_vector); UTLD_save_status_strings(tdbb->tdbb_status_vector);
// Give up whatever we were doing and return to the user. // Give up whatever we were doing and return to the user.
status_exception::raise(tdbb->tdbb_status_vector); status_exception::raise(tdbb->tdbb_status_vector);
} }

View File

@ -66,11 +66,11 @@ namespace
#include <stdio.h> #include <stdio.h>
/** /**
HSHD_debug HSHD_debug
@brief Print out the hash table for debugging. @brief Print out the hash table for debugging.
**/ **/
@ -78,13 +78,13 @@ void HSHD_debug()
{ {
Firebird::ReadLockGuard guard(hash_sync); Firebird::ReadLockGuard guard(hash_sync);
// dump each hash table entry // dump each hash table entry
for (SSHORT h = 0; h < HASH_SIZE; h++) for (SSHORT h = 0; h < HASH_SIZE; h++)
{ {
for (DSQL_SYM collision = hash_table()[h]; collision; for (DSQL_SYM collision = hash_table()[h]; collision;
collision = collision->sym_collision) collision = collision->sym_collision)
{ {
// check any homonyms first // check any homonyms first
fprintf(stderr, "Symbol type %d: %s %p\n", fprintf(stderr, "Symbol type %d: %s %p\n",
collision->sym_type, collision->sym_string, collision->sym_type, collision->sym_string,
collision->sym_dbb); collision->sym_dbb);
@ -102,13 +102,13 @@ void HSHD_debug()
/** /**
HSHD_finish HSHD_finish
@brief Remove symbols used by a particular database. @brief Remove symbols used by a particular database.
Don't bother to release them since their pools Don't bother to release them since their pools
will be released. will be released.
@param database @param database
@ -117,12 +117,12 @@ void HSHD_finish(const void* database)
{ {
Firebird::WriteLockGuard guard(hash_sync); Firebird::WriteLockGuard guard(hash_sync);
// check each hash table entry // check each hash table entry
for (SSHORT h = 0; h < HASH_SIZE; h++) for (SSHORT h = 0; h < HASH_SIZE; h++)
{ {
for (DSQL_SYM* collision = &hash_table()[h]; *collision;) for (DSQL_SYM* collision = &hash_table()[h]; *collision;)
{ {
// check any homonyms first // check any homonyms first
DSQL_SYM chain = *collision; DSQL_SYM chain = *collision;
for (DSQL_SYM* homptr = &chain->sym_homonym; *homptr;) for (DSQL_SYM* homptr = &chain->sym_homonym; *homptr;)
{ {
@ -138,7 +138,7 @@ void HSHD_finish(const void* database)
} }
} }
// now, see if the root entry has to go // now, see if the root entry has to go
if (chain->sym_dbb == database) if (chain->sym_dbb == database)
{ {
if (chain->sym_homonym) if (chain->sym_homonym)
@ -162,11 +162,11 @@ void HSHD_finish(const void* database)
/** /**
HSHD_insert HSHD_insert
@brief Insert a symbol into the hash table. @brief Insert a symbol into the hash table.
@param symbol @param symbol
@ -184,7 +184,7 @@ void HSHD_insert(DSQL_SYM symbol)
{ {
if ((!database || (database == old->sym_dbb)) && if ((!database || (database == old->sym_dbb)) &&
scompare(symbol->sym_string, symbol->sym_length, old->sym_string, scompare(symbol->sym_string, symbol->sym_length, old->sym_string,
old->sym_length)) old->sym_length))
{ {
symbol->sym_homonym = old->sym_homonym; symbol->sym_homonym = old->sym_homonym;
old->sym_homonym = symbol; old->sym_homonym = symbol;
@ -198,12 +198,12 @@ void HSHD_insert(DSQL_SYM symbol)
/** /**
HSHD_lookup HSHD_lookup
@brief Perform a string lookup against hash table. @brief Perform a string lookup against hash table.
Make sure to only return a symbol of the desired type. Make sure to only return a symbol of the desired type.
@param database @param database
@param string @param string
@ -229,7 +229,7 @@ DSQL_SYM HSHD_lookup(const void* database,
if ((database == symbol->sym_dbb) && if ((database == symbol->sym_dbb) &&
scompare(string, length, symbol->sym_string, symbol->sym_length)) scompare(string, length, symbol->sym_string, symbol->sym_length))
{ {
// Search for a symbol of the proper type // Search for a symbol of the proper type
while (symbol && symbol->sym_type != type) while (symbol && symbol->sym_type != type)
{ {
symbol = symbol->sym_homonym; symbol = symbol->sym_homonym;
@ -254,11 +254,11 @@ DSQL_SYM HSHD_lookup(const void* database,
/** /**
HSHD_remove HSHD_remove
@brief Remove a symbol from the hash table. @brief Remove a symbol from the hash table.
@param symbol @param symbol
@ -283,9 +283,9 @@ void HSHD_remove(DSQL_SYM symbol)
/** /**
HSHD_set_flag HSHD_set_flag
@brief Set a flag in all similar objects in a chain. This @brief Set a flag in all similar objects in a chain. This
is used primarily to mark relations, procedures and functions is used primarily to mark relations, procedures and functions
as deleted. The object must have the same name and as deleted. The object must have the same name and
@ -297,7 +297,7 @@ void HSHD_remove(DSQL_SYM symbol)
This is because there's no way at present for DSQL to tell This is because there's no way at present for DSQL to tell
if two databases as represented in DSQL are attachments to if two databases as represented in DSQL are attachments to
the same physical database. the same physical database.
@param database @param database
@param string @param string
@ -337,14 +337,14 @@ void HSHD_set_flag(const void* database,
if (symbol->sym_dbb && (database != symbol->sym_dbb) && if (symbol->sym_dbb && (database != symbol->sym_dbb) &&
scompare(string, length, symbol->sym_string, symbol->sym_length)) scompare(string, length, symbol->sym_string, symbol->sym_length))
{ {
// the symbol name matches and it's from a different database // the symbol name matches and it's from a different database
for (DSQL_SYM homonym = symbol; homonym; for (DSQL_SYM homonym = symbol; homonym;
homonym = homonym->sym_homonym) homonym = homonym->sym_homonym)
{ {
if (homonym->sym_type == type) if (homonym->sym_type == type)
{ {
// the homonym is of the correct type // the homonym is of the correct type
/* the next check is for the same relation or procedure ID, /* the next check is for the same relation or procedure ID,
which indicates that it MAY be the same relation or which indicates that it MAY be the same relation or
@ -381,14 +381,14 @@ void HSHD_set_flag(const void* database,
/** /**
hash
@brief Returns the hash function of a string.
@param hash
@param
@brief Returns the hash function of a string.
@param
@param
**/ **/
static USHORT hash(const SCHAR* string, USHORT length) static USHORT hash(const SCHAR* string, USHORT length)
@ -406,13 +406,13 @@ static USHORT hash(const SCHAR* string, USHORT length)
/** /**
remove_symbol remove_symbol
@brief Given the address of a collision, @brief Given the address of a collision,
remove a symbol from the collision remove a symbol from the collision
and homonym linked lists. and homonym linked lists.
@param collision @param collision
@param symbol @param symbol
@ -450,15 +450,15 @@ static bool remove_symbol(DSQL_SYM* collision, DSQL_SYM symbol)
/** /**
scompare scompare
@brief Compare two symbolic strings @brief Compare two symbolic strings
The character set for these strings is either ASCII or The character set for these strings is either ASCII or
Unicode in UTF format. Unicode in UTF format.
Symbols are case-significant - so no uppercase operation Symbols are case-significant - so no uppercase operation
is performed. is performed.
@param string1 @param string1
@param length1 @param length1

View File

@ -138,7 +138,7 @@ static const TOK tokens[] =
{CURRENT_USER, "CURRENT_USER", 2, false}, {CURRENT_USER, "CURRENT_USER", 2, false},
{CURSOR, "CURSOR", 1, false}, {CURSOR, "CURSOR", 1, false},
{DATABASE, "DATABASE", 1, false}, {DATABASE, "DATABASE", 1, false},
{DATA, "DATA", 2, true}, {DATA, "DATA", 2, true},
{DATE, "DATE", 1, false}, {DATE, "DATE", 1, false},
{DATEADD, "DATEADD", 2, false}, {DATEADD, "DATEADD", 2, false},
{DATEDIFF, "DATEDIFF", 2, false}, {DATEDIFF, "DATEDIFF", 2, false},

View File

@ -40,11 +40,11 @@ static void post_error(const Arg::StatusVector&);
/** /**
MOVD_move MOVD_move
@brief Move (and possible convert) something to something else. @brief Move (and possible convert) something to something else.
@param from @param from
@param to @param to
@ -58,14 +58,14 @@ void MOVD_move(const dsc* from, dsc* to)
/** /**
post_error post_error
@brief A conversion error occurred. Complain. @brief A conversion error occurred. Complain.
@param status @param status
@param @param
**/ **/
static void post_error(const Arg::StatusVector& v) static void post_error(const Arg::StatusVector& v)

View File

@ -370,7 +370,7 @@ dsql_ctx* PASS1_make_context(CompiledStatement* statement, const dsql_nod* relat
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-204) << ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-204) <<
Arg::Gds(isc_dsql_procedure_err) << Arg::Gds(isc_dsql_procedure_err) <<
Arg::Gds(isc_random) << Arg::Str(relation_name->str_data) << Arg::Gds(isc_random) << Arg::Str(relation_name->str_data) <<
Arg::Gds(isc_dsql_line_col_error) << Arg::Num(relation_node->nod_line) << Arg::Gds(isc_dsql_line_col_error) << Arg::Num(relation_node->nod_line) <<
Arg::Num(relation_node->nod_column)); Arg::Num(relation_node->nod_column));
} }
} }
@ -390,7 +390,7 @@ dsql_ctx* PASS1_make_context(CompiledStatement* statement, const dsql_nod* relat
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-204) << ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-204) <<
Arg::Gds(isc_dsql_relation_err) << Arg::Gds(isc_dsql_relation_err) <<
Arg::Gds(isc_random) << Arg::Str(relation_name->str_data) << Arg::Gds(isc_random) << Arg::Str(relation_name->str_data) <<
Arg::Gds(isc_dsql_line_col_error) << Arg::Num(relation_node->nod_line) << Arg::Gds(isc_dsql_line_col_error) << Arg::Num(relation_node->nod_line) <<
Arg::Num(relation_node->nod_column)); Arg::Num(relation_node->nod_column));
} }
} }
@ -398,7 +398,7 @@ dsql_ctx* PASS1_make_context(CompiledStatement* statement, const dsql_nod* relat
if (procedure && !procedure->prc_out_count) { if (procedure && !procedure->prc_out_count) {
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-84) << ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-84) <<
Arg::Gds(isc_dsql_procedure_use_err) << Arg::Str(relation_name->str_data) << Arg::Gds(isc_dsql_procedure_use_err) << Arg::Str(relation_name->str_data) <<
Arg::Gds(isc_dsql_line_col_error) << Arg::Num(relation_node->nod_line) << Arg::Gds(isc_dsql_line_col_error) << Arg::Num(relation_node->nod_line) <<
Arg::Num(relation_node->nod_column)); Arg::Num(relation_node->nod_column));
} }
@ -434,14 +434,14 @@ dsql_ctx* PASS1_make_context(CompiledStatement* statement, const dsql_nod* relat
string = (dsql_str*) relation_node->nod_arg[e_rln_alias]; string = (dsql_str*) relation_node->nod_arg[e_rln_alias];
} }
if (string) if (string)
{ {
context->ctx_internal_alias = (TEXT*) string->str_data; context->ctx_internal_alias = (TEXT*) string->str_data;
} }
DEV_BLKCHK(string, dsql_type_str); DEV_BLKCHK(string, dsql_type_str);
if (statement->req_alias_relation_prefix && !(relation_node->nod_type == nod_derived_table)) if (statement->req_alias_relation_prefix && !(relation_node->nod_type == nod_derived_table))
{ {
if (string) { if (string) {
string = pass1_alias_concat(statement->req_alias_relation_prefix, string); string = pass1_alias_concat(statement->req_alias_relation_prefix, string);
} }
@ -774,9 +774,9 @@ dsql_nod* PASS1_node(CompiledStatement* statement, dsql_nod* input)
{ {
cte->nod_flags |= NOD_DT_CTE_USED; cte->nod_flags |= NOD_DT_CTE_USED;
if ((statement->req_flags & REQ_CTE_recursive) && if ((statement->req_flags & REQ_CTE_recursive) &&
statement->req_curr_ctes.hasData() && statement->req_curr_ctes.hasData() &&
(statement->req_curr_ctes.object() == cte)) (statement->req_curr_ctes.object() == cte))
{ {
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) <<
// Recursive CTE member (%s) can refer itself only in FROM clause // Recursive CTE member (%s) can refer itself only in FROM clause
@ -795,7 +795,7 @@ dsql_nod* PASS1_node(CompiledStatement* statement, dsql_nod* input)
dsql_nod* const select_expr = cte->nod_arg[e_derived_table_rse]; dsql_nod* const select_expr = cte->nod_arg[e_derived_table_rse];
dsql_nod* const query = select_expr->nod_arg[e_sel_query_spec]; dsql_nod* const query = select_expr->nod_arg[e_sel_query_spec];
const bool isRecursive = (query->nod_type == nod_list) && const bool isRecursive = (query->nod_type == nod_list) &&
(query->nod_flags & NOD_UNION_RECURSIVE); (query->nod_flags & NOD_UNION_RECURSIVE);
dsql_str* cte_name = (dsql_str*) cte->nod_arg[e_derived_table_alias]; dsql_str* cte_name = (dsql_str*) cte->nod_arg[e_derived_table_alias];
@ -1751,7 +1751,7 @@ dsql_nod* PASS1_statement(CompiledStatement* statement, dsql_nod* input)
node = MAKE_node(input->nod_type, input->nod_count); node = MAKE_node(input->nod_type, input->nod_count);
node->nod_arg[e_exec_stmt_sql] = node->nod_arg[e_exec_stmt_sql] =
PASS1_node(statement, input->nod_arg[e_exec_stmt_sql]); PASS1_node(statement, input->nod_arg[e_exec_stmt_sql]);
node->nod_arg[e_exec_stmt_inputs] = node->nod_arg[e_exec_stmt_inputs] =
PASS1_node(statement, input->nod_arg[e_exec_stmt_inputs]); PASS1_node(statement, input->nod_arg[e_exec_stmt_inputs]);
// check params names uniqueness, if present // check params names uniqueness, if present
@ -1765,7 +1765,7 @@ dsql_nod* PASS1_statement(CompiledStatement* statement, dsql_nod* input)
for (int i = 0; i < cnt; i++) for (int i = 0; i < cnt; i++)
{ {
const dsql_str* name = (dsql_str*) prm[i]->nod_arg[e_named_param_name]; const dsql_str* name = (dsql_str*) prm[i]->nod_arg[e_named_param_name];
size_t pos; size_t pos;
if (names.find(name->str_data, pos)) { if (names.find(name->str_data, pos)) {
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-637) << ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-637) <<
@ -1776,9 +1776,9 @@ dsql_nod* PASS1_statement(CompiledStatement* statement, dsql_nod* input)
} }
} }
node->nod_arg[e_exec_stmt_outputs] = node->nod_arg[e_exec_stmt_outputs] =
PASS1_node(statement, input->nod_arg[e_exec_stmt_outputs]); PASS1_node(statement, input->nod_arg[e_exec_stmt_outputs]);
if (input->nod_arg[e_exec_stmt_proc_block]) if (input->nod_arg[e_exec_stmt_proc_block])
{ {
statement->req_loop_level++; statement->req_loop_level++;
@ -2464,14 +2464,14 @@ static dsql_nod* ambiguity_check(CompiledStatement* statement, dsql_nod* node,
delete node; delete node;
} }
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-204) << ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-204) <<
Arg::Gds(isc_dsql_ambiguous_field_name) << Arg::Str(buffer) << Arg::Gds(isc_dsql_ambiguous_field_name) << Arg::Str(buffer) <<
Arg::Str(++p) << Arg::Str(++p) <<
Arg::Gds(isc_random) << Arg::Str(name->str_data)); Arg::Gds(isc_random) << Arg::Str(name->str_data));
return NULL; return NULL;
} }
ERRD_post_warning(Arg::Warning(isc_sqlwarn) << Arg::Num(204) << ERRD_post_warning(Arg::Warning(isc_sqlwarn) << Arg::Num(204) <<
Arg::Warning(isc_dsql_ambiguous_field_name) << Arg::Str(buffer) << Arg::Warning(isc_dsql_ambiguous_field_name) << Arg::Str(buffer) <<
Arg::Str(++p) << Arg::Str(++p) <<
Arg::Gds(isc_random) << Arg::Str(name->str_data)); Arg::Gds(isc_random) << Arg::Str(name->str_data));
@ -2697,7 +2697,7 @@ static void field_appears_once(const dsql_nod* fields, const dsql_nod* old_field
{ {
const Firebird::MetaName& n1 = const Firebird::MetaName& n1 =
reinterpret_cast<dsql_fld*>(elem1->nod_arg[e_fld_field])->fld_name; reinterpret_cast<dsql_fld*>(elem1->nod_arg[e_fld_field])->fld_name;
for (int j = i + 1; j < fields->nod_count; ++j) for (int j = i + 1; j < fields->nod_count; ++j)
{ {
const dsql_nod* elem2 = fields->nod_arg[j]; const dsql_nod* elem2 = fields->nod_arg[j];
@ -2708,14 +2708,14 @@ static void field_appears_once(const dsql_nod* fields, const dsql_nod* old_field
{ {
const Firebird::MetaName& n2 = const Firebird::MetaName& n2 =
reinterpret_cast<dsql_fld*>(elem2->nod_arg[e_fld_field])->fld_name; reinterpret_cast<dsql_fld*>(elem2->nod_arg[e_fld_field])->fld_name;
if (n1 == n2) if (n1 == n2)
{ {
const dsql_ctx* tmp_ctx = (dsql_ctx*) elem2->nod_arg[e_fld_context]; const dsql_ctx* tmp_ctx = (dsql_ctx*) elem2->nod_arg[e_fld_context];
const dsql_rel* bad_rel = tmp_ctx ? tmp_ctx->ctx_relation : 0; const dsql_rel* bad_rel = tmp_ctx ? tmp_ctx->ctx_relation : 0;
field_duplication(bad_rel ? bad_rel->rel_name.c_str() : 0, field_duplication(bad_rel ? bad_rel->rel_name.c_str() : 0,
n2.c_str(), n2.c_str(),
is_insert ? old_fields->nod_arg[j]: old_fields->nod_arg[j]->nod_arg[1], is_insert ? old_fields->nod_arg[j]: old_fields->nod_arg[j]->nod_arg[1],
statement); statement);
} }
} }
@ -2751,9 +2751,9 @@ static void field_duplication(const TEXT* qualifier_name, const TEXT* field_name
} }
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-206) << ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-206) <<
Arg::Gds(isc_dsql_no_dup_name) << Arg::Str(field_name) << Arg::Gds(isc_dsql_no_dup_name) << Arg::Str(field_name) <<
Arg::Str(statement) << Arg::Str(statement) <<
Arg::Gds(isc_dsql_line_col_error) << Arg::Num(flawed_node->nod_line) << Arg::Gds(isc_dsql_line_col_error) << Arg::Num(flawed_node->nod_line) <<
Arg::Num(flawed_node->nod_column)); Arg::Num(flawed_node->nod_column));
} }
@ -2789,14 +2789,14 @@ static void field_unknown(const TEXT* qualifier_name, const TEXT* field_name,
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-206) << ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-206) <<
Arg::Gds(isc_dsql_field_err) << Arg::Gds(isc_dsql_field_err) <<
Arg::Gds(isc_random) << Arg::Str(field_name) << Arg::Gds(isc_random) << Arg::Str(field_name) <<
Arg::Gds(isc_dsql_line_col_error) << Arg::Num(flawed_node->nod_line) << Arg::Gds(isc_dsql_line_col_error) << Arg::Num(flawed_node->nod_line) <<
Arg::Num(flawed_node->nod_column)); Arg::Num(flawed_node->nod_column));
} }
else else
{ {
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-206) << ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-206) <<
Arg::Gds(isc_dsql_field_err) << Arg::Gds(isc_dsql_field_err) <<
Arg::Gds(isc_dsql_line_col_error) << Arg::Num(flawed_node->nod_line) << Arg::Gds(isc_dsql_line_col_error) << Arg::Num(flawed_node->nod_line) <<
Arg::Num(flawed_node->nod_column)); Arg::Num(flawed_node->nod_column));
} }
} }
@ -2964,14 +2964,14 @@ static bool get_object_and_field(const dsql_nod* node,
const dsql_ctx* context = reinterpret_cast<dsql_ctx*>(node->nod_arg[e_fld_context]); const dsql_ctx* context = reinterpret_cast<dsql_ctx*>(node->nod_arg[e_fld_context]);
DEV_BLKCHK(context, dsql_type_ctx); DEV_BLKCHK(context, dsql_type_ctx);
if (context->ctx_relation) if (context->ctx_relation)
*obj_name = context->ctx_relation->rel_name.c_str(); *obj_name = context->ctx_relation->rel_name.c_str();
else if (context->ctx_procedure) else if (context->ctx_procedure)
*obj_name = context->ctx_procedure->prc_name.c_str(); *obj_name = context->ctx_procedure->prc_name.c_str();
else else
*obj_name = NULL; *obj_name = NULL;
*fld_name = reinterpret_cast<dsql_fld*>(node->nod_arg[e_fld_field])->fld_name; *fld_name = reinterpret_cast<dsql_fld*>(node->nod_arg[e_fld_field])->fld_name;
return obj_name && fld_name; return obj_name && fld_name;
@ -3361,9 +3361,9 @@ static bool node_match(const dsql_nod* node1, const dsql_nod* node2,
} }
// Handle derived fields. // Handle derived fields.
if ((node1->nod_type == nod_derived_field) || (node2->nod_type == nod_derived_field)) if ((node1->nod_type == nod_derived_field) || (node2->nod_type == nod_derived_field))
{ {
if ((node1->nod_type == nod_derived_field) && (node2->nod_type == nod_derived_field)) if ((node1->nod_type == nod_derived_field) && (node2->nod_type == nod_derived_field))
{ {
const USHORT scope_level1 = (USHORT)(U_IPTR)node1->nod_arg[e_derived_field_scope]; const USHORT scope_level1 = (USHORT)(U_IPTR)node1->nod_arg[e_derived_field_scope];
const USHORT scope_level2 = (USHORT)(U_IPTR)node2->nod_arg[e_derived_field_scope]; const USHORT scope_level2 = (USHORT)(U_IPTR)node2->nod_arg[e_derived_field_scope];
@ -3474,7 +3474,7 @@ static bool node_match(const dsql_nod* node1, const dsql_nod* node2,
(node1->nod_type == nod_agg_total2) || (node1->nod_type == nod_agg_total2) ||
(node1->nod_type == nod_agg_average2) || (node1->nod_type == nod_agg_average2) ||
(node1->nod_type == nod_agg_average) || (node1->nod_type == nod_agg_average) ||
(node1->nod_type == nod_agg_list)) (node1->nod_type == nod_agg_list))
{ {
if ((node1->nod_flags & NOD_AGG_DISTINCT) != if ((node1->nod_flags & NOD_AGG_DISTINCT) !=
(node2->nod_flags & NOD_AGG_DISTINCT)) (node2->nod_flags & NOD_AGG_DISTINCT))
@ -3900,7 +3900,7 @@ static dsql_nod* pass1_constant( CompiledStatement* statement, dsql_nod* input)
*/ */
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-204) << ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-204) <<
Arg::Gds(isc_dsql_datatype_err) << Arg::Gds(isc_dsql_datatype_err) <<
Arg::Gds(isc_collation_not_found) << Arg::Str(global_temp_collation_name->str_data) << Arg::Gds(isc_collation_not_found) << Arg::Str(global_temp_collation_name->str_data) <<
Arg::Str(resolved->intlsym_name)); Arg::Str(resolved->intlsym_name));
} }
resolved = resolved_collation; resolved = resolved_collation;
@ -3925,7 +3925,7 @@ static dsql_nod* pass1_constant( CompiledStatement* statement, dsql_nod* input)
adjust = sizeof(USHORT); adjust = sizeof(USHORT);
else if (constant->nod_desc.dsc_dtype == dtype_cstring) else if (constant->nod_desc.dsc_dtype == dtype_cstring)
adjust = 1; adjust = 1;
constant->nod_desc.dsc_length -= adjust; constant->nod_desc.dsc_length -= adjust;
CharSet* charSet = INTL_charset_lookup(tdbb, INTL_GET_CHARSET(&constant->nod_desc)); CharSet* charSet = INTL_charset_lookup(tdbb, INTL_GET_CHARSET(&constant->nod_desc));
@ -4007,7 +4007,7 @@ static dsql_ctx* pass1_cursor_context( CompiledStatement* statement, const dsql_
{ {
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-504) << ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-504) <<
Arg::Gds(isc_dsql_cursor_err) << Arg::Gds(isc_dsql_cursor_err) <<
Arg::Gds(isc_dsql_cursor_rel_ambiguous) << Arg::Str(rname->str_data) << Arg::Gds(isc_dsql_cursor_rel_ambiguous) << Arg::Str(rname->str_data) <<
Arg::Str(string->str_data)); Arg::Str(string->str_data));
} }
else else
@ -4027,7 +4027,7 @@ static dsql_ctx* pass1_cursor_context( CompiledStatement* statement, const dsql_
{ {
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-504) << ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-504) <<
Arg::Gds(isc_dsql_cursor_err) << Arg::Gds(isc_dsql_cursor_err) <<
Arg::Gds(isc_dsql_cursor_rel_not_found) << Arg::Str(rname->str_data) << Arg::Gds(isc_dsql_cursor_rel_not_found) << Arg::Str(rname->str_data) <<
Arg::Str(string->str_data)); Arg::Str(string->str_data));
} }
@ -4242,7 +4242,7 @@ static dsql_nod* pass1_dbkey( CompiledStatement* statement, dsql_nod* input)
return ambiguity_check(statement, node, MAKE_cstring("RDB$DB_KEY"), contexts); return ambiguity_check(statement, node, MAKE_cstring("RDB$DB_KEY"), contexts);
} }
} }
else else
{ {
const bool cfgRlxAlias = Config::getRelaxedAliasChecking(); const bool cfgRlxAlias = Config::getRelaxedAliasChecking();
bool rlxAlias = false; bool rlxAlias = false;
@ -4280,7 +4280,7 @@ static dsql_nod* pass1_dbkey( CompiledStatement* statement, dsql_nod* input)
if (rlxAlias == cfgRlxAlias) if (rlxAlias == cfgRlxAlias)
break; break;
rlxAlias = cfgRlxAlias; rlxAlias = cfgRlxAlias;
} }
} }
@ -4372,7 +4372,7 @@ static dsql_nod* pass1_delete( CompiledStatement* statement, dsql_nod* input)
pass1_relproc_is_recursive pass1_relproc_is_recursive
@brief check if table reference is recursive i.e. its name is equal @brief check if table reference is recursive i.e. its name is equal
to the name of current processing CTE to the name of current processing CTE
@param statement @param statement
@ -4404,7 +4404,7 @@ static bool pass1_relproc_is_recursive(CompiledStatement* statement, dsql_nod* i
const dsql_nod* curr_cte = statement->req_curr_ctes.object(); const dsql_nod* curr_cte = statement->req_curr_ctes.object();
const dsql_str* cte_name = (dsql_str*) curr_cte->nod_arg[e_derived_table_alias]; const dsql_str* cte_name = (dsql_str*) curr_cte->nod_arg[e_derived_table_alias];
const bool recursive = (cte_name->str_length == rel_name->str_length) && const bool recursive = (cte_name->str_length == rel_name->str_length) &&
(strncmp(rel_name->str_data, cte_name->str_data, cte_name->str_length) == 0); (strncmp(rel_name->str_data, cte_name->str_data, cte_name->str_length) == 0);
if (recursive) { if (recursive) {
@ -4422,7 +4422,7 @@ static bool pass1_relproc_is_recursive(CompiledStatement* statement, dsql_nod* i
@brief check if join have recursive members. If found remove this member @brief check if join have recursive members. If found remove this member
from join and return its boolean (to be added into WHERE clause). from join and return its boolean (to be added into WHERE clause).
We must remove member only if it is a table reference. We must remove member only if it is a table reference.
Punt if recursive reference is found in outer join or more than one Punt if recursive reference is found in outer join or more than one
recursive reference is found recursive reference is found
@param statement @param statement
@ -4433,7 +4433,7 @@ static dsql_nod* pass1_join_is_recursive(CompiledStatement* statement, dsql_nod*
{ {
const NOD_TYPE join_type = input->nod_arg[e_join_type]->nod_type; const NOD_TYPE join_type = input->nod_arg[e_join_type]->nod_type;
bool remove = false; bool remove = false;
bool leftRecursive = false; bool leftRecursive = false;
dsql_nod* leftBool = NULL; dsql_nod* leftBool = NULL;
dsql_nod** join_table = &input->nod_arg[e_join_left_rel]; dsql_nod** join_table = &input->nod_arg[e_join_left_rel];
@ -4508,8 +4508,8 @@ static dsql_nod* pass1_join_is_recursive(CompiledStatement* statement, dsql_nod*
pass1_rse_is_recursive pass1_rse_is_recursive
@brief check if rse is recursive. If recursive reference is a table @brief check if rse is recursive. If recursive reference is a table
in the FROM list remove it. If recursive reference is a part of in the FROM list remove it. If recursive reference is a part of
join add join boolean (returned by pass1_join_is_recursive) to the join add join boolean (returned by pass1_join_is_recursive) to the
WHERE clause. Punt if more than one recursive reference is found WHERE clause. Punt if more than one recursive reference is found
@param statement @param statement
@ -4523,7 +4523,7 @@ static bool pass1_rse_is_recursive(CompiledStatement* statement, dsql_nod* input
dsql_nod* table_list = input->nod_arg[e_qry_from]; dsql_nod* table_list = input->nod_arg[e_qry_from];
dsql_nod** table = table_list->nod_arg; dsql_nod** table = table_list->nod_arg;
dsql_nod** end = table_list->nod_arg + table_list->nod_count; dsql_nod** end = table_list->nod_arg + table_list->nod_count;
bool found = false; bool found = false;
for (dsql_nod** prev = table; table < end; table++) for (dsql_nod** prev = table; table < end; table++)
{ {
@ -4558,7 +4558,7 @@ static bool pass1_rse_is_recursive(CompiledStatement* statement, dsql_nod* input
} }
found = true; found = true;
input->nod_arg[e_qry_where] = input->nod_arg[e_qry_where] =
compose(input->nod_arg[e_qry_where], joinBool, nod_and); compose(input->nod_arg[e_qry_where], joinBool, nod_and);
} }
} }
@ -4582,11 +4582,11 @@ static bool pass1_rse_is_recursive(CompiledStatement* statement, dsql_nod* input
@brief Process derived table which can be recursive CTE @brief Process derived table which can be recursive CTE
If it is non-recursive return input node unchanged If it is non-recursive return input node unchanged
If it is recursive return new derived table which is an union of If it is recursive return new derived table which is an union of
union of anchor (non-recursive) queries and union of recursive union of anchor (non-recursive) queries and union of recursive
queries. Check recursive queries to satisfy various criterias. queries. Check recursive queries to satisfy various criterias.
Note that our parser is right-to-left therefore recursive members Note that our parser is right-to-left therefore recursive members
will be first in union's list will be first in union's list
@param statement @param statement
@ -4628,19 +4628,19 @@ static dsql_nod* pass1_recursive_cte(CompiledStatement* statement, dsql_nod* inp
if (rse->nod_arg[e_qry_distinct]) { if (rse->nod_arg[e_qry_distinct]) {
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) <<
// Recursive member of CTE '%s' has %s clause // Recursive member of CTE '%s' has %s clause
Arg::Gds(isc_dsql_cte_wrong_clause) << Arg::Str(cte_alias->str_data) << Arg::Gds(isc_dsql_cte_wrong_clause) << Arg::Str(cte_alias->str_data) <<
Arg::Str("DISTINCT")); Arg::Str("DISTINCT"));
} }
if (rse->nod_arg[e_qry_group]) { if (rse->nod_arg[e_qry_group]) {
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) <<
// Recursive member of CTE '%s' has %s clause // Recursive member of CTE '%s' has %s clause
Arg::Gds(isc_dsql_cte_wrong_clause) << Arg::Str(cte_alias->str_data) << Arg::Gds(isc_dsql_cte_wrong_clause) << Arg::Str(cte_alias->str_data) <<
Arg::Str("GROUP BY")); Arg::Str("GROUP BY"));
} }
if (rse->nod_arg[e_qry_having]) { if (rse->nod_arg[e_qry_having]) {
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) <<
// Recursive member of CTE '%s' has %s clause // Recursive member of CTE '%s' has %s clause
Arg::Gds(isc_dsql_cte_wrong_clause) << Arg::Str(cte_alias->str_data) << Arg::Gds(isc_dsql_cte_wrong_clause) << Arg::Str(cte_alias->str_data) <<
Arg::Str("HAVING")); Arg::Str("HAVING"));
} }
// hvlad: we need also forbid any aggregate function here // hvlad: we need also forbid any aggregate function here
@ -4675,9 +4675,9 @@ static dsql_nod* pass1_recursive_cte(CompiledStatement* statement, dsql_nod* inp
// Non-recursive member is missing in CTE '%s' // Non-recursive member is missing in CTE '%s'
Arg::Gds(isc_dsql_cte_miss_nonrecursive) << Arg::Str(cte_alias->str_data)); Arg::Gds(isc_dsql_cte_miss_nonrecursive) << Arg::Str(cte_alias->str_data));
} }
qry = recursive_rse; qry = recursive_rse;
dsql_nod* list = 0; dsql_nod* list = 0;
while (qry->nod_arg[0] != anchor_rse) while (qry->nod_arg[0] != anchor_rse)
{ {
list = qry; list = qry;
@ -4698,7 +4698,7 @@ static dsql_nod* pass1_recursive_cte(CompiledStatement* statement, dsql_nod* inp
dsql_nod* select = MAKE_node(nod_select_expr, e_sel_count); dsql_nod* select = MAKE_node(nod_select_expr, e_sel_count);
select->nod_arg[e_sel_query_spec] = union_node; select->nod_arg[e_sel_query_spec] = union_node;
select->nod_arg[e_sel_order] = select->nod_arg[e_sel_rows] = select->nod_arg[e_sel_order] = select->nod_arg[e_sel_rows] =
select->nod_arg[e_sel_with_list] = NULL; select->nod_arg[e_sel_with_list] = NULL;
dsql_nod* node = MAKE_node(nod_derived_table, e_derived_table_count); dsql_nod* node = MAKE_node(nod_derived_table, e_derived_table_count);
@ -4799,14 +4799,14 @@ static dsql_nod* pass1_derived_table(CompiledStatement* statement, dsql_nod* inp
for (DsqlContextStack::iterator stack(*statement->req_context); stack.hasData(); ++stack) for (DsqlContextStack::iterator stack(*statement->req_context); stack.hasData(); ++stack)
{ {
dsql_ctx* local_context = stack.object(); dsql_ctx* local_context = stack.object();
if ((local_context->ctx_scope_level < statement->req_scope_level) || if ((local_context->ctx_scope_level < statement->req_scope_level) ||
(local_context->ctx_flags & CTX_system)) (local_context->ctx_flags & CTX_system))
{ {
temp.push(local_context); temp.push(local_context);
} }
} }
dsql_ctx* baseContext = NULL; dsql_ctx* baseContext = NULL;
if (temp.hasData()) { if (temp.hasData()) {
baseContext = temp.object(); baseContext = temp.object();
} }
statement->req_context = &temp; statement->req_context = &temp;
@ -4815,20 +4815,20 @@ static dsql_nod* pass1_derived_table(CompiledStatement* statement, dsql_nod* inp
dsql_nod* const select_expr = input->nod_arg[e_derived_table_rse]; dsql_nod* const select_expr = input->nod_arg[e_derived_table_rse];
dsql_nod* query = select_expr->nod_arg[e_sel_query_spec]; dsql_nod* query = select_expr->nod_arg[e_sel_query_spec];
dsql_nod* rse = NULL; dsql_nod* rse = NULL;
const bool isRecursive = const bool isRecursive =
(query->nod_type == nod_list) && (query->nod_flags & NOD_UNION_RECURSIVE); (query->nod_type == nod_list) && (query->nod_flags & NOD_UNION_RECURSIVE);
USHORT recursive_map_ctx = 0; USHORT recursive_map_ctx = 0;
if (isRecursive) if (isRecursive)
{ {
// Create dummy, non-recursive select statement by doing a union of // Create dummy, non-recursive select statement by doing a union of
// one, non-recursive member. The dummy will be replaced at the end // one, non-recursive member. The dummy will be replaced at the end
// of this function. // of this function.
query->nod_count = 1; query->nod_count = 1;
query->nod_flags &= ~NOD_UNION_RECURSIVE; query->nod_flags &= ~NOD_UNION_RECURSIVE;
dsql_ctx* baseUnionCtx = statement->req_union_context.hasData() ? dsql_ctx* baseUnionCtx = statement->req_union_context.hasData() ?
statement->req_union_context.object() : NULL; statement->req_union_context.object() : NULL;
// reserve extra context number for map's secondary context // reserve extra context number for map's secondary context
@ -4842,13 +4842,13 @@ static dsql_nod* pass1_derived_table(CompiledStatement* statement, dsql_nod* inp
query->nod_count = 2; query->nod_count = 2;
query->nod_flags |= NOD_UNION_RECURSIVE; query->nod_flags |= NOD_UNION_RECURSIVE;
while (statement->req_union_context.hasData() && while (statement->req_union_context.hasData() &&
statement->req_union_context.object() != baseUnionCtx) statement->req_union_context.object() != baseUnionCtx)
{ {
statement->req_union_context.pop(); statement->req_union_context.pop();
} }
} }
else else
{ {
// AB: 2005-01-06 // AB: 2005-01-06
// If our derived table contains a single query with a sub-select buried // If our derived table contains a single query with a sub-select buried
@ -5014,7 +5014,7 @@ static dsql_nod* pass1_derived_table(CompiledStatement* statement, dsql_nod* inp
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) <<
Arg::Gds(isc_dsql_command_err) << Arg::Gds(isc_dsql_command_err) <<
Arg::Gds(isc_dsql_derived_field_unnamed) << Arg::Num(count + 1) << Arg::Gds(isc_dsql_derived_field_unnamed) << Arg::Num(count + 1) <<
Arg::Str(aliasname)); Arg::Str(aliasname));
} }
} }
@ -5033,7 +5033,7 @@ static dsql_nod* pass1_derived_table(CompiledStatement* statement, dsql_nod* inp
// column %s was specified multiple times for derived table %s // column %s was specified multiple times for derived table %s
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) <<
Arg::Gds(isc_dsql_command_err) << Arg::Gds(isc_dsql_command_err) <<
Arg::Gds(isc_dsql_derived_field_dup_name) << Arg::Str(name1->str_data) << Arg::Gds(isc_dsql_derived_field_dup_name) << Arg::Str(name1->str_data) <<
Arg::Str(aliasname)); Arg::Str(aliasname));
} }
} }
@ -5063,7 +5063,7 @@ static dsql_nod* pass1_derived_table(CompiledStatement* statement, dsql_nod* inp
temp.clear(); temp.clear();
rse->nod_arg[e_rse_items] = context->ctx_rse->nod_arg[e_rse_items]; rse->nod_arg[e_rse_items] = context->ctx_rse->nod_arg[e_rse_items];
dsql_nod* node2 = MAKE_node(nod_derived_table, e_derived_table_count); dsql_nod* node2 = MAKE_node(nod_derived_table, e_derived_table_count);
*node2 = *node; *node2 = *node;
node2->nod_arg[e_derived_table_rse] = rse; node2->nod_arg[e_derived_table_rse] = rse;
@ -5076,12 +5076,12 @@ static dsql_nod* pass1_derived_table(CompiledStatement* statement, dsql_nod* inp
statement->req_context = req_base; statement->req_context = req_base;
// mark union's map context as recursive and assign // mark union's map context as recursive and assign
// secondary context number to it // secondary context number to it
dsql_nod* items = rse->nod_arg[e_rse_items]; dsql_nod* items = rse->nod_arg[e_rse_items];
dsql_nod* map_item = items->nod_arg[0]; dsql_nod* map_item = items->nod_arg[0];
if (map_item->nod_type == nod_derived_field) { if (map_item->nod_type == nod_derived_field) {
map_item = map_item->nod_arg[e_alias_value]; map_item = map_item->nod_arg[e_alias_value];
} }
dsql_ctx* map_context = (dsql_ctx*) map_item->nod_arg[e_map_context]; dsql_ctx* map_context = (dsql_ctx*) map_item->nod_arg[e_map_context];
@ -5348,7 +5348,7 @@ static dsql_nod* pass1_field(CompiledStatement* statement, dsql_nod* input,
bool resolve_by_alias = true; bool resolve_by_alias = true;
const bool relaxedAliasChecking = Config::getRelaxedAliasChecking(); const bool relaxedAliasChecking = Config::getRelaxedAliasChecking();
while (true) while (true)
{ {
// AB: Loop through the scope_levels starting by its own. // AB: Loop through the scope_levels starting by its own.
bool done = false; bool done = false;
@ -5371,7 +5371,7 @@ static dsql_nod* pass1_field(CompiledStatement* statement, dsql_nod* input,
continue; continue;
} }
dsql_fld* field = resolve_context(statement, qualifier, context, is_check_constraint, dsql_fld* field = resolve_context(statement, qualifier, context, is_check_constraint,
resolve_by_alias); resolve_by_alias);
// AB: When there's no relation and no procedure then we have a derived table. // AB: When there's no relation and no procedure then we have a derived table.
@ -5428,7 +5428,7 @@ static dsql_nod* pass1_field(CompiledStatement* statement, dsql_nod* input,
if (field || using_field) { if (field || using_field) {
// Intercept any reference to a field with datatype that // Intercept any reference to a field with datatype that
// did not exist prior to V6 and post an error // did not exist prior to V6 and post an error
if (statement->req_client_dialect <= SQL_DIALECT_V5 && field && if (statement->req_client_dialect <= SQL_DIALECT_V5 && field &&
(field->fld_dtype == dtype_sql_date || (field->fld_dtype == dtype_sql_date ||
field->fld_dtype == dtype_sql_time || field->fld_dtype == dtype_sql_time ||
@ -6228,7 +6228,7 @@ static dsql_nod* pass1_group_by_list(CompiledStatement* statement, dsql_nod* inp
DEV_BLKCHK(*ptr, dsql_type_nod); DEV_BLKCHK(*ptr, dsql_type_nod);
dsql_nod* sub = (*ptr); dsql_nod* sub = (*ptr);
dsql_nod* frnode = NULL; dsql_nod* frnode = NULL;
if (sub->nod_type == nod_field_name) if (sub->nod_type == nod_field_name)
{ {
// check for alias or field node // check for alias or field node
frnode = pass1_field(statement, sub, false, selectList); frnode = pass1_field(statement, sub, false, selectList);
@ -6249,7 +6249,7 @@ static dsql_nod* pass1_group_by_list(CompiledStatement* statement, dsql_nod* inp
{ {
frnode = pass1_node_psql(statement, *ptr, false); frnode = pass1_node_psql(statement, *ptr, false);
} }
stack.push(frnode); stack.push(frnode);
} }
// Finally make the complete list. // Finally make the complete list.
@ -6344,7 +6344,7 @@ static dsql_nod* pass1_insert( CompiledStatement* statement, dsql_nod* input, bo
fields = pass1_node_psql(statement, fields, false); fields = pass1_node_psql(statement, fields, false);
// We do not allow cases like INSERT INTO T(f1, f2, f1)... // We do not allow cases like INSERT INTO T(f1, f2, f1)...
field_appears_once(fields, old_fields, true, "INSERT"); field_appears_once(fields, old_fields, true, "INSERT");
// begin IBO hack // begin IBO hack
// 02-May-2004, Nickolay Samofatov. Do not constify ptr further e.g. to // 02-May-2004, Nickolay Samofatov. Do not constify ptr further e.g. to
// const dsql_nod* const* .... etc. It chokes GCC 3.4.0 // const dsql_nod* const* .... etc. It chokes GCC 3.4.0
@ -6795,7 +6795,7 @@ static dsql_nod* pass1_label(CompiledStatement* statement, dsql_nod* input)
// ERROR: Label %s is not found in the current scope // ERROR: Label %s is not found in the current scope
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) <<
Arg::Gds(isc_dsql_command_err) << Arg::Gds(isc_dsql_command_err) <<
Arg::Gds(isc_dsql_invalid_label) << Arg::Str(string->str_data) << Arg::Gds(isc_dsql_invalid_label) << Arg::Str(string->str_data) <<
Arg::Str("is not found")); Arg::Str("is not found"));
} }
else { else {
@ -6808,7 +6808,7 @@ static dsql_nod* pass1_label(CompiledStatement* statement, dsql_nod* input)
// ERROR: Label %s already exists in the current scope // ERROR: Label %s already exists in the current scope
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) <<
Arg::Gds(isc_dsql_command_err) << Arg::Gds(isc_dsql_command_err) <<
Arg::Gds(isc_dsql_invalid_label) << Arg::Str(string->str_data) << Arg::Gds(isc_dsql_invalid_label) << Arg::Str(string->str_data) <<
Arg::Str("already exists")); Arg::Str("already exists"));
} }
else { else {
@ -6930,7 +6930,7 @@ static dsql_nod* pass1_lookup_alias(CompiledStatement* statement, const dsql_str
strcat(buffer2, " in the select list with name"); strcat(buffer2, " in the select list with name");
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-204) << ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-204) <<
Arg::Gds(isc_dsql_ambiguous_field_name) << Arg::Str(buffer1) << Arg::Gds(isc_dsql_ambiguous_field_name) << Arg::Str(buffer1) <<
Arg::Str(buffer2) << Arg::Str(buffer2) <<
Arg::Gds(isc_random) << Arg::Str(name->str_data)); Arg::Gds(isc_random) << Arg::Str(name->str_data));
} }
@ -7223,7 +7223,7 @@ static dsql_nod* pass1_merge(CompiledStatement* statement, dsql_nod* input)
} }
// Changes statement->isPsql() value, calls PASS1_node and restore statement->isPsql(). // Changes statement->isPsql() value, calls PASS1_node and restore statement->isPsql().
static dsql_nod* pass1_node_psql(CompiledStatement* statement, dsql_nod* input, bool psql) static dsql_nod* pass1_node_psql(CompiledStatement* statement, dsql_nod* input, bool psql)
{ {
PsqlChanger changer(statement, psql); PsqlChanger changer(statement, psql);
@ -7360,7 +7360,7 @@ static dsql_nod* pass1_not(CompiledStatement* statement,
node->nod_arg[0] = PASS1_node(statement, sub); node->nod_arg[0] = PASS1_node(statement, sub);
return node; return node;
} }
if (is_between) { if (is_between) {
// handle the special BETWEEN case // handle the special BETWEEN case
fb_assert(node_type == nod_or); fb_assert(node_type == nod_or);
@ -7484,9 +7484,9 @@ static dsql_nod* pass1_alias_list(CompiledStatement* statement, dsql_nod* alias_
dsql_ctx* context = NULL; dsql_ctx* context = NULL;
while (aliasCount > 0) while (aliasCount > 0)
{ {
if (context) if (context)
{ {
if (context->ctx_rse && !context->ctx_relation && !context->ctx_procedure) if (context->ctx_rse && !context->ctx_relation && !context->ctx_procedure)
{ {
// Derived table // Derived table
statement->req_scope_level++; statement->req_scope_level++;
@ -7501,7 +7501,7 @@ static dsql_nod* pass1_alias_list(CompiledStatement* statement, dsql_nod* alias_
// since we already matched it to the context. // since we already matched it to the context.
for (; arg < end; arg++, aliasCount--) for (; arg < end; arg++, aliasCount--)
{ {
if (!(relation = pass1_base_table(statement, relation, (dsql_str*) *arg))) if (!(relation = pass1_base_table(statement, relation, (dsql_str*) *arg)))
break; break;
} }
@ -7520,7 +7520,7 @@ static dsql_nod* pass1_alias_list(CompiledStatement* statement, dsql_nod* alias_
// calculate the length leaving room for spaces and a null // calculate the length leaving room for spaces and a null
USHORT alias_length = alias_list->nod_count; USHORT alias_length = alias_list->nod_count;
dsql_nod** aliasArg = startArg; dsql_nod** aliasArg = startArg;
for (; aliasArg < end; aliasArg++) for (; aliasArg < end; aliasArg++)
{ {
DEV_BLKCHK(*aliasArg, dsql_type_str); DEV_BLKCHK(*aliasArg, dsql_type_str);
alias_length += static_cast<USHORT>(((dsql_str*) *aliasArg)->str_length); alias_length += static_cast<USHORT>(((dsql_str*) *aliasArg)->str_length);
@ -7530,7 +7530,7 @@ static dsql_nod* pass1_alias_list(CompiledStatement* statement, dsql_nod* alias_
alias->str_length = alias_length; alias->str_length = alias_length;
TEXT* p = new_context->ctx_alias = (TEXT*) alias->str_data; TEXT* p = new_context->ctx_alias = (TEXT*) alias->str_data;
for (aliasArg = startArg; aliasArg < end; aliasArg++) for (aliasArg = startArg; aliasArg < end; aliasArg++)
{ {
for (const TEXT* q = (TEXT*) ((dsql_str*) *aliasArg)->str_data; *q;) for (const TEXT* q = (TEXT*) ((dsql_str*) *aliasArg)->str_data; *q;)
*p++ = *q++; *p++ = *q++;
@ -7540,10 +7540,10 @@ static dsql_nod* pass1_alias_list(CompiledStatement* statement, dsql_nod* alias_
context = new_context; context = new_context;
} }
else else
{ {
context = NULL; context = NULL;
} }
} }
} }
else else
@ -7607,7 +7607,7 @@ static dsql_ctx* pass1_alias(CompiledStatement* statement, DsqlContextStack& sta
} }
// check for matching alias. // check for matching alias.
if (context->ctx_internal_alias) if (context->ctx_internal_alias)
{ {
if (!strcmp(context->ctx_internal_alias, if (!strcmp(context->ctx_internal_alias,
reinterpret_cast<const char*>(alias->str_data))) reinterpret_cast<const char*>(alias->str_data)))
@ -7756,7 +7756,7 @@ static dsql_nod* pass1_returning(CompiledStatement* statement, const dsql_nod* i
// RETURNING without INTO is not allowed for PSQL // RETURNING without INTO is not allowed for PSQL
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) << ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-104) <<
// Unexpected end of command // Unexpected end of command
Arg::Gds(isc_command_end_err2) << Arg::Num(errSrc->nod_line) << Arg::Gds(isc_command_end_err2) << Arg::Num(errSrc->nod_line) <<
Arg::Num(errSrc->nod_column)); Arg::Num(errSrc->nod_column));
} }
@ -7764,12 +7764,12 @@ static dsql_nod* pass1_returning(CompiledStatement* statement, const dsql_nod* i
fb_assert(count); fb_assert(count);
dsql_nod* node = MAKE_node(nod_list, count); dsql_nod* node = MAKE_node(nod_list, count);
if (target) if (target)
{ {
// PSQL case // PSQL case
fb_assert(statement->isPsql()); fb_assert(statement->isPsql());
if (count != target->nod_count) { if (count != target->nod_count) {
// count of column list and value list don't match // count of column list and value list don't match
ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-804) << ERRD_post(Arg::Gds(isc_sqlerr) << Arg::Num(-804) <<
Arg::Gds(isc_dsql_var_count_err)); Arg::Gds(isc_dsql_var_count_err));
} }
@ -7824,11 +7824,11 @@ static dsql_nod* pass1_returning(CompiledStatement* statement, const dsql_nod* i
/** /**
pass1_rse pass1_rse
@brief wrapper for pass1_rse_impl @brief wrapper for pass1_rse_impl
substitute recursive CTE alias (if needed) substitute recursive CTE alias (if needed)
and call pass1_rse_impl and call pass1_rse_impl
@param statement @param statement
@ -7864,7 +7864,7 @@ static dsql_nod* pass1_rse( CompiledStatement* statement, dsql_nod* input, dsql_
/** /**
pass1_rse_impl pass1_rse_impl
@brief Compile a record selection expression. @brief Compile a record selection expression.
@ -7897,12 +7897,12 @@ static dsql_nod* pass1_rse_impl( CompiledStatement* statement, dsql_nod* input,
if (input->nod_type == nod_select_expr) if (input->nod_type == nod_select_expr)
{ {
dsql_nod* node_with = input->nod_arg[e_sel_with_list]; dsql_nod* node_with = input->nod_arg[e_sel_with_list];
try try
{ {
if (node_with) if (node_with)
statement->addCTEs(node_with); statement->addCTEs(node_with);
dsql_nod* ret = dsql_nod* ret =
pass1_rse(statement, input->nod_arg[e_sel_query_spec], pass1_rse(statement, input->nod_arg[e_sel_query_spec],
input->nod_arg[e_sel_order], input->nod_arg[e_sel_rows], input->nod_arg[e_sel_order], input->nod_arg[e_sel_rows],
update_lock, viewFlags); update_lock, viewFlags);
@ -7914,7 +7914,7 @@ static dsql_nod* pass1_rse_impl( CompiledStatement* statement, dsql_nod* input,
} }
return ret; return ret;
} }
catch (const Firebird::Exception&) { catch (const Firebird::Exception&) {
if (node_with) if (node_with)
statement->clearCTEs(); statement->clearCTEs();
@ -8488,7 +8488,7 @@ static dsql_nod* pass1_sort( CompiledStatement* statement, dsql_nod* input, dsql
dsql_nod* node = MAKE_node(input->nod_type, input->nod_count); dsql_nod* node = MAKE_node(input->nod_type, input->nod_count);
dsql_nod** ptr2 = node->nod_arg; dsql_nod** ptr2 = node->nod_arg;
for (int sortloop = 0; sortloop < input->nod_count; sortloop++) for (int sortloop = 0; sortloop < input->nod_count; sortloop++)
{ {
DEV_BLKCHK(input->nod_arg[sortloop], dsql_type_nod); DEV_BLKCHK(input->nod_arg[sortloop], dsql_type_nod);
@ -9895,8 +9895,8 @@ static dsql_nod* remap_field(CompiledStatement* statement, dsql_nod* field,
} }
if (context->ctx_scope_level < lscope_level) { if (context->ctx_scope_level < lscope_level) {
field->nod_arg[e_derived_field_value] = field->nod_arg[e_derived_field_value] =
remap_field(statement, field->nod_arg[e_derived_field_value], remap_field(statement, field->nod_arg[e_derived_field_value],
context, current_level); context, current_level);
} }
return field; return field;
@ -10105,7 +10105,7 @@ static dsql_nod* remap_field(CompiledStatement* statement, dsql_nod* field,
case nod_constant: case nod_constant:
case nod_dbkey: case nod_dbkey:
return post_map(field, context); return post_map(field, context);
default: default:
return field; return field;
@ -10244,9 +10244,9 @@ static dsql_fld* resolve_context( CompiledStatement* statement, const dsql_str*
// return NULL; // return NULL;
// } // }
// AB: If this context is a system generated context as in NEW/OLD inside // AB: If this context is a system generated context as in NEW/OLD inside
// triggers, the qualifier by the field is mandatory. While we can't // triggers, the qualifier by the field is mandatory. While we can't
// fall back from a higher scope-level to the NEW/OLD contexts without // fall back from a higher scope-level to the NEW/OLD contexts without
// the qualifier present. // the qualifier present.
// An exception is a check-constraint that is allowed to reference fields // An exception is a check-constraint that is allowed to reference fields
// without the qualifier. // without the qualifier.
@ -10712,7 +10712,7 @@ dsql_nod* CompiledStatement::findCTE(const dsql_str* name)
dsql_nod* cte = req_ctes[i]; dsql_nod* cte = req_ctes[i];
const dsql_str* cte_name = (dsql_str*) cte->nod_arg[e_derived_table_alias]; const dsql_str* cte_name = (dsql_str*) cte->nod_arg[e_derived_table_alias];
if (name->str_length == cte_name->str_length && if (name->str_length == cte_name->str_length &&
strncmp(name->str_data, cte_name->str_data, cte_name->str_length) == 0) strncmp(name->str_data, cte_name->str_data, cte_name->str_length) == 0)
{ {
return cte; return cte;
@ -10782,9 +10782,9 @@ static void trace_line(const char* message, ...) {
} }
/** /**
DSQL_pretty DSQL_pretty
@brief Pretty print a node tree. @brief Pretty print a node tree.
@ -11035,7 +11035,7 @@ void DSQL_pretty(const dsql_nod* node, int column)
case nod_exec_procedure: case nod_exec_procedure:
verb = "execute procedure"; verb = "execute procedure";
break; break;
case nod_exec_block: case nod_exec_block:
verb = "execute block"; verb = "execute block";
break; break;
case nod_exists: case nod_exists:
@ -11295,7 +11295,7 @@ void DSQL_pretty(const dsql_nod* node, int column)
case nod_join_inner: case nod_join_inner:
verb = "join_inner"; verb = "join_inner";
break; break;
// SKIDDER: some more missing node types // SKIDDER: some more missing node types
case nod_commit: case nod_commit:
verb = "commit"; verb = "commit";
break; break;
@ -11641,7 +11641,7 @@ void DSQL_pretty(const dsql_nod* node, int column)
field->fld_name.c_str(), context->ctx_context); field->fld_name.c_str(), context->ctx_context);
return; return;
} }
case nod_field_name: case nod_field_name:
trace_line("%sfield name: \"", buffer); trace_line("%sfield name: \"", buffer);
string = (dsql_str*) node->nod_arg[e_fln_context]; string = (dsql_str*) node->nod_arg[e_fln_context];
@ -11759,15 +11759,15 @@ void DSQL_pretty(const dsql_nod* node, int column)
case nod_param_val: case nod_param_val:
verb = "param_val"; // do we need more here? verb = "param_val"; // do we need more here?
break; break;
case nod_query_spec: case nod_query_spec:
verb = "query_spec"; verb = "query_spec";
break; break;
case nod_comment: case nod_comment:
verb = "comment"; verb = "comment";
break; break;
case nod_mod_udf: case nod_mod_udf:
verb = "mod_udf"; verb = "mod_udf";
break; break;
@ -11795,11 +11795,11 @@ void DSQL_pretty(const dsql_nod* node, int column)
case nod_collation_specific_attr: case nod_collation_specific_attr:
verb = "collation_specific_attr"; verb = "collation_specific_attr";
break; break;
case nod_returning: case nod_returning:
verb = "returning"; verb = "returning";
break; break;
case nod_tra_misc: case nod_tra_misc:
verb = "tra_misc"; verb = "tra_misc";
break; break;
@ -11850,7 +11850,7 @@ void DSQL_pretty(const dsql_nod* node, int column)
if (node->nod_count == 2) if (node->nod_count == 2)
DSQL_pretty(*ptr, column + 1); DSQL_pretty(*ptr, column + 1);
return; return;
case nod_mod_role: case nod_mod_role:
verb = "mod_role"; verb = "mod_role";
break; break;

View File

@ -1,7 +1,7 @@
/* /*
* PROGRAM: Dynamic SQL runtime support * PROGRAM: Dynamic SQL runtime support
* MODULE: preparse.cpp * MODULE: preparse.cpp
* DESCRIPTION: Dynamic SQL pre parser / parser on client side. * DESCRIPTION: Dynamic SQL pre parser / parser on client side.
* This module will probably change to a YACC parser. * This module will probably change to a YACC parser.
* *
* The contents of this file are subject to the Interbase Public * The contents of this file are subject to the Interbase Public
@ -79,7 +79,7 @@ static const pp_table pp_symbols[] = {
{"", 0, 0} {"", 0, 0}
}; };
// define the tokens // define the tokens
enum token_vals { enum token_vals {
NO_MORE_TOKENS = -1, NO_MORE_TOKENS = -1,
@ -95,9 +95,9 @@ using namespace Firebird;
/** /**
PREPARSE_execute PREPARSE_execute
@brief @brief
@param user_status @param user_status
@ -135,7 +135,7 @@ bool PREPARSE_execute(
if (get_token(user_status, SYMBOL, false, &stmt, stmt_end, token) || if (get_token(user_status, SYMBOL, false, &stmt, stmt_end, token) ||
token.length() != pp_symbols[PP_CREATE].length || token.length() != pp_symbols[PP_CREATE].length ||
token != pp_symbols[PP_CREATE].symbol) token != pp_symbols[PP_CREATE].symbol)
{ {
return false; return false;
} }
@ -144,7 +144,7 @@ bool PREPARSE_execute(
(token.length() != pp_symbols[PP_DATABASE].length && (token.length() != pp_symbols[PP_DATABASE].length &&
token.length() != pp_symbols[PP_SCHEMA].length) || token.length() != pp_symbols[PP_SCHEMA].length) ||
(token != pp_symbols[PP_DATABASE].symbol && (token != pp_symbols[PP_DATABASE].symbol &&
token != pp_symbols[PP_SCHEMA].symbol)) token != pp_symbols[PP_SCHEMA].symbol))
{ {
return false; return false;
} }
@ -175,7 +175,7 @@ bool PREPARSE_execute(
matched = false; matched = false;
for (int i = 3; pp_symbols[i].length && !matched; i++) { for (int i = 3; pp_symbols[i].length && !matched; i++) {
if (token.length() == pp_symbols[i].length && if (token.length() == pp_symbols[i].length &&
token == pp_symbols[i].symbol) token == pp_symbols[i].symbol)
{ {
bool get_out = false; bool get_out = false;
// CVC: What's strange, this routine doesn't check token.length() // CVC: What's strange, this routine doesn't check token.length()
@ -232,7 +232,7 @@ bool PREPARSE_execute(
break; break;
case PP_LENGTH: case PP_LENGTH:
// Skip a token for value // Skip a token for value
if (get_token(user_status, '=', true, &stmt, stmt_end, token) || if (get_token(user_status, '=', true, &stmt, stmt_end, token) ||
get_token(user_status, NUMERIC, false, &stmt, stmt_end, token)) get_token(user_status, NUMERIC, false, &stmt, stmt_end, token))
@ -258,10 +258,10 @@ bool PREPARSE_execute(
} while (matched); } while (matched);
// This code is because 3.3 server does not recognize isc_dpb_overwrite. // This code is because 3.3 server does not recognize isc_dpb_overwrite.
FB_API_HANDLE temp_db_handle = 0; FB_API_HANDLE temp_db_handle = 0;
if (!isc_attach_database(user_status, 0, file_name.c_str(), if (!isc_attach_database(user_status, 0, file_name.c_str(),
&temp_db_handle, dpb.getBufferLength(), &temp_db_handle, dpb.getBufferLength(),
reinterpret_cast<const ISC_SCHAR*>(dpb.getBuffer())) || reinterpret_cast<const ISC_SCHAR*>(dpb.getBuffer())) ||
user_status[1] != isc_io_error) user_status[1] != isc_io_error)
{ {
@ -287,7 +287,7 @@ bool PREPARSE_execute(
isc_create_database(user_status, 0, file_name.c_str(), isc_create_database(user_status, 0, file_name.c_str(),
(db_handle), dpb.getBufferLength(), (db_handle), dpb.getBufferLength(),
reinterpret_cast<const ISC_SCHAR*>(dpb.getBuffer()), reinterpret_cast<const ISC_SCHAR*>(dpb.getBuffer()),
0); 0);
} }
catch (const Exception& ex) catch (const Exception& ex)
@ -301,9 +301,9 @@ bool PREPARSE_execute(
/** /**
generate_error generate_error
@brief @brief
@param user_status @param user_status
@ -351,9 +351,9 @@ static void generate_error(ISC_STATUS* user_status,
/** /**
get_next_token get_next_token
@brief @brief
@param stmt @param stmt
@ -426,7 +426,7 @@ static SSHORT get_next_token(const SCHAR** stmt,
} }
*stmt = s; *stmt = s;
if (token.length() > MAX_TOKEN_SIZE) { if (token.length() > MAX_TOKEN_SIZE) {
// '=' used as then there is no place for null termination // '=' used as then there is no place for null termination
token.erase(MAX_TOKEN_SIZE); token.erase(MAX_TOKEN_SIZE);
return TOKEN_TOO_LONG; return TOKEN_TOO_LONG;
} }
@ -448,7 +448,7 @@ static SSHORT get_next_token(const SCHAR** stmt,
return NUMERIC; return NUMERIC;
} }
// Is is a symbol // Is is a symbol
if (char_class & CHR_LETTER) { if (char_class & CHR_LETTER) {
token += UPPER(c); token += UPPER(c);
@ -473,9 +473,9 @@ static SSHORT get_next_token(const SCHAR** stmt,
/** /**
get_token get_token
@brief @brief
@param status @param status
@ -506,13 +506,13 @@ static SSHORT get_token(ISC_STATUS* status,
case TOKEN_TOO_LONG: case TOKEN_TOO_LONG:
*stmt = temp_stmt; *stmt = temp_stmt;
// generate error here // generate error here
generate_error(status, token, result, 0); generate_error(status, token, result, 0);
return FB_FAILURE; return FB_FAILURE;
} }
// Some token was found // Some token was found
if (result == token_type) { if (result == token_type) {
*stmt = temp_stmt; *stmt = temp_stmt;

View File

@ -57,7 +57,7 @@ enum name_type {
NAME_cursor = 2 NAME_cursor = 2
}; };
/* declare a structure which enables us to associate a cursor with a /* declare a structure which enables us to associate a cursor with a
statement and vice versa */ statement and vice versa */
struct dsql_dbb struct dsql_dbb
@ -70,14 +70,14 @@ struct dsql_name; // fwd. decl.
struct dsql_stmt struct dsql_stmt
{ {
dsql_stmt* stmt_next; // next in chain dsql_stmt* stmt_next; // next in chain
dsql_name* stmt_stmt; // symbol table entry for statement name dsql_name* stmt_stmt; // symbol table entry for statement name
dsql_name* stmt_cursor; // symbol table entry for cursor name dsql_name* stmt_cursor; // symbol table entry for cursor name
FB_API_HANDLE stmt_handle; // stmt handle returned by dsql_xxx FB_API_HANDLE stmt_handle; // stmt handle returned by dsql_xxx
FB_API_HANDLE stmt_db_handle; // database handle for this statement FB_API_HANDLE stmt_db_handle; // database handle for this statement
}; };
// declare a structure to hold the cursor and statement names // declare a structure to hold the cursor and statement names
struct dsql_name struct dsql_name
{ {
@ -109,9 +109,9 @@ static USHORT name_length(const SCHAR*);
static void remove_name(dsql_name*, dsql_name**); static void remove_name(dsql_name*, dsql_name**);
static bool scompare(const SCHAR*, USHORT, const SCHAR*, USHORT); static bool scompare(const SCHAR*, USHORT, const SCHAR*, USHORT);
// declare the private data // declare the private data
static bool init_flag = false; // whether we've been initialized static bool init_flag = false; // whether we've been initialized
static dsql_err_stblock* UDSQL_error = NULL; static dsql_err_stblock* UDSQL_error = NULL;
static dsql_stmt* statements = NULL; static dsql_stmt* statements = NULL;
static dsql_name* statement_names = NULL; static dsql_name* statement_names = NULL;
@ -530,7 +530,7 @@ ISC_STATUS API_ROUTINE isc_embed_dsql_insert(ISC_STATUS* user_status,
INIT_DSQL(user_status, local_status); INIT_DSQL(user_status, local_status);
try try
{ {
// get the symbol table entry // get the symbol table entry
dsql_stmt* statement = lookup_stmt(cursor_name, cursor_names, NAME_cursor); dsql_stmt* statement = lookup_stmt(cursor_name, cursor_names, NAME_cursor);
@ -612,7 +612,7 @@ ISC_STATUS API_ROUTINE isc_embed_dsql_open2(ISC_STATUS* user_status,
INIT_DSQL(user_status, local_status); INIT_DSQL(user_status, local_status);
try try
{ {
// get the symbol table entry // get the symbol table entry
dsql_stmt* statement = lookup_stmt(cursor_name, cursor_names, NAME_cursor); dsql_stmt* statement = lookup_stmt(cursor_name, cursor_names, NAME_cursor);
@ -692,7 +692,7 @@ ISC_STATUS API_ROUTINE isc_embed_dsql_prepare(ISC_STATUS* user_status,
length, string, dialect, sqlda); length, string, dialect, sqlda);
if (s) { if (s) {
// An error occurred. Free any newly allocated statement handle. // An error occurred. Free any newly allocated statement handle.
if (!statement) { if (!statement) {
ISC_STATUS_ARRAY local_status2; ISC_STATUS_ARRAY local_status2;
@ -711,13 +711,13 @@ ISC_STATUS API_ROUTINE isc_embed_dsql_prepare(ISC_STATUS* user_status,
if (!statement) if (!statement)
{ {
statement = (dsql_stmt*) gds__alloc((SLONG) sizeof(dsql_stmt)); statement = (dsql_stmt*) gds__alloc((SLONG) sizeof(dsql_stmt));
// FREE: by user calling isc_embed_dsql_release() // FREE: by user calling isc_embed_dsql_release()
if (!statement) // NOMEM: if (!statement) // NOMEM:
error_post(Arg::Gds(isc_virmemexh)); error_post(Arg::Gds(isc_virmemexh));
#ifdef DEBUG_GDS_ALLOC #ifdef DEBUG_GDS_ALLOC
gds_alloc_flag_unfreed((void *) statement); gds_alloc_flag_unfreed((void *) statement);
#endif // DEBUG_GDS_ALLOC #endif // DEBUG_GDS_ALLOC
statement->stmt_next = statements; statement->stmt_next = statements;
statements = statement; statements = statement;
@ -762,7 +762,7 @@ ISC_STATUS API_ROUTINE isc_embed_dsql_release(ISC_STATUS* user_status,
INIT_DSQL(user_status, local_status); INIT_DSQL(user_status, local_status);
try try
{ {
// If a request already exists under that name, purge it out // If a request already exists under that name, purge it out
dsql_stmt* statement = lookup_stmt(stmt_name, statement_names, NAME_statement); dsql_stmt* statement = lookup_stmt(stmt_name, statement_names, NAME_statement);
@ -852,10 +852,10 @@ ISC_STATUS API_ROUTINE isc_dsql_fetch2_a(ISC_STATUS* user_status,
*sqlcode = 0; *sqlcode = 0;
const ISC_STATUS s = const ISC_STATUS s =
isc_dsql_fetch2(user_status, isc_dsql_fetch2(user_status,
reinterpret_cast<FB_API_HANDLE*>(stmt_handle), reinterpret_cast<FB_API_HANDLE*>(stmt_handle),
dialect, dialect,
reinterpret_cast<XSQLDA*>(sqlda), reinterpret_cast<XSQLDA*>(sqlda),
direction, direction,
offset); offset);
if (s == 100) if (s == 100)
@ -1344,8 +1344,8 @@ static dsql_name* insert_name(const TEXT* symbol_name, dsql_name** list_ptr, dsq
**************************************/ **************************************/
const USHORT l = name_length(symbol_name); const USHORT l = name_length(symbol_name);
dsql_name* name = (dsql_name*) gds__alloc((SLONG) sizeof(dsql_name) + l); dsql_name* name = (dsql_name*) gds__alloc((SLONG) sizeof(dsql_name) + l);
// FREE: by exit handler cleanup() or database_cleanup() // FREE: by exit handler cleanup() or database_cleanup()
if (!name) // NOMEM: if (!name) // NOMEM:
error_post(Arg::Gds(isc_virmemexh)); error_post(Arg::Gds(isc_virmemexh));
name->name_stmt = stmt; name->name_stmt = stmt;
name->name_length = l; name->name_length = l;

View File

@ -332,7 +332,7 @@ int CLIB_ROUTINE main( int argc, char* argv[])
} }
FILE* input_file; FILE* input_file;
if (dudleyGlob.DDL_extract) { if (dudleyGlob.DDL_extract) {
strcpy(dudleyGlob.DB_file_string, file_name_1); strcpy(dudleyGlob.DB_file_string, file_name_1);
strcpy(dudleyGlob.DDL_file_string, file_name_2); strcpy(dudleyGlob.DDL_file_string, file_name_2);
@ -355,8 +355,8 @@ int CLIB_ROUTINE main( int argc, char* argv[])
dudleyGlob.DDL_interactive = dudleyGlob.DDL_service || isatty(0); dudleyGlob.DDL_interactive = dudleyGlob.DDL_service || isatty(0);
} }
else { else {
/* /*
* try to open the input DDL file. * try to open the input DDL file.
* If it already has a .GDL extension, just try to open it. * If it already has a .GDL extension, just try to open it.
* Otherwise, add the extension, try, remove the extension, * Otherwise, add the extension, try, remove the extension,
* and try again. * and try again.
@ -696,7 +696,7 @@ bool DDL_yes_no( USHORT number)
* *
**************************************/ **************************************/
TEXT prompt[128], reprompt[128], yes_ans[128], no_ans[128]; TEXT prompt[128], reprompt[128], yes_ans[128], no_ans[128];
static const SafeArg dummy; static const SafeArg dummy;
fb_msg_format(0, DDL_MSG_FAC, number, sizeof(prompt), prompt, dummy); fb_msg_format(0, DDL_MSG_FAC, number, sizeof(prompt), prompt, dummy);

View File

@ -69,7 +69,7 @@ void EXP_actions(void)
* Expand the output of the parser. * Expand the output of the parser.
* Look for field references and put * Look for field references and put
* them in appropriate context. * them in appropriate context.
* *
**************************************/ **************************************/
ACT action; ACT action;
@ -398,11 +398,11 @@ static DUDLEY_FLD field_context( DUDLEY_NOD node, dudley_lls* contexts, DUDLEY_C
* *
* Functional description * Functional description
* Lookup a field reference, guessing the * Lookup a field reference, guessing the
* context. Since by now all field references * context. Since by now all field references
* ought to be entered in the hash table, this is * ought to be entered in the hash table, this is
* pretty easy. We may be looking up a global * pretty easy. We may be looking up a global
* field reference, in which case the context * field reference, in which case the context
* relation will be null. * relation will be null.
* *
* *
**************************************/ **************************************/
@ -468,7 +468,7 @@ static DUDLEY_FLD field_search( DUDLEY_NOD node, dudley_lls* contexts, DUDLEY_CT
* iteratively. The context indicated is * iteratively. The context indicated is
* the current context. Get to there, then * the current context. Get to there, then
* work backward. * work backward.
* *
**************************************/ **************************************/
DUDLEY_FLD field; DUDLEY_FLD field;
DUDLEY_CTX context, old_context; DUDLEY_CTX context, old_context;
@ -562,7 +562,7 @@ static DUDLEY_FLD lookup_field( DUDLEY_FLD old_field)
* Lookup a field reference, from a modify or * Lookup a field reference, from a modify or
* delete field statement, and make sure we * delete field statement, and make sure we
* found the thing originally. * found the thing originally.
* context. Since by now all field references * context. Since by now all field references
* ought to be entered in the hash table, this is * ought to be entered in the hash table, this is
* pretty easy. * pretty easy.
* *
@ -650,7 +650,7 @@ static DUDLEY_TRG lookup_trigger( DUDLEY_TRG trigger)
{ {
/************************************** /**************************************
* *
* l o o k u p _ t r i g g e r * l o o k u p _ t r i g g e r
* *
************************************** **************************************
* *
@ -886,7 +886,7 @@ static void resolve_rse( DUDLEY_NOD rse, dudley_lls** stack)
************************************** **************************************
* *
* Functional description * Functional description
* Resolve record selection expression, augmenting * Resolve record selection expression, augmenting
* context stack. At the same time, put a context * context stack. At the same time, put a context
* node in front of every context and build a list * node in front of every context and build a list
* out of the whole thing; * out of the whole thing;

View File

@ -36,7 +36,7 @@ static void get_set_generator(STR, DUDLEY_NOD);
static inline void check_blr(str* blr, const int l) static inline void check_blr(str* blr, const int l)
{ {
if (!(blr->str_current - blr->str_start + l <= blr->str_length) if (!(blr->str_current - blr->str_start + l <= blr->str_length)
&& !TRN_get_buffer(blr, l) ) && !TRN_get_buffer(blr, l) )
{ {
DDL_err(289); DDL_err(289);
@ -538,7 +538,7 @@ static void generate( STR blr, DUDLEY_NOD node)
operatr = blr_matching2; operatr = blr_matching2;
break; break;
// case nod_substr: // case nod_substr:
// operatr = blr_substring; // operatr = blr_substring;
// break; // break;
default: default:

View File

@ -173,7 +173,7 @@ struct word {
// {KW_RAW, "RAW"}, // {KW_RAW, "RAW"},
// {KW_RAW_PARTITIONS, "RAW_PARTITIONS"}, // {KW_RAW_PARTITIONS, "RAW_PARTITIONS"},
{KW_REFERENCE, "REFERENCE"}, {KW_REFERENCE, "REFERENCE"},
{KW_RELATION, "RELATION"}, {KW_RELATION, "RELATION"},
{KW_RETURN_ARGUMENT, "RETURN_ARGUMENT"}, /* function argument return_mode */ {KW_RETURN_ARGUMENT, "RETURN_ARGUMENT"}, /* function argument return_mode */
{KW_RETURN_VALUE, "RETURN_VALUE"}, /* function argument return_mode */ {KW_RETURN_VALUE, "RETURN_VALUE"}, /* function argument return_mode */
{KW_REVOKE, "REVOKE"}, {KW_REVOKE, "REVOKE"},
@ -250,8 +250,8 @@ struct word {
{KW_MAX, "MAX"}, {KW_MAX, "MAX"},
{KW_TO, "TO"}, {KW_TO, "TO"},
{KW_TOTAL, "TOTAL"}, {KW_TOTAL, "TOTAL"},
{KW_UNIQUE, "UNIQUE"}, {KW_UNIQUE, "UNIQUE"},
{KW_UPPERCASE, "UPPERCASE"}, {KW_UPPERCASE, "UPPERCASE"},
{KW_WITH, "WITH"} {KW_WITH, "WITH"}
}; };
@ -344,7 +344,7 @@ void HSH_remove( SYM symbol)
{ {
/************************************** /**************************************
* *
* H S H _ r e m o v e * H S H _ r e m o v e
* *
************************************** **************************************
* *

View File

@ -242,7 +242,7 @@ FUNC PARSE_function(int existingFunction)
* *
* Functional description * Functional description
* Get the function block associated with the current token. Also * Get the function block associated with the current token. Also
* advance the token. Create a new function requested. * advance the token. Create a new function requested.
* *
**************************************/ **************************************/
if (dudleyGlob.DDL_token.tok_type != tok_ident) if (dudleyGlob.DDL_token.tok_type != tok_ident)
@ -253,7 +253,7 @@ FUNC PARSE_function(int existingFunction)
FUNC function; FUNC function;
if (symbol && (function = (FUNC) symbol->sym_object) && if (symbol && (function = (FUNC) symbol->sym_object) &&
function->func_database == dudleyGlob.database) function->func_database == dudleyGlob.database)
{ {
LEX_token(); LEX_token();
return function; return function;
@ -324,7 +324,7 @@ DUDLEY_NOD PARSE_make_list(dudley_lls* stack)
while (stack) while (stack)
node->nod_arg[--count] = LLS_POP(&stack); node->nod_arg[--count] = LLS_POP(&stack);
return node; return node;
} }
@ -369,7 +369,7 @@ bool PARSE_match( enum kwwords keyword)
for (SYM symbol = dudleyGlob.DDL_token.tok_symbol; symbol; symbol = symbol->sym_homonym) for (SYM symbol = dudleyGlob.DDL_token.tok_symbol; symbol; symbol = symbol->sym_homonym)
if (symbol->sym_type == SYM_keyword && if (symbol->sym_type == SYM_keyword &&
symbol->sym_keyword == (int) keyword) symbol->sym_keyword == (int) keyword)
{ {
LEX_token(); LEX_token();
return true; return true;
@ -560,7 +560,7 @@ static SYM copy_symbol( SYM old_name)
* does the implicit invocation of same-named * does the implicit invocation of same-named
* global fields. * global fields.
* *
* We'll just leave the type blank for now. * We'll just leave the type blank for now.
* *
**************************************/ **************************************/
SYM new_name = (SYM) DDL_alloc(SYM_LEN + old_name->sym_length); SYM new_name = (SYM) DDL_alloc(SYM_LEN + old_name->sym_length);
@ -674,7 +674,7 @@ static void define_database( enum act_t action_type)
**************************************/ **************************************/
if (dudleyGlob.database) if (dudleyGlob.database)
DDL_error_abort(0, 120); DDL_error_abort(0, 120);
// msg 120: GDEF processes only one database at a time // msg 120: GDEF processes only one database at a time
dudleyGlob.database = (DBB) DDL_alloc(sizeof(dbb)); dudleyGlob.database = (DBB) DDL_alloc(sizeof(dbb));
dudleyGlob.database->dbb_name = PARSE_symbol(tok_quoted); dudleyGlob.database->dbb_name = PARSE_symbol(tok_quoted);
@ -740,7 +740,7 @@ static void define_database( enum act_t action_type)
*/ */
else else
PARSE_error(121, 0, 0); PARSE_error(121, 0, 0);
// msg 121 only SECURITY_CLASS, DESCRIPTION and CACHE can be dropped // msg 121 only SECURITY_CLASS, DESCRIPTION and CACHE can be dropped
} }
else if (PARSE_match(KW_FILE)) { else if (PARSE_match(KW_FILE)) {
FIL file = define_file(); FIL file = define_file();
@ -1113,7 +1113,7 @@ static FIL define_log_file( USHORT log_type)
else if (PARSE_match(KW_RAW_PARTITIONS)) { else if (PARSE_match(KW_RAW_PARTITIONS)) {
if (log_type != DBB_log_preallocated) if (log_type != DBB_log_preallocated)
PARSE_error(332, 0, 0); PARSE_error(332, 0, 0);
// msg 332: Partitions not supported in series of log file specification // msg 332: Partitions not supported in series of log file specification
PARSE_match(KW_EQUALS); PARSE_match(KW_EQUALS);
file->fil_partitions = PARSE_number(); file->fil_partitions = PARSE_number();
file->fil_raw = LOG_raw; file->fil_raw = LOG_raw;
@ -1204,7 +1204,7 @@ static void define_relation(void)
|| EXE_relation(relation))) || EXE_relation(relation)))
{ {
PARSE_error(137, relation->rel_name->sym_string, 0); PARSE_error(137, relation->rel_name->sym_string, 0);
// msg 137: relation %s already exists // msg 137: relation %s already exists
} }
if (PARSE_match(KW_EXTERNAL_FILE)) { if (PARSE_match(KW_EXTERNAL_FILE)) {
@ -1334,7 +1334,7 @@ static void define_shadow(void)
* *
* Functional description * Functional description
* Define a shadow file to the database. * Define a shadow file to the database.
* Parse it as a set of normal file additions, * Parse it as a set of normal file additions,
* setting the shadow number on all files. * setting the shadow number on all files.
* *
**************************************/ **************************************/
@ -1351,7 +1351,7 @@ static void define_shadow(void)
PARSE_error(139, 0, 0); /* msg 139: shadow number must be a positive integer */ PARSE_error(139, 0, 0); /* msg 139: shadow number must be a positive integer */
} }
/* match the keywords MANUAL or AUTO to imply whether the shadow /* match the keywords MANUAL or AUTO to imply whether the shadow
should be automatically deleted when something goes awry */ should be automatically deleted when something goes awry */
if (PARSE_match(KW_MANUAL)) if (PARSE_match(KW_MANUAL))
@ -1365,7 +1365,7 @@ static void define_shadow(void)
shadow->fil_name = PARSE_symbol(tok_quoted); shadow->fil_name = PARSE_symbol(tok_quoted);
if (!check_filename(shadow->fil_name, false)) if (!check_filename(shadow->fil_name, false))
PARSE_error(297, 0, 0); PARSE_error(297, 0, 0);
// msg 297: A node name is not permitted in a shadow or secondary file name // msg 297: A node name is not permitted in a shadow or secondary file name
if (PARSE_match(KW_LENGTH)) { if (PARSE_match(KW_LENGTH)) {
shadow->fil_length = PARSE_number(); shadow->fil_length = PARSE_number();
@ -1424,7 +1424,7 @@ static void define_trigger(void)
trigger->trg_sequence = trg_sequence; trigger->trg_sequence = trg_sequence;
if (!(int) trigger->trg_type) /* still none */ if (!(int) trigger->trg_type) /* still none */
PARSE_error(141, dudleyGlob.DDL_token.tok_string, 0); PARSE_error(141, dudleyGlob.DDL_token.tok_string, 0);
/* msg 141: expected STORE, MODIFY, ERASE, encountered \"%s\" */ /* msg 141: expected STORE, MODIFY, ERASE, encountered \"%s\" */
bool action = false; bool action = false;
@ -1530,7 +1530,7 @@ static void define_view(void)
|| EXE_relation(relation))) || EXE_relation(relation)))
{ {
PARSE_error(300, relation->rel_name->sym_string, 0); PARSE_error(300, relation->rel_name->sym_string, 0);
// msg 300: relation %s already exists // msg 300: relation %s already exists
} }
PARSE_match(KW_OF); PARSE_match(KW_OF);
@ -1895,7 +1895,7 @@ static void end_text( TXT text)
dudleyGlob.DDL_token.tok_position - dudleyGlob.DDL_token.tok_length - text->txt_position; dudleyGlob.DDL_token.tok_position - dudleyGlob.DDL_token.tok_length - text->txt_position;
#if (defined WIN_NT) #if (defined WIN_NT)
/* the length of the text field should subtract out the /* the length of the text field should subtract out the
line feeds, since they are automatically filtered out line feeds, since they are automatically filtered out
when reading from a file */ when reading from a file */
@ -1913,7 +1913,7 @@ static SYM gen_trigger_name( TRG_T type, DUDLEY_REL relation)
************************************** **************************************
* *
* Functional description * Functional description
* Generate a trigger name for an old style trigger. * Generate a trigger name for an old style trigger.
* *
**************************************/ **************************************/
SYM symbol = (SYM) DDL_alloc(SYM_LEN + GDS_NAME_LEN); SYM symbol = (SYM) DDL_alloc(SYM_LEN + GDS_NAME_LEN);
@ -1992,7 +1992,7 @@ static void get_trigger_attributes( int *flags, int *type, int *sequence)
* PRE and POST are optional in new style definitions. * PRE and POST are optional in new style definitions.
* For STORE & MODIFY PRE is the default. * For STORE & MODIFY PRE is the default.
* For ERASE, POST is the default. * For ERASE, POST is the default.
* *
**************************************/ **************************************/
if (PARSE_match(KW_INACTIVE)) { if (PARSE_match(KW_INACTIVE)) {
@ -2098,9 +2098,9 @@ static void grant_user_privilege(void)
PARSE_error(313, dudleyGlob.DDL_token.tok_string, 0); /* msg 313: expected ON or '(', encountered "%s" */ PARSE_error(313, dudleyGlob.DDL_token.tok_string, 0); /* msg 313: expected ON or '(', encountered "%s" */
do { do {
if (dudleyGlob.DDL_token.tok_keyword == KW_SELECT if (dudleyGlob.DDL_token.tok_keyword == KW_SELECT
|| dudleyGlob.DDL_token.tok_keyword == KW_INSERT || dudleyGlob.DDL_token.tok_keyword == KW_INSERT
|| dudleyGlob.DDL_token.tok_keyword == KW_DELETE || dudleyGlob.DDL_token.tok_keyword == KW_DELETE
|| dudleyGlob.DDL_token.tok_keyword == KW_UPDATE) || dudleyGlob.DDL_token.tok_keyword == KW_UPDATE)
{ {
break; break;
@ -2188,7 +2188,7 @@ static DUDLEY_CTX lookup_context( SYM symbol, dudley_lls* contexts)
for (; contexts; contexts = contexts->lls_next) { for (; contexts; contexts = contexts->lls_next) {
DUDLEY_CTX context = (DUDLEY_CTX) contexts->lls_object; DUDLEY_CTX context = (DUDLEY_CTX) contexts->lls_object;
SYM name = context->ctx_name; SYM name = context->ctx_name;
if (name && !strcmp(name->sym_string, symbol->sym_string)) if (name && !strcmp(name->sym_string, symbol->sym_string))
return context; return context;
} }
@ -2713,7 +2713,7 @@ static void modify_trigger(void)
while (!(dudleyGlob.DDL_token.tok_keyword == KW_SEMI)) { while (!(dudleyGlob.DDL_token.tok_keyword == KW_SEMI)) {
if ((PARSE_match(KW_MESSAGE)) || (PARSE_match(KW_MSGADD)) || if ((PARSE_match(KW_MESSAGE)) || (PARSE_match(KW_MSGADD)) ||
(PARSE_match(KW_MSGMODIFY))) (PARSE_match(KW_MSGMODIFY)))
{ {
msg_type = trgmsg_modify; msg_type = trgmsg_modify;
} }
@ -3089,9 +3089,9 @@ static bool parse_action(void)
static void parse_array( DUDLEY_FLD field) static void parse_array( DUDLEY_FLD field)
{ {
/************************************** /**************************************
* *
* p a r s e _ a r r a y * p a r s e _ a r r a y
* *
************************************** **************************************
* *
@ -3149,7 +3149,7 @@ static TXT parse_description(void)
************************************** **************************************
* *
* Functional description * Functional description
* Create a text block to hold the pointer and length * Create a text block to hold the pointer and length
* of the description of a metadata item. * of the description of a metadata item.
* *
**************************************/ **************************************/
@ -3444,7 +3444,7 @@ static void parse_field_dtype( DUDLEY_FLD field)
LEX_token(); LEX_token();
if (field->fld_dtype == blr_text || if (field->fld_dtype == blr_text ||
field->fld_dtype == blr_varying || field->fld_dtype == blr_cstring) field->fld_dtype == blr_varying || field->fld_dtype == blr_cstring)
{ {
if (!PARSE_match(KW_L_BRCKET) && !PARSE_match(KW_LT)) if (!PARSE_match(KW_L_BRCKET) && !PARSE_match(KW_LT))
PARSE_error(200, dudleyGlob.DDL_token.tok_string, 0); /* msg 200: expected \"[\", encountered \"%s\" */ PARSE_error(200, dudleyGlob.DDL_token.tok_string, 0); /* msg 200: expected \"[\", encountered \"%s\" */
@ -3561,7 +3561,7 @@ static FUNCARG parse_function_arg( FUNC function, USHORT * position)
PARSE_error(204, 0, 0); /* msg 204: argument mode is by value, or by reference */ PARSE_error(204, 0, 0); /* msg 204: argument mode is by value, or by reference */
} }
/* (kw_comma or kw_semi) here means this argument is not a /* (kw_comma or kw_semi) here means this argument is not a
return_value or a return_argument in which case it had return_value or a return_argument in which case it had
better not be passed by value */ better not be passed by value */
@ -3786,7 +3786,7 @@ static int parse_page_size(void)
* Functional description * Functional description
* parse the page_size clause of a * parse the page_size clause of a
* define database statement * define database statement
* *
* *
**************************************/ **************************************/
PARSE_match(KW_EQUALS); PARSE_match(KW_EQUALS);
@ -3971,8 +3971,8 @@ static SLONG score_entry( SCE element)
************************************** **************************************
* *
* Functional description * Functional description
* Compute a value to determine placement of an * Compute a value to determine placement of an
* access control element in an Apollo access * access control element in an Apollo access
* control list. * control list.
* *
**************************************/ **************************************/
@ -3982,7 +3982,7 @@ static SLONG score_entry( SCE element)
const TEXT* const* ptr = (TEXT**) element->sce_idents; const TEXT* const* ptr = (TEXT**) element->sce_idents;
for (const TEXT* const* const end = ptr + id_max; ptr < end; for (const TEXT* const* const end = ptr + id_max; ptr < end;
ptr++) ptr++)
{ {
score <<= 1; score <<= 1;
if (*ptr) if (*ptr)

View File

@ -354,7 +354,7 @@ static void add_dimensions( STR dyn, DUDLEY_FLD field)
************************************** **************************************
* *
* Functional description * Functional description
* Generate dynamic DDL to create dimensions. * Generate dynamic DDL to create dimensions.
* First get rid of any old ones. * First get rid of any old ones.
* *
**************************************/ **************************************/
@ -385,7 +385,7 @@ static void add_field( STR dyn, DUDLEY_FLD field, DUDLEY_REL view)
************************************** **************************************
* *
* Functional description * Functional description
* Generate dynamic DDL to create a * Generate dynamic DDL to create a
* local field. * local field.
* *
**************************************/ **************************************/
@ -499,7 +499,7 @@ static void add_filter( STR dyn, FILTER filter)
************************************** **************************************
* *
* Functional description * Functional description
* Generate dynamic DDL to create a * Generate dynamic DDL to create a
* blob filter. * blob filter.
* *
**************************************/ **************************************/
@ -526,7 +526,7 @@ static void add_function( STR dyn, FUNC function)
************************************** **************************************
* *
* Functional description * Functional description
* Generate dynamic DDL to create a * Generate dynamic DDL to create a
* user define function. * user define function.
* *
**************************************/ **************************************/
@ -551,7 +551,7 @@ static void add_function_arg( STR dyn, FUNCARG func_arg)
************************************** **************************************
* *
* Functional description * Functional description
* Generate dynamic DDL to create a * Generate dynamic DDL to create a
* user defined function. * user defined function.
* *
**************************************/ **************************************/
@ -578,7 +578,7 @@ static void add_generator( STR dyn, SYM symbol)
************************************** **************************************
* *
* Functional description * Functional description
* Generate dynamic DDL to create a * Generate dynamic DDL to create a
* generator. * generator.
* *
**************************************/ **************************************/
@ -867,7 +867,7 @@ static void drop_field( STR dyn, DUDLEY_FLD field)
************************************** **************************************
* *
* Functional description * Functional description
* Generate dynamic DDL to eliminate * Generate dynamic DDL to eliminate
* a local field. * a local field.
* *
**************************************/ **************************************/
@ -893,7 +893,7 @@ static void drop_filter( STR dyn, FILTER filter)
************************************** **************************************
* *
* Functional description * Functional description
* Generate dynamic DDL to delete a * Generate dynamic DDL to delete a
* blob filter. * blob filter.
* *
**************************************/ **************************************/
@ -913,7 +913,7 @@ static void drop_function( STR dyn, FUNC function)
************************************** **************************************
* *
* Functional description * Functional description
* Generate dynamic DDL to delete a * Generate dynamic DDL to delete a
* user defined function. * user defined function.
* *
**************************************/ **************************************/
@ -933,7 +933,7 @@ static void drop_global_field( STR dyn, DUDLEY_FLD field)
************************************** **************************************
* *
* Functional description * Functional description
* Generate dynamic DDL to eliminate * Generate dynamic DDL to eliminate
* a global field. * a global field.
* *
**************************************/ **************************************/
@ -969,7 +969,7 @@ static void drop_relation( STR dyn, DUDLEY_REL relation)
{ {
/************************************** /**************************************
* *
* d r o p _ r e l a t i o n * d r o p _ r e l a t i o n
* *
************************************** **************************************
* *
@ -1188,7 +1188,7 @@ static void modify_field( STR dyn, DUDLEY_FLD field, DUDLEY_REL view)
************************************** **************************************
* *
* Functional description * Functional description
* Generate dynamic DDL to modify a * Generate dynamic DDL to modify a
* local field. * local field.
* *
**************************************/ **************************************/
@ -1293,7 +1293,7 @@ static void modify_global_field( STR dyn, DUDLEY_FLD field)
} }
else else
put_symbol(dyn, isc_dyn_fld_query_name, field->fld_query_name); put_symbol(dyn, isc_dyn_fld_query_name, field->fld_query_name);
if (field->fld_flags & fld_null_query_header) { if (field->fld_flags & fld_null_query_header) {
check_dyn(dyn, 3); check_dyn(dyn, 3);
dyn->add_byte(isc_dyn_fld_query_header); dyn->add_byte(isc_dyn_fld_query_header);

View File

@ -64,7 +64,7 @@ be easy to add needed headers to stdafx.h after a makefile is built.
#if defined (_WIN32) #if defined (_WIN32)
/* /*
BOOL APIENTRY DllMain( HANDLE ,//hModule, BOOL APIENTRY DllMain( HANDLE ,//hModule,
DWORD ul_reason_for_call, DWORD ul_reason_for_call,
LPVOID //lpReserved LPVOID //lpReserved
) )
{ {
@ -114,7 +114,7 @@ namespace internal
}; };
/* /*
inline fb_len get_varchar_len(const char* vchar) inline fb_len get_varchar_len(const char* vchar)
{ {
return reinterpret_cast<const vvary*>(vchar)->vary_length; return reinterpret_cast<const vvary*>(vchar)->vary_length;
} }
@ -129,7 +129,7 @@ namespace internal
{ {
reinterpret_cast<vvary*>(vchar)->vary_length = len; reinterpret_cast<vvary*>(vchar)->vary_length = len;
} }
inline void set_varchar_len(ISC_UCHAR* vchar, const fb_len len) inline void set_varchar_len(ISC_UCHAR* vchar, const fb_len len)
{ {
reinterpret_cast<vvary*>(vchar)->vary_length = len; reinterpret_cast<vvary*>(vchar)->vary_length = len;
@ -739,7 +739,7 @@ FBUDF_API void fbround(const paramdsc* v, paramdsc* rc)
rc->dsc_scale = 0; rc->dsc_scale = 0;
return; return;
} }
// round(0.3) => 0 ### round(0.5) => 1 // round(0.3) => 0 ### round(0.5) => 1
// round(-0.3) => 0 ### round(-0.5) => 0 // round(-0.3) => 0 ### round(-0.5) => 0
// round(-0.3) => 0 ### round(-0.5) => -1 ### SYMMETRIC_MATH defined. // round(-0.3) => 0 ### round(-0.5) => -1 ### SYMMETRIC_MATH defined.

View File

@ -15,11 +15,11 @@
* *
* All Rights Reserved. * All Rights Reserved.
* Contributor(s): ______________________________________. * Contributor(s): ______________________________________.
* Changes made by Claudio Valderrama for the Firebird project * Changes made by Claudio Valderrama for the Firebird project
* changes to substr and added substrlen * changes to substr and added substrlen
* 2004.9.1 Claudio Valderrama, change some UDF's to be able to detect NULL. * 2004.9.1 Claudio Valderrama, change some UDF's to be able to detect NULL.
* 2004.12.5 Slavomir Skopalik contributed IB_UDF_frac. * 2004.12.5 Slavomir Skopalik contributed IB_UDF_frac.
* *
*/ */
#include "firebird.h" #include "firebird.h"
@ -145,8 +145,8 @@ double EXPORT IB_UDF_div( ISC_LONG *a, ISC_LONG *b)
} }
else else
{ {
// This is a Kludge! We need to return INF, // This is a Kludge! We need to return INF,
// but this seems to be the only way to do // but this seems to be the only way to do
// it since there seens to be no constant for it. // it since there seens to be no constant for it.
#ifdef HAVE_INFINITY #ifdef HAVE_INFINITY
return INFINITY; return INFINITY;
@ -189,7 +189,7 @@ char *EXPORT IB_UDF_lower(const char *s)
{ {
if (!s) if (!s)
return 0; return 0;
char* buf = (char *) ib_util_malloc(strlen(s) + 1); char* buf = (char *) ib_util_malloc(strlen(s) + 1);
char* p = buf; char* p = buf;
while (*s) while (*s)
@ -211,7 +211,7 @@ char *EXPORT IB_UDF_lpad( const char *s, ISC_LONG *a, const char *c)
return 0; return 0;
const long avalue = *a; const long avalue = *a;
if (avalue >= 0) { if (avalue >= 0) {
long current = 0; long current = 0;
const long length = strlen(s); const long length = strlen(s);
@ -242,10 +242,10 @@ char *EXPORT IB_UDF_ltrim( const char *s)
{ {
if (!s) if (!s)
return 0; return 0;
while (*s == ' ') /* skip leading blanks */ while (*s == ' ') /* skip leading blanks */
s++; s++;
const long length = strlen(s); const long length = strlen(s);
char* buf = (char *) ib_util_malloc(length + 1); char* buf = (char *) ib_util_malloc(length + 1);
memcpy(buf, s, length); memcpy(buf, s, length);
@ -265,8 +265,8 @@ double EXPORT IB_UDF_mod( ISC_LONG *a, ISC_LONG *b)
} }
else else
{ {
// This is a Kludge! We need to return INF, // This is a Kludge! We need to return INF,
// but this seems to be the only way to do // but this seems to be the only way to do
// it since there seens to be no constant for it. // it since there seens to be no constant for it.
#ifdef HAVE_INFINITY #ifdef HAVE_INFINITY
return INFINITY; return INFINITY;
@ -296,7 +296,7 @@ char *EXPORT IB_UDF_rpad( const char *s, ISC_LONG *a, const char *c)
{ {
if (!s || !c) if (!s || !c)
return 0; return 0;
const long avalue = *a; const long avalue = *a;
if (avalue >= 0) { if (avalue >= 0) {
@ -328,10 +328,10 @@ char *EXPORT IB_UDF_rtrim( const char *s)
{ {
if (!s) if (!s)
return 0; return 0;
const char* p = s + strlen(s); const char* p = s + strlen(s);
while (--p >= s && *p == ' '); // empty loop body while (--p >= s && *p == ' '); // empty loop body
const long length = p - s + 1; const long length = p - s + 1;
char* buf = (char *) ib_util_malloc(length + 1); char* buf = (char *) ib_util_malloc(length + 1);
memcpy(buf, s, length); memcpy(buf, s, length);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,23 +1,23 @@
//____________________________________________________________ //____________________________________________________________
// //
// PROGRAM: C preprocessor // PROGRAM: C preprocessor
// MODULE: cme.cpp // MODULE: cme.cpp
// DESCRIPTION: Request expression compiler // DESCRIPTION: Request expression compiler
// //
// The contents of this file are subject to the Interbase Public // The contents of this file are subject to the Interbase Public
// License Version 1.0 (the "License"); you may not use this file // License Version 1.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy // except in compliance with the License. You may obtain a copy
// of the License at http://www.Inprise.com/IPL.html // of the License at http://www.Inprise.com/IPL.html
// //
// Software distributed under the License is distributed on an // Software distributed under the License is distributed on an
// "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express // "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
// or implied. See the License for the specific language governing // or implied. See the License for the specific language governing
// rights and limitations under the License. // rights and limitations under the License.
// //
// The Original Code was created by Inprise Corporation // The Original Code was created by Inprise Corporation
// and its predecessors. Portions created by Inprise Corporation are // and its predecessors. Portions created by Inprise Corporation are
// Copyright (C) Inprise Corporation. // Copyright (C) Inprise Corporation.
// //
// All Rights Reserved. // All Rights Reserved.
// Contributor(s): ______________________________________. // Contributor(s): ______________________________________.
// //
@ -110,7 +110,7 @@ const op_table operators[] =
{ nod_user_name , blr_user_name }, { nod_user_name , blr_user_name },
// { count2 } // { count2 }
// { nod_count, blr_count2 }, // { nod_count, blr_count2 },
// //
{ nod_count , blr_count }, { nod_count , blr_count },
{ nod_max , blr_maximum }, { nod_max , blr_maximum },
{ nod_min , blr_minimum }, { nod_min , blr_minimum },
@ -160,9 +160,9 @@ static inline bool is_date_and_time(const USHORT d1, const USHORT d2)
} }
//____________________________________________________________ //____________________________________________________________
// //
// Compile a random expression. // Compile a random expression.
// //
void CME_expr(GPRE_NOD node, gpre_req* request) void CME_expr(GPRE_NOD node, gpre_req* request)
{ {
@ -312,7 +312,7 @@ void CME_expr(GPRE_NOD node, gpre_req* request)
// STUFF (blr_count); // STUFF (blr_count);
// CME_rse (node->nod_arg [0], request); // CME_rse (node->nod_arg [0], request);
// return; // return;
// //
case nod_agg_total: case nod_agg_total:
if (node->nod_arg[1] && !(request->req_database->dbb_flags & DBB_v3)) if (node->nod_arg[1] && !(request->req_database->dbb_flags & DBB_v3))
@ -336,8 +336,8 @@ void CME_expr(GPRE_NOD node, gpre_req* request)
case nod_dom_value: case nod_dom_value:
request->add_byte(blr_fid); request->add_byte(blr_fid);
request->add_byte(0); // Context request->add_byte(0); // Context
request->add_word(0); // Field id request->add_word(0); // Field id
return; return;
case nod_map_ref: case nod_map_ref:
@ -480,7 +480,7 @@ void CME_expr(GPRE_NOD node, gpre_req* request)
case nod_ansi_any: case nod_ansi_any:
case nod_ansi_all: case nod_ansi_all:
case nod_unique: case nod_unique:
// count2 next line would be deleted // count2 next line would be deleted
case nod_count: case nod_count:
CME_rse((gpre_rse*) node->nod_arg[0], request); CME_rse((gpre_rse*) node->nod_arg[0], request);
break; break;
@ -490,9 +490,9 @@ void CME_expr(GPRE_NOD node, gpre_req* request)
case nod_average: case nod_average:
case nod_total: case nod_total:
case nod_from: case nod_from:
// //
// case nod_count: // case nod_count:
// //
CME_rse((gpre_rse*) node->nod_arg[0], request); CME_rse((gpre_rse*) node->nod_arg[0], request);
CME_expr(node->nod_arg[1], request); CME_expr(node->nod_arg[1], request);
break; break;
@ -506,9 +506,9 @@ void CME_expr(GPRE_NOD node, gpre_req* request)
//____________________________________________________________ //____________________________________________________________
// //
// Compute datatype, length, and scale of an expression. // Compute datatype, length, and scale of an expression.
// //
void CME_get_dtype(const gpre_nod* node, gpre_fld* f) void CME_get_dtype(const gpre_nod* node, gpre_fld* f)
{ {
@ -534,12 +534,12 @@ void CME_get_dtype(const gpre_nod* node, gpre_fld* f)
* SELECT NULL FROM TABLE1; * SELECT NULL FROM TABLE1;
* As we don't have a <dtype_null, HOSTTYPE> datatype pairing, * As we don't have a <dtype_null, HOSTTYPE> datatype pairing,
* we don't know how to map this NULL to a host-language * we don't know how to map this NULL to a host-language
* datatype. Therefore we now describe it as a * datatype. Therefore we now describe it as a
* CHAR(1) CHARACTER SET NONE type. * CHAR(1) CHARACTER SET NONE type.
* No value will ever be sent back, as the value of the select * No value will ever be sent back, as the value of the select
* will be NULL - this is only for purposes of allocating * will be NULL - this is only for purposes of allocating
* values in the message DESCRIBING * values in the message DESCRIBING
* the statement. * the statement.
* Other parts of gpre aren't too happy with a dtype_unknown datatype * Other parts of gpre aren't too happy with a dtype_unknown datatype
*/ */
f->fld_dtype = dtype_text; f->fld_dtype = dtype_text;
@ -710,7 +710,7 @@ void CME_get_dtype(const gpre_nod* node, gpre_fld* f)
CPR_error("expression evaluation not supported"); CPR_error("expression evaluation not supported");
} }
} }
switch (dtype_max) switch (dtype_max)
{ {
case dtype_short: case dtype_short:
@ -1057,7 +1057,7 @@ void CME_get_dtype(const gpre_nod* node, gpre_fld* f)
f->fld_length = strlen(string) - 2; f->fld_length = strlen(string) - 2;
if (gpreGlob.sw_cstring) if (gpreGlob.sw_cstring)
{ {
// add 1 back for the NULL byte // add 1 back for the NULL byte
f->fld_length += 1; f->fld_length += 1;
f->fld_dtype = dtype_cstring; f->fld_dtype = dtype_cstring;
@ -1138,9 +1138,9 @@ void CME_get_dtype(const gpre_nod* node, gpre_fld* f)
//____________________________________________________________ //____________________________________________________________
// //
// Generate a relation reference. // Generate a relation reference.
// //
void CME_relation(gpre_ctx* context, gpre_req* request) void CME_relation(gpre_ctx* context, gpre_req* request)
{ {
@ -1214,9 +1214,9 @@ void CME_relation(gpre_ctx* context, gpre_req* request)
//____________________________________________________________ //____________________________________________________________
// //
// Generate blr for an rse node. // Generate blr for an rse node.
// //
void CME_rse(gpre_rse* selection, gpre_req* request) void CME_rse(gpre_rse* selection, gpre_req* request)
{ {
@ -1234,7 +1234,7 @@ void CME_rse(gpre_rse* selection, gpre_req* request)
else else
request->add_byte(blr_rs_stream); request->add_byte(blr_rs_stream);
// Process unions, if any, otherwise process relations // Process unions, if any, otherwise process relations
gpre_rse* sub_rse = 0; gpre_rse* sub_rse = 0;
gpre_nod* union_node = selection->rse_union; gpre_nod* union_node = selection->rse_union;
@ -1284,7 +1284,7 @@ void CME_rse(gpre_rse* selection, gpre_req* request)
request->add_byte(blr_writelock); request->add_byte(blr_writelock);
} }
// Process the clauses present // Process the clauses present
if (selection->rse_first) if (selection->rse_first)
{ {
@ -1351,11 +1351,11 @@ void CME_rse(gpre_rse* selection, gpre_req* request)
} }
#ifdef SCROLLABLE_CURSORS #ifdef SCROLLABLE_CURSORS
// generate a statement to be executed if the user scrolls // generate a statement to be executed if the user scrolls
// in a direction other than forward; a message is sent outside // in a direction other than forward; a message is sent outside
// the normal send/receive protocol to specify the direction // the normal send/receive protocol to specify the direction
// and offset to scroll; note that we do this only on a SELECT // and offset to scroll; note that we do this only on a SELECT
// type statement and only when talking to a 4.1 engine or greater // type statement and only when talking to a 4.1 engine or greater
if (request->req_flags & REQ_sql_cursor && if (request->req_flags & REQ_sql_cursor &&
request->req_database->dbb_base_level >= 5) request->req_database->dbb_base_level >= 5)
@ -1372,17 +1372,17 @@ void CME_rse(gpre_rse* selection, gpre_req* request)
} }
#endif #endif
// Finish up by making a BLR_END // Finish up by making a BLR_END
request->add_byte(blr_end); request->add_byte(blr_end);
} }
//____________________________________________________________ //____________________________________________________________
// //
// Compile up an array reference putting // Compile up an array reference putting
// out sdl (slice description language) // out sdl (slice description language)
// //
static void cmp_array( GPRE_NOD node, gpre_req* request) static void cmp_array( GPRE_NOD node, gpre_req* request)
{ {
@ -1412,11 +1412,11 @@ static void cmp_array( GPRE_NOD node, gpre_req* request)
reference->add_byte(isc_sdl_struct); reference->add_byte(isc_sdl_struct);
reference->add_byte(1); reference->add_byte(1);
// The datatype of the array elements // The datatype of the array elements
cmp_sdl_dtype(field->fld_array, reference); cmp_sdl_dtype(field->fld_array, reference);
// The relation and field identifiers or strings // The relation and field identifiers or strings
if (gpreGlob.sw_ids) if (gpreGlob.sw_ids)
{ {
@ -1438,11 +1438,11 @@ static void cmp_array( GPRE_NOD node, gpre_req* request)
reference->add_byte(*p); reference->add_byte(*p);
} }
// The loops for the dimensions // The loops for the dimensions
stuff_sdl_loops(reference, field); stuff_sdl_loops(reference, field);
// The array element and its "subscripts" // The array element and its "subscripts"
stuff_sdl_element(reference, field); stuff_sdl_element(reference, field);
@ -1459,10 +1459,10 @@ static void cmp_array( GPRE_NOD node, gpre_req* request)
//____________________________________________________________ //____________________________________________________________
// //
// Compile up a subscripted array reference // Compile up a subscripted array reference
// from an gpre_rse and output blr for this reference // from an gpre_rse and output blr for this reference
// //
static void cmp_array_element( GPRE_NOD node, gpre_req* request) static void cmp_array_element( GPRE_NOD node, gpre_req* request)
{ {
@ -1480,8 +1480,8 @@ static void cmp_array_element( GPRE_NOD node, gpre_req* request)
//____________________________________________________________ //____________________________________________________________
// //
// //
static void cmp_cast( GPRE_NOD node, gpre_req* request) static void cmp_cast( GPRE_NOD node, gpre_req* request)
{ {
@ -1493,9 +1493,9 @@ static void cmp_cast( GPRE_NOD node, gpre_req* request)
//____________________________________________________________ //____________________________________________________________
// //
// Compile up a field reference. // Compile up a field reference.
// //
static void cmp_field( const gpre_nod* node, gpre_req* request) static void cmp_field( const gpre_nod* node, gpre_req* request)
{ {
@ -1554,9 +1554,9 @@ static void cmp_field( const gpre_nod* node, gpre_req* request)
//____________________________________________________________ //____________________________________________________________
// //
// Handle a literal expression. // Handle a literal expression.
// //
static void cmp_literal( const gpre_nod* node, gpre_req* request) static void cmp_literal( const gpre_nod* node, gpre_req* request)
{ {
@ -1584,7 +1584,7 @@ static void cmp_literal( const gpre_nod* node, gpre_req* request)
if (!(request->req_database->dbb_flags & DBB_v3)) if (!(request->req_database->dbb_flags & DBB_v3))
request->add_byte(blr_double); request->add_byte(blr_double);
else if (gpreGlob.sw_know_interp) else if (gpreGlob.sw_know_interp)
{ // then must be using blr_version5 { // then must be using blr_version5
request->add_byte(blr_text2); request->add_byte(blr_text2);
request->add_word(ttype_ascii); request->add_word(ttype_ascii);
} }
@ -1631,7 +1631,7 @@ static void cmp_literal( const gpre_nod* node, gpre_req* request)
else else
long_val = (long) uint64_val; long_val = (long) uint64_val;
request->add_byte(blr_long); request->add_byte(blr_long);
request->add_byte(scale); // scale factor request->add_byte(scale); // scale factor
request->add_word(long_val); request->add_word(long_val);
request->add_word(long_val >> 16); request->add_word(long_val >> 16);
} }
@ -1644,7 +1644,7 @@ static void cmp_literal( const gpre_nod* node, gpre_req* request)
else else
sint64_val = (SINT64) uint64_val; sint64_val = (SINT64) uint64_val;
request->add_byte(blr_int64); request->add_byte(blr_int64);
request->add_byte(scale); // scale factor request->add_byte(scale); // scale factor
request->add_word(sint64_val); request->add_word(sint64_val);
request->add_word(sint64_val >> 16); request->add_word(sint64_val >> 16);
request->add_word(sint64_val >> 32); request->add_word(sint64_val >> 32);
@ -1657,18 +1657,18 @@ static void cmp_literal( const gpre_nod* node, gpre_req* request)
} }
else else
{ {
// Remove surrounding quotes from string, etc. // Remove surrounding quotes from string, etc.
char buffer[MAX_SYM_SIZE]; char buffer[MAX_SYM_SIZE];
char* p = buffer; char* p = buffer;
// Skip introducing quote mark // Skip introducing quote mark
if (*string) if (*string)
string++; string++;
while (*string) while (*string)
*p++ = *string++; *p++ = *string++;
// Zap out terminating quote mark // Zap out terminating quote mark
*--p = 0; *--p = 0;
const SSHORT length = p - buffer; const SSHORT length = p - buffer;
@ -1738,9 +1738,9 @@ static void cmp_literal( const gpre_nod* node, gpre_req* request)
//____________________________________________________________ //____________________________________________________________
// //
// Generate a map for a union or aggregate rse. // Generate a map for a union or aggregate rse.
// //
static void cmp_map(map* a_map, gpre_req* request) static void cmp_map(map* a_map, gpre_req* request)
{ {
@ -1756,13 +1756,13 @@ static void cmp_map(map* a_map, gpre_req* request)
//____________________________________________________________ //____________________________________________________________
// //
// Generate an access plan for a query. // Generate an access plan for a query.
// //
static void cmp_plan(const gpre_nod* plan_expression, gpre_req* request) static void cmp_plan(const gpre_nod* plan_expression, gpre_req* request)
{ {
// stuff the join type // stuff the join type
const gpre_nod* list = plan_expression->nod_arg[1]; const gpre_nod* list = plan_expression->nod_arg[1];
if (list->nod_count > 1) if (list->nod_count > 1)
@ -1775,7 +1775,7 @@ static void cmp_plan(const gpre_nod* plan_expression, gpre_req* request)
request->add_byte(list->nod_count); request->add_byte(list->nod_count);
} }
// stuff one or more plan items // stuff one or more plan items
gpre_nod* const* ptr = list->nod_arg; gpre_nod* const* ptr = list->nod_arg;
for (gpre_nod* const* const end = ptr + list->nod_count; ptr < end; ptr++) for (gpre_nod* const* const end = ptr + list->nod_count; ptr < end; ptr++)
@ -1787,16 +1787,16 @@ static void cmp_plan(const gpre_nod* plan_expression, gpre_req* request)
continue; continue;
} }
// if we're here, it must be a nod_plan_item // if we're here, it must be a nod_plan_item
request->add_byte(blr_retrieve); request->add_byte(blr_retrieve);
/* stuff the relation--the relation id itself is redundant except /* stuff the relation--the relation id itself is redundant except
when there is a need to differentiate the base tables of views */ when there is a need to differentiate the base tables of views */
CME_relation((gpre_ctx*) node->nod_arg[2], request); CME_relation((gpre_ctx*) node->nod_arg[2], request);
// now stuff the access method for this stream // now stuff the access method for this stream
const gpre_nod* arg = node->nod_arg[1]; const gpre_nod* arg = node->nod_arg[1];
switch (arg->nod_type) switch (arg->nod_type)
@ -1829,17 +1829,17 @@ static void cmp_plan(const gpre_nod* plan_expression, gpre_req* request)
//____________________________________________________________ //____________________________________________________________
// //
// Print out the correct blr for // Print out the correct blr for
// this datatype. // this datatype.
// //
static void cmp_sdl_dtype( const gpre_fld* field, REF reference) static void cmp_sdl_dtype( const gpre_fld* field, REF reference)
{ {
switch (field->fld_dtype) switch (field->fld_dtype)
{ {
case dtype_cstring: case dtype_cstring:
// 3.2j has new, tagged blr intruction for cstring // 3.2j has new, tagged blr intruction for cstring
if (gpreGlob.sw_know_interp) if (gpreGlob.sw_know_interp)
{ {
@ -1855,7 +1855,7 @@ static void cmp_sdl_dtype( const gpre_fld* field, REF reference)
break; break;
case dtype_text: case dtype_text:
// 3.2j has new, tagged blr intruction for text too // 3.2j has new, tagged blr intruction for text too
if (gpreGlob.sw_know_interp) if (gpreGlob.sw_know_interp)
{ {
@ -1871,7 +1871,7 @@ static void cmp_sdl_dtype( const gpre_fld* field, REF reference)
break; break;
case dtype_varying: case dtype_varying:
// 3.2j has new, tagged blr intruction for varying also // 3.2j has new, tagged blr intruction for varying also
if (gpreGlob.sw_know_interp) if (gpreGlob.sw_know_interp)
{ {
@ -1940,9 +1940,9 @@ static void cmp_sdl_dtype( const gpre_fld* field, REF reference)
//____________________________________________________________ //____________________________________________________________
// //
// Compile a reference to a user defined function. // Compile a reference to a user defined function.
// //
static void cmp_udf( GPRE_NOD node, gpre_req* request) static void cmp_udf( GPRE_NOD node, gpre_req* request)
{ {
@ -1974,9 +1974,9 @@ static void cmp_udf( GPRE_NOD node, gpre_req* request)
//____________________________________________________________ //____________________________________________________________
// //
// Process a random value expression. // Process a random value expression.
// //
static void cmp_value( const gpre_nod* node, gpre_req* request) static void cmp_value( const gpre_nod* node, gpre_req* request)
{ {
@ -2008,9 +2008,9 @@ static void cmp_value( const gpre_nod* node, gpre_req* request)
//____________________________________________________________ //____________________________________________________________
// //
// Figure out a text length from a datatype and a length // Figure out a text length from a datatype and a length
// //
static USHORT get_string_len( const gpre_fld* field) static USHORT get_string_len( const gpre_fld* field)
{ {
@ -2028,17 +2028,17 @@ static USHORT get_string_len( const gpre_fld* field)
} }
//____________________________________________________________ //____________________________________________________________
// //
// Write to the sdl string, the do // Write to the sdl string, the do
// loop for a particular dimension. // loop for a particular dimension.
// //
static void stuff_sdl_dimension(const dim* dimension, static void stuff_sdl_dimension(const dim* dimension,
ref* reference, SSHORT dimension_count) ref* reference, SSHORT dimension_count)
{ {
// In the future, when we support slices, new code to handle the // In the future, when we support slices, new code to handle the
// user-defined slice ranges will be here. // user-defined slice ranges will be here.
if (dimension->dim_lower == 1) if (dimension->dim_lower == 1)
{ {
@ -2057,11 +2057,11 @@ static void stuff_sdl_dimension(const dim* dimension,
//____________________________________________________________ //____________________________________________________________
// //
// Write the element information // Write the element information
// (including the subscripts) to // (including the subscripts) to
// the SDL string for the array. // the SDL string for the array.
// //
static void stuff_sdl_element(ref* reference, const gpre_fld* field) static void stuff_sdl_element(ref* reference, const gpre_fld* field)
{ {
@ -2072,7 +2072,7 @@ static void stuff_sdl_element(ref* reference, const gpre_fld* field)
reference->add_byte(field->fld_array_info->ary_dimension_count); reference->add_byte(field->fld_array_info->ary_dimension_count);
// Fortran needs the array in column-major order // Fortran needs the array in column-major order
if (gpreGlob.sw_language == lang_fortran) if (gpreGlob.sw_language == lang_fortran)
{ {
@ -2095,10 +2095,10 @@ static void stuff_sdl_element(ref* reference, const gpre_fld* field)
//____________________________________________________________ //____________________________________________________________
// //
// Write loop information to the SDL // Write loop information to the SDL
// string for the array dimensions. // string for the array dimensions.
// //
static void stuff_sdl_loops(ref* reference, const gpre_fld* field) static void stuff_sdl_loops(ref* reference, const gpre_fld* field)
{ {
@ -2129,10 +2129,10 @@ static void stuff_sdl_loops(ref* reference, const gpre_fld* field)
//____________________________________________________________ //____________________________________________________________
// //
// Write the number in the 'smallest' // Write the number in the 'smallest'
// form possible to the SDL string. // form possible to the SDL string.
// //
static void stuff_sdl_number(const SLONG number, REF reference) static void stuff_sdl_number(const SLONG number, REF reference)
{ {
@ -2218,21 +2218,21 @@ static void get_dtype_of_case(const gpre_nod* node, gpre_fld* f)
// (dtype_text, dtype_cstring, dtype_varying, dtype_blob sub_type TEXT) // (dtype_text, dtype_cstring, dtype_varying, dtype_blob sub_type TEXT)
// !! Currently engine cannot convert string to BLOB therefor BLOB isn't allowed. !! // !! Currently engine cannot convert string to BLOB therefor BLOB isn't allowed. !!
// - first character-set and collation are used as output descriptor. // - first character-set and collation are used as output descriptor.
// - if all types have datatype CHAR then output should be CHAR else // - if all types have datatype CHAR then output should be CHAR else
// VARCHAR and with the maximum length used from the given list. // VARCHAR and with the maximum length used from the given list.
// //
// If all of the datatypes are EXACT numeric then the output descriptor // If all of the datatypes are EXACT numeric then the output descriptor
// shall be EXACT numeric with the maximum scale and the maximum precision // shall be EXACT numeric with the maximum scale and the maximum precision
// used. (dtype_byte, dtype_short, dtype_long, dtype_int64) // used. (dtype_byte, dtype_short, dtype_long, dtype_int64)
// //
// If any of the datatypes is APPROXIMATE numeric then each datatype in the // If any of the datatypes is APPROXIMATE numeric then each datatype in the
// list shall be numeric else a error is thrown and the output descriptor // list shall be numeric else a error is thrown and the output descriptor
// shall be APPROXIMATE numeric. (dtype_real, dtype_double, dtype_d_float) // shall be APPROXIMATE numeric. (dtype_real, dtype_double, dtype_d_float)
// //
// If any of the datatypes is a datetime type then each datatype in the // If any of the datatypes is a datetime type then each datatype in the
// list shall be the same datetime type else a error is thrown. // list shall be the same datetime type else a error is thrown.
// numeric. (dtype_sql_date, dtype_sql_time, dtype_timestamp) // numeric. (dtype_sql_date, dtype_sql_time, dtype_timestamp)
// //
// If any of the datatypes is a BLOB datatype then : // If any of the datatypes is a BLOB datatype then :
// - all types should be a BLOB else throw error. // - all types should be a BLOB else throw error.
// - all types should have the same sub_type else throw error. // - all types should have the same sub_type else throw error.
@ -2274,7 +2274,7 @@ static void get_dtype_of_list(const gpre_nod* node, gpre_fld* f)
const gpre_fld& field = field_aux; // Trick to avoid more assignment mistakes. const gpre_fld& field = field_aux; // Trick to avoid more assignment mistakes.
// Initialize some values if this is the first time // Initialize some values if this is the first time
if (firstarg) if (firstarg)
{ {
max_scale = field.fld_scale; max_scale = field.fld_scale;
max_length = max_dtype_length = field.fld_length; max_length = max_dtype_length = field.fld_length;
@ -2404,7 +2404,7 @@ static void get_dtype_of_list(const gpre_nod* node, gpre_fld* f)
any_text_blob = true; any_text_blob = true;
} }
} }
else else
all_blob = false; all_blob = false;
} }
@ -2427,7 +2427,7 @@ static void get_dtype_of_list(const gpre_nod* node, gpre_fld* f)
f->fld_dtype = dtype_cstring; f->fld_dtype = dtype_cstring;
else else
f->fld_dtype = dtype_text; f->fld_dtype = dtype_text;
f->fld_ttype = ttype; f->fld_ttype = ttype;
f->fld_length = maxtextlength; f->fld_length = maxtextlength;
f->fld_scale = 0; f->fld_scale = 0;

View File

@ -1,27 +1,27 @@
//____________________________________________________________ //____________________________________________________________
// //
// PROGRAM: C preprocessor // PROGRAM: C preprocessor
// MODULE: cmp.cpp // MODULE: cmp.cpp
// DESCRIPTION: Request compiler // DESCRIPTION: Request compiler
// //
// The contents of this file are subject to the Interbase Public // The contents of this file are subject to the Interbase Public
// License Version 1.0 (the "License"); you may not use this file // License Version 1.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy // except in compliance with the License. You may obtain a copy
// of the License at http://www.Inprise.com/IPL.html // of the License at http://www.Inprise.com/IPL.html
// //
// Software distributed under the License is distributed on an // Software distributed under the License is distributed on an
// "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express // "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
// or implied. See the License for the specific language governing // or implied. See the License for the specific language governing
// rights and limitations under the License. // rights and limitations under the License.
// //
// The Original Code was created by Inprise Corporation // The Original Code was created by Inprise Corporation
// and its predecessors. Portions created by Inprise Corporation are // and its predecessors. Portions created by Inprise Corporation are
// Copyright (C) Inprise Corporation. // Copyright (C) Inprise Corporation.
// //
// All Rights Reserved. // All Rights Reserved.
// Contributor(s): ______________________________________. // Contributor(s): ______________________________________.
// TMN (Mike Nordell) 11.APR.2001 - Reduce compiler warnings // TMN (Mike Nordell) 11.APR.2001 - Reduce compiler warnings
// //
// //
//____________________________________________________________ //____________________________________________________________
// //
@ -84,11 +84,11 @@ static ULONG next_ident;
const int MAX_TPB = 4000; const int MAX_TPB = 4000;
//____________________________________________________________ //____________________________________________________________
// //
// Check to make sure that generated blr string is not about to // Check to make sure that generated blr string is not about to
// over the memory allocated for it. If so, allocate an extra // over the memory allocated for it. If so, allocate an extra
// couple of hundred bytes to be safe. // couple of hundred bytes to be safe.
// //
void CMP_check( gpre_req* request, SSHORT min_reqd) void CMP_check( gpre_req* request, SSHORT min_reqd)
{ {
@ -112,11 +112,11 @@ void CMP_check( gpre_req* request, SSHORT min_reqd)
//____________________________________________________________ //____________________________________________________________
// //
// Compile a single request, but do not generate any text. // Compile a single request, but do not generate any text.
// Generate port blocks, assign parameter numbers, message // Generate port blocks, assign parameter numbers, message
// numbers, and internal idents. Compute length of request. // numbers, and internal idents. Compute length of request.
// //
void CMP_compile_request( gpre_req* request) void CMP_compile_request( gpre_req* request)
{ {
@ -135,7 +135,7 @@ void CMP_compile_request( gpre_req* request)
request->req_ident = CMP_next_ident(); request->req_ident = CMP_next_ident();
// If this is an SQL blob cursor, compile the blob and get out fast. // If this is an SQL blob cursor, compile the blob and get out fast.
if (request->req_flags & (REQ_sql_blob_open | REQ_sql_blob_create)) { if (request->req_flags & (REQ_sql_blob_open | REQ_sql_blob_create)) {
for (blb* blob = request->req_blobs; blob; blob = blob->blb_next) for (blb* blob = request->req_blobs; blob; blob = blob->blb_next)
@ -144,7 +144,7 @@ void CMP_compile_request( gpre_req* request)
} }
// Before we get too far, make sure an eof field has been // Before we get too far, make sure an eof field has been
// constructed. If not, do so now. // constructed. If not, do so now.
ref* reference; ref* reference;
if (!eof_field) { if (!eof_field) {
@ -162,7 +162,7 @@ void CMP_compile_request( gpre_req* request)
lit1 = MSC_unary(nod_literal, (GPRE_NOD) reference); lit1 = MSC_unary(nod_literal, (GPRE_NOD) reference);
} }
// Handle different request types differently // Handle different request types differently
switch (request->req_type) { switch (request->req_type) {
case REQ_create_database: case REQ_create_database:
@ -180,12 +180,12 @@ void CMP_compile_request( gpre_req* request)
cmp_procedure(request); cmp_procedure(request);
return; return;
} }
// expand any incomplete references or values // expand any incomplete references or values
expand_references(request->req_references); expand_references(request->req_references);
expand_references(request->req_values); expand_references(request->req_values);
// Initialize the blr string // Initialize the blr string
request->req_blr = request->req_base = MSC_alloc(500); request->req_blr = request->req_base = MSC_alloc(500);
request->req_length = 500; request->req_length = 500;
@ -195,13 +195,13 @@ void CMP_compile_request( gpre_req* request)
request->add_byte(blr_version5); request->add_byte(blr_version5);
// If there are values to be transmitted, make a port // If there are values to be transmitted, make a port
// to hold them // to hold them
if (request->req_values) if (request->req_values)
request->req_vport = make_port(request, request->req_values); request->req_vport = make_port(request, request->req_values);
#ifdef SCROLLABLE_CURSORS #ifdef SCROLLABLE_CURSORS
// If there is an asynchronous message to be sent, make a port for it // If there is an asynchronous message to be sent, make a port for it
if (request->req_flags & REQ_sql_cursor && if (request->req_flags & REQ_sql_cursor &&
request->req_database->dbb_base_level >= 5) request->req_database->dbb_base_level >= 5)
@ -221,7 +221,7 @@ void CMP_compile_request( gpre_req* request)
#endif #endif
// If this is a FOR type request, an eof field reference needs // If this is a FOR type request, an eof field reference needs
// to be generated. Do it. // to be generated. Do it.
if (request->req_type == REQ_for || if (request->req_type == REQ_for ||
request->req_type == REQ_cursor || request->req_type == REQ_any) request->req_type == REQ_cursor || request->req_type == REQ_any)
@ -238,7 +238,7 @@ void CMP_compile_request( gpre_req* request)
else else
reference = request->req_references; reference = request->req_references;
// Assume that a general port needs to be constructed. // Assume that a general port needs to be constructed.
gpre_port* port; gpre_port* port;
if ((request->req_type != REQ_insert) && (request->req_type != REQ_store2) if ((request->req_type != REQ_insert) && (request->req_type != REQ_store2)
@ -249,7 +249,7 @@ void CMP_compile_request( gpre_req* request)
// Loop thru actions looking for something interesting to do. Not // Loop thru actions looking for something interesting to do. Not
// all action types are "interesting", so don't worry about missing // all action types are "interesting", so don't worry about missing
// ones. // ones.
upd* update; upd* update;
for (act* action = request->req_actions; action; action = action->act_next) for (act* action = request->req_actions; action; action = action->act_next)
@ -286,12 +286,12 @@ void CMP_compile_request( gpre_req* request)
cmp_blr(request); cmp_blr(request);
request->add_byte(blr_eoc); request->add_byte(blr_eoc);
// Compute out final blr lengths // Compute out final blr lengths
request->req_length = request->req_blr - request->req_base; request->req_length = request->req_blr - request->req_base;
request->req_blr = request->req_base; request->req_blr = request->req_base;
// Finally, assign identifiers to any blobs that may have been referenced // Finally, assign identifiers to any blobs that may have been referenced
for (blb* blob = request->req_blobs; blob; blob = blob->blb_next) for (blb* blob = request->req_blobs; blob; blob = blob->blb_next)
cmp_blob(blob, false); cmp_blob(blob, false);
@ -299,12 +299,12 @@ void CMP_compile_request( gpre_req* request)
//____________________________________________________________ //____________________________________________________________
// //
// Stuff field datatype info into request. // Stuff field datatype info into request.
// Text fields are not remapped to process text type. // Text fields are not remapped to process text type.
// This is used by the CAST & COLLATE operators to // This is used by the CAST & COLLATE operators to
// indicate cast datatypes. // indicate cast datatypes.
// //
void CMP_external_field( gpre_req* request, const gpre_fld* field) void CMP_external_field( gpre_req* request, const gpre_fld* field)
{ {
@ -336,10 +336,10 @@ void CMP_external_field( gpre_req* request, const gpre_fld* field)
//____________________________________________________________ //____________________________________________________________
// //
// Initialize (or re-initialize) for request compilation. This is // Initialize (or re-initialize) for request compilation. This is
// called at most once per module. // called at most once per module.
// //
void CMP_init(void) void CMP_init(void)
{ {
@ -351,9 +351,9 @@ void CMP_init(void)
//____________________________________________________________ //____________________________________________________________
// //
// Give out next identifier. // Give out next identifier.
// //
ULONG CMP_next_ident(void) ULONG CMP_next_ident(void)
{ {
@ -362,9 +362,9 @@ ULONG CMP_next_ident(void)
//____________________________________________________________ //____________________________________________________________
// //
// Stuff a symbol. // Stuff a symbol.
// //
void CMP_stuff_symbol( gpre_req* request, const gpre_sym* symbol) void CMP_stuff_symbol( gpre_req* request, const gpre_sym* symbol)
{ {
@ -376,17 +376,17 @@ void CMP_stuff_symbol( gpre_req* request, const gpre_sym* symbol)
//____________________________________________________________ //____________________________________________________________
// //
// Take a transaction block with (potentially) a // Take a transaction block with (potentially) a
// lot of relation lock blocks, and generate TPBs // lot of relation lock blocks, and generate TPBs
// //
// We'll always generate TPB's, and link them // We'll always generate TPB's, and link them
// into the DBB for that database so they get // into the DBB for that database so they get
// generated. If there's no lock list, we generate // generated. If there's no lock list, we generate
// a simple TPB for every database in the program. // a simple TPB for every database in the program.
// If there is a lock list, we generate a more complex // If there is a lock list, we generate a more complex
// TPB for each database referenced. // TPB for each database referenced.
// //
void CMP_t_start( gpre_tra* trans) void CMP_t_start( gpre_tra* trans)
{ {
@ -394,7 +394,7 @@ void CMP_t_start( gpre_tra* trans)
char tpb_buffer[MAX_TRA_OPTIONS + 1]; char tpb_buffer[MAX_TRA_OPTIONS + 1];
// fill out a standard tpb buffer ahead of time so we know // fill out a standard tpb buffer ahead of time so we know
// how large it is // how large it is
char* text = tpb_buffer; char* text = tpb_buffer;
*text++ = isc_tpb_version1; *text++ = isc_tpb_version1;
@ -421,7 +421,7 @@ void CMP_t_start( gpre_tra* trans)
for (dbb* database = gpreGlob.isc_databases; database; database = database->dbb_next) for (dbb* database = gpreGlob.isc_databases; database; database = database->dbb_next)
{ {
/* /*
* figure out if this is a simple transaction or a reserving * figure out if this is a simple transaction or a reserving
* transaction. Allocate a TPB of the right size in either * transaction. Allocate a TPB of the right size in either
* case. * case.
@ -459,7 +459,7 @@ void CMP_t_start( gpre_tra* trans)
new_tpb->tpb_length = buff_len + tpb_len; new_tpb->tpb_length = buff_len + tpb_len;
database->dbb_rrls = NULL; database->dbb_rrls = NULL;
} }
else // this database isn't referenced else // this database isn't referenced
continue; continue;
/* link this into the TPB chains (gpre_tra and DBB) */ /* link this into the TPB chains (gpre_tra and DBB) */
@ -471,7 +471,7 @@ void CMP_t_start( gpre_tra* trans)
trans->tra_tpb = new_tpb; trans->tra_tpb = new_tpb;
trans->tra_db_count++; trans->tra_db_count++;
// fill in the standard TPB and concatenate the relation names // fill in the standard TPB and concatenate the relation names
new_tpb->tpb_ident = CMP_next_ident(); new_tpb->tpb_ident = CMP_next_ident();
@ -485,9 +485,9 @@ void CMP_t_start( gpre_tra* trans)
//____________________________________________________________ //____________________________________________________________
// //
// Generate blr tree for free standing ANY expression. // Generate blr tree for free standing ANY expression.
// //
static void cmp_any( gpre_req* request) static void cmp_any( gpre_req* request)
{ {
@ -502,7 +502,7 @@ static void cmp_any( gpre_req* request)
gpre_nod* value = MSC_unary(nod_value, (GPRE_NOD) port->por_references); gpre_nod* value = MSC_unary(nod_value, (GPRE_NOD) port->por_references);
// Make a send to signal end of file // Make a send to signal end of file
request->add_byte(blr_assignment); request->add_byte(blr_assignment);
CME_expr(lit1, request); CME_expr(lit1, request);
@ -526,9 +526,9 @@ static void cmp_any( gpre_req* request)
//____________________________________________________________ //____________________________________________________________
// //
// Compile a build assignment statement. // Compile a build assignment statement.
// //
static void cmp_assignment( GPRE_NOD node, gpre_req* request) static void cmp_assignment( GPRE_NOD node, gpre_req* request)
{ {
@ -540,9 +540,9 @@ static void cmp_assignment( GPRE_NOD node, gpre_req* request)
//____________________________________________________________ //____________________________________________________________
// //
// Compile a blob parameter block, if required. // Compile a blob parameter block, if required.
// //
static void cmp_blob(blb* blob, static void cmp_blob(blb* blob,
bool sql_flag) bool sql_flag)
@ -588,7 +588,7 @@ static void cmp_blob(blb* blob,
} }
if (blob->blb_from_charset) { if (blob->blb_from_charset) {
// create bpb instruction for source character set // create bpb instruction for source character set
*p++ = isc_bpb_source_interp; *p++ = isc_bpb_source_interp;
*p++ = 2; *p++ = 2;
@ -598,7 +598,7 @@ static void cmp_blob(blb* blob,
if (blob->blb_to_charset) { if (blob->blb_to_charset) {
// create bpb instruction for target character set // create bpb instruction for target character set
*p++ = isc_bpb_target_interp; *p++ = isc_bpb_target_interp;
*p++ = 2; *p++ = 2;
@ -611,21 +611,21 @@ static void cmp_blob(blb* blob,
//____________________________________________________________ //____________________________________________________________
// //
// Build a request tree for a request. // Build a request tree for a request.
// //
static void cmp_blr( gpre_req* request) static void cmp_blr( gpre_req* request)
{ {
request->add_byte(blr_begin); request->add_byte(blr_begin);
// build message definition for each port // build message definition for each port
gpre_port* port; gpre_port* port;
for (port = request->req_ports; port; port = port->por_next) for (port = request->req_ports; port; port = port->por_next)
cmp_port(port, request); cmp_port(port, request);
// See if there is a receive to be built // See if there is a receive to be built
if ((request->req_type == REQ_store) || (request->req_type == REQ_store2)) if ((request->req_type == REQ_store) || (request->req_type == REQ_store2))
port = request->req_primary; port = request->req_primary;
@ -635,7 +635,7 @@ static void cmp_blr( gpre_req* request)
if (port) if (port)
make_receive(port, request); make_receive(port, request);
// Compile up request // Compile up request
switch (request->req_type) { switch (request->req_type) {
case REQ_cursor: case REQ_cursor:
@ -670,9 +670,9 @@ static void cmp_blr( gpre_req* request)
//____________________________________________________________ //____________________________________________________________
// //
// Generate blr for ERASE action. // Generate blr for ERASE action.
// //
static void cmp_erase( act* action, gpre_req* request) static void cmp_erase( act* action, gpre_req* request)
{ {
@ -689,11 +689,11 @@ static void cmp_erase( act* action, gpre_req* request)
//____________________________________________________________ //____________________________________________________________
// //
// Go over an SQL fetch list and expand // Go over an SQL fetch list and expand
// references to indicator variables. // references to indicator variables.
// Not tough. // Not tough.
// //
static void cmp_fetch( act* action) static void cmp_fetch( act* action)
{ {
@ -717,9 +717,9 @@ static void cmp_fetch( act* action)
//____________________________________________________________ //____________________________________________________________
// //
// Stuff field datatype info into request. // Stuff field datatype info into request.
// //
static void cmp_field( gpre_req* request, const gpre_fld* field, static void cmp_field( gpre_req* request, const gpre_fld* field,
const ref* reference) const ref* reference)
@ -741,7 +741,7 @@ static void cmp_field( gpre_req* request, const gpre_fld* field,
request->add_word(field->fld_length); request->add_word(field->fld_length);
} }
else { else {
// 3.2j has new, tagged blr instruction for cstring // 3.2j has new, tagged blr instruction for cstring
request->add_byte(blr_cstring2); request->add_byte(blr_cstring2);
request->add_word(field->fld_ttype); request->add_word(field->fld_ttype);
@ -755,7 +755,7 @@ static void cmp_field( gpre_req* request, const gpre_fld* field,
request->add_word(field->fld_length); request->add_word(field->fld_length);
} }
else { else {
// 3.2j has new, tagged blr instruction for text too // 3.2j has new, tagged blr instruction for text too
request->add_byte(blr_text2); request->add_byte(blr_text2);
request->add_word(field->fld_ttype); request->add_word(field->fld_ttype);
@ -769,7 +769,7 @@ static void cmp_field( gpre_req* request, const gpre_fld* field,
request->add_word(field->fld_length); request->add_word(field->fld_length);
} }
else { else {
// 3.2j has new, tagged blr instruction for varying also // 3.2j has new, tagged blr instruction for varying also
request->add_byte(blr_varying2); request->add_byte(blr_varying2);
request->add_word(field->fld_ttype); request->add_word(field->fld_ttype);
@ -834,9 +834,9 @@ static void cmp_field( gpre_req* request, const gpre_fld* field,
//____________________________________________________________ //____________________________________________________________
// //
// Generate blr tree for for statement // Generate blr tree for for statement
// //
static void cmp_for( gpre_req* request) static void cmp_for( gpre_req* request)
{ {
@ -863,7 +863,7 @@ static void cmp_for( gpre_req* request)
CME_rse(request->req_rse, request); CME_rse(request->req_rse, request);
// Loop thru actions looking for primary port. While we're at it, // Loop thru actions looking for primary port. While we're at it,
// count the number of update actions. // count the number of update actions.
bool updates = false; bool updates = false;
@ -877,11 +877,11 @@ static void cmp_for( gpre_req* request)
break; break;
} }
} }
if (updates) if (updates)
request->add_byte(blr_begin); request->add_byte(blr_begin);
// Build the primary send statement // Build the primary send statement
gpre_port* port = request->req_primary; gpre_port* port = request->req_primary;
make_send(port, request); make_send(port, request);
@ -916,7 +916,7 @@ static void cmp_for( gpre_req* request)
} }
request->add_byte(blr_end); request->add_byte(blr_end);
// If there are any actions, handle them here // If there are any actions, handle them here
if (updates) { if (updates) {
request->add_byte(blr_label); request->add_byte(blr_label);
@ -943,7 +943,7 @@ static void cmp_for( gpre_req* request)
request->add_byte(blr_end); request->add_byte(blr_end);
} }
// Make a send to signal end of file // Make a send to signal end of file
make_send(port, request); make_send(port, request);
request->add_byte(blr_assignment); request->add_byte(blr_assignment);
@ -956,9 +956,9 @@ static void cmp_for( gpre_req* request)
//____________________________________________________________ //____________________________________________________________
// //
// Compile a mass looping update statement. // Compile a mass looping update statement.
// //
static void cmp_loop( gpre_req* request) static void cmp_loop( gpre_req* request)
{ {
@ -972,7 +972,7 @@ static void cmp_loop( gpre_req* request)
for (ref* reference = primary->por_references; reference; for (ref* reference = primary->por_references; reference;
reference = reference->ref_next) reference = reference->ref_next)
{ {
if (reference->ref_field == count_field) if (reference->ref_field == count_field)
counter->nod_arg[0] = (GPRE_NOD) reference; counter->nod_arg[0] = (GPRE_NOD) reference;
} }
@ -1041,9 +1041,9 @@ static void cmp_loop( gpre_req* request)
//____________________________________________________________ //____________________________________________________________
// //
// Generate a receive and modify tree for a modify action. // Generate a receive and modify tree for a modify action.
// //
static void cmp_modify( act* action, gpre_req* request) static void cmp_modify( act* action, gpre_req* request)
{ {
@ -1058,7 +1058,7 @@ static void cmp_modify( act* action, gpre_req* request)
request->add_byte(update->upd_source->ctx_internal); request->add_byte(update->upd_source->ctx_internal);
request->add_byte(update->upd_update->ctx_internal); request->add_byte(update->upd_update->ctx_internal);
// count the references and build an assignment block // count the references and build an assignment block
gpre_nod* list = update->upd_assignments; gpre_nod* list = update->upd_assignments;
request->add_byte(blr_begin); request->add_byte(blr_begin);
@ -1078,9 +1078,9 @@ static void cmp_modify( act* action, gpre_req* request)
//____________________________________________________________ //____________________________________________________________
// //
// Build a request tree for a request. // Build a request tree for a request.
// //
static void cmp_port( gpre_port* port, gpre_req* request) static void cmp_port( gpre_port* port, gpre_req* request)
{ {
@ -1100,9 +1100,9 @@ static void cmp_port( gpre_port* port, gpre_req* request)
//____________________________________________________________ //____________________________________________________________
// //
// Compile a EXECUTE PROCEDURE request. // Compile a EXECUTE PROCEDURE request.
// //
static void cmp_procedure( gpre_req* request) static void cmp_procedure( gpre_req* request)
{ {
@ -1111,7 +1111,7 @@ static void cmp_procedure( gpre_req* request)
// Remember the order of the references. The exec_proc blr verb // Remember the order of the references. The exec_proc blr verb
// requires parameters to be in parameter order which may be changed // requires parameters to be in parameter order which may be changed
// when there references are expanded. // when there references are expanded.
gpre_lls* outputs = NULL; gpre_lls* outputs = NULL;
ref* reference = request->req_references; ref* reference = request->req_references;
@ -1122,7 +1122,7 @@ static void cmp_procedure( gpre_req* request)
} }
} }
// Expand any incomplete references or values. // Expand any incomplete references or values.
expand_references(request->req_values); expand_references(request->req_values);
expand_references(request->req_references); expand_references(request->req_references);
@ -1144,7 +1144,7 @@ static void cmp_procedure( gpre_req* request)
request->req_primary = make_port(request, request->req_references); request->req_primary = make_port(request, request->req_references);
request->req_references = request->req_primary->por_references; request->req_references = request->req_primary->por_references;
// build message definition for each port // build message definition for each port
for (gpre_port* port = request->req_ports; port; port = port->por_next) for (gpre_port* port = request->req_ports; port; port = port->por_next)
cmp_port(port, request); cmp_port(port, request);
@ -1196,10 +1196,10 @@ static void cmp_procedure( gpre_req* request)
//____________________________________________________________ //____________________________________________________________
// //
// Generate parameter buffer for READY with // Generate parameter buffer for READY with
// buffercount. // buffercount.
// //
static void cmp_ready( gpre_req* request) static void cmp_ready( gpre_req* request)
{ {
@ -1241,10 +1241,10 @@ static void cmp_ready( gpre_req* request)
request->add_byte(4); request->add_byte(4);
request->add_long(db->dbb_users); request->add_long(db->dbb_users);
} }
const TEXT* p; const TEXT* p;
SSHORT l; SSHORT l;
if (db->dbb_c_user && !db->dbb_r_user) { if (db->dbb_c_user && !db->dbb_r_user) {
request->add_byte(isc_dpb_user_name); request->add_byte(isc_dpb_user_name);
l = strlen(db->dbb_c_user); l = strlen(db->dbb_c_user);
@ -1273,7 +1273,7 @@ static void cmp_ready( gpre_req* request)
} }
if (db->dbb_c_lc_messages && !db->dbb_r_lc_messages) { if (db->dbb_c_lc_messages && !db->dbb_r_lc_messages) {
// Language must be an ASCII string // Language must be an ASCII string
request->add_byte(isc_dpb_lc_messages); request->add_byte(isc_dpb_lc_messages);
l = strlen(db->dbb_c_lc_messages); l = strlen(db->dbb_c_lc_messages);
request->add_byte(l); request->add_byte(l);
@ -1283,7 +1283,7 @@ static void cmp_ready( gpre_req* request)
} }
if (db->dbb_c_lc_ctype && !db->dbb_r_lc_ctype) { if (db->dbb_c_lc_ctype && !db->dbb_r_lc_ctype) {
// Character Format must be an ASCII string // Character Format must be an ASCII string
request->add_byte(isc_dpb_lc_ctype); request->add_byte(isc_dpb_lc_ctype);
l = strlen(db->dbb_c_lc_ctype); l = strlen(db->dbb_c_lc_ctype);
request->add_byte(l); request->add_byte(l);
@ -1301,10 +1301,10 @@ static void cmp_ready( gpre_req* request)
//____________________________________________________________ //____________________________________________________________
// //
// Build in a fudge to bias the language specific subscript to the // Build in a fudge to bias the language specific subscript to the
// declared array subscript [i.e. C subscripts are zero based]. // declared array subscript [i.e. C subscripts are zero based].
// //
static void cmp_sdl_fudge( gpre_req* request, SLONG lower_bound) static void cmp_sdl_fudge( gpre_req* request, SLONG lower_bound)
{ {
@ -1329,11 +1329,11 @@ static void cmp_sdl_fudge( gpre_req* request, SLONG lower_bound)
} }
//____________________________________________________________ //____________________________________________________________
// //
// Build an SDL loop for GET_SLICE/PUT_SLICE unless the upper and // Build an SDL loop for GET_SLICE/PUT_SLICE unless the upper and
// lower bounds are constant. Return true if a loop has been built, // lower bounds are constant. Return true if a loop has been built,
// otherwise false. // otherwise false.
// //
static bool cmp_sdl_loop(gpre_req* request, static bool cmp_sdl_loop(gpre_req* request,
USHORT index, USHORT index,
@ -1361,10 +1361,10 @@ static bool cmp_sdl_loop(gpre_req* request,
//____________________________________________________________ //____________________________________________________________
// //
// Write the number in the 'smallest' // Write the number in the 'smallest'
// form possible to the SDL string. // form possible to the SDL string.
// //
static void cmp_sdl_number( gpre_req* request, SLONG number) static void cmp_sdl_number( gpre_req* request, SLONG number)
{ {
@ -1385,10 +1385,10 @@ static void cmp_sdl_number( gpre_req* request, SLONG number)
//____________________________________________________________ //____________________________________________________________
// //
// Build an SDL loop for GET_SLICE/PUT_SLICE unless the upper and // Build an SDL loop for GET_SLICE/PUT_SLICE unless the upper and
// lower bounds are constant. // lower bounds are constant.
// //
static void cmp_sdl_subscript(gpre_req* request, USHORT index, const slc* slice, static void cmp_sdl_subscript(gpre_req* request, USHORT index, const slc* slice,
const ary* array) const ary* array)
@ -1407,9 +1407,9 @@ static void cmp_sdl_subscript(gpre_req* request, USHORT index, const slc* slice,
//____________________________________________________________ //____________________________________________________________
// //
// Stuff a slice description language value. // Stuff a slice description language value.
// //
static void cmp_sdl_value( gpre_req* request, const gpre_nod* node) static void cmp_sdl_value( gpre_req* request, const gpre_nod* node)
{ {
@ -1432,9 +1432,9 @@ static void cmp_sdl_value( gpre_req* request, const gpre_nod* node)
//____________________________________________________________ //____________________________________________________________
// //
// generate blr for set generator // generate blr for set generator
// //
static void cmp_set_generator( gpre_req* request) static void cmp_set_generator( gpre_req* request)
{ {
@ -1467,8 +1467,8 @@ static void cmp_set_generator( gpre_req* request)
//____________________________________________________________ //____________________________________________________________
// //
// //
static void cmp_slice( gpre_req* request) static void cmp_slice( gpre_req* request)
{ {
@ -1478,7 +1478,7 @@ static void cmp_slice( gpre_req* request)
gpre_fld* element = field->fld_array; gpre_fld* element = field->fld_array;
const ary* array = field->fld_array_info; const ary* array = field->fld_array_info;
// Process variable references // Process variable references
for (ref* reference = request->req_values; reference; for (ref* reference = request->req_values; reference;
reference = reference->ref_next) reference = reference->ref_next)
@ -1507,7 +1507,7 @@ static void cmp_slice( gpre_req* request)
for (bool* p = loop_flags; n < slice->slc_dimensions; n++, p++) for (bool* p = loop_flags; n < slice->slc_dimensions; n++, p++)
*p = cmp_sdl_loop(request, n, slice, array); *p = cmp_sdl_loop(request, n, slice, array);
} // end scope block } // end scope block
request->add_byte(isc_sdl_element); request->add_byte(isc_sdl_element);
request->add_byte(1); request->add_byte(1);
request->add_byte(isc_sdl_scalar); request->add_byte(isc_sdl_scalar);
@ -1529,9 +1529,9 @@ static void cmp_slice( gpre_req* request)
//____________________________________________________________ //____________________________________________________________
// //
// Generate blr for a store request. // Generate blr for a store request.
// //
static void cmp_store( gpre_req* request) static void cmp_store( gpre_req* request)
{ {
@ -1544,7 +1544,7 @@ static void cmp_store( gpre_req* request)
CME_relation(request->req_contexts, request); CME_relation(request->req_contexts, request);
// Make an assignment list // Make an assignment list
gpre_nod* list = request->req_node; gpre_nod* list = request->req_node;
request->add_byte(blr_begin); request->add_byte(blr_begin);
@ -1559,7 +1559,7 @@ static void cmp_store( gpre_req* request)
request->add_byte(blr_end); request->add_byte(blr_end);
if (request->req_type == REQ_store2) { if (request->req_type == REQ_store2) {
// whip through actions to find return list // whip through actions to find return list
act* action; act* action;
for (action = request->req_actions;; action = action->act_next) { for (action = request->req_actions;; action = action->act_next) {
@ -1585,13 +1585,13 @@ static void cmp_store( gpre_req* request)
//____________________________________________________________ //____________________________________________________________
// //
// During the parsing of an SQL statement // During the parsing of an SQL statement
// we may have run into an indicator variable. // we may have run into an indicator variable.
// If so, all we've got now is its name, and // If so, all we've got now is its name, and
// we really ought to build a full reference // we really ought to build a full reference
// block for it before we forget. // block for it before we forget.
// //
static void expand_references( REF reference) static void expand_references( REF reference)
{ {
@ -1609,10 +1609,10 @@ static void expand_references( REF reference)
//____________________________________________________________ //____________________________________________________________
// //
// Make up a port block and process a linked list // Make up a port block and process a linked list
// of field references. // of field references.
// //
static gpre_port* make_port( gpre_req* request, REF reference) static gpre_port* make_port( gpre_req* request, REF reference)
{ {
@ -1622,8 +1622,8 @@ static gpre_port* make_port( gpre_req* request, REF reference)
port->por_next = request->req_ports; port->por_next = request->req_ports;
request->req_ports = port; request->req_ports = port;
// Hmmm -- no references. Not going to fly. // Hmmm -- no references. Not going to fly.
// Make up a dummy reference. // Make up a dummy reference.
if (!reference) { if (!reference) {
reference = (REF) MSC_alloc(REF_LEN); reference = (REF) MSC_alloc(REF_LEN);
@ -1684,9 +1684,9 @@ static gpre_port* make_port( gpre_req* request, REF reference)
//____________________________________________________________ //____________________________________________________________
// //
// Make a receive node for a given port. // Make a receive node for a given port.
// //
static void make_receive( gpre_port* port, gpre_req* request) static void make_receive( gpre_port* port, gpre_req* request)
{ {
@ -1696,9 +1696,9 @@ static void make_receive( gpre_port* port, gpre_req* request)
//____________________________________________________________ //____________________________________________________________
// //
// Make a receive node for a given port. // Make a receive node for a given port.
// //
static void make_send( gpre_port* port, gpre_req* request) static void make_send( gpre_port* port, gpre_req* request)
{ {
@ -1708,10 +1708,10 @@ static void make_send( gpre_port* port, gpre_req* request)
//____________________________________________________________ //____________________________________________________________
// //
// where a duplicate reference list is used // where a duplicate reference list is used
// to build the port, fix request_references // to build the port, fix request_references
// //
static void update_references( REF references) static void update_references( REF references)
{ {

File diff suppressed because it is too large Load Diff

View File

@ -1,30 +1,30 @@
//____________________________________________________________ //____________________________________________________________
// //
// PROGRAM: BLR Pretty Printer // PROGRAM: BLR Pretty Printer
// MODULE: dyntable.cpp // MODULE: dyntable.cpp
// DESCRIPTION: Dynamic DDL to internal conversion table generator // DESCRIPTION: Dynamic DDL to internal conversion table generator
// //
// The contents of this file are subject to the Interbase Public // The contents of this file are subject to the Interbase Public
// License Version 1.0 (the "License"); you may not use this file // License Version 1.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy // except in compliance with the License. You may obtain a copy
// of the License at http://www.Inprise.com/IPL.html // of the License at http://www.Inprise.com/IPL.html
// //
// Software distributed under the License is distributed on an // Software distributed under the License is distributed on an
// "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express // "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
// or implied. See the License for the specific language governing // or implied. See the License for the specific language governing
// rights and limitations under the License. // rights and limitations under the License.
// //
// The Original Code was created by Inprise Corporation // The Original Code was created by Inprise Corporation
// and its predecessors. Portions created by Inprise Corporation are // and its predecessors. Portions created by Inprise Corporation are
// Copyright (C) Inprise Corporation. // Copyright (C) Inprise Corporation.
// //
// All Rights Reserved. // All Rights Reserved.
// Contributor(s): ______________________________________. // Contributor(s): ______________________________________.
// //
// //
//____________________________________________________________ //____________________________________________________________
// //
// $Id: dyntable.cpp,v 1.10 2005-05-27 22:42:14 asfernandes Exp $ // $Id: dyntable.cpp,v 1.11 2008-12-05 01:19:48 asfernandes Exp $
// //
// CVC: Strange, this file is only referenced in a MacOsX project and gpre // CVC: Strange, this file is only referenced in a MacOsX project and gpre
// works directly with dyntable.h. // works directly with dyntable.h.
@ -117,9 +117,9 @@ struct dyn {
//____________________________________________________________ //____________________________________________________________
// //
// Spit out a conversion table. // Spit out a conversion table.
// //
int main() int main()
{ {

View File

@ -1,27 +1,27 @@
//____________________________________________________________ //____________________________________________________________
// //
// PROGRAM: C preprocessor // PROGRAM: C preprocessor
// MODULE: exp.cpp // MODULE: exp.cpp
// DESCRIPTION: Expression parser // DESCRIPTION: Expression parser
// //
// The contents of this file are subject to the Interbase Public // The contents of this file are subject to the Interbase Public
// License Version 1.0 (the "License"); you may not use this file // License Version 1.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy // except in compliance with the License. You may obtain a copy
// of the License at http://www.Inprise.com/IPL.html // of the License at http://www.Inprise.com/IPL.html
// //
// Software distributed under the License is distributed on an // Software distributed under the License is distributed on an
// "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express // "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
// or implied. See the License for the specific language governing // or implied. See the License for the specific language governing
// rights and limitations under the License. // rights and limitations under the License.
// //
// The Original Code was created by Inprise Corporation // The Original Code was created by Inprise Corporation
// and its predecessors. Portions created by Inprise Corporation are // and its predecessors. Portions created by Inprise Corporation are
// Copyright (C) Inprise Corporation. // Copyright (C) Inprise Corporation.
// //
// All Rights Reserved. // All Rights Reserved.
// Contributor(s): ______________________________________. // Contributor(s): ______________________________________.
// TMN (Mike Nordell) 11.APR.2001 - Reduce compiler warnings // TMN (Mike Nordell) 11.APR.2001 - Reduce compiler warnings
// //
// //
//____________________________________________________________ //____________________________________________________________
// //
@ -112,9 +112,9 @@ static const dtypes data_types[] = {
//____________________________________________________________ //____________________________________________________________
// //
// Parse array subscript. // Parse array subscript.
// //
GPRE_NOD EXP_array(gpre_req* request, gpre_fld* field, bool subscript_flag, bool sql_flag) GPRE_NOD EXP_array(gpre_req* request, gpre_fld* field, bool subscript_flag, bool sql_flag)
{ {
@ -123,9 +123,9 @@ GPRE_NOD EXP_array(gpre_req* request, gpre_fld* field, bool subscript_flag, bool
//____________________________________________________________ //____________________________________________________________
// //
// Parse a datatype cast (sans leading period). // Parse a datatype cast (sans leading period).
// //
gpre_fld* EXP_cast(gpre_fld* field) gpre_fld* EXP_cast(gpre_fld* field)
{ {
@ -225,7 +225,7 @@ gpre_ctx* EXP_context(gpre_req* request, gpre_sym* initial_symbol)
// block. Then check for the keyword IN. If it's // block. Then check for the keyword IN. If it's
// missing, either complain or punt, depending on the // missing, either complain or punt, depending on the
// error flag. In either case, be sure to get rid of // error flag. In either case, be sure to get rid of
// the symbol. If things look kosher, continue. // the symbol. If things look kosher, continue.
gpre_sym* symbol = initial_symbol; gpre_sym* symbol = initial_symbol;
if (!symbol) { if (!symbol) {
@ -249,11 +249,11 @@ gpre_ctx* EXP_context(gpre_req* request, gpre_sym* initial_symbol)
//____________________________________________________________ //____________________________________________________________
// //
// Parse a qualified field clause. If recognized, // Parse a qualified field clause. If recognized,
// return both the field block (as value) and the // return both the field block (as value) and the
// context block (by reference). // context block (by reference).
// //
gpre_fld* EXP_field(gpre_ctx** rcontext) gpre_fld* EXP_field(gpre_ctx** rcontext)
{ {
@ -290,9 +290,9 @@ gpre_fld* EXP_field(gpre_ctx** rcontext)
//____________________________________________________________ //____________________________________________________________
// //
// Eat a left parenthesis, complain if not there. // Eat a left parenthesis, complain if not there.
// //
void EXP_left_paren(const TEXT* string) void EXP_left_paren(const TEXT* string)
{ {
@ -302,9 +302,9 @@ void EXP_left_paren(const TEXT* string)
//____________________________________________________________ //____________________________________________________________
// //
// Parse a native literal constant value. // Parse a native literal constant value.
// //
GPRE_NOD EXP_literal(void) GPRE_NOD EXP_literal(void)
{ {
@ -361,7 +361,7 @@ GPRE_NOD EXP_literal(void)
((INTLSYM) (symbol->sym_object))->intlsym_ttype; ((INTLSYM) (symbol->sym_object))->intlsym_ttype;
} }
else if (gpreGlob.sw_language == lang_internal) { else if (gpreGlob.sw_language == lang_internal) {
// literals referenced in an Internal request are always correct charset // literals referenced in an Internal request are always correct charset
reference->ref_flags |= REF_ttype; reference->ref_flags |= REF_ttype;
reference->ref_ttype = ttype_metadata; reference->ref_ttype = ttype_metadata;
} }
@ -371,10 +371,10 @@ GPRE_NOD EXP_literal(void)
//____________________________________________________________ //____________________________________________________________
// //
// Parse and convert to binary a numeric token. // Parse and convert to binary a numeric token.
// Restrict to LONG range. // Restrict to LONG range.
// //
SINT64 EXP_SINT64_ordinal(bool advance_flag) SINT64 EXP_SINT64_ordinal(bool advance_flag)
{ {
@ -386,7 +386,7 @@ SINT64 EXP_SINT64_ordinal(bool advance_flag)
const char format[8] = "%"SQUADFORMAT; const char format[8] = "%"SQUADFORMAT;
SINT64 n; SINT64 n;
sscanf(gpreGlob.token_global.tok_string, format, &n); sscanf(gpreGlob.token_global.tok_string, format, &n);
char buffer[64]; char buffer[64];
sprintf(buffer, format, n); sprintf(buffer, format, n);
if (strcmp(buffer, gpreGlob.token_global.tok_string) != 0) if (strcmp(buffer, gpreGlob.token_global.tok_string) != 0)
@ -399,10 +399,10 @@ SINT64 EXP_SINT64_ordinal(bool advance_flag)
} }
//____________________________________________________________ //____________________________________________________________
// //
// Parse and convert to binary a numeric token. // Parse and convert to binary a numeric token.
// Restrict to LONG range. // Restrict to LONG range.
// //
SLONG EXP_SLONG_ordinal(bool advance_flag) SLONG EXP_SLONG_ordinal(bool advance_flag)
{ {
@ -425,10 +425,10 @@ SLONG EXP_SLONG_ordinal(bool advance_flag)
//____________________________________________________________ //____________________________________________________________
// //
// Parse and convert to binary a numeric token. // Parse and convert to binary a numeric token.
// A SSHORT is desired. // A SSHORT is desired.
// //
SSHORT EXP_SSHORT_ordinal(bool advance_flag) SSHORT EXP_SSHORT_ordinal(bool advance_flag)
{ {
@ -451,10 +451,10 @@ SSHORT EXP_SSHORT_ordinal(bool advance_flag)
//____________________________________________________________ //____________________________________________________________
// //
// Parse and convert to binary a numeric token. // Parse and convert to binary a numeric token.
// Restrict to LONG range. // Restrict to LONG range.
// //
ULONG EXP_ULONG_ordinal(bool advance_flag) ULONG EXP_ULONG_ordinal(bool advance_flag)
{ {
@ -475,9 +475,9 @@ ULONG EXP_ULONG_ordinal(bool advance_flag)
//____________________________________________________________ //____________________________________________________________
// //
// Parse and convert to binary a numeric token. // Parse and convert to binary a numeric token.
// //
USHORT EXP_USHORT_ordinal(bool advance_flag) USHORT EXP_USHORT_ordinal(bool advance_flag)
{ {
@ -496,10 +496,10 @@ USHORT EXP_USHORT_ordinal(bool advance_flag)
//____________________________________________________________ //____________________________________________________________
// //
// Parse and convert to binary a numeric token. // Parse and convert to binary a numeric token.
// Which must be non-zero. // Which must be non-zero.
// //
USHORT EXP_pos_USHORT_ordinal(bool advance_flag) USHORT EXP_pos_USHORT_ordinal(bool advance_flag)
{ {
@ -512,10 +512,10 @@ USHORT EXP_pos_USHORT_ordinal(bool advance_flag)
//____________________________________________________________ //____________________________________________________________
// //
// We have a free reference to array. Make sure the whole damn thing // We have a free reference to array. Make sure the whole damn thing
// gets sucked up. // gets sucked up.
// //
void EXP_post_array( REF reference) void EXP_post_array( REF reference)
{ {
@ -546,12 +546,12 @@ void EXP_post_array( REF reference)
//____________________________________________________________ //____________________________________________________________
// //
// Post a field reference to a request. This // Post a field reference to a request. This
// can be called from either par_variable (free // can be called from either par_variable (free
// standing field reference) or EXP\par_value // standing field reference) or EXP\par_value
// (cross request field reference). // (cross request field reference).
// //
REF EXP_post_field(gpre_fld* field, gpre_ctx* context, bool null_flag) REF EXP_post_field(gpre_fld* field, gpre_ctx* context, bool null_flag)
{ {
@ -559,7 +559,7 @@ REF EXP_post_field(gpre_fld* field, gpre_ctx* context, bool null_flag)
gpre_req* request = context->ctx_request; gpre_req* request = context->ctx_request;
// If the reference is already posted, return the reference // If the reference is already posted, return the reference
ref* reference; ref* reference;
for (reference = request->req_references; reference; for (reference = request->req_references; reference;
@ -594,7 +594,7 @@ REF EXP_post_field(gpre_fld* field, gpre_ctx* context, bool null_flag)
} }
} }
// This is first occurrence of field, make a new reference // This is first occurrence of field, make a new reference
reference = MSC_reference(&request->req_references); reference = MSC_reference(&request->req_references);
reference->ref_context = context; reference->ref_context = context;
@ -609,10 +609,10 @@ REF EXP_post_field(gpre_fld* field, gpre_ctx* context, bool null_flag)
//____________________________________________________________ //____________________________________________________________
// //
// Match a trailing parenthesis. If isn't one, generate an error // Match a trailing parenthesis. If isn't one, generate an error
// and return FALSE. // and return FALSE.
// //
bool EXP_match_paren(void) bool EXP_match_paren(void)
{ {
@ -625,9 +625,9 @@ bool EXP_match_paren(void)
//____________________________________________________________ //____________________________________________________________
// //
// Parse and look up a qualified relation name. // Parse and look up a qualified relation name.
// //
gpre_rel* EXP_relation(void) gpre_rel* EXP_relation(void)
{ {
@ -637,7 +637,7 @@ gpre_rel* EXP_relation(void)
// The current token is (i.e. should be) either a relation // The current token is (i.e. should be) either a relation
// name or a database name. If it's a database name, search // name or a database name. If it's a database name, search
// it for the relation name. If it's an unqualified relation // it for the relation name. If it's an unqualified relation
// name, search all databases for the name // name, search all databases for the name
gpre_rel* relation = NULL; gpre_rel* relation = NULL;
@ -677,15 +677,15 @@ gpre_rel* EXP_relation(void)
//____________________________________________________________ //____________________________________________________________
// //
// Parse a record selection expression. If there is an // Parse a record selection expression. If there is an
// error, return NULL. This is slightly complicated by // error, return NULL. This is slightly complicated by
// the fact that PASCAL and FORTRAN have a native FOR // the fact that PASCAL and FORTRAN have a native FOR
// statement, and ADA has a FOR <variable> IN statement. // statement, and ADA has a FOR <variable> IN statement.
// //
// If an initial symbol is given, the caller has already // If an initial symbol is given, the caller has already
// parsed the <contect> IN part of the expression. // parsed the <contect> IN part of the expression.
// //
gpre_rse* EXP_rse(gpre_req* request, gpre_sym* initial_symbol) gpre_rse* EXP_rse(gpre_req* request, gpre_sym* initial_symbol)
{ {
@ -698,7 +698,7 @@ gpre_rse* EXP_rse(gpre_req* request, gpre_sym* initial_symbol)
first = par_value(request, global_count_field); first = par_value(request, global_count_field);
} }
// parse first context clause // parse first context clause
if (initial_symbol && gpreGlob.sw_language == lang_ada && !check_relation()) if (initial_symbol && gpreGlob.sw_language == lang_ada && !check_relation())
return NULL; return NULL;
@ -706,7 +706,7 @@ gpre_rse* EXP_rse(gpre_req* request, gpre_sym* initial_symbol)
gpre_ctx* context = EXP_context(request, initial_symbol); gpre_ctx* context = EXP_context(request, initial_symbol);
SSHORT count = 1; SSHORT count = 1;
// parse subsequent context clauses if this is a join // parse subsequent context clauses if this is a join
gpre_nod* boolean = NULL; gpre_nod* boolean = NULL;
while (MSC_match(KW_CROSS)) { while (MSC_match(KW_CROSS)) {
context = EXP_context(request, 0); context = EXP_context(request, 0);
@ -715,11 +715,11 @@ gpre_rse* EXP_rse(gpre_req* request, gpre_sym* initial_symbol)
boolean = make_and(boolean, par_over(context)); boolean = make_and(boolean, par_over(context));
} }
// bug_3380 - could have an "over" clause without a "cross" clause // bug_3380 - could have an "over" clause without a "cross" clause
if (MSC_match(KW_OVER)) if (MSC_match(KW_OVER))
boolean = make_and(boolean, par_over(context)); boolean = make_and(boolean, par_over(context));
// build rse node // build rse node
gpre_rse* rec_expr = (gpre_rse*) MSC_alloc(RSE_LEN(count)); gpre_rse* rec_expr = (gpre_rse*) MSC_alloc(RSE_LEN(count));
rec_expr->rse_count = count; rec_expr->rse_count = count;
@ -733,14 +733,14 @@ gpre_rse* EXP_rse(gpre_req* request, gpre_sym* initial_symbol)
} }
// parse boolean, if any. If there is an error, ignore the // parse boolean, if any. If there is an error, ignore the
// boolean, but keep the rse // boolean, but keep the rse
if (MSC_match(KW_WITH)) if (MSC_match(KW_WITH))
boolean = make_and(boolean, par_boolean(request)); boolean = make_and(boolean, par_boolean(request));
rec_expr->rse_boolean = boolean; rec_expr->rse_boolean = boolean;
// Parse SORT clause, if any. // Parse SORT clause, if any.
// CVC: It's not clear whether this var should be initialized at the same // CVC: It's not clear whether this var should be initialized at the same
// level than "direction". // level than "direction".
@ -793,7 +793,7 @@ gpre_rse* EXP_rse(gpre_req* request, gpre_sym* initial_symbol)
} }
} }
// Parse REDUCED clause, if any. // Parse REDUCED clause, if any.
else if (MSC_match(KW_REDUCED)) { else if (MSC_match(KW_REDUCED)) {
MSC_match(KW_TO); MSC_match(KW_TO);
@ -822,10 +822,10 @@ gpre_rse* EXP_rse(gpre_req* request, gpre_sym* initial_symbol)
//____________________________________________________________ //____________________________________________________________
// //
// Remove any context variables from hash table for a record // Remove any context variables from hash table for a record
// selection expression. // selection expression.
// //
void EXP_rse_cleanup( gpre_rse* rs) void EXP_rse_cleanup( gpre_rse* rs)
{ {
@ -838,12 +838,12 @@ void EXP_rse_cleanup( gpre_rse* rs)
if ((*context)->ctx_symbol) if ((*context)->ctx_symbol)
HSH_remove((*context)->ctx_symbol); HSH_remove((*context)->ctx_symbol);
// If this is an aggregate, clean up the underlying rse // If this is an aggregate, clean up the underlying rse
if (rs->rse_aggregate) if (rs->rse_aggregate)
EXP_rse_cleanup(rs->rse_aggregate); EXP_rse_cleanup(rs->rse_aggregate);
// If this is a union, clean up each of the primitive rse's // If this is a union, clean up each of the primitive rse's
gpre_nod* node = rs->rse_union; gpre_nod* node = rs->rse_union;
if (node) { if (node) {
@ -854,16 +854,16 @@ void EXP_rse_cleanup( gpre_rse* rs)
//____________________________________________________________ //____________________________________________________________
// //
// Parse a subscript value. This is called by PAR\par_slice. // Parse a subscript value. This is called by PAR\par_slice.
// //
GPRE_NOD EXP_subscript(gpre_req* request) GPRE_NOD EXP_subscript(gpre_req* request)
{ {
ref* reference = (REF) MSC_alloc(REF_LEN); ref* reference = (REF) MSC_alloc(REF_LEN);
gpre_nod* node = MSC_unary(nod_value, (GPRE_NOD) reference); gpre_nod* node = MSC_unary(nod_value, (GPRE_NOD) reference);
// Special case literals // Special case literals
if (gpreGlob.token_global.tok_type == tok_number) { if (gpreGlob.token_global.tok_type == tok_number) {
node->nod_type = nod_literal; node->nod_type = nod_literal;
@ -886,16 +886,16 @@ GPRE_NOD EXP_subscript(gpre_req* request)
//____________________________________________________________ //____________________________________________________________
// //
// Check current token for either a relation or database name. // Check current token for either a relation or database name.
// //
static bool check_relation(void) static bool check_relation(void)
{ {
// The current token is (i.e. should be) either a relation // The current token is (i.e. should be) either a relation
// name or a database name. If it's a database name, search // name or a database name. If it's a database name, search
// it for the relation name. If it's an unqualified relation // it for the relation name. If it's an unqualified relation
// name, search all databases for the name // name, search all databases for the name
gpre_sym* symbol = gpreGlob.token_global.tok_symbol; gpre_sym* symbol = gpreGlob.token_global.tok_symbol;
if (symbol && symbol->sym_type == SYM_database) if (symbol && symbol->sym_type == SYM_database)
@ -911,11 +911,11 @@ static bool check_relation(void)
//____________________________________________________________ //____________________________________________________________
// //
// Check to see if the current token is a field name corresponding // Check to see if the current token is a field name corresponding
// to a given context. If so, return a field block (with reference // to a given context. If so, return a field block (with reference
// block) for field. // block) for field.
// //
static GPRE_NOD lookup_field(gpre_ctx* context) static GPRE_NOD lookup_field(gpre_ctx* context)
{ {
@ -933,11 +933,11 @@ static GPRE_NOD lookup_field(gpre_ctx* context)
//____________________________________________________________ //____________________________________________________________
// //
// Combine two (potention) conjuncts into a single, valid // Combine two (potention) conjuncts into a single, valid
// boolean. Either or both on the conjunctions may be NULL. // boolean. Either or both on the conjunctions may be NULL.
// If both are null, return null. // If both are null, return null.
// //
static GPRE_NOD make_and( GPRE_NOD node1, GPRE_NOD node2) static GPRE_NOD make_and( GPRE_NOD node1, GPRE_NOD node2)
{ {
@ -952,9 +952,9 @@ static GPRE_NOD make_and( GPRE_NOD node1, GPRE_NOD node2)
//____________________________________________________________ //____________________________________________________________
// //
// Make a generic variable length node from a stack. // Make a generic variable length node from a stack.
// //
static GPRE_NOD make_list( gpre_lls* stack) static GPRE_NOD make_list( gpre_lls* stack)
{ {
@ -972,13 +972,13 @@ static GPRE_NOD make_list( gpre_lls* stack)
//____________________________________________________________ //____________________________________________________________
// //
// "Normalize" the array index so that // "Normalize" the array index so that
// the index used in the rse refers to // the index used in the rse refers to
// the same relative position in the // the same relative position in the
// dimension in the database as it is // dimension in the database as it is
// in the user's program. // in the user's program.
// //
static GPRE_NOD normalize_index( dim* dimension, GPRE_NOD user_index, USHORT array_base) static GPRE_NOD normalize_index( dim* dimension, GPRE_NOD user_index, USHORT array_base)
{ {
@ -1021,9 +1021,9 @@ static GPRE_NOD normalize_index( dim* dimension, GPRE_NOD user_index, USHORT arr
//____________________________________________________________ //____________________________________________________________
// //
// Parse a boolean AND. // Parse a boolean AND.
// //
static GPRE_NOD par_and( gpre_req* request) static GPRE_NOD par_and( gpre_req* request)
{ {
@ -1037,11 +1037,11 @@ static GPRE_NOD par_and( gpre_req* request)
//____________________________________________________________ //____________________________________________________________
// //
// Parse a array element reference // Parse a array element reference
// (array name and subscript list) // (array name and subscript list)
// in an gpre_rse. // in an gpre_rse.
// //
static GPRE_NOD par_array(gpre_req* request, static GPRE_NOD par_array(gpre_req* request,
gpre_fld* field, bool subscript_flag, bool sql_flag) gpre_fld* field, bool subscript_flag, bool sql_flag)
@ -1071,7 +1071,7 @@ static GPRE_NOD par_array(gpre_req* request,
global_subscript_field = MET_make_field("gds_array_subscript", dtype_long, global_subscript_field = MET_make_field("gds_array_subscript", dtype_long,
4, false); 4, false);
// Parse a commalist of subscripts and build a tree of index nodes // Parse a commalist of subscripts and build a tree of index nodes
int i = 1; int i = 1;
for (dim* dimension = field->fld_array_info->ary_dimension; for (dim* dimension = field->fld_array_info->ary_dimension;
@ -1095,7 +1095,7 @@ static GPRE_NOD par_array(gpre_req* request,
case lang_c: case lang_c:
case lang_cxx: case lang_cxx:
case lang_internal: case lang_internal:
index_node->nod_arg[0] = normalize_index(dimension, index_node->nod_arg[0] = normalize_index(dimension,
index_node->nod_arg[0], index_node->nod_arg[0],
ZERO_BASED); ZERO_BASED);
break; break;
@ -1107,9 +1107,9 @@ static GPRE_NOD par_array(gpre_req* request,
break; break;
} }
// Error checking of constants being out of range will be here in the future. // Error checking of constants being out of range will be here in the future.
// Good ole Fortran's column major order needs to be accomodated. // Good ole Fortran's column major order needs to be accomodated.
if (gpreGlob.sw_language == lang_fortran) if (gpreGlob.sw_language == lang_fortran)
array_node->nod_arg[fortran_adjustment - i] = index_node; array_node->nod_arg[fortran_adjustment - i] = index_node;
@ -1120,7 +1120,7 @@ static GPRE_NOD par_array(gpre_req* request,
CPR_s_error("Adequate number of subscripts for this array reference."); CPR_s_error("Adequate number of subscripts for this array reference.");
} }
// Match the parenthesis or bracket // Match the parenthesis or bracket
if (paren && !MSC_match(KW_RIGHT_PAREN)) if (paren && !MSC_match(KW_RIGHT_PAREN))
CPR_s_error("Missing parenthesis for array reference."); CPR_s_error("Missing parenthesis for array reference.");
@ -1133,10 +1133,10 @@ static GPRE_NOD par_array(gpre_req* request,
//____________________________________________________________ //____________________________________________________________
// //
// Parse a boolean expression. Actually, just parse // Parse a boolean expression. Actually, just parse
// an OR node or anything of lower precedence. // an OR node or anything of lower precedence.
// //
static GPRE_NOD par_boolean( gpre_req* request) static GPRE_NOD par_boolean( gpre_req* request)
{ {
@ -1150,16 +1150,16 @@ static GPRE_NOD par_boolean( gpre_req* request)
//____________________________________________________________ //____________________________________________________________
// //
// Parse a field reference. Anything else is an error. // Parse a field reference. Anything else is an error.
// //
static GPRE_NOD par_field( gpre_req* request) static GPRE_NOD par_field( gpre_req* request)
{ {
const gpre_sym* symbol = gpreGlob.token_global.tok_symbol; const gpre_sym* symbol = gpreGlob.token_global.tok_symbol;
if (!symbol) if (!symbol)
CPR_s_error("qualified field reference"); CPR_s_error("qualified field reference");
bool upcase_flag = false; bool upcase_flag = false;
gpre_nod* prefix_node = 0; gpre_nod* prefix_node = 0;
if (MSC_match(KW_UPPERCASE)) { if (MSC_match(KW_UPPERCASE)) {
@ -1190,7 +1190,7 @@ static GPRE_NOD par_field( gpre_req* request)
// There is a legit field reference. If the reference is // There is a legit field reference. If the reference is
// to a field in this request, make up a reference block // to a field in this request, make up a reference block
// and a field node, and return. // and a field node, and return.
if (!field->fld_array_info) if (!field->fld_array_info)
node = MSC_node(nod_field, 1); node = MSC_node(nod_field, 1);
@ -1234,10 +1234,10 @@ static GPRE_NOD par_field( gpre_req* request)
//____________________________________________________________ //____________________________________________________________
// //
// Parse a value expression. In specific, handle the lowest // Parse a value expression. In specific, handle the lowest
// precedence operator plus/minus. // precedence operator plus/minus.
// //
static GPRE_NOD par_multiply( gpre_req* request, gpre_fld* field) static GPRE_NOD par_multiply( gpre_req* request, gpre_fld* field)
{ {
@ -1259,15 +1259,15 @@ static GPRE_NOD par_multiply( gpre_req* request, gpre_fld* field)
//____________________________________________________________ //____________________________________________________________
// //
// Parse a native C value. // Parse a native C value.
// //
static GPRE_NOD par_native_value( gpre_req* request, gpre_fld* field) static GPRE_NOD par_native_value( gpre_req* request, gpre_fld* field)
{ {
TEXT s[64]; TEXT s[64];
// Special case literals // Special case literals
if (gpreGlob.token_global.tok_type == tok_number || gpreGlob.token_global.tok_type == tok_sglquoted if (gpreGlob.token_global.tok_type == tok_number || gpreGlob.token_global.tok_type == tok_sglquoted
|| (gpreGlob.token_global.tok_type == tok_dblquoted && gpreGlob.sw_sql_dialect == 1)) || (gpreGlob.token_global.tok_type == tok_dblquoted && gpreGlob.sw_sql_dialect == 1))
@ -1281,7 +1281,7 @@ static GPRE_NOD par_native_value( gpre_req* request, gpre_fld* field)
// Handle general native value references. Since these values will need // Handle general native value references. Since these values will need
// to be exported to the database system, make sure there is a reference // to be exported to the database system, make sure there is a reference
// field. // field.
reference->ref_value = PAR_native_value(false, false); reference->ref_value = PAR_native_value(false, false);
@ -1299,9 +1299,9 @@ static GPRE_NOD par_native_value( gpre_req* request, gpre_fld* field)
//____________________________________________________________ //____________________________________________________________
// //
// Parse either a boolean NOT or a boolean parenthetical. // Parse either a boolean NOT or a boolean parenthetical.
// //
static GPRE_NOD par_not( gpre_req* request) static GPRE_NOD par_not( gpre_req* request)
{ {
@ -1323,9 +1323,9 @@ static GPRE_NOD par_not( gpre_req* request)
//____________________________________________________________ //____________________________________________________________
// //
// Parse the substance of an OVER clause (but not the leading keyword). // Parse the substance of an OVER clause (but not the leading keyword).
// //
static GPRE_NOD par_over( gpre_ctx* context) static GPRE_NOD par_over( gpre_ctx* context)
{ {
@ -1360,10 +1360,10 @@ static GPRE_NOD par_over( gpre_ctx* context)
//____________________________________________________________ //____________________________________________________________
// //
// Parse a value expression. In specific, handle the lowest // Parse a value expression. In specific, handle the lowest
// precedence operator plus/minus. // precedence operator plus/minus.
// //
static GPRE_NOD par_primitive_value( gpre_req* request, gpre_fld* field) static GPRE_NOD par_primitive_value( gpre_req* request, gpre_fld* field)
{ {
@ -1398,7 +1398,7 @@ static GPRE_NOD par_primitive_value( gpre_req* request, gpre_fld* field)
return node; return node;
} }
// Check for user defined functions // Check for user defined functions
gpre_nod* node = par_udf(request, UDF_value, field); gpre_nod* node = par_udf(request, UDF_value, field);
if (node) if (node)
@ -1413,9 +1413,9 @@ static GPRE_NOD par_primitive_value( gpre_req* request, gpre_fld* field)
//____________________________________________________________ //____________________________________________________________
// //
// Parse a relational expression. // Parse a relational expression.
// //
static GPRE_NOD par_relational( gpre_req* request) static GPRE_NOD par_relational( gpre_req* request)
{ {
@ -1436,7 +1436,7 @@ static GPRE_NOD par_relational( gpre_req* request)
} }
// That's right, three pointer dereferences to get to the reference // That's right, three pointer dereferences to get to the reference
// structure if there's a UDF. V3 bug#531. MaryAnn 12/4/89 // structure if there's a UDF. V3 bug#531. MaryAnn 12/4/89
gpre_nod* expr1 = par_udf(request, UDF_value, 0); gpre_nod* expr1 = par_udf(request, UDF_value, 0);
ref* reference; ref* reference;
@ -1449,7 +1449,7 @@ static GPRE_NOD par_relational( gpre_req* request)
gpre_fld* field = reference->ref_field; gpre_fld* field = reference->ref_field;
// Check for any of the binary guys // Check for any of the binary guys
const bool negation = MSC_match(KW_NOT); const bool negation = MSC_match(KW_NOT);
@ -1517,18 +1517,18 @@ static GPRE_NOD par_relational( gpre_req* request)
//____________________________________________________________ //____________________________________________________________
// //
// Parse a user defined function. If the current token isn't one, // Parse a user defined function. If the current token isn't one,
// return NULL. Otherwise try to parse one. If things go badly, // return NULL. Otherwise try to parse one. If things go badly,
// complain bitterly. // complain bitterly.
// //
static GPRE_NOD par_udf( gpre_req* request, USHORT type, gpre_fld* field) static GPRE_NOD par_udf( gpre_req* request, USHORT type, gpre_fld* field)
{ {
if (!request) if (!request)
return NULL; return NULL;
// Check for user defined functions // Check for user defined functions
udf* new_udf; udf* new_udf;
for (gpre_sym* symbol = gpreGlob.token_global.tok_symbol; symbol; symbol = symbol->sym_homonym) for (gpre_sym* symbol = gpreGlob.token_global.tok_symbol; symbol; symbol = symbol->sym_homonym)
@ -1558,10 +1558,10 @@ static GPRE_NOD par_udf( gpre_req* request, USHORT type, gpre_fld* field)
//____________________________________________________________ //____________________________________________________________
// //
// Parse a value expression. In specific, handle the lowest // Parse a value expression. In specific, handle the lowest
// precedence operator plus/minus. // precedence operator plus/minus.
// //
static GPRE_NOD par_value( gpre_req* request, gpre_fld* field) static GPRE_NOD par_value( gpre_req* request, gpre_fld* field)
{ {

View File

@ -1539,7 +1539,7 @@ EXPORT RM_ENTRY(rmc_ftoc)
*(float *)arg_vector[-1].a_address = arg; *(float *)arg_vector[-1].a_address = arg;
else else
*(double *)arg_vector[-1].a_address = arg; *(double *)arg_vector[-1].a_address = arg;
return (0); return (0);
} }
@ -1552,7 +1552,7 @@ EXPORT RM_ENTRY(rmc_stoc)
const int dlen = arg_vector[-1].a_length; const int dlen = arg_vector[-1].a_length;
const char* src = (char*) arg_vector[0].a_address; const char* src = (char*) arg_vector[0].a_address;
const int slen = arg_vector[0].a_length; const int slen = arg_vector[0].a_length;
int i = slen - 1; int i = slen - 1;
while (src[i] == ' ' && i >= 0) while (src[i] == ' ' && i >= 0)
--i; --i;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,28 +1,28 @@
/* /*
* tab=4 * tab=4
*____________________________________________________________ *____________________________________________________________
* *
* PROGRAM: C preprocessor * PROGRAM: C preprocessor
* MODULE: gpre_meta_boot.cpp * MODULE: gpre_meta_boot.cpp
* DESCRIPTION: Meta data interface to system * DESCRIPTION: Meta data interface to system
* *
* The contents of this file are subject to the Interbase Public * The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file * License Version 1.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy * except in compliance with the License. You may obtain a copy
* of the License at http://www.Inprise.com/IPL.html * of the License at http://www.Inprise.com/IPL.html
* *
* Software distributed under the License is distributed on an * Software distributed under the License is distributed on an
* "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
* or implied. See the License for the specific language governing * or implied. See the License for the specific language governing
* rights and limitations under the License. * rights and limitations under the License.
* *
* The Original Code was created by Inprise Corporation * The Original Code was created by Inprise Corporation
* and its predecessors. Portions created by Inprise Corporation are * and its predecessors. Portions created by Inprise Corporation are
* Copyright (C) Inprise Corporation. * Copyright (C) Inprise Corporation.
* *
* All Rights Reserved. * All Rights Reserved.
* Contributor(s): ______________________________________. * Contributor(s): ______________________________________.
* *
* *
*____________________________________________________________ *____________________________________________________________
* *
@ -63,10 +63,10 @@ static int upcase(const TEXT*, TEXT* const);
#endif #endif
/*____________________________________________________________ /*____________________________________________________________
* *
* Lookup a field by name in a context. * Lookup a field by name in a context.
* If found, return field block. If not, return NULL. * If found, return field block. If not, return NULL.
*/ */
gpre_fld* MET_context_field( gpre_ctx* context, const char* string) gpre_fld* MET_context_field( gpre_ctx* context, const char* string)
{ {
@ -102,16 +102,16 @@ gpre_fld* MET_context_field( gpre_ctx* context, const char* string)
/*____________________________________________________________ /*____________________________________________________________
* *
* Initialize meta data access to database. If the * Initialize meta data access to database. If the
* database can't be opened, return FALSE. * database can't be opened, return FALSE.
*/ */
bool MET_database(DBB db, bool MET_database(DBB db,
bool print_version) bool print_version)
{ {
/* /*
** Each info item requested will return ** Each info item requested will return
** **
** 1 byte for the info item tag ** 1 byte for the info item tag
** 2 bytes for the length of the information that follows ** 2 bytes for the length of the information that follows
@ -127,10 +127,10 @@ bool MET_database(DBB db,
/*____________________________________________________________ /*____________________________________________________________
* *
* Lookup a domain by name. * Lookup a domain by name.
* Initialize the size of the field. * Initialize the size of the field.
*/ */
bool MET_domain_lookup(gpre_req* request, bool MET_domain_lookup(gpre_req* request,
gpre_fld* field, gpre_fld* field,
@ -172,9 +172,9 @@ bool MET_domain_lookup(gpre_req* request,
/*____________________________________________________________ /*____________________________________________________________
* *
* Gets the default value for a domain of an existing table * Gets the default value for a domain of an existing table
*/ */
bool MET_get_domain_default(DBB db, bool MET_get_domain_default(DBB db,
const TEXT* domain_name, const TEXT* domain_name,
@ -187,16 +187,16 @@ bool MET_get_domain_default(DBB db,
/*____________________________________________________________ /*____________________________________________________________
* *
* Gets the default value for a column of an existing table. * Gets the default value for a column of an existing table.
* Will check the default for the column of the table, if that is * Will check the default for the column of the table, if that is
* not present, will check for the default of the relevant domain * not present, will check for the default of the relevant domain
* *
* The default blr is returned in buffer. The blr is of the form * The default blr is returned in buffer. The blr is of the form
* blr_version4 blr_literal ..... blr_eoc * blr_version4 blr_literal ..... blr_eoc
* *
* Reads the system tables RDB$FIELDS and RDB$RELATION_FIELDS. * Reads the system tables RDB$FIELDS and RDB$RELATION_FIELDS.
*/ */
bool MET_get_column_default(const gpre_rel* relation, bool MET_get_column_default(const gpre_rel* relation,
const TEXT* column_name, const TEXT* column_name,
@ -209,11 +209,11 @@ bool MET_get_column_default(const gpre_rel* relation,
/*____________________________________________________________ /*____________________________________________________________
* *
* Lookup the fields for the primary key * Lookup the fields for the primary key
* index on a relation, returning a list * index on a relation, returning a list
* of the fields. * of the fields.
*/ */
gpre_lls* MET_get_primary_key(DBB db, const TEXT* relation_name) gpre_lls* MET_get_primary_key(DBB db, const TEXT* relation_name)
{ {
@ -234,10 +234,10 @@ gpre_lls* MET_get_primary_key(DBB db, const TEXT* relation_name)
/*____________________________________________________________ /*____________________________________________________________
* *
* Lookup a field by name in a relation. * Lookup a field by name in a relation.
* If found, return field block. If not, return NULL. * If found, return field block. If not, return NULL.
*/ */
gpre_fld* MET_field(gpre_rel* relation, const char* string) gpre_fld* MET_field(gpre_rel* relation, const char* string)
{ {
@ -269,9 +269,9 @@ gpre_fld* MET_field(gpre_rel* relation, const char* string)
/*____________________________________________________________ /*____________________________________________________________
* *
* Return a list of the fields in a relation * Return a list of the fields in a relation
*/ */
GPRE_NOD MET_fields(gpre_ctx* context) GPRE_NOD MET_fields(gpre_ctx* context)
{ {
@ -318,9 +318,9 @@ GPRE_NOD MET_fields(gpre_ctx* context)
/*____________________________________________________________ /*____________________________________________________________
* *
* Shutdown all attached databases. * Shutdown all attached databases.
*/ */
void MET_fini( DBB end) void MET_fini( DBB end)
{ {
@ -329,10 +329,10 @@ void MET_fini( DBB end)
/*____________________________________________________________ /*____________________________________________________________
* *
* Lookup a generator by name. * Lookup a generator by name.
* If found, return string. If not, return NULL. * If found, return string. If not, return NULL.
*/ */
const SCHAR* MET_generator(const TEXT* string, DBB db) const SCHAR* MET_generator(const TEXT* string, DBB db)
{ {
@ -342,7 +342,7 @@ const SCHAR* MET_generator(const TEXT* string, DBB db)
for (gpre_sym* symbol = HSH_lookup(name); symbol; symbol = symbol->sym_homonym) for (gpre_sym* symbol = HSH_lookup(name); symbol; symbol = symbol->sym_homonym)
if ((symbol->sym_type == SYM_generator) && if ((symbol->sym_type == SYM_generator) &&
(db == (DBB) (symbol->sym_object))) (db == (DBB) (symbol->sym_object)))
{ {
return symbol->sym_string; return symbol->sym_string;
} }
@ -352,9 +352,9 @@ const SCHAR* MET_generator(const TEXT* string, DBB db)
/*____________________________________________________________ /*____________________________________________________________
* *
* Compute internal datatype and length based on system relation field values. * Compute internal datatype and length based on system relation field values.
*/ */
USHORT MET_get_dtype(USHORT blr_dtype, USHORT sub_type, USHORT* length) USHORT MET_get_dtype(USHORT blr_dtype, USHORT sub_type, USHORT* length)
{ {
@ -441,12 +441,12 @@ USHORT MET_get_dtype(USHORT blr_dtype, USHORT sub_type, USHORT* length)
/*____________________________________________________________ /*____________________________________________________________
* *
* Lookup a procedure (represented by a token) in a database. * Lookup a procedure (represented by a token) in a database.
* Return a procedure block (if name is found) or NULL. * Return a procedure block (if name is found) or NULL.
* *
* This function has been cloned into MET_get_udf * This function has been cloned into MET_get_udf
*/ */
gpre_prc* MET_get_procedure(DBB db, const TEXT* string, const TEXT* owner_name) gpre_prc* MET_get_procedure(DBB db, const TEXT* string, const TEXT* owner_name)
{ {
@ -462,7 +462,7 @@ gpre_prc* MET_get_procedure(DBB db, const TEXT* string, const TEXT* owner_name)
procedure->prc_database == db && procedure->prc_database == db &&
(!owner[0] || (!owner[0] ||
(procedure->prc_owner (procedure->prc_owner
&& !strcmp(owner, procedure->prc_owner->sym_string)))) && !strcmp(owner, procedure->prc_owner->sym_string))))
{ {
break; break;
} }
@ -479,16 +479,16 @@ gpre_prc* MET_get_procedure(DBB db, const TEXT* string, const TEXT* owner_name)
/*____________________________________________________________ /*____________________________________________________________
* *
* Lookup a relation (represented by a token) in a database. * Lookup a relation (represented by a token) in a database.
* Return a relation block (if name is found) or NULL. * Return a relation block (if name is found) or NULL.
*/ */
gpre_rel* MET_get_relation(DBB db, const TEXT* string, const TEXT* owner_name) gpre_rel* MET_get_relation(DBB db, const TEXT* string, const TEXT* owner_name)
{ {
gpre_rel* relation; gpre_rel* relation;
SCHAR name[NAME_SIZE], owner[NAME_SIZE]; SCHAR name[NAME_SIZE], owner[NAME_SIZE];
strcpy(name, string); strcpy(name, string);
strcpy(owner, owner_name); strcpy(owner, owner_name);
@ -509,8 +509,8 @@ gpre_rel* MET_get_relation(DBB db, const TEXT* string, const TEXT* owner_name)
/*____________________________________________________________ /*____________________________________________________________
* *
*/ */
INTLSYM MET_get_text_subtype(SSHORT ttype) INTLSYM MET_get_text_subtype(SSHORT ttype)
{ {
@ -523,12 +523,12 @@ INTLSYM MET_get_text_subtype(SSHORT ttype)
/*____________________________________________________________ /*____________________________________________________________
* *
* Lookup a udf (represented by a token) in a database. * Lookup a udf (represented by a token) in a database.
* Return a udf block (if name is found) or NULL. * Return a udf block (if name is found) or NULL.
* *
* This function was cloned from MET_get_procedure * This function was cloned from MET_get_procedure
*/ */
udf* MET_get_udf(DBB db, const TEXT* string) udf* MET_get_udf(DBB db, const TEXT* string)
{ {
@ -552,11 +552,11 @@ udf* MET_get_udf(DBB db, const TEXT* string)
/*____________________________________________________________ /*____________________________________________________________
* *
* Return relation if the passed view_name represents a * Return relation if the passed view_name represents a
* view with the passed relation as a base table * view with the passed relation as a base table
* (the relation could be an alias). * (the relation could be an alias).
*/ */
gpre_rel* MET_get_view_relation(gpre_req* request, gpre_rel* MET_get_view_relation(gpre_req* request,
const char* view_name, const char* view_name,
@ -568,10 +568,10 @@ gpre_rel* MET_get_view_relation(gpre_req* request,
/*____________________________________________________________ /*____________________________________________________________
* *
* Lookup an index for a database. * Lookup an index for a database.
* Return an index block (if name is found) or NULL. * Return an index block (if name is found) or NULL.
*/ */
IND MET_index(DBB db, const TEXT* string) IND MET_index(DBB db, const TEXT* string)
{ {
@ -594,11 +594,11 @@ IND MET_index(DBB db, const TEXT* string)
/*____________________________________________________________ /*____________________________________________________________
* *
* Load all of the relation names * Load all of the relation names
* and user defined function names * and user defined function names
* into the symbol (hash) table. * into the symbol (hash) table.
*/ */
void MET_load_hash_table( DBB db) void MET_load_hash_table( DBB db)
{ {
@ -611,9 +611,9 @@ void MET_load_hash_table( DBB db)
/*____________________________________________________________ /*____________________________________________________________
* *
* Make a field symbol. * Make a field symbol.
*/ */
gpre_fld* MET_make_field(const SCHAR* name, gpre_fld* MET_make_field(const SCHAR* name,
SSHORT dtype, SSHORT dtype,
@ -634,9 +634,9 @@ gpre_fld* MET_make_field(const SCHAR* name,
/*____________________________________________________________ /*____________________________________________________________
* *
* Make an index symbol. * Make an index symbol.
*/ */
IND MET_make_index(const SCHAR* name) IND MET_make_index(const SCHAR* name)
{ {
@ -648,9 +648,9 @@ IND MET_make_index(const SCHAR* name)
/*____________________________________________________________ /*____________________________________________________________
* *
* Make an relation symbol. * Make an relation symbol.
*/ */
gpre_rel* MET_make_relation(const SCHAR* name) gpre_rel* MET_make_relation(const SCHAR* name)
{ {
@ -663,9 +663,9 @@ gpre_rel* MET_make_relation(const SCHAR* name)
/*____________________________________________________________ /*____________________________________________________________
* *
* Lookup a type name for a field. * Lookup a type name for a field.
*/ */
bool MET_type(gpre_fld* field, bool MET_type(gpre_fld* field,
const TEXT* string, const TEXT* string,
@ -688,12 +688,12 @@ bool MET_type(gpre_fld* field,
/*____________________________________________________________ /*____________________________________________________________
* *
* Lookup an index for a database. * Lookup an index for a database.
* *
* Return: true if the trigger exists * Return: true if the trigger exists
* false otherwise * false otherwise
*/ */
bool MET_trigger_exists(DBB db, bool MET_trigger_exists(DBB db,
const TEXT* trigger_name) const TEXT* trigger_name)
@ -708,16 +708,16 @@ bool MET_trigger_exists(DBB db,
#ifdef NOT_USED_OR_REPLACED #ifdef NOT_USED_OR_REPLACED
/*____________________________________________________________ /*____________________________________________________________
* *
* Compute and return the size of the array. * Compute and return the size of the array.
*/ */
static SLONG array_size( gpre_fld* field) static SLONG array_size( gpre_fld* field)
{ {
ary* array_block = field->fld_array_info; ary* array_block = field->fld_array_info;
SLONG count = field->fld_array->fld_length; SLONG count = field->fld_array->fld_length;
for (dim* dimension = array_block->ary_dimension; dimension; for (dim* dimension = array_block->ary_dimension; dimension;
dimension = dimension->dim_next) dimension = dimension->dim_next)
{ {
count = count =
count * (dimension->dim_upper - dimension->dim_lower + 1); count * (dimension->dim_upper - dimension->dim_lower + 1);
@ -728,9 +728,9 @@ static SLONG array_size( gpre_fld* field)
/*____________________________________________________________ /*____________________________________________________________
* *
* See if field is array. * See if field is array.
*/ */
static void get_array( DBB db, const TEXT* field_name, gpre_fld* field) static void get_array( DBB db, const TEXT* field_name, gpre_fld* field)
{ {
@ -740,22 +740,22 @@ static void get_array( DBB db, const TEXT* field_name, gpre_fld* field)
/*____________________________________________________________ /*____________________________________________________________
* *
* Character types can be specified as either: * Character types can be specified as either:
* b) A POSIX style locale name "<collation>.<characterset>" * b) A POSIX style locale name "<collation>.<characterset>"
* or * or
* c) A simple <characterset> name (using default collation) * c) A simple <characterset> name (using default collation)
* d) A simple <collation> name (use charset for collation) * d) A simple <collation> name (use charset for collation)
* *
* Given an ASCII7 string which could be any of the above, try to * Given an ASCII7 string which could be any of the above, try to
* resolve the name in the order b, c, d. * resolve the name in the order b, c, d.
* b) is only tried iff the name contains a period. * b) is only tried iff the name contains a period.
* (in which case c) and d) are not tried). * (in which case c) and d) are not tried).
* *
* Return: * Return:
* true if no errors (and *id is set). * true if no errors (and *id is set).
* false if the name could not be resolved. * false if the name could not be resolved.
*/ */
static bool get_intl_char_subtype(SSHORT* id, static bool get_intl_char_subtype(SSHORT* id,
const UCHAR* name, const UCHAR* name,
@ -772,31 +772,31 @@ static bool get_intl_char_subtype(SSHORT* id,
/*____________________________________________________________ /*____________________________________________________________
* *
* Given ASCII7 name of charset & collation * Given ASCII7 name of charset & collation
* resolve the specification to a ttype (id) that implements * resolve the specification to a ttype (id) that implements
* it. * it.
* *
* Inputs: * Inputs:
* (charset) * (charset)
* ASCII7z name of characterset. * ASCII7z name of characterset.
* NULL (implying unspecified) means use the character set * NULL (implying unspecified) means use the character set
* for defined for (collation). * for defined for (collation).
* *
* (collation) * (collation)
* ASCII7z name of collation. * ASCII7z name of collation.
* NULL means use the default collation for (charset). * NULL means use the default collation for (charset).
* *
* Outputs: * Outputs:
* (*id) * (*id)
* Set to subtype specified by this name. * Set to subtype specified by this name.
* *
* Return: * Return:
* true if no errors (and *id is set). * true if no errors (and *id is set).
* false if either name not found. * false if either name not found.
* or if names found, but the collation isn't for the specified * or if names found, but the collation isn't for the specified
* character set. * character set.
*/ */
static bool resolve_charset_and_collation( static bool resolve_charset_and_collation(
SSHORT* id, SSHORT* id,
@ -810,7 +810,7 @@ static bool resolve_charset_and_collation(
/*____________________________________________________________ /*____________________________________________________________
* *
* Upcase a string into another string. Return * Upcase a string into another string. Return
* length of string. * length of string.
*/ */

View File

@ -52,9 +52,9 @@ static struct word {
//____________________________________________________________ //____________________________________________________________
// //
// Release space used by keywords. // Release space used by keywords.
// //
void HSH_fini(void) void HSH_fini(void)
{ {
@ -68,10 +68,10 @@ void HSH_fini(void)
//____________________________________________________________ //____________________________________________________________
// //
// Initialize the hash table. This mostly involves // Initialize the hash table. This mostly involves
// inserting all known keywords. // inserting all known keywords.
// //
void HSH_init(void) void HSH_init(void)
{ {
@ -98,9 +98,9 @@ void HSH_init(void)
//____________________________________________________________ //____________________________________________________________
// //
// Insert a symbol into the hash table. // Insert a symbol into the hash table.
// //
void HSH_insert( gpre_sym* symbol) void HSH_insert( gpre_sym* symbol)
{ {
@ -115,7 +115,7 @@ void HSH_insert( gpre_sym* symbol)
} }
if (scompare(symbol->sym_string, (*next)->sym_string)) { if (scompare(symbol->sym_string, (*next)->sym_string)) {
/* insert in most recently seen order; /* insert in most recently seen order;
This is important for alias resolution in subqueries. This is important for alias resolution in subqueries.
BUT insert tokens AFTER keyword! BUT insert tokens AFTER keyword!
In a lookup, keyword should be found first. In a lookup, keyword should be found first.
@ -143,16 +143,16 @@ void HSH_insert( gpre_sym* symbol)
//____________________________________________________________ //____________________________________________________________
// //
// Perform a string lookup against hash table. // Perform a string lookup against hash table.
// //
gpre_sym* HSH_lookup(const SCHAR* string) gpre_sym* HSH_lookup(const SCHAR* string)
{ {
for (gpre_sym* symbol = hash_table[hash(string)]; symbol; for (gpre_sym* symbol = hash_table[hash(string)]; symbol;
symbol = symbol->sym_collision) symbol = symbol->sym_collision)
{ {
if (scompare(string, symbol->sym_string)) if (scompare(string, symbol->sym_string))
return symbol; return symbol;
} }
@ -160,18 +160,18 @@ gpre_sym* HSH_lookup(const SCHAR* string)
} }
//____________________________________________________________ //____________________________________________________________
// //
// Perform a string lookup against hash table. // Perform a string lookup against hash table.
// Calls scompare2 which performs case insensitive // Calls scompare2 which performs case insensitive
// compare. // compare.
// //
gpre_sym* HSH_lookup2(const SCHAR* string) gpre_sym* HSH_lookup2(const SCHAR* string)
{ {
for (gpre_sym* symbol = hash_table[hash(string)]; symbol; for (gpre_sym* symbol = hash_table[hash(string)]; symbol;
symbol = symbol->sym_collision) symbol = symbol->sym_collision)
{ {
if (scompare2(string, symbol->sym_string)) if (scompare2(string, symbol->sym_string))
return symbol; return symbol;
} }
@ -180,9 +180,9 @@ gpre_sym* HSH_lookup2(const SCHAR* string)
//____________________________________________________________ //____________________________________________________________
// //
// Remove a symbol from the hash table. // Remove a symbol from the hash table.
// //
void HSH_remove( gpre_sym* symbol) void HSH_remove( gpre_sym* symbol)
{ {
@ -219,9 +219,9 @@ void HSH_remove( gpre_sym* symbol)
//____________________________________________________________ //____________________________________________________________
// //
// Returns the hash function of a string. // Returns the hash function of a string.
// //
static int hash(const SCHAR* string) static int hash(const SCHAR* string)
{ {
@ -237,9 +237,9 @@ static int hash(const SCHAR* string)
//____________________________________________________________ //____________________________________________________________
// //
// case sensitive Compare // case sensitive Compare
// //
static bool scompare(const SCHAR* string1, static bool scompare(const SCHAR* string1,
const SCHAR* string2) const SCHAR* string2)
@ -248,9 +248,9 @@ static bool scompare(const SCHAR* string1,
} }
//____________________________________________________________ //____________________________________________________________
// //
// Compare two strings // Compare two strings
// //
static bool scompare2(const SCHAR* string1, static bool scompare2(const SCHAR* string1,
const SCHAR* string2) const SCHAR* string2)
@ -262,7 +262,7 @@ static bool scompare2(const SCHAR* string1,
if (!(c2 = *string2++) || (UPPER(c1) != UPPER(c2))) if (!(c2 = *string2++) || (UPPER(c1) != UPPER(c2)))
return false; return false;
} }
if (*string2) if (*string2)
return false; return false;

View File

@ -1,27 +1,27 @@
//____________________________________________________________ //____________________________________________________________
// //
// PROGRAM: C preprocess // PROGRAM: C preprocess
// MODULE: int_cxx.cpp // MODULE: int_cxx.cpp
// DESCRIPTION: Code generate for internal JRD modules // DESCRIPTION: Code generate for internal JRD modules
// //
// The contents of this file are subject to the Interbase Public // The contents of this file are subject to the Interbase Public
// License Version 1.0 (the "License"); you may not use this file // License Version 1.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy // except in compliance with the License. You may obtain a copy
// of the License at http://www.Inprise.com/IPL.html // of the License at http://www.Inprise.com/IPL.html
// //
// Software distributed under the License is distributed on an // Software distributed under the License is distributed on an
// "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express // "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
// or implied. See the License for the specific language governing // or implied. See the License for the specific language governing
// rights and limitations under the License. // rights and limitations under the License.
// //
// The Original Code was created by Inprise Corporation // The Original Code was created by Inprise Corporation
// and its predecessors. Portions created by Inprise Corporation are // and its predecessors. Portions created by Inprise Corporation are
// Copyright (C) Inprise Corporation. // Copyright (C) Inprise Corporation.
// //
// All Rights Reserved. // All Rights Reserved.
// Contributor(s): ______________________________________. // Contributor(s): ______________________________________.
// TMN (Mike Nordell) 11.APR.2001 - Reduce compiler warnings in generated code // TMN (Mike Nordell) 11.APR.2001 - Reduce compiler warnings in generated code
// //
// //
//____________________________________________________________ //____________________________________________________________
// //
@ -86,13 +86,13 @@ static inline void endp(const int column)
} }
//____________________________________________________________ //____________________________________________________________
// //
// //
void INT_CXX_action( const act* action, int column) void INT_CXX_action( const act* action, int column)
{ {
// Put leading braces where required // Put leading braces where required
switch (action->act_type) { switch (action->act_type) {
case ACT_for: case ACT_for:
@ -156,16 +156,16 @@ void INT_CXX_action( const act* action, int column)
return; return;
} }
// Put in a trailing brace for those actions still with us // Put in a trailing brace for those actions still with us
endp(column); endp(column);
} }
//____________________________________________________________ //____________________________________________________________
// //
// Align output to a specific column for output. // Align output to a specific column for output.
// //
static void align(const int column) static void align(const int column)
{ {
@ -185,10 +185,10 @@ static void align(const int column)
//____________________________________________________________ //____________________________________________________________
// //
// Build an assignment from a host language variable to // Build an assignment from a host language variable to
// a port variable. // a port variable.
// //
static void asgn_from( REF reference, int column) static void asgn_from( REF reference, int column)
{ {
@ -229,10 +229,10 @@ static void asgn_from( REF reference, int column)
//____________________________________________________________ //____________________________________________________________
// //
// Build an assignment to a host language variable from // Build an assignment to a host language variable from
// a port variable. // a port variable.
// //
#ifdef NOT_USED_OR_REPLACED #ifdef NOT_USED_OR_REPLACED
static void asgn_to( REF reference) static void asgn_to( REF reference)
{ {
@ -259,9 +259,9 @@ static void asgn_to( REF reference)
#endif #endif
//____________________________________________________________ //____________________________________________________________
// //
// Generate code for AT END clause of FETCH. // Generate code for AT END clause of FETCH.
// //
static void gen_at_end( const act* action, int column) static void gen_at_end( const act* action, int column)
{ {
@ -273,9 +273,9 @@ static void gen_at_end( const act* action, int column)
//____________________________________________________________ //____________________________________________________________
// //
// Callback routine for BLR pretty printer. // Callback routine for BLR pretty printer.
// //
static void gen_blr(void* user_arg, SSHORT offset, const char* string) static void gen_blr(void* user_arg, SSHORT offset, const char* string)
{ {
@ -284,9 +284,9 @@ static void gen_blr(void* user_arg, SSHORT offset, const char* string)
//____________________________________________________________ //____________________________________________________________
// //
// Generate text to compile a request. // Generate text to compile a request.
// //
static void gen_compile( const gpre_req* request, int column) static void gen_compile( const gpre_req* request, int column)
{ {
@ -302,9 +302,9 @@ static void gen_compile( const gpre_req* request, int column)
//____________________________________________________________ //____________________________________________________________
// //
// Generate insertion text for the database statement. // Generate insertion text for the database statement.
// //
static void gen_database( const act* action, int column) static void gen_database( const act* action, int column)
{ {
@ -319,9 +319,9 @@ static void gen_database( const act* action, int column)
//____________________________________________________________ //____________________________________________________________
// //
// Generate substitution text for END_MODIFY. // Generate substitution text for END_MODIFY.
// //
static void gen_emodify( const act* action, int column) static void gen_emodify( const act* action, int column)
{ {
@ -358,9 +358,9 @@ static void gen_emodify( const act* action, int column)
//____________________________________________________________ //____________________________________________________________
// //
// Generate substitution text for END_STORE. // Generate substitution text for END_STORE.
// //
static void gen_estore( const act* action, int column, bool special) static void gen_estore( const act* action, int column, bool special)
{ {
@ -372,9 +372,9 @@ static void gen_estore( const act* action, int column, bool special)
//____________________________________________________________ //____________________________________________________________
// //
// Generate definitions associated with a single request. // Generate definitions associated with a single request.
// //
static void gen_endfor( const act* action, int column) static void gen_endfor( const act* action, int column)
{ {
@ -389,9 +389,9 @@ static void gen_endfor( const act* action, int column)
//____________________________________________________________ //____________________________________________________________
// //
// Generate substitution text for ERASE. // Generate substitution text for ERASE.
// //
static void gen_erase( const act* action, int column) static void gen_erase( const act* action, int column)
{ {
@ -401,9 +401,9 @@ static void gen_erase( const act* action, int column)
//____________________________________________________________ //____________________________________________________________
// //
// Generate substitution text for FOR statement. // Generate substitution text for FOR statement.
// //
static void gen_for( const act* action, int column) static void gen_for( const act* action, int column)
{ {
@ -424,10 +424,10 @@ static void gen_for( const act* action, int column)
//____________________________________________________________ //____________________________________________________________
// //
// Generate a name for a reference. Name is constructed from // Generate a name for a reference. Name is constructed from
// port and parameter idents. // port and parameter idents.
// //
static char* gen_name(char* const string, const ref* reference) static char* gen_name(char* const string, const ref* reference)
{ {
@ -440,9 +440,9 @@ static char* gen_name(char* const string, const ref* reference)
//____________________________________________________________ //____________________________________________________________
// //
// Generate BLR in raw, numeric form. Ugly but dense. // Generate BLR in raw, numeric form. Ugly but dense.
// //
static void gen_raw( const gpre_req* request) static void gen_raw( const gpre_req* request)
{ {
@ -473,9 +473,9 @@ static void gen_raw( const gpre_req* request)
//____________________________________________________________ //____________________________________________________________
// //
// Generate a send or receive call for a port. // Generate a send or receive call for a port.
// //
static void gen_receive( const gpre_req* request, const gpre_port* port) static void gen_receive( const gpre_req* request, const gpre_port* port)
{ {
@ -488,9 +488,9 @@ static void gen_receive( const gpre_req* request, const gpre_port* port)
//____________________________________________________________ //____________________________________________________________
// //
// Generate definitions associated with a single request. // Generate definitions associated with a single request.
// //
static void gen_request( const gpre_req* request) static void gen_request( const gpre_req* request)
{ {
@ -514,15 +514,15 @@ static void gen_request( const gpre_req* request)
//____________________________________________________________ //____________________________________________________________
// //
// Process routine head. If there are gpreGlob.requests in the // Process routine head. If there are gpreGlob.requests in the
// routine, insert local definitions. // routine, insert local definitions.
// //
static void gen_routine( const act* action, int column) static void gen_routine( const act* action, int column)
{ {
for (const gpre_req* request = (gpre_req*) action->act_object; request; for (const gpre_req* request = (gpre_req*) action->act_object; request;
request = request->req_routine) request = request->req_routine)
{ {
for (gpre_port* port = request->req_ports; port; port = port->por_next) for (gpre_port* port = request->req_ports; port; port = port->por_next)
make_port(port, column + INDENT); make_port(port, column + INDENT);
@ -531,9 +531,9 @@ static void gen_routine( const act* action, int column)
//____________________________________________________________ //____________________________________________________________
// //
// Generate substitution text for END_STREAM. // Generate substitution text for END_STREAM.
// //
static void gen_s_end( const act* action, int column) static void gen_s_end( const act* action, int column)
{ {
@ -543,9 +543,9 @@ static void gen_s_end( const act* action, int column)
//____________________________________________________________ //____________________________________________________________
// //
// Generate substitution text for FETCH. // Generate substitution text for FETCH.
// //
static void gen_s_fetch( const act* action, int column) static void gen_s_fetch( const act* action, int column)
{ {
@ -558,10 +558,10 @@ static void gen_s_fetch( const act* action, int column)
//____________________________________________________________ //____________________________________________________________
// //
// Generate text to compile and start a stream. This is // Generate text to compile and start a stream. This is
// used both by START_STREAM and FOR // used both by START_STREAM and FOR
// //
static void gen_s_start( const act* action, int column) static void gen_s_start( const act* action, int column)
{ {
@ -577,9 +577,9 @@ static void gen_s_start( const act* action, int column)
//____________________________________________________________ //____________________________________________________________
// //
// Generate a send or receive call for a port. // Generate a send or receive call for a port.
// //
static void gen_send( const gpre_req* request, const gpre_port* port, static void gen_send( const gpre_req* request, const gpre_port* port,
int column, bool special) int column, bool special)
@ -599,9 +599,9 @@ static void gen_send( const gpre_req* request, const gpre_port* port,
//____________________________________________________________ //____________________________________________________________
// //
// Generate a START. // Generate a START.
// //
static void gen_start( const gpre_req* request, const gpre_port* port, static void gen_start( const gpre_req* request, const gpre_port* port,
int column, bool special) int column, bool special)
@ -617,9 +617,9 @@ static void gen_start( const gpre_req* request, const gpre_port* port,
//____________________________________________________________ //____________________________________________________________
// //
// Substitute for a variable reference. // Substitute for a variable reference.
// //
static void gen_type( const act* action, int column) static void gen_type( const act* action, int column)
{ {
@ -629,9 +629,9 @@ static void gen_type( const act* action, int column)
//____________________________________________________________ //____________________________________________________________
// //
// Substitute for a variable reference. // Substitute for a variable reference.
// //
static void gen_variable( const act* action, int column) static void gen_variable( const act* action, int column)
{ {
@ -644,9 +644,9 @@ static void gen_variable( const act* action, int column)
//____________________________________________________________ //____________________________________________________________
// //
// Insert a port record description in output. // Insert a port record description in output.
// //
static void make_port( gpre_port* port, int column) static void make_port( gpre_port* port, int column)
{ {
@ -697,7 +697,7 @@ static void make_port( gpre_port* port, int column)
fprintf(gpreGlob.out_file, " ISC_QUAD jrd_%d;\t// %s ", fprintf(gpreGlob.out_file, " ISC_QUAD jrd_%d;\t// %s ",
reference->ref_ident, name); reference->ref_ident, name);
break; break;
case dtype_blob: case dtype_blob:
fprintf(gpreGlob.out_file, " bid jrd_%d;\t// %s ", fprintf(gpreGlob.out_file, " bid jrd_%d;\t// %s ",
reference->ref_ident, name); reference->ref_ident, name);
@ -736,9 +736,9 @@ static void make_port( gpre_port* port, int column)
//____________________________________________________________ //____________________________________________________________
// //
// Print a fixed string at a particular column. // Print a fixed string at a particular column.
// //
static void printa(const int column, const TEXT* string, ...) static void printa(const int column, const TEXT* string, ...)
{ {

View File

@ -1,28 +1,28 @@
//____________________________________________________________ //____________________________________________________________
// //
// PROGRAM: JRD Access Method // PROGRAM: JRD Access Method
// MODULE: jrdmet.cpp // MODULE: jrdmet.cpp
// DESCRIPTION: Non-database meta data for internal JRD stuff // DESCRIPTION: Non-database meta data for internal JRD stuff
// //
// The contents of this file are subject to the Interbase Public // The contents of this file are subject to the Interbase Public
// License Version 1.0 (the "License"); you may not use this file // License Version 1.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy // except in compliance with the License. You may obtain a copy
// of the License at http://www.Inprise.com/IPL.html // of the License at http://www.Inprise.com/IPL.html
// //
// Software distributed under the License is distributed on an // Software distributed under the License is distributed on an
// "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express // "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
// or implied. See the License for the specific language governing // or implied. See the License for the specific language governing
// rights and limitations under the License. // rights and limitations under the License.
// //
// The Original Code was created by Inprise Corporation // The Original Code was created by Inprise Corporation
// and its predecessors. Portions created by Inprise Corporation are // and its predecessors. Portions created by Inprise Corporation are
// Copyright (C) Inprise Corporation. // Copyright (C) Inprise Corporation.
// //
// All Rights Reserved. // All Rights Reserved.
// Contributor(s): ______________________________________. // Contributor(s): ______________________________________.
// TMN (Mike Nordell) 11.APR.2001 - Reduce compiler warnings // TMN (Mike Nordell) 11.APR.2001 - Reduce compiler warnings
// There however is still a bunch of constness errors in this file // There however is still a bunch of constness errors in this file
// //
// //
// //
@ -42,9 +42,9 @@
//____________________________________________________________ //____________________________________________________________
// //
// Initialize in memory meta data. // Initialize in memory meta data.
// //
void JRDMET_init( DBB db) void JRDMET_init( DBB db)
{ {
@ -65,7 +65,7 @@ void JRDMET_init( DBB db)
HSH_insert(symbol); HSH_insert(symbol);
const int* fld = relfld + RFLD_RPT; const int* fld = relfld + RFLD_RPT;
for (int n = 0; fld[RFLD_F_NAME]; ++n, fld += RFLD_F_LENGTH) for (int n = 0; fld[RFLD_F_NAME]; ++n, fld += RFLD_F_LENGTH)
{ {
const gfld* gfield = (fld[RFLD_F_UPD_MINOR]) ? const gfld* gfield = (fld[RFLD_F_UPD_MINOR]) ?
&gfields[fld[RFLD_F_UPD_ID]] : &gfields[fld[RFLD_F_UPD_ID]] :

View File

@ -1,23 +1,23 @@
//____________________________________________________________ //____________________________________________________________
// //
// PROGRAM: Gpre support // PROGRAM: Gpre support
// MODULE: movg.cpp // MODULE: movg.cpp
// DESCRIPTION: Data mover and converter and comparator, etc. // DESCRIPTION: Data mover and converter and comparator, etc.
// //
// The contents of this file are subject to the Interbase Public // The contents of this file are subject to the Interbase Public
// License Version 1.0 (the "License"); you may not use this file // License Version 1.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy // except in compliance with the License. You may obtain a copy
// of the License at http://www.Inprise.com/IPL.html // of the License at http://www.Inprise.com/IPL.html
// //
// Software distributed under the License is distributed on an // Software distributed under the License is distributed on an
// "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express // "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
// or implied. See the License for the specific language governing // or implied. See the License for the specific language governing
// rights and limitations under the License. // rights and limitations under the License.
// //
// The Original Code was created by Inprise Corporation // The Original Code was created by Inprise Corporation
// and its predecessors. Portions created by Inprise Corporation are // and its predecessors. Portions created by Inprise Corporation are
// Copyright (C) Inprise Corporation. // Copyright (C) Inprise Corporation.
// //
// All Rights Reserved. // All Rights Reserved.
// Contributor(s): ______________________________________. // Contributor(s): ______________________________________.
// TMN (Mike Nordell) 11.APR.2001 - Reduce compiler warnings // TMN (Mike Nordell) 11.APR.2001 - Reduce compiler warnings
@ -35,7 +35,7 @@
// the latter references a macro from the former, and doesn't include that // the latter references a macro from the former, and doesn't include that
// header file itself. We need to include gpre_proto.h since we use gpre // header file itself. We need to include gpre_proto.h since we use gpre
// functions. // functions.
// //
#include "../gpre/gpre.h" #include "../gpre/gpre.h"
#include "../gpre/gpre_proto.h" #include "../gpre/gpre_proto.h"
#include "../common/cvt.h" #include "../common/cvt.h"
@ -44,9 +44,9 @@ static void post_error(const Firebird::Arg::StatusVector&);
//____________________________________________________________ //____________________________________________________________
// //
// Move (and possible convert) something to something else. // Move (and possible convert) something to something else.
// //
void MOVG_move(const dsc* from, dsc* to) void MOVG_move(const dsc* from, dsc* to)
{ {
@ -55,9 +55,9 @@ void MOVG_move(const dsc* from, dsc* to)
//____________________________________________________________ //____________________________________________________________
// //
// A conversion error occurred. Complain. // A conversion error occurred. Complain.
// //
static void post_error(const Firebird::Arg::StatusVector&) static void post_error(const Firebird::Arg::StatusVector&)
{ {

View File

@ -1,47 +1,47 @@
//____________________________________________________________ //____________________________________________________________
// //
// PROGRAM: C preprocessor // PROGRAM: C preprocessor
// MODULE: msc.cpp // MODULE: msc.cpp
// DESCRIPTION: Miscellaneous little stuff // DESCRIPTION: Miscellaneous little stuff
// //
// The contents of this file are subject to the Interbase Public // The contents of this file are subject to the Interbase Public
// License Version 1.0 (the "License"); you may not use this file // License Version 1.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy // except in compliance with the License. You may obtain a copy
// of the License at http://www.Inprise.com/IPL.html // of the License at http://www.Inprise.com/IPL.html
// //
// Software distributed under the License is distributed on an // Software distributed under the License is distributed on an
// "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express // "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
// or implied. See the License for the specific language governing // or implied. See the License for the specific language governing
// rights and limitations under the License. // rights and limitations under the License.
// //
// The Original Code was created by Inprise Corporation // The Original Code was created by Inprise Corporation
// and its predecessors. Portions created by Inprise Corporation are // and its predecessors. Portions created by Inprise Corporation are
// Copyright (C) Inprise Corporation. // Copyright (C) Inprise Corporation.
// //
// All Rights Reserved. // All Rights Reserved.
// Contributor(s): ______________________________________. // Contributor(s): ______________________________________.
// TMN (Mike Nordell) 11.APR.2001 - Reduce compiler warnings // TMN (Mike Nordell) 11.APR.2001 - Reduce compiler warnings
// //
// //
//____________________________________________________________ //____________________________________________________________
// //
// //
// //
// //
// *************************************************** // ***************************************************
// THIS MODULE HAS SEVERAL KISSING COUSINS; IF YOU // THIS MODULE HAS SEVERAL KISSING COUSINS; IF YOU
// SHOULD CHANGE ONE OF THE MODULES IN THE FOLLOWING // SHOULD CHANGE ONE OF THE MODULES IN THE FOLLOWING
// LIST, PLEASE BE SURE TO CHECK THE OTHERS FOR // LIST, PLEASE BE SURE TO CHECK THE OTHERS FOR
// SIMILAR CHANGES: // SIMILAR CHANGES:
// //
// dsql/all.cpp // dsql/all.cpp
// jrd/all.cpp // jrd/all.cpp
// pipe/allp.cpp // pipe/allp.cpp
// qli/all.cpp // qli/all.cpp
// remote/allr.cpp // remote/allr.cpp
// gpre/msc.cpp // gpre/msc.cpp
// //
// - THANK YOU // - THANK YOU
//************************************************** //**************************************************
@ -64,9 +64,9 @@ static gpre_lls* free_lls;
//____________________________________________________________ //____________________________________________________________
// //
// Make an action and link it to a request. // Make an action and link it to a request.
// //
act* MSC_action( gpre_req* request, enum act_t type) act* MSC_action( gpre_req* request, enum act_t type)
{ {
@ -84,8 +84,8 @@ act* MSC_action( gpre_req* request, enum act_t type)
//____________________________________________________________ //____________________________________________________________
// //
// //
UCHAR* MSC_alloc(int size) UCHAR* MSC_alloc(int size)
{ {
@ -97,7 +97,7 @@ UCHAR* MSC_alloc(int size)
if (!next) if (!next)
CPR_error("virtual memory exhausted"); CPR_error("virtual memory exhausted");
#ifdef DEBUG_GDS_ALLOC #ifdef DEBUG_GDS_ALLOC
// For V4.0 we don't care about gpre specific memory leaks // For V4.0 we don't care about gpre specific memory leaks
gds_alloc_flag_unfreed(next); gds_alloc_flag_unfreed(next);
#endif #endif
next->spc_next = space; next->spc_next = space;
@ -114,9 +114,9 @@ UCHAR* MSC_alloc(int size)
//____________________________________________________________ //____________________________________________________________
// //
// Allocate a block in permanent memory. // Allocate a block in permanent memory.
// //
UCHAR* MSC_alloc_permanent(int size) UCHAR* MSC_alloc_permanent(int size)
{ {
@ -128,7 +128,7 @@ UCHAR* MSC_alloc_permanent(int size)
if (!next) if (!next)
CPR_error("virtual memory exhausted"); CPR_error("virtual memory exhausted");
#ifdef DEBUG_GDS_ALLOC #ifdef DEBUG_GDS_ALLOC
// For V4.0 we don't care about gpre specific memory leaks // For V4.0 we don't care about gpre specific memory leaks
gds_alloc_flag_unfreed(next); gds_alloc_flag_unfreed(next);
#endif #endif
next->spc_next = permanent_space; next->spc_next = permanent_space;
@ -146,9 +146,9 @@ UCHAR* MSC_alloc_permanent(int size)
//____________________________________________________________ //____________________________________________________________
// //
// Make a binary node. // Make a binary node.
// //
GPRE_NOD MSC_binary(NOD_T type, GPRE_NOD arg1, GPRE_NOD arg2) GPRE_NOD MSC_binary(NOD_T type, GPRE_NOD arg1, GPRE_NOD arg2)
{ {
@ -161,9 +161,9 @@ GPRE_NOD MSC_binary(NOD_T type, GPRE_NOD arg1, GPRE_NOD arg2)
//____________________________________________________________ //____________________________________________________________
// //
// Make a new context for a request and link it up to the request. // Make a new context for a request and link it up to the request.
// //
gpre_ctx* MSC_context(gpre_req* request) gpre_ctx* MSC_context(gpre_req* request)
{ {
@ -174,7 +174,7 @@ gpre_ctx* MSC_context(gpre_req* request)
context->ctx_internal = request->req_internal++; context->ctx_internal = request->req_internal++;
context->ctx_scope_level = request->req_scope_level; context->ctx_scope_level = request->req_scope_level;
// link in with the request block // link in with the request block
context->ctx_next = request->req_contexts; context->ctx_next = request->req_contexts;
request->req_contexts = context; request->req_contexts = context;
@ -184,9 +184,9 @@ gpre_ctx* MSC_context(gpre_req* request)
//____________________________________________________________ //____________________________________________________________
// //
// Copy one string into another. // Copy one string into another.
// //
void MSC_copy(const char* from, int length, char* to) void MSC_copy(const char* from, int length, char* to)
{ {
@ -198,9 +198,9 @@ void MSC_copy(const char* from, int length, char* to)
} }
//____________________________________________________________ //____________________________________________________________
// //
// Copy two strings into another. // Copy two strings into another.
// //
void MSC_copy_cat(const char* from1, int length1, const char* from2, int length2, void MSC_copy_cat(const char* from1, int length1, const char* from2, int length2,
char* to) char* to)
@ -215,9 +215,9 @@ void MSC_copy_cat(const char* from1, int length1, const char* from2, int length2
} }
//____________________________________________________________ //____________________________________________________________
// //
// Find a symbol of a particular type. // Find a symbol of a particular type.
// //
gpre_sym* MSC_find_symbol(gpre_sym* symbol, enum sym_t type) gpre_sym* MSC_find_symbol(gpre_sym* symbol, enum sym_t type)
{ {
@ -231,9 +231,9 @@ gpre_sym* MSC_find_symbol(gpre_sym* symbol, enum sym_t type)
//____________________________________________________________ //____________________________________________________________
// //
// Free a block. // Free a block.
// //
void MSC_free(void* block) void MSC_free(void* block)
{ {
@ -242,9 +242,9 @@ void MSC_free(void* block)
//____________________________________________________________ //____________________________________________________________
// //
// Get rid of an erroroneously allocated request block. // Get rid of an erroroneously allocated request block.
// //
void MSC_free_request( gpre_req* request) void MSC_free_request( gpre_req* request)
{ {
@ -256,10 +256,10 @@ void MSC_free_request( gpre_req* request)
//____________________________________________________________ //____________________________________________________________
// //
// Initialize (or more properly, re-initialize) the memory // Initialize (or more properly, re-initialize) the memory
// allocator. // allocator.
// //
void MSC_init(void) void MSC_init(void)
{ {
@ -274,11 +274,11 @@ void MSC_init(void)
//____________________________________________________________ //____________________________________________________________
// //
// Match the current token against a keyword. If successful, // Match the current token against a keyword. If successful,
// advance the token stream and return true. Otherwise return // advance the token stream and return true. Otherwise return
// false. // false.
// //
bool MSC_match(KWWORDS keyword) bool MSC_match(KWWORDS keyword)
{ {
@ -289,7 +289,7 @@ bool MSC_match(KWWORDS keyword)
symbol = symbol->sym_collision) symbol = symbol->sym_collision)
{ {
if ((strcmp(symbol->sym_string, gpreGlob.token_global.tok_string) == if ((strcmp(symbol->sym_string, gpreGlob.token_global.tok_string) ==
0) && symbol->sym_keyword != KW_none) 0) && symbol->sym_keyword != KW_none)
{ {
gpreGlob.token_global.tok_symbol = symbol; gpreGlob.token_global.tok_symbol = symbol;
gpreGlob.token_global.tok_keyword = static_cast < kwwords > (symbol->sym_keyword); gpreGlob.token_global.tok_keyword = static_cast < kwwords > (symbol->sym_keyword);
@ -307,10 +307,10 @@ bool MSC_match(KWWORDS keyword)
#ifdef NOT_USED_OR_REPLACED #ifdef NOT_USED_OR_REPLACED
//____________________________________________________________ //____________________________________________________________
// //
// Determinate where a specific object is // Determinate where a specific object is
// represented on a linked list stack. // represented on a linked list stack.
// //
bool MSC_member(GPRE_NOD object, gpre_lls* stack) bool MSC_member(GPRE_NOD object, gpre_lls* stack)
{ {
@ -324,9 +324,9 @@ bool MSC_member(GPRE_NOD object, gpre_lls* stack)
#endif #endif
//____________________________________________________________ //____________________________________________________________
// //
// Allocate an initialize a syntax node. // Allocate an initialize a syntax node.
// //
GPRE_NOD MSC_node(enum nod_t type, SSHORT count) GPRE_NOD MSC_node(enum nod_t type, SSHORT count)
{ {
@ -339,9 +339,9 @@ GPRE_NOD MSC_node(enum nod_t type, SSHORT count)
//____________________________________________________________ //____________________________________________________________
// //
// Pop an item off a linked list stack. Free the stack node. // Pop an item off a linked list stack. Free the stack node.
// //
GPRE_NOD MSC_pop(gpre_lls** pointer) GPRE_NOD MSC_pop(gpre_lls** pointer)
{ {
@ -357,9 +357,9 @@ GPRE_NOD MSC_pop(gpre_lls** pointer)
//____________________________________________________________ //____________________________________________________________
// //
// Allocate a new privilege (grant/revoke) block. // Allocate a new privilege (grant/revoke) block.
// //
PRV MSC_privilege_block(void) PRV MSC_privilege_block(void)
{ {
@ -375,9 +375,9 @@ PRV MSC_privilege_block(void)
//____________________________________________________________ //____________________________________________________________
// //
// Push an arbitrary object onto a linked list stack. // Push an arbitrary object onto a linked list stack.
// //
void MSC_push( GPRE_NOD object, gpre_lls** pointer) void MSC_push( GPRE_NOD object, gpre_lls** pointer)
{ {
@ -394,10 +394,10 @@ void MSC_push( GPRE_NOD object, gpre_lls** pointer)
//____________________________________________________________ //____________________________________________________________
// //
// Generate a reference and possibly link the reference into // Generate a reference and possibly link the reference into
// a linked list. // a linked list.
// //
REF MSC_reference(REF* link) REF MSC_reference(REF* link)
{ {
@ -413,10 +413,10 @@ REF MSC_reference(REF* link)
//____________________________________________________________ //____________________________________________________________
// //
// Set up for a new request. Make request and action // Set up for a new request. Make request and action
// blocks, all linked up and ready to go. // blocks, all linked up and ready to go.
// //
gpre_req* MSC_request(enum req_t type) gpre_req* MSC_request(enum req_t type)
{ {
@ -438,9 +438,9 @@ gpre_req* MSC_request(enum req_t type)
//____________________________________________________________ //____________________________________________________________
// //
// Copy a string into a permanent block. // Copy a string into a permanent block.
// //
SCHAR* MSC_string(const TEXT* input) SCHAR* MSC_string(const TEXT* input)
{ {
@ -452,9 +452,9 @@ SCHAR* MSC_string(const TEXT* input)
//____________________________________________________________ //____________________________________________________________
// //
// Allocate and initialize a symbol block. // Allocate and initialize a symbol block.
// //
gpre_sym* MSC_symbol(enum sym_t type, const TEXT* string, USHORT length, gpre_ctx* object) gpre_sym* MSC_symbol(enum sym_t type, const TEXT* string, USHORT length, gpre_ctx* object)
{ {
@ -472,9 +472,9 @@ gpre_sym* MSC_symbol(enum sym_t type, const TEXT* string, USHORT length, gpre_ct
//____________________________________________________________ //____________________________________________________________
// //
// Make a unary node. // Make a unary node.
// //
GPRE_NOD MSC_unary(NOD_T type, GPRE_NOD arg) GPRE_NOD MSC_unary(NOD_T type, GPRE_NOD arg)
{ {
@ -486,9 +486,9 @@ GPRE_NOD MSC_unary(NOD_T type, GPRE_NOD arg)
//____________________________________________________________ //____________________________________________________________
// //
// Set up for a new username. // Set up for a new username.
// //
gpre_usn* MSC_username(SCHAR* name, USHORT name_dyn) gpre_usn* MSC_username(SCHAR* name, USHORT name_dyn)
{ {

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,26 +1,26 @@
//____________________________________________________________ //____________________________________________________________
// //
// PROGRAM: Language Preprocessor // PROGRAM: Language Preprocessor
// MODULE: pat.cpp // MODULE: pat.cpp
// DESCRIPTION: Code generator pattern generator // DESCRIPTION: Code generator pattern generator
// //
// The contents of this file are subject to the Interbase Public // The contents of this file are subject to the Interbase Public
// License Version 1.0 (the "License"); you may not use this file // License Version 1.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy // except in compliance with the License. You may obtain a copy
// of the License at http://www.Inprise.com/IPL.html // of the License at http://www.Inprise.com/IPL.html
// //
// Software distributed under the License is distributed on an // Software distributed under the License is distributed on an
// "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express // "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
// or implied. See the License for the specific language governing // or implied. See the License for the specific language governing
// rights and limitations under the License. // rights and limitations under the License.
// //
// The Original Code was created by Inprise Corporation // The Original Code was created by Inprise Corporation
// and its predecessors. Portions created by Inprise Corporation are // and its predecessors. Portions created by Inprise Corporation are
// Copyright (C) Inprise Corporation. // Copyright (C) Inprise Corporation.
// //
// All Rights Reserved. // All Rights Reserved.
// Contributor(s): ______________________________________. // Contributor(s): ______________________________________.
// //
// //
//____________________________________________________________ //____________________________________________________________
// //
@ -38,23 +38,23 @@
typedef enum { typedef enum {
NL, NL,
RH, RL, RT, RI, RS, // Request handle, level, transaction, ident, length RH, RL, RT, RI, RS, // Request handle, level, transaction, ident, length
DH, DF, // Database handle, filename DH, DF, // Database handle, filename
TH, // Transaction handle TH, // Transaction handle
BH, BI, // Blob handle, blob_ident BH, BI, // Blob handle, blob_ident
FH, // Form handle FH, // Form handle
V1, V2, // Status vectors V1, V2, // Status vectors
I1, I2, // Identifier numbers I1, I2, // Identifier numbers
RF, RE, // OS- and language-dependent REF and REF-end character RF, RE, // OS- and language-dependent REF and REF-end character
VF, VE, // OS- and language-dependent VAL and VAL-end character VF, VE, // OS- and language-dependent VAL and VAL-end character
S1, S2, S3, S4, S5, S6, S7, S1, S2, S3, S4, S5, S6, S7,
// Arbitrary strings // Arbitrary strings
N1, N2, N3, N4, // Arbitrary number (SSHORT) N1, N2, N3, N4, // Arbitrary number (SSHORT)
L1, L2, // Arbitrary number (SLONG) L1, L2, // Arbitrary number (SLONG)
PN, PL, PI, // Port number, port length, port ident PN, PL, PI, // Port number, port length, port ident
QN, QL, QI, // Second port number, port length, port ident QN, QL, QI, // Second port number, port length, port ident
IF, EL, EN, // If, else, end IF, EL, EN, // If, else, end
FR // Field reference FR // Field reference
} PAT_T; } PAT_T;
static const struct ops { static const struct ops {
@ -109,9 +109,9 @@ static const struct ops {
//____________________________________________________________ //____________________________________________________________
// //
// Expand a pattern. // Expand a pattern.
// //
void PATTERN_expand( USHORT column, const TEXT* pattern, PAT* args) void PATTERN_expand( USHORT column, const TEXT* pattern, PAT* args)
{ {
@ -378,7 +378,7 @@ void PATTERN_expand( USHORT column, const TEXT* pattern, PAT* args)
sprintf(p, gpreGlob.long_ident_pattern, long_value); sprintf(p, gpreGlob.long_ident_pattern, long_value);
else else
sprintf(p, gpreGlob.ident_pattern, value); sprintf(p, gpreGlob.ident_pattern, value);
} }
else if (reference) { else if (reference) {
if (!reference->ref_port) if (!reference->ref_port)
sprintf(p, gpreGlob.ident_pattern, reference->ref_ident); sprintf(p, gpreGlob.ident_pattern, reference->ref_ident);

View File

@ -1,27 +1,27 @@
//____________________________________________________________ //____________________________________________________________
// //
// PROGRAM: BLR Pretty Printer // PROGRAM: BLR Pretty Printer
// MODULE: pretty.cpp // MODULE: pretty.cpp
// DESCRIPTION: BLR Pretty Printer // DESCRIPTION: BLR Pretty Printer
// //
// The contents of this file are subject to the Interbase Public // The contents of this file are subject to the Interbase Public
// License Version 1.0 (the "License"); you may not use this file // License Version 1.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy // except in compliance with the License. You may obtain a copy
// of the License at http://www.Inprise.com/IPL.html // of the License at http://www.Inprise.com/IPL.html
// //
// Software distributed under the License is distributed on an // Software distributed under the License is distributed on an
// "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express // "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
// or implied. See the License for the specific language governing // or implied. See the License for the specific language governing
// rights and limitations under the License. // rights and limitations under the License.
// //
// The Original Code was created by Inprise Corporation // The Original Code was created by Inprise Corporation
// and its predecessors. Portions created by Inprise Corporation are // and its predecessors. Portions created by Inprise Corporation are
// Copyright (C) Inprise Corporation. // Copyright (C) Inprise Corporation.
// //
// All Rights Reserved. // All Rights Reserved.
// Contributor(s): ______________________________________. // Contributor(s): ______________________________________.
// TMN (Mike Nordell) 11.APR.2001 - Reduce compiler warnings // TMN (Mike Nordell) 11.APR.2001 - Reduce compiler warnings
// //
// //
//____________________________________________________________ //____________________________________________________________
// //
@ -48,10 +48,10 @@
typedef struct ctl { typedef struct ctl {
UCHAR *ctl_blr; // Running blr string UCHAR *ctl_blr; // Running blr string
UCHAR *ctl_blr_start; // Original start of blr string UCHAR *ctl_blr_start; // Original start of blr string
FPTR_PRINT_CALLBACK ctl_routine; // Call back FPTR_PRINT_CALLBACK ctl_routine; // Call back
void *ctl_user_arg; // User argument void *ctl_user_arg; // User argument
TEXT *ctl_ptr; TEXT *ctl_ptr;
SSHORT ctl_language; SSHORT ctl_language;
SSHORT ctl_level; SSHORT ctl_level;
@ -102,9 +102,9 @@ const char *map_strings[] = {
}; };
//____________________________________________________________ //____________________________________________________________
// //
// Pretty print create database parameter buffer thru callback routine. // Pretty print create database parameter buffer thru callback routine.
// //
int PRETTY_print_cdb( UCHAR* blr, int PRETTY_print_cdb( UCHAR* blr,
FPTR_PRINT_CALLBACK routine, FPTR_PRINT_CALLBACK routine,
@ -134,7 +134,7 @@ int PRETTY_print_cdb( UCHAR* blr,
else else
sprintf(temp, "gds__dpb_version%d", i); sprintf(temp, "gds__dpb_version%d", i);
blr_format(control, temp); blr_format(control, temp);
SSHORT offset = 0; SSHORT offset = 0;
print_line(control, offset); print_line(control, offset);
@ -167,11 +167,11 @@ int PRETTY_print_cdb( UCHAR* blr,
int PRETTY_print_dyn( int PRETTY_print_dyn(
UCHAR* blr, UCHAR* blr,
//____________________________________________________________ //____________________________________________________________
// //
// Pretty print dynamic DDL thru callback routine. // Pretty print dynamic DDL thru callback routine.
// //
FPTR_PRINT_CALLBACK routine, FPTR_PRINT_CALLBACK routine,
void* user_arg, SSHORT language) void* user_arg, SSHORT language)
{ {
ctl ctl_buffer; ctl ctl_buffer;
@ -215,9 +215,9 @@ int PRETTY_print_dyn(
int int
PRETTY_print_sdl(UCHAR* blr, PRETTY_print_sdl(UCHAR* blr,
//____________________________________________________________ //____________________________________________________________
// //
// Pretty print slice description language. // Pretty print slice description language.
// //
FPTR_PRINT_CALLBACK routine, FPTR_PRINT_CALLBACK routine,
void *user_arg, SSHORT language) void *user_arg, SSHORT language)
@ -260,9 +260,9 @@ PRETTY_print_sdl(UCHAR* blr,
//____________________________________________________________ //____________________________________________________________
// //
// Format an utterance. // Format an utterance.
// //
static int blr_format(CTL control, const char *string, ...) static int blr_format(CTL control, const char *string, ...)
{ {
@ -273,15 +273,15 @@ static int blr_format(CTL control, const char *string, ...)
va_end(ptr); va_end(ptr);
while (*control->ctl_ptr) while (*control->ctl_ptr)
control->ctl_ptr++; control->ctl_ptr++;
return 0; return 0;
} }
//____________________________________________________________ //____________________________________________________________
// //
// Put out an error msg and punt. // Put out an error msg and punt.
// //
static int error( CTL control, SSHORT offset, const TEXT * string, int arg) static int error( CTL control, SSHORT offset, const TEXT * string, int arg)
{ {
@ -297,9 +297,9 @@ static int error( CTL control, SSHORT offset, const TEXT * string, int arg)
//____________________________________________________________ //____________________________________________________________
// //
// Indent for pretty printing. // Indent for pretty printing.
// //
static int indent( CTL control, SSHORT level) static int indent( CTL control, SSHORT level)
{ {
@ -312,10 +312,10 @@ static int indent( CTL control, SSHORT level)
//____________________________________________________________ //____________________________________________________________
// //
// Print a datatype sequence and return the length of the // Print a datatype sequence and return the length of the
// data described. // data described.
// //
static int print_blr_dtype(CTL control, static int print_blr_dtype(CTL control,
bool print_object) bool print_object)
@ -326,7 +326,7 @@ static int print_blr_dtype(CTL control,
const USHORT dtype = BLR_BYTE; const USHORT dtype = BLR_BYTE;
// Special case blob (261) to keep down the size of the // Special case blob (261) to keep down the size of the
// jump table // jump table
switch (dtype) { switch (dtype) {
case blr_short: case blr_short:
@ -418,7 +418,7 @@ static int print_blr_dtype(CTL control,
if (!print_object) if (!print_object)
return length; return length;
// TMN: FIX FIX Note that offset is not initialized to anything useful // TMN: FIX FIX Note that offset is not initialized to anything useful
// for e.g. print_word(control, (SSHORT)offset). I assume it's better to initialize it to zero // for e.g. print_word(control, (SSHORT)offset). I assume it's better to initialize it to zero
// than letting it be random. // than letting it be random.
@ -470,9 +470,9 @@ static int print_blr_dtype(CTL control,
//____________________________________________________________ //____________________________________________________________
// //
// Print a line of pretty-printed BLR. // Print a line of pretty-printed BLR.
// //
static void print_blr_line(void* arg, SSHORT offset, const char* line) static void print_blr_line(void* arg, SSHORT offset, const char* line)
{ {
@ -498,9 +498,9 @@ static void print_blr_line(void* arg, SSHORT offset, const char* line)
//____________________________________________________________ //____________________________________________________________
// //
// Print a byte as a numeric value and return same. // Print a byte as a numeric value and return same.
// //
static int print_byte( CTL control, SSHORT offset) static int print_byte( CTL control, SSHORT offset)
{ {
@ -514,9 +514,9 @@ static int print_byte( CTL control, SSHORT offset)
//____________________________________________________________ //____________________________________________________________
// //
// Print a byte as a numeric value and return same. // Print a byte as a numeric value and return same.
// //
static int print_char( CTL control, SSHORT offset) static int print_char( CTL control, SSHORT offset)
{ {
@ -536,9 +536,9 @@ static int print_char( CTL control, SSHORT offset)
//____________________________________________________________ //____________________________________________________________
// //
// Primary recursive routine to print dynamic DDL. // Primary recursive routine to print dynamic DDL.
// //
static int print_dyn_verb( CTL control, SSHORT level) static int print_dyn_verb( CTL control, SSHORT level)
{ {
@ -560,7 +560,7 @@ static int print_dyn_verb( CTL control, SSHORT level)
++level; ++level;
int length; int length;
switch (dyn_operator) { switch (dyn_operator) {
case isc_dyn_drop_difference: case isc_dyn_drop_difference:
case isc_dyn_begin_backup: case isc_dyn_begin_backup:
@ -721,9 +721,9 @@ static int print_dyn_verb( CTL control, SSHORT level)
//____________________________________________________________ //____________________________________________________________
// //
// Invoke callback routine to print (or do something with) a line. // Invoke callback routine to print (or do something with) a line.
// //
static int print_line( CTL control, SSHORT offset) static int print_line( CTL control, SSHORT offset)
{ {
@ -736,9 +736,9 @@ static int print_line( CTL control, SSHORT offset)
//____________________________________________________________ //____________________________________________________________
// //
// Print a VAX word as a numeric value an return same. // Print a VAX word as a numeric value an return same.
// //
static SLONG print_long( CTL control, SSHORT offset) static SLONG print_long( CTL control, SSHORT offset)
{ {
@ -757,9 +757,9 @@ static SLONG print_long( CTL control, SSHORT offset)
//____________________________________________________________ //____________________________________________________________
// //
// Primary recursive routine to print slice description language. // Primary recursive routine to print slice description language.
// //
static int print_sdl_verb( CTL control, SSHORT level) static int print_sdl_verb( CTL control, SSHORT level)
{ {
@ -865,9 +865,9 @@ static int print_sdl_verb( CTL control, SSHORT level)
//____________________________________________________________ //____________________________________________________________
// //
// Print a byte-counted string. // Print a byte-counted string.
// //
static int print_string( CTL control, SSHORT offset) static int print_string( CTL control, SSHORT offset)
{ {
@ -881,9 +881,9 @@ static int print_string( CTL control, SSHORT offset)
//____________________________________________________________ //____________________________________________________________
// //
// Print a VAX word as a numeric value an return same. // Print a VAX word as a numeric value an return same.
// //
static int print_word( CTL control, SSHORT offset) static int print_word( CTL control, SSHORT offset)
{ {

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -153,9 +153,9 @@ ULONG CVBIG5_unicode_to_big5(csconvert* obj,
const int tmp1 = big5_ch / 256; const int tmp1 = big5_ch / 256;
const int tmp2 = big5_ch % 256; const int tmp2 = big5_ch % 256;
if (tmp1 == 0) { /* ASCII character */ if (tmp1 == 0) { /* ASCII character */
fb_assert((UCHAR(tmp2) & 0x80) == 0); fb_assert((UCHAR(tmp2) & 0x80) == 0);
*big5_str++ = tmp2; *big5_str++ = tmp2;
big5_len--; big5_len--;
unicode_len -= sizeof(*unicode_str); unicode_len -= sizeof(*unicode_str);
@ -190,9 +190,9 @@ INTL_BOOL CVBIG5_check_big5(charset* cs,
/************************************** /**************************************
* Functional description * Functional description
* Make sure that the big5 string does not have any truncated 2 byte * Make sure that the big5 string does not have any truncated 2 byte
* character at the end. * character at the end.
* If we have a truncated character then, * If we have a truncated character then,
* return false. * return false.
* else return(true); * else return(true);
**************************************/ **************************************/
const UCHAR* big5_str_start = big5_str; const UCHAR* big5_str_start = big5_str;

View File

@ -113,7 +113,7 @@ ULONG CVGB_unicode_to_gb2312(csconvert* obj,
const UCHAR* p_unicode_str, const UCHAR* p_unicode_str,
ULONG gb_len, ULONG gb_len,
UCHAR* gb_str, UCHAR* gb_str,
USHORT* err_code, USHORT* err_code,
ULONG* err_position) ULONG* err_position)
{ {
fb_assert(obj != NULL); fb_assert(obj != NULL);
@ -152,9 +152,9 @@ ULONG CVGB_unicode_to_gb2312(csconvert* obj,
const int tmp1 = gb_ch / 256; const int tmp1 = gb_ch / 256;
const int tmp2 = gb_ch % 256; const int tmp2 = gb_ch % 256;
if (tmp1 == 0) { /* ASCII character */ if (tmp1 == 0) { /* ASCII character */
fb_assert((UCHAR(tmp2) & 0x80) == 0); fb_assert((UCHAR(tmp2) & 0x80) == 0);
*gb_str++ = tmp2; *gb_str++ = tmp2;
gb_len--; gb_len--;
unicode_len -= sizeof(*unicode_str); unicode_len -= sizeof(*unicode_str);
@ -186,9 +186,9 @@ INTL_BOOL CVGB_check_gb2312(charset* cs, ULONG gb_len, const UCHAR *gb_str, ULON
/************************************** /**************************************
* Functional description * Functional description
* Make sure that the GB2312 string does not have any truncated 2 byte * Make sure that the GB2312 string does not have any truncated 2 byte
* character at the end. * character at the end.
* If we have a truncated character then, * If we have a truncated character then,
* return false. * return false.
* else return(true); * else return(true);
**************************************/ **************************************/
const UCHAR* gb_str_start = gb_str; const UCHAR* gb_str_start = gb_str;

View File

@ -241,7 +241,7 @@ Received: by dbase.a-t.com (/\==/\ Smail3.1.21.1 #21.5)
id <m0kjfXI-0004qKC@dbase.a-t.com>; Tue, 19 Nov 91 16:11 PST id <m0kjfXI-0004qKC@dbase.a-t.com>; Tue, 19 Nov 91 16:11 PST
Received: by tate.a-t.com (/\==/\ Smail3.1.21.1 #21.1) Received: by tate.a-t.com (/\==/\ Smail3.1.21.1 #21.1)
id <m0kjfPU-000Gf0C@tate.a-t.com>; Tue, 19 Nov 91 16:03 PST id <m0kjfPU-000Gf0C@tate.a-t.com>; Tue, 19 Nov 91 16:03 PST
Received: from Sun.COM by relay1.UU.NET with SMTP Received: from Sun.COM by relay1.UU.NET with SMTP
(5.61/UUNET-internet-primary) id AA21144; Tue, 19 Nov 91 18:45:19 -0500 (5.61/UUNET-internet-primary) id AA21144; Tue, 19 Nov 91 18:45:19 -0500
Received: from Eng.Sun.COM (zigzag-bb.Corp.Sun.COM) by Sun.COM (4.1/SMI-4.1) Received: from Eng.Sun.COM (zigzag-bb.Corp.Sun.COM) by Sun.COM (4.1/SMI-4.1)
id AA04289; Tue, 19 Nov 91 15:40:59 PST id AA04289; Tue, 19 Nov 91 15:40:59 PST
@ -350,7 +350,7 @@ STEPS:
EX: JIS 1st is in the range 33-94, so we execute step 3(a). JIS 1st = 76 EX: JIS 1st is in the range 33-94, so we execute step 3(a). JIS 1st = 76
(is NOT odd), so JIS 2nd = 150 ((76/2) + 112) (is NOT odd), so JIS 2nd = 150 ((76/2) + 112)
JIS 1st: 150 JIS 1st: 150
JIS 2nd: 162 JIS 2nd: 162
@ -561,7 +561,7 @@ INTL_BOOL CVJIS_check_euc(charset* cs, ULONG euc_len, const UCHAR* euc_str, ULON
* Functional description * Functional description
* This is a cousin of the KANJI_check_sjis routine. * This is a cousin of the KANJI_check_sjis routine.
* Make sure that the euc string does not have any truncated 2 byte * Make sure that the euc string does not have any truncated 2 byte
* character at the end. * If we have a truncated character then, * character at the end. * If we have a truncated character then,
* return false. * return false.
* else return true; * else return true;
**************************************/ **************************************/
@ -598,9 +598,9 @@ INTL_BOOL CVJIS_check_sjis(charset* cs, ULONG sjis_len, const UCHAR* sjis_str, U
* *
* Functional description * Functional description
* This is a cousin of the KANJI_check_euc routine. * This is a cousin of the KANJI_check_euc routine.
* Make sure that the sjis string does not have any truncated 2 byte * Make sure that the sjis string does not have any truncated 2 byte
* character at the end. * If we have a truncated character then, * character at the end. * If we have a truncated character then,
* return 1. * return 1.
* else return(0); * else return(0);
**************************************/ **************************************/
const UCHAR* start = sjis_str; const UCHAR* start = sjis_str;

View File

@ -29,7 +29,7 @@
/* /*
* KSC-5601 -> unicode * KSC-5601 -> unicode
* % KSC-5601 is same to EUC cs1(codeset 1). Then converting * % KSC-5601 is same to EUC cs1(codeset 1). Then converting
* KSC-5601 to EUC is not needed. * KSC-5601 to EUC is not needed.
*/ */
@ -156,7 +156,7 @@ ULONG CVKSC_unicode_to_ksc(csconvert* obj,
const int tmp1 = ksc_ch / 256; const int tmp1 = ksc_ch / 256;
const int tmp2 = ksc_ch % 256; const int tmp2 = ksc_ch % 256;
if (tmp1 == 0) { /* ASCII character */ if (tmp1 == 0) { /* ASCII character */
fb_assert((UCHAR(tmp2) & 0x80) == 0); fb_assert((UCHAR(tmp2) & 0x80) == 0);
*ksc_str++ = tmp2; *ksc_str++ = tmp2;

View File

@ -167,7 +167,7 @@ static fss_size_t fss_mbtowc( fss_wchar_t* p, const UCHAR* s, fss_size_t n)
int nc = 0; int nc = 0;
if (n <= nc) if (n <= nc)
return -1; return -1;
const int c0 = *s & 0xff; const int c0 = *s & 0xff;
long l = c0; long l = c0;
for (const Fss_table* t = fss_sequence_table; t->cmask; t++) { for (const Fss_table* t = fss_sequence_table; t->cmask; t++) {
@ -265,7 +265,7 @@ ULONG CS_UTFFSS_fss_to_unicode_cc(csconvert* obj,
fb_assert(obj != NULL); fb_assert(obj != NULL);
fb_assert(obj->csconvert_fn_convert == CS_UTFFSS_fss_to_unicode_cc); fb_assert(obj->csconvert_fn_convert == CS_UTFFSS_fss_to_unicode_cc);
return fss_to_unicode(src_len, src_ptr, return fss_to_unicode(src_len, src_ptr,
dest_len, Firebird::OutAligner<UNICODE>(dest_ptr, dest_len), err_code, err_position); dest_len, Firebird::OutAligner<UNICODE>(dest_ptr, dest_len), err_code, err_position);
} }

View File

@ -55,15 +55,15 @@ USHORT KANJI_check_euc(const UCHAR* euc_str, USHORT euc_len)
{ {
/************************************** /**************************************
* *
* K A N J I _ c h e c k _ e u c * K A N J I _ c h e c k _ e u c
* *
************************************** **************************************
* *
* Functional description * Functional description
* This is a cousin of the KANJI_check_sjis routine. * This is a cousin of the KANJI_check_sjis routine.
* Make sure that the euc string does not have any truncated 2 byte * Make sure that the euc string does not have any truncated 2 byte
* character at the end. * If we have a truncated character then, * character at the end. * If we have a truncated character then,
* return 1. * return 1.
* else return(0); * else return(0);
**************************************/ **************************************/
while (euc_len--) { while (euc_len--) {
@ -93,9 +93,9 @@ USHORT KANJI_check_sjis(const UCHAR* sjis_str, USHORT sjis_len)
* *
* Functional description * Functional description
* This is a cousin of the KANJI_check_euc routine. * This is a cousin of the KANJI_check_euc routine.
* Make sure that the sjis string does not have any truncated 2 byte * Make sure that the sjis string does not have any truncated 2 byte
* character at the end. * If we have a truncated character then, * character at the end. * If we have a truncated character then,
* return 1. * return 1.
* else return(0); * else return(0);
**************************************/ **************************************/
while (sjis_len--) { while (sjis_len--) {

View File

@ -121,7 +121,7 @@ static inline bool FAMILY_ASCII(texttype* cache,
TextTypeImpl* impl = FB_NEW(*getDefaultMemoryPool()) TextTypeImpl; TextTypeImpl* impl = FB_NEW(*getDefaultMemoryPool()) TextTypeImpl;
cache->texttype_impl = impl; cache->texttype_impl = impl;
memset(&impl->cs, 0, sizeof(impl->cs)); memset(&impl->cs, 0, sizeof(impl->cs));
LD_lookup_charset(&impl->cs, cs_name, config_info); LD_lookup_charset(&impl->cs, cs_name, config_info);
@ -504,7 +504,7 @@ USHORT famasc_key_length(texttype* obj, USHORT inLen)
* *
* For ASCII type collation (codepoint collation) this mearly * For ASCII type collation (codepoint collation) this mearly
* involves stripping the space character off the key. * involves stripping the space character off the key.
* *
* RETURN: * RETURN:
* Length, in bytes, of returned key * Length, in bytes, of returned key
*/ */
@ -569,7 +569,7 @@ SSHORT famasc_compare(texttype* obj, ULONG l1, const BYTE* s1, ULONG l2, const B
return 1; return 1;
if (s1[i] < s2[i]) if (s1[i] < s2[i])
return -1; return -1;
return 1; return 1;
} }

View File

@ -1,7 +1,7 @@
/* /*
* PROGRAM: InterBase International support * PROGRAM: InterBase International support
* MODULE: lc_big5.cpp * MODULE: lc_big5.cpp
* DESCRIPTION: Language Drivers in the BIG5 family. * DESCRIPTION: Language Drivers in the BIG5 family.
* *
* The contents of this file are subject to the Interbase Public * The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file * License Version 1.0 (the "License"); you may not use this file

View File

@ -1,7 +1,7 @@
/* /*
* PROGRAM: InterBase International support * PROGRAM: InterBase International support
* MODULE: lc_gb2312.cpp * MODULE: lc_gb2312.cpp
* DESCRIPTION: Language Drivers in the GB2312 family. * DESCRIPTION: Language Drivers in the GB2312 family.
* *
* The contents of this file are subject to the Interbase Public * The contents of this file are subject to the Interbase Public
* License Version 1.0 (the "License"); you may not use this file * License Version 1.0 (the "License"); you may not use this file

View File

@ -81,7 +81,7 @@ const UINT16 NULL_TERTIARY = 0;
* + 2 * ns * + 2 * ns
* + 3 * nt * + 3 * nt
* + 3 * (nc/2) * + 3 * (nc/2)
* + 3 * 2 * ne * + 3 * 2 * ne
* + 2 * nsp * + 2 * nsp
* + 1 (if nsp > 0, for separating keys from special keys) * + 1 (if nsp > 0, for separating keys from special keys)
* *
@ -161,7 +161,7 @@ static ULONG do_debug = 0;
/* /*
* *
* Convert a user string to a sequence that will collate bytewise. * Convert a user string to a sequence that will collate bytewise.
* *
* RETURN: * RETURN:
* Length, in bytes, of returned key * Length, in bytes, of returned key
*/ */
@ -205,7 +205,7 @@ USHORT LC_NARROW_string_to_key(texttype* obj, USHORT iInLen, const BYTE* pInChar
} }
iInLen = (inbuff - pInChar + 1); iInLen = (inbuff - pInChar + 1);
USHORT i; USHORT i;
for (i = 0; i < iInLen; i++, pInChar++) { for (i = 0; i < iInLen; i++, pInChar++) {
@ -546,7 +546,7 @@ static const SortOrderTblEntry* get_coltab_entry(texttype* obj, const UCHAR** p,
#define XOR ^ /* C bitwise XOR operator - defined for readability */ #define XOR ^ /* C bitwise XOR operator - defined for readability */
SSHORT LC_NARROW_compare(texttype* obj, ULONG l1, const BYTE* s1, ULONG l2, const BYTE* s2, SSHORT LC_NARROW_compare(texttype* obj, ULONG l1, const BYTE* s1, ULONG l2, const BYTE* s2,
INTL_BOOL* error_flag) INTL_BOOL* error_flag)
{ {
fb_assert(obj != NULL); fb_assert(obj != NULL);
@ -583,7 +583,7 @@ SSHORT LC_NARROW_compare(texttype* obj, ULONG l1, const BYTE* s1, ULONG l2, cons
coltab_status stat1, stat2; coltab_status stat1, stat2;
stat1.stat_flags = 0; stat1.stat_flags = 0;
stat2.stat_flags = 0; stat2.stat_flags = 0;
const SortOrderTblEntry* col1 = 0; const SortOrderTblEntry* col1 = 0;
const SortOrderTblEntry* col2 = 0; const SortOrderTblEntry* col2 = 0;
@ -689,7 +689,7 @@ static SSHORT old_fam2_compare(texttype* obj, ULONG l1, const BYTE* s1,
return (-1); return (-1);
if (len1 > len2) if (len1 > len2)
return (1); return (1);
return (0); return (0);
} }
#endif /* DEBUG_COMPARE */ #endif /* DEBUG_COMPARE */

View File

@ -528,7 +528,7 @@ INTL_BOOL FB_DLL_EXPORT LD_lookup_texttype(texttype* tt, const ASCII* texttype_n
{ {
if (LD_lookup_charset(&cs, charset_name, configInfo)) if (LD_lookup_charset(&cs, charset_name, configInfo))
break; break;
return false; return false;
} }
} }
@ -563,7 +563,7 @@ ULONG FB_DLL_EXPORT LD_setup_attributes(
{ {
Firebird::string specificAttributes((const char*) src, srcLen); Firebird::string specificAttributes((const char*) src, srcLen);
Firebird::string newSpecificAttributes = specificAttributes; Firebird::string newSpecificAttributes = specificAttributes;
if (!LCICU_setup_attributes(textTypeName, charSetName, configInfo, if (!LCICU_setup_attributes(textTypeName, charSetName, configInfo,
specificAttributes, newSpecificAttributes)) specificAttributes, newSpecificAttributes))
{ {

View File

@ -48,7 +48,7 @@ No errors
#include "../intl/cs_iso8859_1.h" #include "../intl/cs_iso8859_1.h"
*/ */
/* /*
-- Multibyte character sets -- -- Multibyte character sets --
#include "../intl/cs_big5.h" #include "../intl/cs_big5.h"
#include "../intl/cs_gb2312.h" #include "../intl/cs_gb2312.h"

View File

@ -28,7 +28,7 @@
ColList::item::item(const char* name, int len) ColList::item::item(const char* name, int len)
: col_len(len), next(0) : col_len(len), next(0)
{ {
fb_utils::copy_terminate(col_name, name, sizeof(col_name)); fb_utils::copy_terminate(col_name, name, sizeof(col_name));
} }

View File

@ -93,17 +93,17 @@ void Extender::grow(size_t n)
alloc(n); alloc(n);
return; return;
} }
if (m_size < n) if (m_size < n)
{ {
const size_t old_pos = getUsed(); const size_t old_pos = getUsed();
char* const old_buf = m_buf; char* const old_buf = m_buf;
m_buf = new char[m_size = n]; m_buf = new char[m_size = n];
memcpy(m_buf, old_buf, old_pos); // Copy only the used bytes. memcpy(m_buf, old_buf, old_pos); // Copy only the used bytes.
m_pos = m_buf + old_pos; // Reposition the current insertion point. m_pos = m_buf + old_pos; // Reposition the current insertion point.
m_pos[0] = 0; // Same as alloc(). m_pos[0] = 0; // Same as alloc().
delete[] old_buf; delete[] old_buf;
} }
} }

View File

@ -33,7 +33,7 @@ int OptionsBase::getCommand(const char* cmd) const
const size_t swlen = strlen(cmd); const size_t swlen = strlen(cmd);
if (!swlen) if (!swlen)
return m_wrong; return m_wrong;
for (int i = 0; i < m_size; ++i) for (int i = 0; i < m_size; ++i)
{ {
const optionsMap& item = m_options[i]; const optionsMap& item = m_options[i];
@ -64,10 +64,10 @@ void OptionsBase::showCommands(FILE* out) const
const optionsMap& item = m_options[i]; const optionsMap& item = m_options[i];
if (item.text[0] != cap) if (item.text[0] != cap)
continue; continue;
const size_t swlen = strlen(item.text); const size_t swlen = strlen(item.text);
fb_assert(swlen >= item.abbrlen || !item.abbrlen); fb_assert(swlen >= item.abbrlen || !item.abbrlen);
if (!item.abbrlen) if (!item.abbrlen)
fprintf(out, "%-25s", item.text); fprintf(out, "%-25s", item.text);
else else
@ -84,11 +84,11 @@ void OptionsBase::showCommands(FILE* out) const
fputc(c, out); fputc(c, out);
} }
for (; j < 25; ++j) for (; j < 25; ++j)
fputc(' ', out); fputc(' ', out);
} }
if (newline == 2) if (newline == 2)
{ {
fputc('\n', out); fputc('\n', out);
@ -98,7 +98,7 @@ void OptionsBase::showCommands(FILE* out) const
++newline; ++newline;
} }
} }
if (newline) // Last line was without newline. if (newline) // Last line was without newline.
fputc('\n', out); fputc('\n', out);
} }

View File

@ -69,7 +69,7 @@ scrollkeys key2scroll[] = {
{VK_RIGHT, WM_HSCROLL, SB_PAGEDOWN} {VK_RIGHT, WM_HSCROLL, SB_PAGEDOWN}
}; };
// data initialized by first instance // data initialized by first instance
struct tagSETUPDATA { struct tagSETUPDATA {
SCHAR appName[20]; SCHAR appName[20];
@ -79,27 +79,27 @@ struct tagSETUPDATA {
}; };
typedef tagSETUPDATA SETUPDATA; typedef tagSETUPDATA SETUPDATA;
// various temp file names // various temp file names
static SCHAR defInputFile[MAXPATHLEN]; // default input file name static SCHAR defInputFile[MAXPATHLEN]; // default input file name
static SCHAR defOutputFile[MAXPATHLEN]; // default output file name static SCHAR defOutputFile[MAXPATHLEN]; // default output file name
static SCHAR defHistFile[MAXPATHLEN]; // command history file name static SCHAR defHistFile[MAXPATHLEN]; // command history file name
static SCHAR defSessionFile[MAXPATHLEN]; // SQL session file static SCHAR defSessionFile[MAXPATHLEN]; // SQL session file
static FILE *ipf; // input file static FILE *ipf; // input file
static FILE *opf; // output file static FILE *opf; // output file
static FILE *chf; // command history static FILE *chf; // command history
static FILE *sss; // SQL session static FILE *sss; // SQL session
// global flags // global flags
static SSHORT gflags; static SSHORT gflags;
const SSHORT DBINITED = 1; // database initilized flag const SSHORT DBINITED = 1; // database initilized flag
const SSHORT DEFINPUT = 2; // default input file exists flag const SSHORT DEFINPUT = 2; // default input file exists flag
const SSHORT DEFOUTPUT = 4; // default output file exists flag const SSHORT DEFOUTPUT = 4; // default output file exists flag
const SSHORT COMHIST = 8; // command history file exists flag const SSHORT COMHIST = 8; // command history file exists flag
const SSHORT OVERWRITE = 16; // overwrite/append to window const SSHORT OVERWRITE = 16; // overwrite/append to window
const SSHORT SESSFILE = 32; // SQL session file exists flag const SSHORT SESSFILE = 32; // SQL session file exists flag
SETUPDATA SetUpData; SETUPDATA SetUpData;
@ -108,44 +108,44 @@ SETUPDATA SetUpData;
program but not passed to other instances program but not passed to other instances
*/ */
HINSTANCE hInst; // hInstance of application HINSTANCE hInst; // hInstance of application
HWND hWndMain; // hWnd of main window HWND hWndMain; // hWnd of main window
int xChar, yChar, yCharnl; // character size int xChar, yChar, yCharnl; // character size
int xClient, yClient; // client window size int xClient, yClient; // client window size
LOGFONT cursfont; // font structure LOGFONT cursfont; // font structure
HFONT holdsfont; // handle of original font HFONT holdsfont; // handle of original font
HFONT hnewsfont; // handle of new fixed font HFONT hnewsfont; // handle of new fixed font
SCHAR tmpDialogParam[1024]; // used by dialog boxes SCHAR tmpDialogParam[1024]; // used by dialog boxes
// window scroll/paint stuff // window scroll/paint stuff
int nVscrollMax, nHscrollMax; // scroll ranges int nVscrollMax, nHscrollMax; // scroll ranges
int nVscrollPos, nHscrollPos; // current scroll positions int nVscrollPos, nHscrollPos; // current scroll positions
int numlines; // number of lines in file int numlines; // number of lines in file
int maxwidth; // width of display format int maxwidth; // width of display format
int nVscrollInc, nHscrollInc; // scroll increments int nVscrollInc, nHscrollInc; // scroll increments
int nPageMaxLines; // max lines on screen int nPageMaxLines; // max lines on screen
// arguments passed to ISQL // arguments passed to ISQL
int ISQL_argc; // argument count int ISQL_argc; // argument count
char *ISQL_argv[20]; // argument vector char *ISQL_argv[20]; // argument vector
char ISQL_args[1024]; // space for arguments char ISQL_args[1024]; // space for arguments
char *ISQL_cursor; // cursor into arguments char *ISQL_cursor; // cursor into arguments
// database startup parameters // database startup parameters
static SCHAR newDataBase[256]; static SCHAR newDataBase[256];
static SCHAR newUserName[32]; static SCHAR newUserName[32];
static SCHAR newPassword[16]; static SCHAR newPassword[16];
// script parameters // script parameters
static SCHAR scriptName[256]; static SCHAR scriptName[256];
static SCHAR scriptOutput[256]; static SCHAR scriptOutput[256];
// extract parameters // extract parameters
static SCHAR extractDbName[256]; static SCHAR extractDbName[256];
static SCHAR extractOutput[256]; static SCHAR extractOutput[256];
static SCHAR extractTarget[256]; static SCHAR extractTarget[256];
@ -216,8 +216,8 @@ LRESULT CALLBACK _export ISQLWndProc(HWND hWnd,
* depends on message. * depends on message.
* *
********************************************************************/ ********************************************************************/
DLGPROC lpproc; // pointer to thunk for dialog box DLGPROC lpproc; // pointer to thunk for dialog box
SCHAR buf[1024]; // temp buffer SCHAR buf[1024]; // temp buffer
SCHAR pwbuf[50]; SCHAR pwbuf[50];
SCHAR unbuf[50]; SCHAR unbuf[50];
SSHORT i; SSHORT i;
@ -232,18 +232,18 @@ LRESULT CALLBACK _export ISQLWndProc(HWND hWnd,
case WM_COMMAND: case WM_COMMAND:
switch (GET_WM_COMMAND_ID(wParam, lParam)) { switch (GET_WM_COMMAND_ID(wParam, lParam)) {
case IDM_QUIT: case IDM_QUIT:
// User selected Quit on menu // User selected Quit on menu
PostMessage(hWnd, WM_CLOSE, 0, 0L); PostMessage(hWnd, WM_CLOSE, 0, 0L);
break; break;
case IDM_HOME: case IDM_HOME:
// Used to implement home to topleft from keyboard. // Used to implement home to topleft from keyboard.
SendMessage(hWnd, WM_HSCROLL, GET_WM_HSCROLL_MPS(SB_TOP, 0, 0)); SendMessage(hWnd, WM_HSCROLL, GET_WM_HSCROLL_MPS(SB_TOP, 0, 0));
SendMessage(hWnd, WM_VSCROLL, GET_WM_VSCROLL_MPS(SB_TOP, 0, 0)); SendMessage(hWnd, WM_VSCROLL, GET_WM_VSCROLL_MPS(SB_TOP, 0, 0));
break; break;
case IDM_ABOUT: case IDM_ABOUT:
// Display about box. // Display about box.
lpproc = lpproc =
(DLGPROC) MakeProcInstance((FARPROC) aboutDlgProc, hInst); (DLGPROC) MakeProcInstance((FARPROC) aboutDlgProc, hInst);
DialogBox(hInst, MAKEINTRESOURCE(ABOUT), hWnd, lpproc); DialogBox(hInst, MAKEINTRESOURCE(ABOUT), hWnd, lpproc);
@ -356,7 +356,7 @@ LRESULT CALLBACK _export ISQLWndProc(HWND hWnd,
DialogBox(hInst, MAKEINTRESOURCE(EXEC_SCRIPT), hWnd, lpproc); DialogBox(hInst, MAKEINTRESOURCE(EXEC_SCRIPT), hWnd, lpproc);
FreeProcInstance((FARPROC) lpproc); FreeProcInstance((FARPROC) lpproc);
if (ret) { if (ret) {
// generate an argc/argv // generate an argc/argv
ISQL_cursor = ISQL_args; ISQL_cursor = ISQL_args;
ISQL_argc = 0; ISQL_argc = 0;
@ -365,7 +365,7 @@ LRESULT CALLBACK _export ISQLWndProc(HWND hWnd,
pusharg(scriptName); pusharg(scriptName);
pusharg("-output"); pusharg("-output");
// use specified output file, or default // use specified output file, or default
if (scriptOutput[0]) if (scriptOutput[0])
pusharg(scriptOutput); pusharg(scriptOutput);
@ -391,7 +391,7 @@ LRESULT CALLBACK _export ISQLWndProc(HWND hWnd,
} }
ISQL_main(ISQL_argc, ISQL_argv); ISQL_main(ISQL_argc, ISQL_argv);
// reopen default files and database // reopen default files and database
ipf = fopen(defInputFile, "r"); ipf = fopen(defInputFile, "r");
opf = fopen(defOutputFile, "a"); opf = fopen(defOutputFile, "a");
@ -412,7 +412,7 @@ LRESULT CALLBACK _export ISQLWndProc(HWND hWnd,
ret = DialogBox(hInst, MAKEINTRESOURCE(EXTRACT_DB), hWnd, lpproc); ret = DialogBox(hInst, MAKEINTRESOURCE(EXTRACT_DB), hWnd, lpproc);
FreeProcInstance((FARPROC) lpproc); FreeProcInstance((FARPROC) lpproc);
if (ret) { if (ret) {
// create an argument vector for ISQL // create an argument vector for ISQL
ISQL_cursor = ISQL_args; ISQL_cursor = ISQL_args;
ISQL_argc = 0; ISQL_argc = 0;
@ -434,7 +434,7 @@ LRESULT CALLBACK _export ISQLWndProc(HWND hWnd,
ISQL_main(ISQL_argc, ISQL_argv); ISQL_main(ISQL_argc, ISQL_argv);
ISQL_exit_db(); ISQL_exit_db();
// reopen default files and database // reopen default files and database
ipf = fopen(defInputFile, "r"); ipf = fopen(defInputFile, "r");
opf = fopen(defOutputFile, "a"); opf = fopen(defOutputFile, "a");
@ -457,7 +457,7 @@ LRESULT CALLBACK _export ISQLWndProc(HWND hWnd,
gflags |= OVERWRITE; gflags |= OVERWRITE;
break; break;
// Send the proper frontend commands for these: // Send the proper frontend commands for these:
case IDM_BLOB_TYPE: case IDM_BLOB_TYPE:
tmpDialogParam[0] = '\0'; tmpDialogParam[0] = '\0';
@ -531,7 +531,7 @@ LRESULT CALLBACK _export ISQLWndProc(HWND hWnd,
} }
break; break;
// Send the proper show commands for these: // Send the proper show commands for these:
case IDM_SHOW_VERSION: case IDM_SHOW_VERSION:
test_overwrite(); test_overwrite();
@ -648,15 +648,15 @@ LRESULT CALLBACK _export ISQLWndProc(HWND hWnd,
break; break;
case WM_SIZE: case WM_SIZE:
// Save size of window client area. // Save size of window client area.
if (lParam) { if (lParam) {
yClient = HIWORD(lParam); yClient = HIWORD(lParam);
xClient = LOWORD(lParam); xClient = LOWORD(lParam);
yClient = (yClient / yCharnl + 1) * yCharnl; yClient = (yClient / yCharnl + 1) * yCharnl;
lParam = MAKELONG(xClient, yClient); lParam = MAKELONG(xClient, yClient);
// Go setup scroll ranges and file display area based upon // Go setup scroll ranges and file display area based upon
// client area size. // client area size.
setup_scroll(hWnd); setup_scroll(hWnd);
return DefWindowProc(hWnd, message, wParam, lParam); return DefWindowProc(hWnd, message, wParam, lParam);
@ -664,7 +664,7 @@ LRESULT CALLBACK _export ISQLWndProc(HWND hWnd,
break; break;
case WM_VSCROLL: case WM_VSCROLL:
// React to the various vertical scroll related actions. // React to the various vertical scroll related actions.
switch (GET_WM_VSCROLL_CODE(wParam, lParam)) { switch (GET_WM_VSCROLL_CODE(wParam, lParam)) {
case SB_TOP: case SB_TOP:
@ -705,7 +705,7 @@ LRESULT CALLBACK _export ISQLWndProc(HWND hWnd,
break; break;
case WM_HSCROLL: case WM_HSCROLL:
// React to the various horizontal scroll related actions. // React to the various horizontal scroll related actions.
switch (GET_WM_HSCROLL_CODE(wParam, lParam)) { switch (GET_WM_HSCROLL_CODE(wParam, lParam)) {
case SB_LINEUP: case SB_LINEUP:
@ -740,8 +740,8 @@ LRESULT CALLBACK _export ISQLWndProc(HWND hWnd,
break; break;
case WM_KEYDOWN: case WM_KEYDOWN:
// Translate various keydown messages to appropriate horizontal // Translate various keydown messages to appropriate horizontal
// and vertical scroll actions. // and vertical scroll actions.
for (i = 0; i < FB_NELEM(key2scroll); i++) { for (i = 0; i < FB_NELEM(key2scroll); i++) {
if (wParam == key2scroll[i].wVirtkey) { if (wParam == key2scroll[i].wVirtkey) {
@ -753,31 +753,31 @@ LRESULT CALLBACK _export ISQLWndProc(HWND hWnd,
break; break;
case WM_PAINT: case WM_PAINT:
// Go paint the client area of the window with the appropriate // Go paint the client area of the window with the appropriate
// part of the selected file. // part of the selected file.
paint_isql(hWnd); paint_isql(hWnd);
break; break;
case WM_DESTROY: case WM_DESTROY:
// This is the end if we were closed by a DestroyWindow call. // This is the end if we were closed by a DestroyWindow call.
close_isql(); // take any necessary wrapup action. close_isql(); // take any necessary wrapup action.
PostQuitMessage(0); // this is the end... PostQuitMessage(0); // this is the end...
break; break;
case WM_QUERYENDSESSION: case WM_QUERYENDSESSION:
// If we return TRUE we are saying it's ok with us to end the // If we return TRUE we are saying it's ok with us to end the
// windows session. // windows session.
close_isql(); // take any necessary wrapup action. close_isql(); // take any necessary wrapup action.
return (long) TRUE; // we agree to end session. return (long) TRUE; // we agree to end session.
case WM_CLOSE: case WM_CLOSE:
// Tell windows to destroy our window. // Tell windows to destroy our window.
DestroyWindow(hWnd); DestroyWindow(hWnd);
break; break;
default: default:
// Let windows handle all messages we choose to ignore. // Let windows handle all messages we choose to ignore.
return DefWindowProc(hWnd, message, wParam, lParam); return DefWindowProc(hWnd, message, wParam, lParam);
} }
@ -857,28 +857,28 @@ static int cmdline_isql( HINSTANCE hInstance, LPSTR pCmdLine)
* return from ISQL * return from ISQL
* *
********************************************************************/ ********************************************************************/
FILE *inputfile; // input file FILE *inputfile; // input file
FILE *outputfile; // output file FILE *outputfile; // output file
SCHAR inputfilename[MAXPATHLEN]; // input file name SCHAR inputfilename[MAXPATHLEN]; // input file name
SCHAR outputfilename[MAXPATHLEN]; // output file name SCHAR outputfilename[MAXPATHLEN]; // output file name
SCHAR arg[MAXPATHLEN]; // current argument SCHAR arg[MAXPATHLEN]; // current argument
const SCHAR *cp; // command line cursor const SCHAR *cp; // command line cursor
SCHAR *ap; // current argument cursor SCHAR *ap; // current argument cursor
// create default input and output files // create default input and output files
if (!open_temp_file if (!open_temp_file
(hInstance, &inputfile, inputfilename, IDS_TEMP_IN_FILE)) return 0; (hInstance, &inputfile, inputfilename, IDS_TEMP_IN_FILE)) return 0;
if (!open_temp_file if (!open_temp_file
(hInstance, &outputfile, outputfilename, IDS_TEMP_OUT_FILE)) return 0; (hInstance, &outputfile, outputfilename, IDS_TEMP_OUT_FILE)) return 0;
// create failsafe input file // create failsafe input file
fprintf(inputfile, "QUIT;\n"); fprintf(inputfile, "QUIT;\n");
fclose(inputfile); fclose(inputfile);
fclose(outputfile); fclose(outputfile);
// create an argument vector, including the default files and command line args // create an argument vector, including the default files and command line args
ISQL_cursor = ISQL_args; ISQL_cursor = ISQL_args;
ISQL_argc = 0; ISQL_argc = 0;
@ -922,7 +922,7 @@ static void display_page( HWND hWnd)
***************************************************************/ ***************************************************************/
FILE *fh; FILE *fh;
// Determine file size and some display paramaters. // Determine file size and some display paramaters.
nVscrollPos = numlines; nVscrollPos = numlines;
numlines = 0; numlines = 0;
maxwidth = 0; maxwidth = 0;
@ -939,11 +939,11 @@ static void display_page( HWND hWnd)
} }
opf = fopen(defOutputFile, "a"); opf = fopen(defOutputFile, "a");
// Go setup scroll ranges for this file. // Go setup scroll ranges for this file.
setup_scroll(hWnd); setup_scroll(hWnd);
// Show first part of file. // Show first part of file.
InvalidateRect(hWnd, NULL, TRUE); InvalidateRect(hWnd, NULL, TRUE);
UpdateWindow(hWnd); UpdateWindow(hWnd);
@ -980,7 +980,7 @@ static SSHORT init_isql(
DLGPROC dlgProc; DLGPROC dlgProc;
int iReturn; int iReturn;
// perform instance dependant Windows initialization // perform instance dependant Windows initialization
if (!hPrevInstance) if (!hPrevInstance)
init_isql_first(hInstance); init_isql_first(hInstance);
@ -989,11 +989,11 @@ static SSHORT init_isql(
init_isql_added(hPrevInstance); init_isql_added(hPrevInstance);
#endif #endif
// perform common instance Windows initialization // perform common instance Windows initialization
init_isql_every(hInstance, cmdShow); init_isql_every(hInstance, cmdShow);
// open all the files // open all the files
if (!open_temp_file(hInstance, &ipf, defInputFile, IDS_DEF_IN_FILE)) if (!open_temp_file(hInstance, &ipf, defInputFile, IDS_DEF_IN_FILE))
return FALSE; return FALSE;
@ -1042,7 +1042,7 @@ static void init_isql_added( HINSTANCE hPrevInstance)
* *
*********************************************************************/ *********************************************************************/
// get the results of the initialization of first instance // get the results of the initialization of first instance
GetInstanceData(hPrevInstance, (BYTE *) & SetUpData, sizeof(SETUPDATA)); GetInstanceData(hPrevInstance, (BYTE *) & SetUpData, sizeof(SETUPDATA));
} }
@ -1071,28 +1071,28 @@ static void init_isql_every( HINSTANCE hInstance, int cmdShow)
TEXTMETRIC tm; TEXTMETRIC tm;
HDC hDC; HDC hDC;
hInst = hInstance; // save for use by window procs hInst = hInstance; // save for use by window procs
// Create applications main window. // Create applications main window.
hWndMain = CreateWindow(SetUpData.appName, // window class name hWndMain = CreateWindow(SetUpData.appName, // window class name
SetUpData.appName, // window title SetUpData.appName, // window title
WS_OVERLAPPEDWINDOW | // type of window WS_OVERLAPPEDWINDOW | // type of window
WS_HSCROLL | WS_VSCROLL, CW_USEDEFAULT, // x window location WS_HSCROLL | WS_VSCROLL, CW_USEDEFAULT, // x window location
CW_USEDEFAULT, // y CW_USEDEFAULT, // y
CW_USEDEFAULT, // cx and size CW_USEDEFAULT, // cx and size
CW_USEDEFAULT, // cy CW_USEDEFAULT, // cy
NULL, // no parent for this window NULL, // no parent for this window
NULL, // use the class menu NULL, // use the class menu
hInstance, // who created this window hInstance, // who created this window
NULL // no parms to pass on NULL // no parms to pass on
); );
// Get the display context. // Get the display context.
hDC = GetDC(hWndMain); hDC = GetDC(hWndMain);
// Build fixed screen font. // Build fixed screen font.
cursfont.lfHeight = 14; cursfont.lfHeight = 14;
cursfont.lfWidth = 9; cursfont.lfWidth = 9;
@ -1111,11 +1111,11 @@ static void init_isql_every( HINSTANCE hInstance, int cmdShow)
hnewsfont = CreateFontIndirect((LPLOGFONT) & cursfont); hnewsfont = CreateFontIndirect((LPLOGFONT) & cursfont);
// Install the font in the current display context. // Install the font in the current display context.
holdsfont = SelectObject(hDC, hnewsfont); holdsfont = SelectObject(hDC, hnewsfont);
// get text metrics for paint // get text metrics for paint
GetTextMetrics(hDC, &tm); GetTextMetrics(hDC, &tm);
xChar = tm.tmAveCharWidth; xChar = tm.tmAveCharWidth;
@ -1123,11 +1123,11 @@ static void init_isql_every( HINSTANCE hInstance, int cmdShow)
yCharnl = tm.tmHeight; yCharnl = tm.tmHeight;
numlines = 0; numlines = 0;
// Release the display context. // Release the display context.
ReleaseDC(hWndMain, hDC); ReleaseDC(hWndMain, hDC);
// Update display of main window. // Update display of main window.
ShowWindow(hWndMain, cmdShow); ShowWindow(hWndMain, cmdShow);
UpdateWindow(hWndMain); UpdateWindow(hWndMain);
@ -1152,14 +1152,14 @@ static void init_isql_first( HINSTANCE hInstance)
********************************************************************/ ********************************************************************/
WNDCLASS wcISQLClass; WNDCLASS wcISQLClass;
// Get string from resource with application name. // Get string from resource with application name.
LoadString(hInstance, IDS_NAME, (LPSTR) SetUpData.appName, 20); LoadString(hInstance, IDS_NAME, (LPSTR) SetUpData.appName, 20);
LoadString(hInstance, IDS_MENUNAME, (LPSTR) SetUpData.menuName, 20); LoadString(hInstance, IDS_MENUNAME, (LPSTR) SetUpData.menuName, 20);
LoadString(hInstance, IDS_ICONNAME, (LPSTR) SetUpData.iconName, 20); LoadString(hInstance, IDS_ICONNAME, (LPSTR) SetUpData.iconName, 20);
LoadString(hInstance, IDS_ERROR, (LPSTR) SetUpData.errorString, 20); LoadString(hInstance, IDS_ERROR, (LPSTR) SetUpData.errorString, 20);
// Define the window class for this application. // Define the window class for this application.
wcISQLClass.lpszClassName = SetUpData.appName; wcISQLClass.lpszClassName = SetUpData.appName;
wcISQLClass.hInstance = hInstance; wcISQLClass.hInstance = hInstance;
@ -1172,7 +1172,7 @@ static void init_isql_first( HINSTANCE hInstance)
wcISQLClass.cbClsExtra = 0; wcISQLClass.cbClsExtra = 0;
wcISQLClass.cbWndExtra = 0; wcISQLClass.cbWndExtra = 0;
// Register the class // Register the class
RegisterClass(&wcISQLClass); RegisterClass(&wcISQLClass);
} }
@ -1238,12 +1238,12 @@ static int windows_isql(
********************************************************************/ \ ********************************************************************/ \
MSG msg; MSG msg;
// Go init this application. // Go init this application.
if (!init_isql(hInstance, hPrevInstance, cmdShow)) if (!init_isql(hInstance, hPrevInstance, cmdShow))
return 0; return 0;
// Get and dispatch messages for this applicaton. // Get and dispatch messages for this applicaton.
while (GetMessage(&msg, NULL, NULL, NULL)) { while (GetMessage(&msg, NULL, NULL, NULL)) {
TranslateMessage(&msg); TranslateMessage(&msg);
@ -1281,28 +1281,28 @@ static void paint_isql( HWND hWnd)
BeginPaint(hWnd, (LPPAINTSTRUCT) & ps); BeginPaint(hWnd, (LPPAINTSTRUCT) & ps);
hDC = ps.hdc; hDC = ps.hdc;
// Establish fixed font in display context. // Establish fixed font in display context.
SelectObject(hDC, hnewsfont); SelectObject(hDC, hnewsfont);
if (numlines) { if (numlines) {
// Open the file to display // Open the file to display
// (files should not stay open over multiple windows messages) // (files should not stay open over multiple windows messages)
hfile = fopen(defOutputFile, "r"); hfile = fopen(defOutputFile, "r");
if (hfile) { if (hfile) {
// Skip lines outside window limits // Skip lines outside window limits
for (i = 0; i < nVscrollPos; i++) for (i = 0; i < nVscrollPos; i++)
fgets(buf, sizeof(buf), hfile); fgets(buf, sizeof(buf), hfile);
// Read visible lines // Read visible lines
for (i = 0; i < nPageMaxLines; i++) { for (i = 0; i < nPageMaxLines; i++) {
if (!fgets(buf, sizeof(buf), hfile)) if (!fgets(buf, sizeof(buf), hfile))
break; break;
// figure out shortest text to put // figure out shortest text to put
for (e = strlen(buf); e >= 0; e--) for (e = strlen(buf); e >= 0; e--)
if (buf[e] > ' ' && buf[e] <= '~') if (buf[e] > ' ' && buf[e] <= '~')
@ -1363,7 +1363,7 @@ static void setup_scroll( HWND hWnd)
* *
*********************************************************************/ *********************************************************************/
// numlines established during open // numlines established during open
nVscrollMax = max(0, numlines - yClient / yChar); nVscrollMax = max(0, numlines - yClient / yChar);
nVscrollPos = min(nVscrollPos, nVscrollMax); nVscrollPos = min(nVscrollPos, nVscrollMax);
@ -1665,7 +1665,7 @@ BOOL CALLBACK _export createDbDlgProc(HWND hDlg,
break; break;
case IDCANCEL: case IDCANCEL:
// Terminate this dialog box. // Terminate this dialog box.
EndDialog(hDlg, FALSE); EndDialog(hDlg, FALSE);
break; break;
@ -1739,7 +1739,7 @@ BOOL CALLBACK _export dbNameDlgProc(HWND hDlg,
break; break;
case IDCANCEL: case IDCANCEL:
// Terminate this dialog box. // Terminate this dialog box.
EndDialog(hDlg, FALSE); EndDialog(hDlg, FALSE);
break; break;
@ -1795,7 +1795,7 @@ BOOL CALLBACK _export dropDbDlgProc(HWND hDlg,
break; break;
case IDCANCEL: case IDCANCEL:
// Terminate this dialog box. // Terminate this dialog box.
EndDialog(hDlg, FALSE); EndDialog(hDlg, FALSE);
break; break;
@ -1963,7 +1963,7 @@ BOOL CALLBACK _export extractDlgProc(HWND hDlg,
break; break;
case IDCANCEL: case IDCANCEL:
// Terminate this dialog box. // Terminate this dialog box.
EndDialog(hDlg, FALSE); EndDialog(hDlg, FALSE);
break; break;
@ -2173,7 +2173,7 @@ BOOL CALLBACK _export scriptDlgProc(HWND hDlg,
break; break;
case IDCANCEL: case IDCANCEL:
// Terminate this dialog box. // Terminate this dialog box.
EndDialog(hDlg, FALSE); EndDialog(hDlg, FALSE);
break; break;

View File

@ -527,7 +527,7 @@ private:
{ {
if (aux(obj, flags, search, end_search, match, end_match)) if (aux(obj, flags, search, end_search, match, end_match))
return true; return true;
if (search < end_search) if (search < end_search)
{ {
const CharType d = *search++; const CharType d = *search++;
@ -545,18 +545,18 @@ private:
{ {
if (search >= end_search) if (search >= end_search)
return false; return false;
search++; search++;
} }
else { else {
if (++match >= end_match) if (++match >= end_match)
return true; return true;
for (;;) for (;;)
{ {
if (aux(obj, flags, search, end_search, match, end_match)) if (aux(obj, flags, search, end_search, match, end_match))
return true; return true;
if (++search >= end_search) if (++search >= end_search)
return false; return false;
} }
@ -581,7 +581,7 @@ private:
{ {
if (aux(obj, flags, search, end_search, match, end_match)) if (aux(obj, flags, search, end_search, match, end_match))
return true; return true;
if (search < end_search) if (search < end_search)
{ {
if (!className(obj, flags, char_class, end_class, *search++)) if (!className(obj, flags, char_class, end_class, *search++))
@ -622,7 +622,7 @@ private:
// Japanese version operates on short-based buffer, // Japanese version operates on short-based buffer,
// instead of SCHAR-based. // instead of SCHAR-based.
static bool className(Jrd::TextType* obj, USHORT flags, static bool className(Jrd::TextType* obj, USHORT flags,
const CharType* char_class, const CharType* const end_class, const CharType* char_class, const CharType* const end_class,
CharType character) CharType character)
{ {
fb_assert(char_class != NULL); fb_assert(char_class != NULL);
@ -656,9 +656,9 @@ private:
} }
// Merge the matching pattern and control strings to give a cannonical // Merge the matching pattern and control strings to give a cannonical
// matching pattern. Return the length of the combined string. // matching pattern. Return the length of the combined string.
// //
// What this routine does is to take the language template, strip off // What this routine does is to take the language template, strip off
// the prefix and put it in the output string, then parse the definitions // the prefix and put it in the output string, then parse the definitions
// into an array of character pointers. The index array is the defined // into an array of character pointers. The index array is the defined
// character. The routine then takes the actual match pattern and uses // character. The routine then takes the actual match pattern and uses
@ -738,7 +738,7 @@ private:
while (*p) while (*p)
*comb++ = *p++; *comb++ = *p++;
// if we've got the definition of a quote character, // if we've got the definition of a quote character,
// slurp the next character too // slurp the next character too
if (comb > combined && comb[-1] == *(CharType*) obj->getCanonicalChar(CHAR_GDML_QUOTE) && *match) if (comb > combined && comb[-1] == *(CharType*) obj->getCanonicalChar(CHAR_GDML_QUOTE) && *match)
@ -932,7 +932,7 @@ Collation* Collation::createInstance(MemoryPool& pool, TTYPE_ID id, texttype* tt
MatchesMatcherULongCanonical, SleuthMatcherULongCanonical>(id, tt, cs); MatchesMatcherULongCanonical, SleuthMatcherULongCanonical>(id, tt, cs);
} }
fb_assert(false); fb_assert(false);
return NULL; // compiler silencer return NULL; // compiler silencer
} }

View File

@ -1,5 +1,5 @@
/* /*
* PROGRAM: * PROGRAM:
* MODULE: DataTypeUtil.cpp * MODULE: DataTypeUtil.cpp
* DESCRIPTION: Data Type Utility functions * DESCRIPTION: Data Type Utility functions
* *
@ -40,7 +40,7 @@ using namespace Firebird;
SSHORT DataTypeUtilBase::getResultBlobSubType(const dsc* value1, const dsc* value2) SSHORT DataTypeUtilBase::getResultBlobSubType(const dsc* value1, const dsc* value2)
{ {
SSHORT subType1 = value1->getBlobSubType(); SSHORT subType1 = value1->getBlobSubType();
SSHORT subType2 = value2->getBlobSubType(); SSHORT subType2 = value2->getBlobSubType();
@ -71,40 +71,40 @@ USHORT DataTypeUtilBase::getResultTextType(const dsc* value1, const dsc* value2)
void DataTypeUtilBase::makeFromList(dsc* result, const char* expressionName, int argsCount, const dsc** args) void DataTypeUtilBase::makeFromList(dsc* result, const char* expressionName, int argsCount, const dsc** args)
{ {
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
// [Arno Brinkman] 2003-08-23 // [Arno Brinkman] 2003-08-23
// //
// This function is made to determine a output descriptor from a given list // This function is made to determine a output descriptor from a given list
// of expressions according to the latest SQL-standard that was available. // of expressions according to the latest SQL-standard that was available.
// (ISO/ANSI SQL:200n WG3:DRS-013 H2-2002-358 August, 2002) // (ISO/ANSI SQL:200n WG3:DRS-013 H2-2002-358 August, 2002)
// //
// If any datatype has a character type then : // If any datatype has a character type then :
// - the output will always be a character type except unconvertable types. // - the output will always be a character type except unconvertable types.
// (dtype_text, dtype_cstring, dtype_varying, dtype_blob sub_type TEXT) // (dtype_text, dtype_cstring, dtype_varying, dtype_blob sub_type TEXT)
// !! Currently engine cannot convert string to BLOB therefor BLOB isn't allowed. !! // !! Currently engine cannot convert string to BLOB therefor BLOB isn't allowed. !!
// - first character-set and collation are used as output descriptor. // - first character-set and collation are used as output descriptor.
// - if all types have datatype CHAR then output should be CHAR else // - if all types have datatype CHAR then output should be CHAR else
// VARCHAR and with the maximum length used from the given list. // VARCHAR and with the maximum length used from the given list.
// //
// If all of the datatypes are EXACT numeric then the output descriptor // If all of the datatypes are EXACT numeric then the output descriptor
// shall be EXACT numeric with the maximum scale and the maximum precision // shall be EXACT numeric with the maximum scale and the maximum precision
// used. (dtype_byte, dtype_short, dtype_long, dtype_int64) // used. (dtype_byte, dtype_short, dtype_long, dtype_int64)
// //
// If any of the datatypes is APPROXIMATE numeric then each datatype in the // If any of the datatypes is APPROXIMATE numeric then each datatype in the
// list shall be numeric else a error is thrown and the output descriptor // list shall be numeric else a error is thrown and the output descriptor
// shall be APPROXIMATE numeric. (dtype_real, dtype_double, dtype_d_float) // shall be APPROXIMATE numeric. (dtype_real, dtype_double, dtype_d_float)
// //
// If any of the datatypes is a datetime type then each datatype in the // If any of the datatypes is a datetime type then each datatype in the
// list shall be the same datetime type else a error is thrown. // list shall be the same datetime type else a error is thrown.
// numeric. (dtype_sql_date, dtype_sql_time, dtype_timestamp) // numeric. (dtype_sql_date, dtype_sql_time, dtype_timestamp)
// //
// If any of the datatypes is a BLOB datatype then : // If any of the datatypes is a BLOB datatype then :
// - all types should be a BLOB else throw error. // - all types should be a BLOB else throw error.
// - all types should have the same sub_type else throw error. // - all types should have the same sub_type else throw error.
// - when TEXT type then use first character-set and collation as output // - when TEXT type then use first character-set and collation as output
// descriptor. // descriptor.
// (dtype_blob) // (dtype_blob)
// //
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
// Initialize values. // Initialize values.
@ -161,10 +161,10 @@ void DataTypeUtilBase::makeFromList(dsc* result, const char* expressionName, int
} }
else { else {
if (all_equal) { if (all_equal) {
all_equal = all_equal =
(max_dtype == arg->dsc_dtype) && (max_dtype == arg->dsc_dtype) &&
(max_scale == arg->dsc_scale) && (max_scale == arg->dsc_scale) &&
(max_length == arg->dsc_length) && (max_length == arg->dsc_length) &&
(max_sub_type == arg->dsc_sub_type); (max_sub_type == arg->dsc_sub_type);
} }
} }
@ -175,7 +175,7 @@ void DataTypeUtilBase::makeFromList(dsc* result, const char* expressionName, int
// Is there any approximate numeric? // Is there any approximate numeric?
if (DTYPE_IS_APPROX(arg->dsc_dtype)) { if (DTYPE_IS_APPROX(arg->dsc_dtype)) {
any_approx = true; any_approx = true;
// Dialect 1 NUMERIC and DECIMAL are stored as sub-types // Dialect 1 NUMERIC and DECIMAL are stored as sub-types
// 1 and 2 from float types dtype_real, dtype_double // 1 and 2 from float types dtype_real, dtype_double
if (!any_float) { if (!any_float) {
any_float = (arg->dsc_sub_type == 0); any_float = (arg->dsc_sub_type == 0);
@ -218,11 +218,11 @@ void DataTypeUtilBase::makeFromList(dsc* result, const char* expressionName, int
if (DTYPE_IS_TEXT(arg->dsc_dtype) || if (DTYPE_IS_TEXT(arg->dsc_dtype) ||
(arg->dsc_dtype == dtype_blob && arg->dsc_sub_type == isc_blob_text)) (arg->dsc_dtype == dtype_blob && arg->dsc_sub_type == isc_blob_text))
{ {
// Pick first characterset-collate from args-list // Pick first characterset-collate from args-list
// //
// Is there an better way to determine the // Is there an better way to determine the
// characterset / collate from the list ? // characterset / collate from the list ?
// Maybe first according SQL-standard which has an order // Maybe first according SQL-standard which has an order
// UTF32 -> UTF16 -> UTF8 then by a Firebird specified order // UTF32 -> UTF16 -> UTF8 then by a Firebird specified order
// //
// At least give any first charset other than ASCII/NONE precedence // At least give any first charset other than ASCII/NONE precedence
@ -351,7 +351,7 @@ void DataTypeUtilBase::makeFromList(dsc* result, const char* expressionName, int
// If all of the arguments are from type text use a text type. // If all of the arguments are from type text use a text type.
// Firebird behaves a little bit different than standard here, because // Firebird behaves a little bit different than standard here, because
// any datatype (except BLOB) can be converted to a character-type we // any datatype (except BLOB) can be converted to a character-type we
// allow to use numeric and datetime types together with a // allow to use numeric and datetime types together with a
// character-type, but output will always be varying ! // character-type, but output will always be varying !
if (all_text || (any_text && (any_numeric || any_datetime))) { if (all_text || (any_text && (any_numeric || any_datetime))) {
if (any_text_blob) if (any_text_blob)

View File

@ -960,7 +960,7 @@ void DatabaseSnapshot::putDatabase(const Database* database,
// SQL dialect // SQL dialect
temp = (database->dbb_flags & DBB_DB_SQL_dialect_3) ? 3 : 1; temp = (database->dbb_flags & DBB_DB_SQL_dialect_3) ? 3 : 1;
writer.insertInt(f_mon_db_dialect, temp); writer.insertInt(f_mon_db_dialect, temp);
// shutdown mode // shutdown mode
if (database->dbb_ast_flags & DBB_shutdown_full) if (database->dbb_ast_flags & DBB_shutdown_full)
temp = shut_mode_full; temp = shut_mode_full;

View File

@ -54,7 +54,7 @@ void DBG_parse_debug_info(USHORT length, const UCHAR* data, Firebird::DbgInfo& d
bad_format = true; bad_format = true;
} }
while (!bad_format && (data < end)) while (!bad_format && (data < end))
{ {
switch (*data++) switch (*data++)
{ {

View File

@ -45,7 +45,7 @@
using namespace Firebird; using namespace Firebird;
namespace namespace
{ {
class ModulesMap : public GenericMap<Pair<Left<PathName, ModuleLoader::Module*> > > class ModulesMap : public GenericMap<Pair<Left<PathName, ModuleLoader::Module*> > >
{ {
@ -243,7 +243,7 @@ const IntlManager::CharSetAliasDefinition IntlManager::defaultCharSetAliases[] =
{"GB2312", CS_GB2312}, {"GB2312", CS_GB2312},
{"DOS_936", CS_GB2312}, {"DOS_936", CS_GB2312},
{"WIN_936", CS_GB2312}, {"WIN_936", CS_GB2312},
{NULL, 0} {NULL, 0}
}; };
const IntlManager::CollationDefinition IntlManager::defaultCollations[] = const IntlManager::CollationDefinition IntlManager::defaultCollations[] =
@ -566,7 +566,7 @@ bool IntlManager::lookupCharSet(const Firebird::string& charSetName, charset* cs
else else
{ {
ModuleLoader::Module* module; ModuleLoader::Module* module;
if (modules->get(externalInfo.moduleName, module) && module) if (modules->get(externalInfo.moduleName, module) && module)
module->findSymbol(STRINGIZE(CHARSET_ENTRYPOINT), lookupFunction); module->findSymbol(STRINGIZE(CHARSET_ENTRYPOINT), lookupFunction);
} }
@ -601,7 +601,7 @@ bool IntlManager::lookupCollation(const Firebird::string& collationName,
else else
{ {
ModuleLoader::Module* module; ModuleLoader::Module* module;
if (modules->get(collationExternalInfo.moduleName, module) && module) if (modules->get(collationExternalInfo.moduleName, module) && module)
module->findSymbol(STRINGIZE(TEXTTYPE_ENTRYPOINT), lookupFunction); module->findSymbol(STRINGIZE(TEXTTYPE_ENTRYPOINT), lookupFunction);
} }
@ -638,7 +638,7 @@ bool IntlManager::setupCollationAttributes(
else else
{ {
ModuleLoader::Module* module; ModuleLoader::Module* module;
if (modules->get(collationExternalInfo.moduleName, module) && module) if (modules->get(collationExternalInfo.moduleName, module) && module)
module->findSymbol(STRINGIZE(INTL_SETUP_ATTRIBUTES_ENTRYPOINT), attributesFunction); module->findSymbol(STRINGIZE(INTL_SETUP_ATTRIBUTES_ENTRYPOINT), attributesFunction);
} }

View File

@ -144,7 +144,7 @@ bool IntlUtil::parseSpecificAttributes(
while (p < end) while (p < end)
{ {
uSize = cs->getConvToUnicode().convert(size, p, sizeof(uc), uc); uSize = cs->getConvToUnicode().convert(size, p, sizeof(uc), uc);
if (uSize == 2 && if (uSize == 2 &&
((*(USHORT*)uc >= 'A' && *(USHORT*)uc <= 'Z') || ((*(USHORT*)uc >= 'A' && *(USHORT*)uc <= 'Z') ||
(*(USHORT*)uc >= 'a' && *(USHORT*)uc <= 'z') || (*(USHORT*)uc >= 'a' && *(USHORT*)uc <= 'z') ||
@ -478,7 +478,7 @@ ULONG IntlUtil::toLower(Jrd::CharSet* cs, ULONG srcLen, const UCHAR* src, ULONG
// convert to lowercase // convert to lowercase
Firebird::HalfStaticArray<UCHAR, BUFFER_SMALL> lower_str; Firebird::HalfStaticArray<UCHAR, BUFFER_SMALL> lower_str;
srcLen = UnicodeUtil::utf16LowerCase(srcLen, Firebird::Aligner<USHORT>(utf16_ptr, srcLen), srcLen = UnicodeUtil::utf16LowerCase(srcLen, Firebird::Aligner<USHORT>(utf16_ptr, srcLen),
utf16_length, Firebird::OutAligner<USHORT>(lower_str.getBuffer(utf16_length), utf16_length), utf16_length, Firebird::OutAligner<USHORT>(lower_str.getBuffer(utf16_length), utf16_length),
exceptions); exceptions);
// convert to original character set // convert to original character set
@ -504,7 +504,7 @@ ULONG IntlUtil::toUpper(Jrd::CharSet* cs, ULONG srcLen, const UCHAR* src, ULONG
// convert to uppercase // convert to uppercase
Firebird::HalfStaticArray<UCHAR, BUFFER_SMALL> upper_str; Firebird::HalfStaticArray<UCHAR, BUFFER_SMALL> upper_str;
srcLen = UnicodeUtil::utf16UpperCase(srcLen, Firebird::Aligner<USHORT>(utf16_ptr, srcLen), srcLen = UnicodeUtil::utf16UpperCase(srcLen, Firebird::Aligner<USHORT>(utf16_ptr, srcLen),
utf16_length, Firebird::OutAligner<USHORT>(upper_str.getBuffer(utf16_length), utf16_length), utf16_length, Firebird::OutAligner<USHORT>(upper_str.getBuffer(utf16_length), utf16_length),
exceptions); exceptions);
// convert to original character set // convert to original character set
@ -580,7 +580,7 @@ string IntlUtil::escapeAttribute(Jrd::CharSet* cs, const string& s)
{ {
*(USHORT*)uc = '\\'; *(USHORT*)uc = '\\';
UCHAR bytes[sizeof(ULONG)]; UCHAR bytes[sizeof(ULONG)];
ULONG bytesSize = cs->getConvFromUnicode().convert( ULONG bytesSize = cs->getConvFromUnicode().convert(
sizeof(USHORT), uc, sizeof(bytes), bytes); sizeof(USHORT), uc, sizeof(bytes), bytes);

Some files were not shown because too many files have changed in this diff Show More