Bug #370 bad indentation
Submitted: 5 May 2003 7:39 Modified: 2 Jun 2003 7:20
Reporter: Dennis Haney Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.1 OS:
Assigned to: CPU Architecture:Any

[5 May 2003 7:39] Dennis Haney
Description:
patch attached

How to repeat:

Suggested fix:
===== libmysql.c 1.156 vs edited =====
--- 1.156/libmysql/libmysql.c   Wed Apr 23 16:37:28 2003
+++ edited/libmysql.c   Mon May  5 15:38:13 2003
@@ -92,7 +92,7 @@
 const char *sql_protocol_names_lib[] =
 { "TCP", "SOCKET", "PIPE", "MEMORY",NullS };
 TYPELIB sql_protocol_typelib = {array_elements(sql_protocol_names_lib)-1,"",
-                          sql_protocol_names_lib};
+                                sql_protocol_names_lib};
 /*
   If allowed through some configuration, then this needs to
   be changed
@@ -137,16 +137,16 @@
 my_bool STDCALL mysql_thread_init()
 {
 #ifdef THREAD
-    return my_thread_init();
+  return my_thread_init();
 #else
-    return 0;
+  return 0;
 #endif
 }

 void STDCALL mysql_thread_end()
 {
 #ifdef THREAD
-    my_thread_end();
+  my_thread_end();
 #endif
 }

@@ -156,7 +156,7 @@
 */

 #if !defined(__WIN__) && defined(SIGPIPE) && !defined(THREAD)
-#define init_sigpipe_variables  sig_return old_signal_handler=(sig_return) 0;
+#define init_sigpipe_variables  sig_return old_signal_handler=(sig_return) 0
 #define set_sigpipe(mysql)     if ((mysql)->client_flag & CLIENT_IGNORE_SIGPIPE) old_signal_handler=signal(SIGPIPE,pipe_sig_handler)
 #define reset_sigpipe(mysql) if ((mysql)->client_flag & CLIENT_IGNORE_SIGPIPE) signal(SIGPIPE,old_signal_handler);
 #else
