Commit ade20c5b authored by monty@hundin.mysql.fi's avatar monty@hundin.mysql.fi

Indentation cleanup & new comments

parent ddc8c540
...@@ -62,9 +62,9 @@ mysysobjects1 = my_init.lo my_static.lo my_malloc.lo my_realloc.lo \ ...@@ -62,9 +62,9 @@ mysysobjects1 = my_init.lo my_static.lo my_malloc.lo my_realloc.lo \
my_getopt.lo my_gethostbyname.lo my_getopt.lo my_gethostbyname.lo
# Not needed in the minimum library # Not needed in the minimum library
mysysobjects2 = getvar.lo my_lib.lo mysysobjects2 = my_lib.lo
mysysobjects = $(mysysobjects1) $(mysysobjects2) mysysobjects = $(mysysobjects1) $(mysysobjects2)
target_libadd = $(mysysobjects) $(mystringsobjects) $(dbugobjects) \ target_libadd = $(mysysobjects) $(mystringsobjects) $(dbugobjects) \
$(vio_objects) $(vio_objects)
target_ldflags = -version-info @SHARED_LIB_VERSION@ target_ldflags = -version-info @SHARED_LIB_VERSION@
vio_objects= vio.lo viosocket.lo viossl.lo viosslfactories.lo vio_objects= vio.lo viosocket.lo viossl.lo viosslfactories.lo
......
...@@ -72,8 +72,8 @@ int _mi_read_cache(IO_CACHE *info, byte *buff, my_off_t pos, uint length, ...@@ -72,8 +72,8 @@ int _mi_read_cache(IO_CACHE *info, byte *buff, my_off_t pos, uint length,
in_buff_length=0; in_buff_length=0;
if (flag & READING_NEXT || info->share) if (flag & READING_NEXT || info->share)
{ {
if (pos != if (pos != (info->pos_in_file + (uint) (info->read_end -
(info->pos_in_file + (uint) (info->read_end - info->request_pos))) info->request_pos)))
{ {
info->pos_in_file=pos; /* Force start here */ info->pos_in_file=pos; /* Force start here */
info->read_pos=info->read_end=info->request_pos; /* Everything used */ info->read_pos=info->read_end=info->request_pos; /* Everything used */
......
This diff is collapsed.
This diff is collapsed.
...@@ -18,12 +18,10 @@ ...@@ -18,12 +18,10 @@
#include "myrg_def.h" #include "myrg_def.h"
int myrg_delete( int myrg_delete(MYRG_INFO *info, const byte *record)
MYRG_INFO *info,
const byte *record)
{ {
if (!info->current_table) if (!info->current_table)
return my_errno=HA_ERR_NO_ACTIVE_RECORD ; return (my_errno= HA_ERR_NO_ACTIVE_RECORD);
return mi_delete(info->current_table->table,record); return mi_delete(info->current_table->table,record);
} }
...@@ -19,10 +19,10 @@ ...@@ -19,10 +19,10 @@
int myrg_rsame(MYRG_INFO *info,byte *record,int inx) int myrg_rsame(MYRG_INFO *info,byte *record,int inx)
{ {
if (inx) /* not yet used, should be 0 */ if (inx) /* not yet used, should be 0 */
return my_errno=HA_ERR_WRONG_INDEX; return (my_errno=HA_ERR_WRONG_INDEX);
if (!info->current_table) if (!info->current_table)
return my_errno=HA_ERR_NO_ACTIVE_RECORD; return (my_errno=HA_ERR_NO_ACTIVE_RECORD);
return mi_rsame(info->current_table->table,record,inx); return mi_rsame(info->current_table->table,record,inx);
} }
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
int myrg_update(register MYRG_INFO *info,const byte *oldrec, byte *newrec) int myrg_update(register MYRG_INFO *info,const byte *oldrec, byte *newrec)
{ {
if (!info->current_table) if (!info->current_table)
return my_errno=HA_ERR_NO_ACTIVE_RECORD; return (my_errno=HA_ERR_NO_ACTIVE_RECORD);
return mi_update(info->current_table->table,oldrec,newrec); return mi_update(info->current_table->table,oldrec,newrec);
} }
...@@ -26,5 +26,5 @@ int myrg_write(register MYRG_INFO *info, byte *rec) ...@@ -26,5 +26,5 @@ int myrg_write(register MYRG_INFO *info, byte *rec)
else if (info->merge_insert_method == MERGE_INSERT_TO_LAST) else if (info->merge_insert_method == MERGE_INSERT_TO_LAST)
return mi_write(info->end_table[-1].table,rec); return mi_write(info->end_table[-1].table,rec);
else /* unsupported insertion method */ else /* unsupported insertion method */
return my_errno=HA_ERR_WRONG_COMMAND; return (my_errno= HA_ERR_WRONG_COMMAND);
} }
...@@ -44,7 +44,7 @@ libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c\ ...@@ -44,7 +44,7 @@ libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c\
my_delete.c my_rename.c my_redel.c my_tempnam.c \ my_delete.c my_rename.c my_redel.c my_tempnam.c \
my_chsize.c my_lread.c my_lwrite.c my_clock.c \ my_chsize.c my_lread.c my_lwrite.c my_clock.c \
my_quick.c my_lockmem.c my_static.c \ my_quick.c my_lockmem.c my_static.c \
my_getopt.c getvar.c my_mkdir.c \ my_getopt.c my_mkdir.c \
default.c my_compress.c checksum.c raid.cc \ default.c my_compress.c checksum.c raid.cc \
my_net.c \ my_net.c \
my_vsnprintf.c charset.c my_bitmap.c my_bit.c md5.c \ my_vsnprintf.c charset.c my_bitmap.c my_bit.c md5.c \
......
/* Copyright (C) 2000 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* Allow use of the -O variable= option to set long variables */
#include "mysys_priv.h"
#include <m_string.h>
#include <m_ctype.h>
#include <my_getopt.h>
/* set all changeable variables */
void set_all_changeable_vars(CHANGEABLE_VAR *vars)
{
for ( ; vars->name ; vars++)
*vars->varptr= vars->def_value;
}
my_bool set_changeable_varval(const char* var, ulong val,
CHANGEABLE_VAR *vars)
{
char buffer[256];
sprintf( buffer, "%s=%lu", var, (unsigned long) val );
return set_changeable_var( buffer, vars );
}
my_bool set_changeable_var(my_string str,CHANGEABLE_VAR *vars)
{
char endchar;
my_string end;
DBUG_ENTER("set_changeable_var");
DBUG_PRINT("enter",("%s",str));
if (str)
{
if (!(end=strchr(str,'=')))
fprintf(stderr,"Can't find '=' in expression '%s' to option -O\n",str);
else
{
uint length,found_count=0;
CHANGEABLE_VAR *var,*found;
my_string var_end;
const char *name;
longlong num;
/* Skip end space from variable */
for (var_end=end ; end > str && isspace(var_end[-1]) ; var_end--) ;
length=(uint) (var_end-str);
/* Skip start space from argument */
for (end++ ; isspace(*end) ; end++) ;
for (var=vars,found=0 ; (name=var->name) ; var++)
{
if (!my_casecmp(name,str,length))
{
found=var; found_count++;
if (!name[length])
{
found_count=1;
break;
}
}
}
if (found_count == 0)
{
fprintf(stderr,"No variable match for: -O '%s'\n",str);
DBUG_RETURN(1);
}
if (found_count > 1)
{
fprintf(stderr,"Variable prefix '%*s' is not unique\n",length,str);
DBUG_RETURN(1);
}
num=strtoll(end, (char **)NULL, 10); endchar=strend(end)[-1];
if (endchar == 'k' || endchar == 'K')
num*=1024;
else if (endchar == 'm' || endchar == 'M')
num*=1024L*1024L;
else if (endchar == 'g' || endchar == 'G')
num*=1024L*1024L*1024L;
else if (!isdigit(endchar))
{
fprintf(stderr,"Unknown prefix used for variable value '%s'\n",str);
DBUG_RETURN(1);
}
if (num < (longlong) found->min_value)
num=(longlong) found->min_value;
else if (num > 0 && (ulonglong) num > (ulonglong) (ulong) found->max_value)
num=(longlong) (ulong) found->max_value;
num=((num- (longlong) found->sub_size) / (ulonglong) found->block_size);
(*found->varptr)= (long) (num*(ulonglong) found->block_size);
DBUG_RETURN(0);
}
}
DBUG_RETURN(1);
}
...@@ -312,8 +312,8 @@ bool Field::optimize_range(uint idx) ...@@ -312,8 +312,8 @@ bool Field::optimize_range(uint idx)
} }
/**************************************************************************** /****************************************************************************
** Functions for the Field_decimal class Functions for the Field_decimal class
** This is an unpacked number. This is an number stored as a pre-space (or pre-zero) string
****************************************************************************/ ****************************************************************************/
void void
...@@ -326,6 +326,8 @@ void Field_decimal::overflow(bool negative) ...@@ -326,6 +326,8 @@ void Field_decimal::overflow(bool negative)
{ {
uint len=field_length; uint len=field_length;
char *to=ptr, filler= '9'; char *to=ptr, filler= '9';
current_thd->cuted_fields++;
if (negative) if (negative)
{ {
if (!unsigned_flag) if (!unsigned_flag)
...@@ -419,7 +421,7 @@ void Field_decimal::store(const char *from,uint len) ...@@ -419,7 +421,7 @@ void Field_decimal::store(const char *from,uint len)
if ((tmp_dec=dec)) if ((tmp_dec=dec))
tmp_dec++; tmp_dec++;
for (; from!=end && isspace(*from); from++) ; // Read spaces for (; from !=end && isspace(*from); from++) ; // Read spaces
if (from == end) if (from == end)
{ {
current_thd->cuted_fields++; current_thd->cuted_fields++;
...@@ -428,23 +430,22 @@ void Field_decimal::store(const char *from,uint len) ...@@ -428,23 +430,22 @@ void Field_decimal::store(const char *from,uint len)
else if (*from == '+' || *from == '-') // Found some sign ? else if (*from == '+' || *from == '-') // Found some sign ?
{ {
sign_char= *from++; sign_char= *from++;
/* /*
Unsigned can't have any flag. So we'll just drop "+" Unsigned can't have any flag. So we'll just drop "+"
and will overflow on "-" and will overflow on "-"
*/ */
if (unsigned_flag) if (unsigned_flag)
{ {
if (sign_char=='-') if (sign_char=='-')
{ {
current_thd->cuted_fields++;
Field_decimal::overflow(1); Field_decimal::overflow(1);
return; return;
} }
else else
sign_char=0; sign_char=0;
} }
} }
pre_zeros_from= from; pre_zeros_from= from;
for (; from!=end && *from == '0'; from++) ; // Read prezeros for (; from!=end && *from == '0'; from++) ; // Read prezeros
pre_zeros_end=int_digits_from=from; pre_zeros_end=int_digits_from=from;
...@@ -484,7 +485,7 @@ void Field_decimal::store(const char *from,uint len) ...@@ -484,7 +485,7 @@ void Field_decimal::store(const char *from,uint len)
if (current_thd->count_cuted_fields) if (current_thd->count_cuted_fields)
{ {
for (;from!=end && isspace(*from); from++) ; // Read end spaces for (;from != end && isspace(*from); from++) ; // Read end spaces
if (from != end) // If still something left, warn if (from != end) // If still something left, warn
{ {
current_thd->cuted_fields++; current_thd->cuted_fields++;
...@@ -563,7 +564,6 @@ void Field_decimal::store(const char *from,uint len) ...@@ -563,7 +564,6 @@ void Field_decimal::store(const char *from,uint len)
if (field_length < tmp_uint + (int) (sign_char == '-')) if (field_length < tmp_uint + (int) (sign_char == '-'))
{ {
current_thd->cuted_fields++;
// too big number, change to max or min number // too big number, change to max or min number
Field_decimal::overflow(sign_char == '-'); Field_decimal::overflow(sign_char == '-');
return; return;
...@@ -606,7 +606,7 @@ void Field_decimal::store(const char *from,uint len) ...@@ -606,7 +606,7 @@ void Field_decimal::store(const char *from,uint len)
} }
else else
{ {
left_wall=to+(sign_char!=0)-1; left_wall=to+(sign_char != 0)-1;
if (!expo_sign_char) // If exponent was specified, ignore prezeros if (!expo_sign_char) // If exponent was specified, ignore prezeros
{ {
for (;pos != left_wall && pre_zeros_from !=pre_zeros_end; for (;pos != left_wall && pre_zeros_from !=pre_zeros_end;
...@@ -659,7 +659,7 @@ void Field_decimal::store(const char *from,uint len) ...@@ -659,7 +659,7 @@ void Field_decimal::store(const char *from,uint len)
{ {
if (tmp_char != '0') // Losing a non zero digit ? if (tmp_char != '0') // Losing a non zero digit ?
{ {
if (current_thd->count_cuted_fields && !is_cuted_fields_incr) if (!is_cuted_fields_incr)
current_thd->cuted_fields++; current_thd->cuted_fields++;
return; return;
} }
...@@ -696,14 +696,12 @@ void Field_decimal::store(double nr) ...@@ -696,14 +696,12 @@ void Field_decimal::store(double nr)
if (unsigned_flag && nr < 0) if (unsigned_flag && nr < 0)
{ {
overflow(1); overflow(1);
current_thd->cuted_fields++;
return; return;
} }
if (isinf(nr)) // Handle infinity as special case if (isinf(nr)) // Handle infinity as special case
{ {
overflow(nr < 0.0); overflow(nr < 0.0);
current_thd->cuted_fields++;
return; return;
} }
...@@ -721,10 +719,7 @@ void Field_decimal::store(double nr) ...@@ -721,10 +719,7 @@ void Field_decimal::store(double nr)
length=(uint) strlen(buff); length=(uint) strlen(buff);
if (length > field_length) if (length > field_length)
{
overflow(nr < 0.0); overflow(nr < 0.0);
current_thd->cuted_fields++;
}
else else
{ {
to=ptr; to=ptr;
...@@ -740,7 +735,6 @@ void Field_decimal::store(longlong nr) ...@@ -740,7 +735,6 @@ void Field_decimal::store(longlong nr)
if (unsigned_flag && nr < 0) if (unsigned_flag && nr < 0)
{ {
overflow(1); overflow(1);
current_thd->cuted_fields++;
return; return;
} }
char buff[22]; char buff[22];
...@@ -748,10 +742,7 @@ void Field_decimal::store(longlong nr) ...@@ -748,10 +742,7 @@ void Field_decimal::store(longlong nr)
uint int_part=field_length- (dec ? dec+1 : 0); uint int_part=field_length- (dec ? dec+1 : 0);
if (length > int_part) if (length > int_part)
{
overflow(test(nr < 0L)); /* purecov: inspected */ overflow(test(nr < 0L)); /* purecov: inspected */
current_thd->cuted_fields++; /* purecov: inspected */
}
else else
{ {
char fyllchar = zerofill ? (char) '0' : (char) ' '; char fyllchar = zerofill ? (char) '0' : (char) ' ';
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment