Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 25 Mar 2011 14:36:15 GMT
From:      Michael Gmelin <freebsd@grem.de>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   ports/155934: Incorporate patch from the Ice project into devel/mcpp
Message-ID:  <201103251436.p2PEaFOk045647@red.freebsd.org>
Resent-Message-ID: <201103251440.p2PEeA6T083773@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         155934
>Category:       ports
>Synopsis:       Incorporate patch from the Ice project into devel/mcpp
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Mar 25 14:40:10 UTC 2011
>Closed-Date:
>Last-Modified:
>Originator:     Michael Gmelin
>Release:        FreeBSD 8.1 RELEASE amd64
>Organization:
Grem Equity GmbH
>Environment:
FreeBSD server.grem.de 8.1-RELEASE-p2 FreeBSD 8.1-RELEASE-p2 #2 r216068: Tue Nov 30 03:00:30 CET 2010 root@bsdsource.grem.de:/usr/obj/usr/src/sys/GENERIC  amd64

>Description:
The Ice project by ZeroC (devel/ice and devel/py-ice) did some patches and security updates for the mcpp preprocessor. Without those patches, important parts of ice are not functioning properly. The patches have been applied to various linux package trees in the past successfully. I got in touch with the author and package maintainer of the devel/mcpp port, but he's currently unable to do any work on the project, but gave his consent to applying the patch:

====
Hello,

I'm very sorry, but I have no time for mcpp now.  I think the Zeroc
patch is correct, and has no undesirable side effect.  So, if someone
make an mcpp package applying the patch, and commit it to FreeBSD or any
other system, I will agree with it.

--
Kiyoshi Matsui, the maintainer of mcpp
===

It should be emphasized, that right now ice is the only port using mcpp and that it's misbehaving in subtle ways if the patch is not applied at runtime. So this is somehow critical.
>How-To-Repeat:
Run mcpp like this:
mcpp -C << EOF
> test; // comment
> EOF
#line 1 "<stdin>"
// commenttest;

This clearly shows the critical misbehaviour when comments are preserved (that's the way slice2java, slice2py and slice2html are calling mcpp).
>Fix:
Apply the patch attached to this PR and reinstall mcpp:

sudo mkdir -p /usr/ports/devel/mcpp/files
sudo cp patch-mcpp-ice.txt /usr/ports/devel/mcpp/files
sudo portupgrade -f devel/mcpp

It would be good, if this patch could be incorporated into the port skeleton of devel/mcpp directly. The original patch is part of the third party sources tarball found on zeroc.com: http://www.zeroc.com/download/Ice/3.4/ThirdParty-Sources-3.4.1.tar.gz


Patch attached with submission follows:

diff -c -r -N ../mcpp-2.7.2/src/internal.H ./src/internal.H
*** ../mcpp-2.7.2/src/internal.H	2008-08-27 10:31:16.000000000 -0230
--- ./src/internal.H	2009-12-17 21:01:35.000000000 -0330
***************
*** 390,395 ****
--- 390,397 ----
  extern char     identifier[];       /* Lastly scanned name          */
  extern IFINFO   ifstack[];          /* Information of #if nesting   */
  extern char     work_buf[];
+ extern FILEINFO * sh_file;
+ extern int      sh_line;
          /* Temporary buffer for directive line and macro expansion  */
  
  /* main.c   */
***************
*** 557,562 ****
  #endif
  #endif
  
! #if HOST_HAVE_STPCPY
  extern char *   stpcpy( char * dest, const char * src);
  #endif
--- 559,564 ----
  #endif
  #endif
  
! #if HOST_HAVE_STPCPY && !defined(stpcpy)
  extern char *   stpcpy( char * dest, const char * src);
  #endif
diff -c -r -N ../mcpp-2.7.2/src/main.c ./src/main.c
*** ../mcpp-2.7.2/src/main.c	2008-11-05 05:04:46.000000000 -0330
--- ./src/main.c	2009-12-17 20:42:42.000000000 -0330
***************
*** 326,331 ****
--- 326,333 ----
              = FALSE;
      option_flags.trig = TRIGRAPHS_INIT;
      option_flags.dig = DIGRAPHS_INIT;
+     sh_file = NULL;
+     sh_line = 0;
  }
  
  int     mcpp_lib_main
diff -c -r -N ../mcpp-2.7.2/src/support.c ./src/support.c
*** ../mcpp-2.7.2/src/support.c	2008-06-10 06:02:33.000000000 -0230
--- ./src/support.c	2009-12-17 20:42:39.000000000 -0330
***************
*** 188,194 ****
      size_t      length
  )
  {
!     if (mem_buf_p->bytes_avail < length) {  /* Need to allocate more memory */
          size_t size = MAX( BUF_INCR_SIZE, length);
  
          if (mem_buf_p->buffer == NULL) {            /* 1st append   */
--- 188,194 ----
      size_t      length
  )
  {
!     if (mem_buf_p->bytes_avail < length + 1) {  /* Need to allocate more memory */
          size_t size = MAX( BUF_INCR_SIZE, length);
  
          if (mem_buf_p->buffer == NULL) {            /* 1st append   */
***************
*** 1722,1727 ****
--- 1722,1729 ----
                      sp -= 2;
                      while (*sp != '\n')     /* Until end of line    */
                          mcpp_fputc( *sp++, OUT);
+                     mcpp_fputc( '\n', OUT);
+                     wrong_line = TRUE;
                  }
                  goto  end_line;
              default:                        /* Not a comment        */
diff -c -r -N ../mcpp-2.7.2/src/system.c ./src/system.c
*** ../mcpp-2.7.2/src/system.c	2008-11-26 06:23:51.000000000 -0330
--- ./src/system.c	2009-12-17 20:42:42.000000000 -0330
***************
*** 3858,3863 ****
--- 3858,3866 ----
  }
  #endif
  
+ FILEINFO*       sh_file;
+ int             sh_line;
+ 
  void    sharp(
      FILEINFO *  sharp_file,
      int         flag        /* Flag to append to the line for GCC   */
***************
*** 3868,3875 ****
   * else (i.e. 'sharp_file' is NULL) 'infile'.
   */
  {
-     static FILEINFO *   sh_file;
-     static int  sh_line;
      FILEINFO *  file;
      int         line;
  
--- 3871,3876 ----


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201103251436.p2PEaFOk045647>