@@ -570,7 +570,7 @@
 {
   NET *net= &mysql->net;
   ulong len=0;
-  init_sigpipe_variables
+  init_sigpipe_variables;

   /* Don't give sigpipe errors if the client doesn't want them */
   set_sigpipe(mysql);
@@ -629,7 +629,7 @@
 {
   NET *net= &mysql->net;
   my_bool result= 1;
-  init_sigpipe_variables
+  init_sigpipe_variables;

   /* Don't give sigpipe errors if the client doesn't want them */
   set_sigpipe(mysql);
@@ -852,7 +852,7 @@
   DBUG_ENTER("end_server");
   if (mysql->net.vio != 0)
   {
-    init_sigpipe_variables
+    init_sigpipe_variables;
     DBUG_PRINT("info",("Net: %s", vio_description(mysql->net.vio)));
     set_sigpipe(mysql);
     vio_delete(mysql->net.vio);
@@ -1930,7 +1930,7 @@
 #ifdef HAVE_SYS_UN_H
   struct       sockaddr_un UNIXaddr;
 #endif
-  init_sigpipe_variables
+  init_sigpipe_variables;
   DBUG_ENTER("mysql_real_connect");
   LINT_INIT(host_info);
[5 May 2003 7:54] Dennis Haney
Ups. incomplete patch...

===== libmysql.c 1.156 vs edited =====
--- 1.156/libmysql/libmysql.c	Wed Apr 23 16:37:28 2003
+++ edited/libmysql.c	Mon May  5 15:53:12 2003
@@ -92,7 +92,7 @@
 const char *sql_protocol_names_lib[] =
 { "TCP", "SOCKET", "PIPE", "MEMORY",NullS };
 TYPELIB sql_protocol_typelib = {array_elements(sql_protocol_names_lib)-1,"",
-			   sql_protocol_names_lib};
+                                sql_protocol_names_lib};
 /*
   If allowed through some configuration, then this needs to
   be changed
@@ -137,16 +137,16 @@
 my_bool STDCALL mysql_thread_init()
 {
 #ifdef THREAD
-    return my_thread_init();
+  return my_thread_init();
 #else
-    return 0;
+  return 0;
 #endif
 }
 
 void STDCALL mysql_thread_end()
 {
 #ifdef THREAD
-    my_thread_end();
+  my_thread_end();
 #endif
 }
 
@@ -156,7 +156,7 @@
 */
 
 #if !defined(__WIN__) && defined(SIGPIPE) && !defined(THREAD)
-#define init_sigpipe_variables  sig_return old_signal_handler=(sig_return) 0;
+#define init_sigpipe_variables  sig_return old_signal_handler=(sig_return) 0
 #define set_sigpipe(mysql)     if ((mysql)->client_flag & CLIENT_IGNORE_SIGPIPE) old_signal_handler=signal(SIGPIPE,pipe_sig_handler)
 #define reset_sigpipe(mysql) if ((mysql)->client_flag & CLIENT_IGNORE_SIGPIPE) signal(SIGPIPE,old_signal_handler);
 #else
@@ -403,10 +403,10 @@
 
 /*
   The name of event and file-mapping events create agree next rule:
-            shared_memory_base_name+unique_part
+  shared_memory_base_name+unique_part
   Where:
-    shared_memory_base_name is unique value for each server
-    unique_part is uniquel value for each object (events and file-mapping)
+  shared_memory_base_name is unique value for each server
+  unique_part is uniquel value for each object (events and file-mapping)
 */
   suffix_pos = strxmov(tmp,shared_memory_base_name,"_",NullS);
   strmov(suffix_pos, "CONNECT_REQUEST");
@@ -460,9 +460,9 @@
     The name of event and file-mapping events create agree next rule:
     shared_memory_base_name+unique_part+number_of_connection
     Where:
-      shared_memory_base_name is uniquel value for each server
-      unique_part is uniquel value for each object (events and file-mapping)
-      number_of_connection is number of connection between server and client
+    shared_memory_base_name is uniquel value for each server
+    unique_part is uniquel value for each object (events and file-mapping)
+    number_of_connection is number of connection between server and client
   */
   suffix_pos = strxmov(tmp,shared_memory_base_name,"_",connect_number_char,
 		       "_",NullS);
@@ -570,7 +570,7 @@
 {
   NET *net= &mysql->net;
   ulong len=0;
-  init_sigpipe_variables
+  init_sigpipe_variables;
 
   /* Don't give sigpipe errors if the client doesn't want them */
   set_sigpipe(mysql);
@@ -629,7 +629,7 @@
 {
   NET *net= &mysql->net;
   my_bool result= 1;
-  init_sigpipe_variables
+  init_sigpipe_variables;
 
   /* Don't give sigpipe errors if the client doesn't want them */
   set_sigpipe(mysql);
@@ -677,7 +677,7 @@
   if (!skip_check)
     result= ((mysql->packet_length=net_safe_read(mysql)) == packet_error ?
 	     1 : 0);
- end:
+end:
   reset_sigpipe(mysql);
   return result;
 }
@@ -852,7 +852,7 @@
   DBUG_ENTER("end_server");
   if (mysql->net.vio != 0)
   {
-    init_sigpipe_variables
+    init_sigpipe_variables;
     DBUG_PRINT("info",("Net: %s", vio_description(mysql->net.vio)));
     set_sigpipe(mysql);
     vio_delete(mysql->net.vio);
@@ -1367,7 +1367,7 @@
 
 /* perform query on master */
 my_bool STDCALL mysql_master_query(MYSQL *mysql, const char *q,
-			       unsigned long length)
+                                   unsigned long length)
 {
   DBUG_ENTER("mysql_master_query");
   if (mysql_master_send_query(mysql, q, length))
@@ -1399,7 +1399,7 @@
 
 
 my_bool STDCALL mysql_slave_send_query(MYSQL *mysql, const char *q,
-				   unsigned long length)
+                                       unsigned long length)
 {
   MYSQL* last_used_slave, *slave_to_use = 0;
   DBUG_ENTER("mysql_slave_send_query");
@@ -1414,7 +1414,7 @@
   */
   mysql->last_used_con = mysql->last_used_slave = slave_to_use;
   if (!slave_to_use->net.vio && !mysql_real_connect(slave_to_use, 0,0,0,
-						   0,0,0,0))
+                                                    0,0,0,0))
     DBUG_RETURN(1);
   DBUG_RETURN(simple_command(slave_to_use, COM_QUERY, q, length, 1));
 }
@@ -1551,7 +1551,7 @@
     }
 
     if (!(slave = spawn_init(mysql, row[1], atoi(row[port_ind]),
-			    tmp_user, tmp_pass)))
+                             tmp_user, tmp_pass)))
       goto err;
 
     /* Now add slave into the circular linked list */
