[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Keyboard problems with MiNT 1.15.0 Beta 4 and Milan



> > |> 
> > |>                 /* xconin[] are always blocking, and we don't want to   
> > |>                    hang at ipl7 even if something impossible like a     
> > |>                    `magically' empty buffer happens.  so check again. */
> > |>                 if (ior->tail != ior->head)
> > |>                         if (buf)                                        
> > |>                                 *p++ = callout1(*cin, bdev);            
> > |>                         else                                            
> > |>                                 (void) callout1(*cin, bdev);            
> > 
> > There is no semantic difference between theses two, it's just a matter of
> > style.
> 
> Really? It seemed to me that the latter means:
> 
>                 if (ior->tail != ior->head) {                  
>                          if (buf)                             
>                                  *p++ = callout1(*cin, bdev); 
>                 } else {                                 
>                                  (void) callout1(*cin, bdev); 
> 
> 		}
> 
> rather than:
> 
>                 if (ior->tail != ior->head) {                 
>                          if (buf) {                            
>                                  *p++ = callout1(*cin, bdev); 
>                 	 } else {                                      
>                                  (void) callout1(*cin, bdev);
> 			 }                                    
>                 }                                             
> 
> I.e. the "else" will be interpreted as opposite to "if (ior->tail !=
> ior->head)" rather than to "if (buf)".

It means the second version - i.e. the "else" does get included with the
nested if ("if (buf)") because

	if (expression) statement1 else statement2

counts as a single statement so there's no need for curly brackets ("{}").
'Course, if the "else" was really supposed to refer to the outer if, then
curly brackets would be needed around the "if (buf) ..." statement to
show that the else wasn't part of that statement.

ATB,
Aidan.