Ticket #43585: patch-compiler.diff

File patch-compiler.diff, 10.1 KB (added by lockhart (Thomas Lockhart), 10 years ago)

Patches to update code for modern compilers.

  • Array.h

    diff -u ../terra.orig/Array.h ./Array.h
    old new  
    11#ifndef ARRAY_INCLUDED // -*- C++ -*-
    22#define ARRAY_INCLUDED
    33
     4#include <memory.h>
     5
     6
    47//
    58// Array classes
    69//
  • GreedyInsert.cc

    diff -u ../terra.orig/GreedyInsert.cc ./GreedyInsert.cc
    old new  
    1 #include <iostream.h>
     1#include <iostream>
    22#include "GreedyInsert.h"
    3 
     3#include <assert.h>
    44#include "Mask.h"
    55extern ImportMask *MASK;
    66
     7using namespace std;
     8
    79void TrackedTriangle::update(Subdivision& s)
    810{
    911    GreedySubdivision& gs = (GreedySubdivision&)s;
     
    209211
    210212    is_used(sx,sy) = DATA_POINT_USED;
    211213    count++;
     214#if 0
    212215    return insert(Vec2(sx,sy), t);
     216#endif
     217    Vec2 vec(sx,sy);
     218    return insert(vec, t);
    213219}
    214220
    215221
  • Heap.cc

    Only in .: GreedyInsert.o
    diff -u ../terra.orig/Heap.cc ./Heap.cc
    old new  
    11#include <assert.h>
    2 #include <iostream.h>
     2#include <iostream>
    33#include "Heap.h"
    44
     5using namespace std;
     6
    57
    68void Heap::swap(int i,int j)
    79{
  • Makefile

    Only in .: Heap.o
    diff -u ../terra.orig/Makefile ./Makefile
    old new  
    44# You should change these to fit your system.
    55#
    66
    7 CC = cc
    8 C++ = CC
     7CC = gcc
     8C++ = g++
    99
    1010# For compiling on SGI's with the pre-5.3 (ie. cfront-based) compiler:
    1111# add '-ptr/tmp/terra_ptrepository' to OPTFLAGS
    1212# add '-pte.cc' to LFLAGS
    1313
    14 OPTFLAGS = -g -mips2
     14# OPTFLAGS = -g -mips2
    1515# OPTFLAGS = -O2 -mips2
     16OPTFLAGS = -g -Wall
    1617
    1718GUI_LIBS = -lglut -lGLU -lGL -lXmu -lX11
    18 LIBS = -lmalloc -lmx
     19LIBS = # -lmalloc -lmx
    1920
    2021#
    2122# This defines the location of the GLUT libraries
    2223#
    23 ANIM = /afs/cs/project/anim/garland
     24ANIM = /opt/local
    2425GLUT_FLAGS =
    2526GLUT_INCDIR = $(ANIM)/include
    2627GLUT_LIBDIR = $(ANIM)/lib
     
    3435#
    3536# These are the flags for compilation (CFLAGS) and linking (LFLAGS)
    3637#
    37 CFLAGS = $(INCDIR) $(OPTFLAGS) -DSAFETY
     38CFLAGS = $(INCDIR) $(OPTFLAGS) -DIOSTREAMH # -DSAFETY
    3839LFLAGS = $(LIBDIR) $(OPTFLAGS)
    3940
    4041
     
    8182
    8283depend :
    8384        touch Makefile.depend
    84         makedepend -fMakefile.depend $(INCDIR) -I/usr/include/CC $(BASE_SRCS) $(GUI_SRCS)
     85        makedepend -fMakefile.depend $(INCDIR) $(BASE_SRCS) $(GUI_SRCS)
    8586        /bin/rm -f Makefile.depend.bak
    8687
    8788sinclude Makefile.depend
  • Map.h

    diff -u ../terra.orig/Map.h ./Map.h
    old new  
    22#define MAP_INCLUDED
    33
    44#include <stdlib.h>
    5 #include <iostream.h>
     5#include <iostream>
    66
    77#include "Geom.h"
    88
     9using namespace std;
     10
     11
    912class Map
    1013{
    1114public:
  • Mask.cc

    Only in .: Map.o
    diff -u ../terra.orig/Mask.cc ./Mask.cc
    old new  
    11#include <math.h>
    22#include <stdlib.h>
    3 #include <iostream.h>
     3#include <iostream>
    44
    55#include "Geom.h"
    66#include "Mask.h"
    77
     8using namespace std;
     9
    810
    911RealMask *readMask(istream& in)
    1012{
  • Mask.h

    diff -u ../terra.orig/Mask.h ./Mask.h
    old new  
    11#ifndef MASK_INCLUDED // -*- C++ -*-
    22#define MASK_INCLUDED
    33
     4#include <istream>
     5
     6using namespace std;
     7
     8
    49class ImportMask
    510{
    611
  • Quadedge.cc

    Only in .: Mask.o
    diff -u ../terra.orig/Quadedge.cc ./Quadedge.cc
    old new  
    11#include <stdlib.h>
    2 #include <iostream.h>
     2#include <iostream>
    33
    44#include "Quadedge.h"
    55
     6using namespace std;
     7
    68Edge::Edge(const Edge&)
    79{
    810    cerr << "Edge: Edge assignments are forbidden." << endl;
  • Subdivision.cc

    Only in .: Quadedge.o
    diff -u ../terra.orig/Subdivision.cc ./Subdivision.cc
    old new  
    11#include <stdlib.h>
    2 #include <iostream.h>
     2#include <iostream>
    33#include <assert.h>
    44
    55#include "Subdivision.h"
    66
     7using namespace std;
    78
    89
    910Edge *Subdivision::makeEdge(Vec2& org, Vec2& dest)
     
    105106
    106107static void overEdge(Edge *e, edge_callback fn, void *closure)
    107108{
    108     if( e->token != timestamp )
     109    if( static_cast<typeof(timestamp)>(e->token) != timestamp )
    109110    {
    110111        e->token = timestamp;
    111112        e->Sym()->token = timestamp;
     
    214215        real td = triArea(x, ed->Dest(), ed->Org());
    215216
    216217        if (td>0)                       // x is below ed
    217             if (to>0 || to==0 && t==0) {// x is interior, or origin endpoint
     218            if (to>0 || (to==0 && t==0)) {// x is interior, or origin endpoint
    218219                startingEdge = e;
    219220                return e;
    220221            }
     
    259260
    260261    if ( (x == e->Org()) || (x == e->Dest()) ) {
    261262        // point is already in the mesh
     263#if 0
    262264        //
    263265        cerr << "WARNING: Tried to reinsert point: " << x << endl;
    264266        cerr << "         org: " << e->Org() << endl;
    265267        cerr << "        dest: " << e->Dest() << endl;
     268#endif
    266269        return NULL;
    267270    }
    268271
     
    338341    do {
    339342
    340343        Edge *e = spoke->Lnext();
     344#if 0
    341345        Edge *t = e->Oprev();
     346#endif
    342347
    343348        if( isInterior(e) && shouldSwap(x, e) )
    344349            swap(e);
  • Vec2.h

    Only in .: Subdivision.o
    diff -u ../terra.orig/Vec2.h ./Vec2.h
    old new  
    11#ifndef VEC2_INCLUDED // -*- C++ -*-
    22#define VEC2_INCLUDED
    33
     4#include <iostream>
     5
     6using namespace std;
     7
     8
    49class Vec2 {
    510protected:
    611    real elt[2];
     
    163168
    164169inline istream& operator>>(istream& in, Vec2& v)
    165170{
     171#if 0
    166172    return in >> "[" >> v[0] >> v[1] >> "]";
     173#endif
     174    in.ignore(1, '[');
     175    in >> v[0] >> v[1];
     176    in.ignore(1, ']');
     177    return in;
    167178}
    168179#endif
    169180
  • Vec3.h

    diff -u ../terra.orig/Vec3.h ./Vec3.h
    old new  
    11#ifndef VEC3_INCLUDED // -*- C++ -*-
    22#define VEC3_INCLUDED
    33
     4#include <iostream>
     5
     6using namespace std;
     7
     8
    49class Vec3 {
    510protected:
    611    real elt[3];
     
    173178
    174179inline istream& operator>>(istream& in, Vec3& v)
    175180{
     181#if 0
    176182    return in >> "[" >> v[0] >> v[1] >> v[2] >> "]";
     183#endif
     184    in.ignore(1, '[');
     185    in >> v[0] >> v[1];
     186    in.ignore(1, ']');
     187    return in;
    177188}
    178189#endif
    179190
  • cmdline.cc

    Only in .: altadena-lake.osm
    Only in .: altadena.osm
    diff -u ../terra.orig/cmdline.cc ./cmdline.cc
    old new  
    11#include <stdlib.h>
    2 #include <fstream.h>
     2#include <fstream>
    33#include <string.h>
    44#include "terra.h"
     5#include <getopt.h>
     6
    57
    68GreedySubdivision *mesh;
    79Map *DEM;
     
    1820char *mask_filename   = NULL;
    1921char *script_filename = NULL;
    2022
    21 static char *options = "e:p:h:o:m:s:";
     23static const char *options = "e:p:h:o:m:s:";
    2224
    23 static char *usage_string =
     25static const char *usage_string =
    2426"-e <thresh>      Sets the tolerable error threshold\n"
    2527"-p <count>       Sets the maximum number of allowable points\n"
    2628"-h <factor>      Sets the height scaling factor.  For example,\n"
     
    3133"-s <file>        Execute preinsertion script from <file>\n"
    3234"\n";
    3335
    34 static void usage_error(char *msg = NULL)
     36static void usage_error(const char *msg = NULL)
    3537{
    3638    if( msg )
    3739        cerr << msg << endl;
  • glHacks.h

    Only in .: cmdline.o
    diff -u ../terra.orig/glHacks.h ./glHacks.h
    old new  
    44#include <GL/glx.h>
    55#include <GL/gl.h>
    66#include <GL/glu.h>
     7#include <iostream>
     8
     9using namespace std;
    710
    811
    912/*************************************************************************
  • greedy.cc

    Only in .: glHacks.o
    diff -u ../terra.orig/greedy.cc ./greedy.cc
    old new  
    11#include "terra.h"
     2#include <fstream>
     3
    24
    35void scripted_preinsertion(istream& script)
    46{
     
    6466inline int goal_not_met()
    6567{
    6668    return mesh->maxError() > error_threshold &&
    67            mesh->pointCount() < point_limit;
     69      static_cast<typeof(point_limit)>(mesh->pointCount()) < point_limit;
    6870}
    6971
    7072static void announce_goal()
  • output.cc

    diff -u ../terra.orig/output.cc ./output.cc
    old new  
    11#include "terra.h"
    2 #include <fstream.h>
     2#include <fstream>
    33
    44
    5 void generate_output(char *filename, FileFormat format)
     5void generate_output(const char *filename, FileFormat format)
    66{
    77    if( !filename )
    88        filename = output_filename;
  • terra.cc

    Only in .: output.o
    Only in .: terra
    diff -u ../terra.orig/terra.cc ./terra.cc
    old new  
    11#include "terra.h"
    22
    3 main(int argc, char **argv)
     3int main(int argc, char **argv)
    44{
    55    process_cmdline(argc, argv);
    66
    77    greedy_insertion();
    88
    99    generate_output();
     10
     11    return 0;
    1012}
  • terra.h

    diff -u ../terra.orig/terra.h ./terra.h
    old new  
    2424extern void scripted_preinsertion(istream&);
    2525extern void subsample_insertion(int target_width);
    2626
    27 extern void generate_output(char *filename=NULL,
     27extern void generate_output(const char *filename=NULL,
    2828                            FileFormat format=NULLfile);
    2929extern void output_tin(ostream&);
    3030extern void output_eps(ostream&);
  • xterra.cc

    Only in .: terra.o
    Only in .: xterra
    diff -u ../terra.orig/xterra.cc ./xterra.cc
    old new  
    55
    66
    77
    8 main(int argc, char **argv)
     8int main(int argc, char **argv)
    99{
    1010    glutInit(&argc, argv);
    1111    process_cmdline(argc, argv);
     
    1515
    1616
    1717    gui_interact();
     18
     19    return 0;
    1820}