@@ -1561,7 +1561,7 @@
   error = 0;
 err:
   if (res)
-   mysql_free_result(res);
+    mysql_free_result(res);
   DBUG_RETURN(error);
 }
 
@@ -1708,13 +1708,13 @@
   Initialize the MySQL library
 
   SYNOPSIS
-    mysql_once_init()
+    mysql_once_init()
 
   NOTES
-    Can't be static on NetWare
-    This function is called by mysql_init() and indirectly called
-    by mysql_query(), so one should never have to call this from an
-    outside program.
+  Can't be static on NetWare
+  This function is called by mysql_init() and indirectly called
+  by mysql_query(), so one should never have to call this from an
+  outside program.
 */
 
 void mysql_once_init(void)
@@ -1930,7 +1930,7 @@
 #ifdef HAVE_SYS_UN_H
   struct	sockaddr_un UNIXaddr;
 #endif
-  init_sigpipe_variables
+  init_sigpipe_variables;
   DBUG_ENTER("mysql_real_connect");
   LINT_INIT(host_info);
 
@@ -2472,7 +2472,7 @@
   if (!mysql->reconnect ||
       (mysql->server_status & SERVER_STATUS_IN_TRANS) || !mysql->host_info)
   {
-   /* Allow reconnect next time */
+    /* Allow reconnect next time */
     mysql->server_status&= ~SERVER_STATUS_IN_TRANS;
     mysql->net.last_errno=CR_SERVER_GONE_ERROR;
     strmov(mysql->net.last_error,ER(mysql->net.last_errno));
@@ -2516,7 +2516,7 @@
   if (!passwd)
     passwd="";
 
-   /* Store user into the buffer */
+  /* Store user into the buffer */
   end=strmov(end,user)+1;
 
   /*
@@ -2538,10 +2538,10 @@
   }
   else
   {
-   /*
-     Real scramble is only sent to old servers. This can be blocked 
-     by calling mysql_options(MYSQL *, MYSQL_SECURE_CONNECT, (char*) &1);
-   */
+    /*
+      Real scramble is only sent to old servers. This can be blocked 
+      by calling mysql_options(MYSQL *, MYSQL_SECURE_CONNECT, (char*) &1);
+    */
     end=scramble(end, mysql->scramble_buff, passwd,
                  (my_bool) (mysql->protocol_version == 9));
   }
@@ -2734,9 +2734,9 @@
 
 int
 STDCALL mysql_add_slave(MYSQL* mysql, const char* host,
-					   unsigned int port,
-					   const char* user,
-					   const char* passwd)
+                        unsigned int port,
+                        const char* user,
+                        const char* passwd)
 {
   MYSQL* slave;
   if (!(slave = spawn_init(mysql, host, port, user, passwd)))
@@ -3596,7 +3596,7 @@
     if (use_mb_flag && (l = my_ismbchar(charset_info, from, end)))
     {
       while (l--)
-	  *to++ = *from++;
+        *to++ = *from++;
       from--;
       continue;
     }
@@ -3966,14 +3966,14 @@
     like SHOW and DESCRIBE commands
   */
   if (!(stmt->fields= (MYSQL_FIELD *) alloc_root(alloc, 
-        sizeof(MYSQL_FIELD) * stmt->field_count)) || 
+                                                 sizeof(MYSQL_FIELD) * stmt->field_count)) || 
       !(stmt->bind= (MYSQL_BIND *) alloc_root(alloc, 
-        sizeof(MYSQL_BIND ) * stmt->field_count)))
+                                              sizeof(MYSQL_BIND ) * stmt->field_count)))
     return 0;
   
   for (fields= stmt->mysql->fields, end= fields+stmt->field_count, 
-       field= stmt->fields;
+         field= stmt->fields;
        field && fields < end; fields++, field++)
   {
     field->db       = strdup_root(alloc,fields->db);
@@ -4713,23 +4713,23 @@
     int8store(buffer, value);
     break;
   case MYSQL_TYPE_FLOAT:
-    {
-      float data= (float)value;
-      float4store(buffer, data);
-      break;
-    }
+  {
+    float data= (float)value;
+    float4store(buffer, data);
+    break;
+  }
   case MYSQL_TYPE_DOUBLE:
-    {
-      double data= (double)value;
-      float8store(buffer, data);
-      break;
-    }
+  {
+    double data= (double)value;
+    float8store(buffer, data);
+    break;
+  }
   default:
-    {
-      uint length= (uint)(longlong10_to_str(value,buffer,10)-buffer);
-      *param->length= length;
-      buffer[length]='\0';
-    }
+  {
+    uint length= (uint)(longlong10_to_str(value,buffer,10)-buffer);
+    *param->length= length;
+    buffer[length]='\0';
+  }
   } 
 }
 
