aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula/mcpp.rb
diff options
context:
space:
mode:
authorDavid M. Lee2012-05-01 14:33:09 -0500
committerJack Nagel2012-06-07 17:19:36 -0500
commitd9476a9d1564af87a2fc83a61c434d327a87b8bc (patch)
tree16a03564612076ad52648a645134ffba3a5c4578 /Library/Formula/mcpp.rb
parent7499e9bd4893650aa283a77c5837073f58c6fee8 (diff)
downloadhomebrew-d9476a9d1564af87a2fc83a61c434d327a87b8bc.tar.bz2
mcpp: Patch from ZeroC for handling EOL comments
Closes #11993. Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Diffstat (limited to 'Library/Formula/mcpp.rb')
-rw-r--r--Library/Formula/mcpp.rb111
1 files changed, 107 insertions, 4 deletions
diff --git a/Library/Formula/mcpp.rb b/Library/Formula/mcpp.rb
index 59bf0f18a..925d1091c 100644
--- a/Library/Formula/mcpp.rb
+++ b/Library/Formula/mcpp.rb
@@ -6,6 +6,8 @@ class Mcpp < Formula
md5 '512de48c87ab023a69250edc7a0c7b05'
# stpcpy is a macro on OS X; trying to define it as an extern is invalid.
+ # Patch from ZeroC fixing EOL comment parsing
+ # http://www.zeroc.com/forums/bug-reports/5309-mishap-slice-compilers.html#post23231
def patches; DATA; end
def install
@@ -16,10 +18,20 @@ class Mcpp < Formula
end
__END__
-diff -ur mcpp-2.7.2-orig/src/internal.H mcpp-2.7.2/src/internal.H
---- mcpp-2.7.2-orig/src/internal.H 2008-08-27 08:01:16.000000000 -0500
-+++ mcpp-2.7.2/src/internal.H 2010-11-08 15:53:38.000000000 -0600
-@@ -557,6 +557,6 @@
+diff --git a/src/internal.H b/src/internal.H
+index 5e1c19f..39aff8c 100644
+--- a/src/internal.H
++++ b/src/internal.H
+@@ -390,6 +390,8 @@ extern char * const work_end; /* End of work[] buffer */
+ 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,6 +559,6 @@ extern void init_system( void);
#endif
#endif
@@ -27,3 +39,94 @@ diff -ur mcpp-2.7.2-orig/src/internal.H mcpp-2.7.2/src/internal.H
+#if HOST_HAVE_STPCPY && !defined(stpcpy)
extern char * stpcpy( char * dest, const char * src);
#endif
+diff --git a/src/main.c b/src/main.c
+index a438894..8da4b58 100644
+--- a/src/main.c
++++ b/src/main.c
+@@ -326,6 +326,8 @@ static void init_main( void)
+ = FALSE;
+ option_flags.trig = TRIGRAPHS_INIT;
+ option_flags.dig = DIGRAPHS_INIT;
++ sh_file = NULL;
++ sh_line = 0;
+ }
+
+ int mcpp_lib_main
+diff --git a/src/support.c b/src/support.c
+index c57eaef..348ede0 100644
+--- a/src/support.c
++++ b/src/support.c
+@@ -188,7 +188,7 @@ static char * append_to_buffer(
+ size_t length
+ )
+ {
+- if (mem_buf_p->bytes_avail < length) { /* Need to allocate more memory */
++ 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,6 +1722,8 @@ com_start:
+ 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 --git a/src/system.c b/src/system.c
+index 4759469..4e008fa 100644
+--- a/src/system.c
++++ b/src/system.c
+@@ -3534,6 +3534,32 @@ void add_file(
+ FILEINFO * file;
+ const char * too_many_include_nest =
+ "More than %.0s%ld nesting of #include"; /* _F_ _W4_ */
++
++ //
++ // When encoding is UTF-8, skip BOM if present.
++ //
++ if(mbchar == UTF8 && fp != NULL && ftell(fp) == 0)
++ {
++ const unsigned char UTF8_BOM[3] = {0xEF, 0xBB, 0xBF};
++ unsigned char FILE_HEAD[3] = {0, 0, 0};
++ int i;
++ for(i = 0; i < 3; ++i)
++ {
++ FILE_HEAD[i] = getc(fp);
++ if(FILE_HEAD[i] != UTF8_BOM[i])
++ {
++ if(FILE_HEAD[i] == (unsigned char)EOF)
++ {
++ i--;
++ }
++ for(; i >= 0; --i)
++ {
++ ungetc(FILE_HEAD[i], fp);
++ }
++ break;
++ }
++ }
++ }
+
+ filename = set_fname( filename); /* Search or append to fnamelist[] */
+ fullname = set_fname( fullname); /* Search or append to fnamelist[] */
+@@ -3858,6 +3884,9 @@ static int chk_dirp(
+ }
+ #endif
+
++FILEINFO* sh_file;
++int sh_line;
++
+ void sharp(
+ FILEINFO * sharp_file,
+ int flag /* Flag to append to the line for GCC */
+@@ -3868,8 +3897,6 @@ void sharp(
+ * else (i.e. 'sharp_file' is NULL) 'infile'.
+ */
+ {
+- static FILEINFO * sh_file;
+- static int sh_line;
+ FILEINFO * file;
+ int line;
+