The : problem should indeed have been fixed, but apparently not well 
enough.  It looks like in the end it will be easier to fix the return(x 
problem than all of the problems that deleting and readding and expression 
E entails :)

julia


On Wed, 23 Jun 2010, Josh Triplett wrote:

> When attempting to apply this semantic patch:
> 
> @@
> expression E;
> @@
> -return(E);
> +return E;
> 
> 
> I ran into multiple cases where whitespace and comments disappeared.
> Some examples:
> 
> @@ -593,10 +593,7 @@ static int row_byte_cns11643 (int row) {
>    return 0x100 * (row / 94) + (row % 94) + 0x21;
>  }
>  static int byte_row_cns11643 (int byte) {
> -  return (byte >= 0x100 && byte < 0x200 ? byte-0x121 :
> -          byte >= 0x200 && byte < 0x300 ? byte-0x221+94 :
> -          byte >= 0x300 && byte < 0x400 ? byte-0x321+2*94 :
> -          -1);
> +  return byte >= 0x100 && byte < 0x200 ? byte - 0x121 :byte >= 0x200 && byte 
> < 0x300 ? byte - 0x221 + 94 :byte >= 0x300 && byte < 0x400 ? byte - 0x321 + 2 
> * 94 :-1;
>  }
>  
>  static void do_cns11643_only_uni2charset (const char* name)
> 
> 
> @@ -173,10 +173,7 @@ XRegisterIMInstantiateCallback(
>      XLCd       lcd = _XOpenLC( (char *)NULL );
>  
>      if( !lcd )
> -       return( False );
> -    return( (*lcd->methods->register_callback)( lcd, display, rdb, res_name,
> -                                               res_class, callback,
> -                                               client_data ) );
> +       return False;return (*lcd->methods->register_callback)(lcd, display, 
> rdb, res_name, res_class, callback, client_data);
>  }
>  
>  /*
> 
> 
> @@ -869,10 +869,9 @@ _XcmsResolveColorString (
>         if (result_format != XcmsUndefinedFormat
>                 && pColor_exact_return->format != result_format) {
>             /* need to be converted to the target format */
> -           return(XcmsConvertColors(ccc, pColor_exact_return, 1,
> -                   result_format, (Bool *)NULL));
> +           return XcmsConvertColors(ccc, pColor_exact_return, 1, 
> result_format, (Bool *)NULL);
>         } else {
> -           return(XcmsSuccess);
> +           return XcmsSuccess;
>         }
>      }
>  
> @@ -442,30 +442,12 @@ XcmsCCCOfColormap(
>          */
>         if (nScrn == 1) {
>             /* Assume screenNumber == 0 */
> -           return(pRec->ccc = XcmsCreateCCC(
> -                   dpy,
> -                   0,                  /* screenNumber */
> -                   pRec->visual,
> -                   (XcmsColor *)NULL,  /* clientWhitePt */
> -                   (XcmsCompressionProc)NULL,  /* gamutCompProc */
> -                   (XPointer)NULL,     /* gamutCompClientData */
> -                   (XcmsWhiteAdjustProc)NULL,  /* whitePtAdjProc */
> -                   (XPointer)NULL      /* whitePtAdjClientData */
> -                   ));
> +           return pRec->ccc = XcmsCreateCCC(dpy, 0, pRec->visual, (XcmsColor 
> *)NULL, (XcmsCompressionProc)NULL, (XPointer)NULL, (XcmsWhiteAdjustProc)NULL, 
> (XPointer)NULL);
>         } else {
>             if (XGetWindowAttributes(dpy, pRec->windowID, &windowAttr)) {
>                 for (i = 0; i < nScrn; i++) {
>                     if (ScreenOfDisplay(dpy, i) == windowAttr.screen) {
> -                       return(pRec->ccc = XcmsCreateCCC(
> -                               dpy,
> -                               i,                 /* screenNumber */
> -                               pRec->visual,
> -                               (XcmsColor *)NULL, /* clientWhitePt */
> -                               (XcmsCompressionProc)NULL, /* gamutCompProc */
> -                               (XPointer)NULL,    /* gamutCompClientData */
> -                               (XcmsWhiteAdjustProc)NULL, /* whitePtAdjProc 
> */
> -                               (XPointer)NULL     /* whitePtAdjClientData */
> -                               ));
> +                       return pRec->ccc = XcmsCreateCCC(dpy, i, 
> pRec->visual, (XcmsColor *)NULL, (XcmsCompressionProc)NULL, (XPointer)NULL, 
> (XcmsWhiteAdjustProc)NULL, (XPointer)NULL);
>                     }
>                 }
>             }
> 
> 
> I also noticed some issues with ternary operators, such as in the first
> example above, or here:
> 
> @@ -152,7 +152,7 @@ mb_mbchar(
>         return 0x7f;
>      }
>      /* Return a 'char' equivalent to wc. */
> -    return (wc >= 0 && wc <= 0x7f ? wc : 0x7f);
> +    return wc >= 0 && wc <= 0x7f ? wc :0x7f;
>  }
>  
>  /* Terminates a sequence of calls to mbchar. */
> 
> 
> I tested this with coccinelle 0.2.3rc3, which as I understand it has the
> fix for the ternary-operator spacing problem.
> 
> - Josh Triplett
> _______________________________________________
> Cocci mailing list
> [email protected]
> http://lists.diku.dk/mailman/listinfo/cocci
> (Web access from inside DIKUs LAN only)
> 
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)

Reply via email to