@@ -4753,23 +4753,23 @@
     int8store(buffer, (longlong)value);
     break;
   case MYSQL_TYPE_FLOAT:
-    {
-      float data= (float)value;
-      float4store(buffer, data);
-      break;
-    }
+  {
+    float data= (float)value;
+    float4store(buffer, data);
+    break;
+  }
   case MYSQL_TYPE_DOUBLE:
-    {
-      double data= (double)value;
-      float8store(buffer, data);
-      break;
-    }
+  {
+    double data= (double)value;
+    float8store(buffer, data);
+    break;
+  }
   default:
-    {
-      uint length= my_sprintf(buffer,(buffer,"%g",value));
-      *param->length= length;
-      buffer[length]='\0';
-    }
+  {
+    uint length= my_sprintf(buffer,(buffer,"%g",value));
+    *param->length= length;
+    buffer[length]='\0';
+  }
   } 
 }
 
@@ -4861,7 +4861,7 @@
     switch (ltime.time_type) {
     case MYSQL_TIMESTAMP_DATE:
       length= my_sprintf(buff,(buff, "%04d-%02d-%02d", ltime.year,
-                         ltime.month,ltime.day));      
+                               ltime.month,ltime.day));      
       break;
     case MYSQL_TIMESTAMP_FULL:
       length= my_sprintf(buff,(buff, "%04d-%02d-%02d %02d:%02d:%02d",
@@ -4870,7 +4870,7 @@
       break;
     case MYSQL_TIMESTAMP_TIME:
       length= my_sprintf(buff, (buff, "%02d:%02d:%02d",
-	                 	     ltime.hour,ltime.minute,ltime.second));
+                                ltime.hour,ltime.minute,ltime.second));
       break;
     default:
       length= 0;
@@ -4894,7 +4894,7 @@
   {
     char value= (char) **row;
     longlong data= (field_is_unsigned) ? (longlong) (unsigned char) value:
-                                         (longlong) value;
+      (longlong) value;
     send_data_long(param,data);
     length= 1;
     break;
@@ -4904,7 +4904,7 @@
   {
     short value= sint2korr(*row);
     longlong data= (field_is_unsigned) ? (longlong) (unsigned short) value:
-                                         (longlong) value;
+      (longlong) value;
     send_data_long(param,data);
     length= 2;    
     break;
@@ -4913,7 +4913,7 @@
   {
     long value= sint4korr(*row);
     longlong data= (field_is_unsigned) ? (longlong) (unsigned long) value:
-                                         (longlong) value;
+      (longlong) value;
     send_data_long(param,data);
     length= 4;
     break;
@@ -5173,8 +5173,8 @@
   
   /* Copy complete row to application buffers */
   for (bind= stmt->bind, end= (MYSQL_BIND *) bind + stmt->field_count, 
-       field= stmt->fields, 
-       field_end= (MYSQL_FIELD *)stmt->fields+stmt->field_count;
+         field= stmt->fields, 
+         field_end= (MYSQL_FIELD *)stmt->fields+stmt->field_count;
        bind < end && field < field_end;
        bind++, field++)
   {         
@@ -5245,7 +5245,7 @@
 }
 
 /* 
-  Read all rows of data from server  (binary format)
+   Read all rows of data from server  (binary format)
 */
 
 static MYSQL_DATA *read_binary_rows(MYSQL_STMT *stmt)
@@ -5285,7 +5285,7 @@
     result->rows++;
 
     if (!(cur= (MYSQL_ROWS*) alloc_root(&result->alloc,sizeof(MYSQL_ROWS))) ||
-	      !(cur->data= ((MYSQL_ROW) alloc_root(&result->alloc, pkt_len))))
+        !(cur->data= ((MYSQL_ROW) alloc_root(&result->alloc, pkt_len))))
     {
       free_rows(result);
       net->last_errno=CR_OUT_OF_MEMORY;
@@ -5333,10 +5333,10 @@
   }
   mysql->status= MYSQL_STATUS_READY;		/* server is ready */
   if (!(result= (MYSQL_RES*) my_malloc((uint) (sizeof(MYSQL_RES)+
-					      sizeof(ulong) *
-					      stmt->field_count),
-				      MYF(MY_WME | MY_ZEROFILL))))
+                                               sizeof(ulong) *
+                                               stmt->field_count),
+                                       MYF(MY_WME | MY_ZEROFILL))))
   {
     set_stmt_error(stmt, CR_OUT_OF_MEMORY);
     DBUG_RETURN(1);
@@ -5571,7 +5571,7 @@
   DBUG_ENTER("mysql_more_results");
   
   result= (mysql->last_used_con->server_status & SERVER_MORE_RESULTS_EXISTS) ? 
-          1: 0;
+    1: 0;
   
   DBUG_PRINT("exit",("More results exists ? %d", result)); 
   DBUG_RETURN(result);
[7 May 2003 7:51] MySQL Verification Team
Thanks for you bug report.
What editor you have used for to verify the indentation?
Because in my XEmacs some lines are correct and anothers no.
[9 May 2003 11:03] Dennis Haney
The first patch followed by C-x h followed by an C-M-\ and then an M-x untabify

emacs 21.3

c-basic-indent is 2
c-offset-alist is (hint: use C-c C-s and C-c C-o in the lines that are interesting)
((string . c-lineup-dont-change)
 (c . c-lineup-C-comments)
 (defun-open . 0)
 (defun-close . 0)
 (defun-block-intro . +)
 (class-open . 0)
 (class-close . 0)
 (inline-open . +)
 (inline-close . 0)
 (func-decl-cont . +)
 (knr-argdecl . 0)
 (topmost-intro . 0)
 (topmost-intro-cont . 0)
 (member-init-intro . +)
 (member-init-cont . c-lineup-multi-inher)
 (inher-intro . +)
 (inher-cont . c-lineup-multi-inher)
 (block-open . 0)
 (block-close . 0)
 (brace-list-open . 0)
 (brace-list-close . 0)
 (brace-list-intro . +)
 (brace-list-entry . 0)
 (brace-entry-open . 0)
 (statement . 0)
 (statement-case-intro . +)
 (statement-case-open . 0)
 (substatement . +)
 (case-label . 0)
 (access-label . -)
 (do-while-closure . 0)
 (else-clause . 0)
 (catch-clause . 0)
 (comment-intro . c-lineup-comment)
 (arglist-intro . +)
 (arglist-cont . 0)
 (arglist-cont-nonempty . c-lineup-arglist)
 (arglist-close . +)
 (stream-op . c-lineup-streamop)
 (inclass . +)
 (cpp-macro .
            [0])
 (cpp-macro-cont . c-lineup-dont-change)
 (friend . 0)
 (objc-method-intro .
                    [0])
 (objc-method-args-cont . c-lineup-ObjC-method-args)
 (objc-method-call-cont . c-lineup-ObjC-method-call)
 (extern-lang-open . 0)
 (extern-lang-close . 0)
 (inextern-lang . +)
 (namespace-open . 0)
 (namespace-close . 0)
 (innamespace . +)
 (template-args-cont c-lineup-template-args +)
 (inlambda . c-lineup-inexpr-block)
 (lambda-intro-cont . +)
 (inexpr-statement . 0)
 (inexpr-class . +)
 (statement-block-intro . +)
 (knr-argdecl-intro . 0)
 (substatement-open . 0)
 (label . 0)
 (statement-cont . +))
[1 Jun 2003 14:56] Michael Widenius
Thank you for your bug report. This issue has been fixed in the latest
development tree for that product. You can find more information about
accessing our development trees at 
    http://www.mysql.com/doc/en/Installing_source_tree.html

I have now applied this to the 4.1 tree.  Thanks