Changeset 2785 for trunk/external-alma


Ignore:
Timestamp:
03/08/13 17:58:53 (11 years ago)
Author:
Takeshi Nakazato
Message:

New Development: No

JIRA Issue: No

Ready for Test: Yes

Interface Changes: No

What Interface Changed: Please list interface changes

Test Programs: List test programs

Put in Release Notes: Yes/No?

Module(s): Module Names change impacts.

Description: Describe your changes here...

Candidate bug fix for seg. fault on Mac.

Location:
trunk/external-alma/atnf/PKSIO
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/external-alma/atnf/PKSIO/ASTEDataset.cc

    r2783 r2785  
    3535#include <iostream>
    3636#include <cstring>
     37
     38#define STRING2CHAR(s) const_cast<char *>((s).c_str())
    3739
    3840using namespace std ;
     
    7981  int arymax = arrayMax();
    8082
    81   string str120( 120, ' ' ) ;
    82   char c120[120] ;
    8383  // make sure file pointer points a beginning of the file
    8484  fseek( fp_, 0, SEEK_SET ) ;
     
    8787
    8888  // specific part
    89   strcpy( c120, str120.c_str() ) ;
    90   if ( readHeader( c120, 116 ) == -1 ) {
     89  CDMY1.resize(116);
     90  if ( readHeader( STRING2CHAR(CDMY1), 116 ) == -1 ) {
    9191    os << LogIO::WARN << "Error while reading data CDMY1." << LogIO::POST ;
    9292    return -1 ;
    9393  }
    94   c120[116] = '\0' ;
    95   CDMY1 = string( c120 ) ;
    9694  // DEBUG
    9795  //cout << "CDMY1 = " << CDMY1 << endl ;
  • trunk/external-alma/atnf/PKSIO/NRODataset.cc

    r2783 r2785  
    4646#include <fstream>
    4747
     48#define STRING2CHAR(s) const_cast<char *>((s).c_str())
     49
    4850//#include <casa/namespace.h>
    4951
     
    195197  }
    196198
    197 //   //scanNum_ = NSCAN + 1 ; // includes ZERO scan
    198 //   scanLen_ = SCNLEN ;
    199 //   dataLen_ = scanLen_ - SCAN_HEADER_SIZE ;
    200 //   scanNum_ = getScanNum();
    201 //   rowNum_ = scanNum_ * ARYNM ;
    202 //   chmax_ = (int) ( dataLen_ * 8 / IBIT ) ;
    203 //   record_->LDATA = new char[dataLen_] ;
    204 
    205199  initArray();
    206200
     
    215209
    216210  int arymax = arrayMax() ;
    217 
    218   string str4( 4, ' ' ) ;
    219   string str8( 8, ' ' ) ;
    220   string str16( 16, ' ' ) ;
    221   string str18( 18, ' ' ) ;
    222   string str24( 24, ' ' ) ;
    223   string str40( 40, ' ' ) ;
    224   string str120( 120, ' ' ) ;
    225   char c4[4] ;
    226   char c8[8] ;
    227   char c16[16] ;
    228   char c18[18] ;
    229   char c24[24] ;
    230   char c40[40] ;
    231   char c120[120] ;
    232211
    233212  // make sure file pointer points a beginning of the file
     
    235214
    236215  // read data header
    237   strcpy( c8, str8.c_str() ) ;
    238   if ( readHeader( c8, 8 ) == -1 ) {
     216  LOFIL.resize(8);
     217  if ( readHeader( STRING2CHAR(LOFIL), 8 ) == -1 ) {
    239218    os << LogIO::WARN << "Error while reading data LOFIL." << LogIO::POST ;
    240219    return -1 ;
    241220  }
    242   LOFIL = string( c8 ) ;
    243221  // DEBUG
    244222  //cout << "LOFIL = " << LOFIL << endl ;
    245223  //
    246   strcpy( c8, str8.c_str() ) ;
    247   if ( readHeader( c8, 8 ) == -1 ) {
     224  VER.resize(8);
     225  if ( readHeader( STRING2CHAR(VER), 8 ) == -1 ) {
    248226    os << LogIO::WARN << "Error while reading data VER." << LogIO::POST ;
    249227    return -1 ;
    250228  }
    251   VER = string( c8 ) ;
    252229  // DEBUG
    253230  //cout << "VER = " << VER << endl ;
    254231  //
    255   strcpy( c16, str16.c_str() ) ;
    256   if ( readHeader( c16, 16 ) == -1 ) {
     232  GROUP.resize(16);
     233  if ( readHeader( STRING2CHAR(GROUP), 16 ) == -1 ) {
    257234    os << LogIO::WARN << "Error while reading data GROUP." << LogIO::POST ;
    258235    return -1 ;
    259236  }
    260   GROUP = string( c16 ) ;
    261237  // DEBUG
    262238  //cout << "GROUP = " << GROUP << endl ;
    263239  //
    264   strcpy( c16, str16.c_str() ) ;
    265   if ( readHeader( c16, 16 ) == -1 ) {
     240  PROJ.resize(16);
     241  if ( readHeader( STRING2CHAR(PROJ), 16 ) == -1 ) {
    266242    os << LogIO::WARN << "Error while reading data PROJ." << LogIO::POST ;
    267243    return -1 ;
    268244  }
    269   PROJ = string( c16 ) ;
    270245  // DEBUG
    271246  //cout << "PROJ = " << PROJ << endl ;
    272247  //
    273   strcpy( c24, str24.c_str() ) ;
    274   if ( readHeader( c24, 24 ) == -1 ) {
     248  SCHED.resize(24);
     249  if ( readHeader( STRING2CHAR(SCHED), 24 ) == -1 ) {
    275250    os << LogIO::WARN << "Error while reading data SCHED." << LogIO::POST ;
    276251    return -1 ;
    277252  }
    278   SCHED = string( c24 ) ;
    279253  // DEBUG
    280254  //cout << "SCHED = " << SCHED << endl ;
    281255  //
    282   strcpy( c40, str40.c_str() ) ;
    283   if ( readHeader( c40, 40 ) == -1 ) {
     256  OBSVR.resize(40);
     257  if ( readHeader( STRING2CHAR(OBSVR), 40 ) == -1 ) {
    284258    os << LogIO::WARN << "Error while reading data OBSVR." << LogIO::POST ;
    285259    return -1 ;
    286260  } 
    287   OBSVR = string( c40 ) ;
    288261  // DEBUG
    289262  //cout << "OBSVR = " << OBSVR << endl ;
    290263  //
    291   strcpy( c16, str16.c_str() ) ;
    292   if ( readHeader( c16, 16 ) == -1 ) {
     264  LOSTM.resize(16);
     265  if ( readHeader( STRING2CHAR(LOSTM), 16 ) == -1 ) {
    293266    os << LogIO::WARN << "Error while reading data LOSTM." << LogIO::POST ;
    294267    return -1 ;
    295268  }
    296   LOSTM = string( c16 ) ;
    297269  // DEBUG
    298270  //cout << "LOSTM = " << LOSTM << endl ;
    299271  //
    300   strcpy( c16, str16.c_str() ) ;
    301   if ( readHeader( c16, 16 ) == -1 ) {
     272  LOETM.resize(16);
     273  if ( readHeader( STRING2CHAR(LOETM), 16 ) == -1 ) {
    302274    os << LogIO::WARN << "Error while reading data LOETM." << LogIO::POST ;
    303275    return -1 ;
    304276  }
    305   LOETM = string( c16 ) ;
    306277  // DEBUG
    307278  //cout << "LOETM = " << LOETM << endl ;
     
    321292  //cout << "NSCAN = " << NSCAN << endl ;
    322293  //
    323   strcpy( c120, str120.c_str() ) ;
    324   if ( readHeader( c120, 120 ) == -1 ) {
     294  TITLE.resize(120);
     295  if ( readHeader( STRING2CHAR(TITLE), 120 ) == -1 ) {
    325296    os << LogIO::WARN << "Error while reading data TITLE." << LogIO::POST ;
    326297    return -1 ;
    327298  }
    328   TITLE = string( c120 ) ;
    329299  // DEBUG
    330300  //cout << "TITLE = " << TITLE << endl ;
    331301  //
    332   strcpy( c16, str16.c_str() ) ;
    333   if ( readHeader( c16, 16 ) == -1 ) {
     302  OBJ.resize(16);
     303  if ( readHeader( STRING2CHAR(OBJ), 16 ) == -1 ) {
    334304    os << LogIO::WARN << "Error while reading data OBJ." << LogIO::POST ;
    335305    return -1 ;
    336306  }
    337   OBJ = string( c16 ) ;
    338307  // DEBUG
    339308  //cout << "OBJ = " << OBJ << endl ;
    340309  //
    341   strcpy( c8, str8.c_str() ) ;
    342   if ( readHeader( c8, 8 ) == -1 ) {
     310  EPOCH.resize(8);
     311  if ( readHeader( STRING2CHAR(EPOCH), 8 ) == -1 ) {
    343312    os << LogIO::WARN << "Error while reading data EPOCH." << LogIO::POST ;
    344313    return -1 ;
    345314  }
    346   EPOCH = string( c8 ) ;
    347315  // DEBUG
    348316  //cout << "EPOCH = " << EPOCH << endl ;
     
    390358  //cout << "SCNCD = " << SCNCD << endl ;
    391359  //
    392   strcpy( c120, str120.c_str() ) ;
    393   if ( readHeader( c120, 120 ) == -1 ) {
     360  SCMOD.resize(120);
     361  if ( readHeader( STRING2CHAR(SCMOD), 120 ) == -1 ) {
    394362    os << LogIO::WARN << "Error while reading data SCMOD." << LogIO::POST ;
    395363    return -1 ;
    396364  }
    397   SCMOD = string( c120 ) ;
    398365  // DEBUG
    399366  //cout << "SCMOD = " << SCMOD << endl ;
     
    406373  //cout << "URVEL = " << URVEL << endl ;
    407374  //
    408   strcpy( c4, str4.c_str() ) ;
    409   if ( readHeader( c4, 4 ) == -1 ) {
     375  VREF.resize(4);
     376  if ( readHeader( STRING2CHAR(VREF), 4 ) == -1 ) {
    410377    os << LogIO::WARN << "Error while reading data VREF." << LogIO::POST ;
    411378    return -1 ;
    412379  }
    413   VREF = string( c4 ) ;
    414380  // DEBUG
    415381  //cout << "VREF = " << VREF << endl ;
    416382  //
    417   strcpy( c4, str4.c_str() ) ;
    418   if ( readHeader( c4, 4 ) == -1 ) {
     383  VDEF.resize(4);
     384  if ( readHeader( STRING2CHAR(VDEF), 4 ) == -1 ) {
    419385    os << LogIO::WARN << "Error while reading data VDEF." << LogIO::POST ;
    420386    return -1 ;
    421387  }
    422   VDEF = string( c4 ) ;
    423388  // DEBUG
    424389  //cout << "VDEF = " << VDEF << endl ;
    425390  //
    426   strcpy( c8, str8.c_str() ) ;
    427   if ( readHeader( c8, 8 ) == -1 ) {
     391  SWMOD.resize(8);
     392  if ( readHeader( STRING2CHAR(SWMOD), 8 ) == -1 ) {
    428393    os << LogIO::WARN << "Error while reading data SWMOD." << LogIO::POST ;
    429394    return -1 ;
    430395  }
    431   SWMOD = string( c8 ) + "::OTF" ;
     396  SWMOD += "::OTF" ;
    432397  // DEBUG
    433398  //cout << "SWMOD = " << SWMOD << endl ;
     
    489454  //cout << "CMTI = " << CMTI << endl ;
    490455  //
    491   strcpy( c24, str24.c_str() ) ;
    492   if ( readHeader( c24, 24 ) == -1 ) {
     456  CMTTM.resize(24);
     457  if ( readHeader( STRING2CHAR(CMTTM), 24 ) == -1 ) {
    493458    os << LogIO::WARN << "Error while reading data CMTTM." << LogIO::POST ;
    494459    return -1 ;
    495460  }
    496   CMTTM = string( c24 ) ;
    497461  // DEBUG
    498462  //cout << "CMTTM = " << CMTTM << endl ;
     
    590554  //
    591555  for ( int i = 0 ; i < arymax ; i++ ) {
    592     strcpy( c18, str18.c_str() ) ;
    593     if ( readHeader( c18, 16 ) == -1 ) {
     556    RX[i].resize(16);
     557    if ( readHeader( STRING2CHAR(RX[i]), 16 ) == -1 ) {
    594558      os << LogIO::WARN << "Error while reading data RX[" << i << "]." << LogIO::POST ;
    595559      return -1 ;
    596560    }
    597     c18[16] = '\0' ;
    598     RX[i] = string( c18 ) ;
    599561  }
    600562  // DEBUG
     
    656618  //
    657619  for ( int i = 0 ; i < arymax ; i++) {
    658     strcpy( c4, str4.c_str() ) ;
    659     if ( readHeader( c4, 4 ) == -1 ) {
     620    HORN[i].resize(4);
     621    if ( readHeader( STRING2CHAR(HORN[i]), 4 ) == -1 ) {
    660622      os << LogIO::WARN << "Error while reading data HORN[" << i << "]." << LogIO::POST ;
    661623      return -1 ;
    662624    }
    663     HORN[i] = string( c4 ) ;
    664625  }
    665626  // DEBUG
     
    667628  //
    668629  for ( int i = 0 ; i < arymax ; i++) {
    669     strcpy( c4, str4.c_str() ) ;
    670     if ( readHeader( c4, 4 ) == -1 ) {
     630    POLTP[i].resize(4);
     631    if ( readHeader( STRING2CHAR(POLTP[i]), 4 ) == -1 ) {
    671632      os << LogIO::WARN << "Error while reading data POLTP[" << i << "]." << LogIO::POST ;
    672633      return -1 ;
    673634    }
    674     POLTP[i] = string( c4 ) ;
    675635  }
    676636  // DEBUG
     
    705665  //
    706666  for ( int i = 0 ; i < arymax ; i++) {
    707     strcpy( c4, str4.c_str() ) ;
    708     if ( readHeader( c4, 4 ) == -1 ) {
     667    SIDBD[i].resize(4);
     668    if ( readHeader( STRING2CHAR(SIDBD[i]), 4 ) == -1 ) {
    709669      os << LogIO::WARN << "Error while reading data SIDBD[" << i << "]." << LogIO::POST ;
    710670      return -1 ;
    711671    }
    712     SIDBD[i] = string( c4 ) ;
    713672  }
    714673  // DEBUG
     
    752711  //
    753712  for ( int i = 0 ; i < arymax ; i++) {
    754     strcpy( c8, str8.c_str() ) ;
    755     if ( readHeader( c8, 8 ) == -1 ) {
     713    LAGWIND[i].resize(8);
     714    if ( readHeader( STRING2CHAR(LAGWIND[i]), 8 ) == -1 ) {
    756715      os << LogIO::WARN << "Error while reading data LAGWIND[" << i << "]." << LogIO::POST ;
    757716      return -1 ;
    758717    }
    759     LAGWIND[i] = string( c8 ) ;
    760718  }
    761719  // DEBUG
     
    870828  //cout << "IBIT = " << IBIT << endl ;
    871829  //
    872   strcpy( c8, str8.c_str() ) ;
    873   if ( readHeader( c8, 8 ) == -1 ) {
     830  SITE.resize(8);
     831  if ( readHeader( STRING2CHAR(SITE), 8 ) == -1 ) {
    874832    os << LogIO::WARN << "Error while reading data SITE." << LogIO::POST ;
    875833    return -1 ;
    876834  }
    877   SITE = string( c8 ) ;
    878835  // DEBUG
    879836  //cout << "SITE = " << SITE << endl ;
  • trunk/external-alma/atnf/PKSIO/NROOTFDataset.cc

    r2783 r2785  
    3535#include <iostream>
    3636#include <cstring>
     37
     38#define STRING2CHAR(s) const_cast<char *>((s).c_str())
    3739
    3840using namespace std ;
     
    8082  LogIO os( LogOrigin( "NROOTFDataset", "fillHeader()", WHERE ) ) ;
    8183
    82   int arymax = arrayMax() ;
    83 
    84   string str256( 256, ' ' ) ;
    85   char c256[256] ;
    8684  // make sure file pointer points a beginning of the file
    8785  fseek( fp_, 0, SEEK_SET ) ;
     
    9088
    9189  // specific part
    92   strcpy( c256, str256.c_str() ) ;
    93   if ( readHeader( c256, 180 ) == -1 ) {
     90  CDMY1.resize(180);
     91  if ( readHeader( STRING2CHAR(CDMY1), 180 ) == -1 ) {
    9492    os << LogIO::WARN << "Error while reading data CDMY1." << LogIO::POST ;
    9593    return -1 ;
    9694  }
    97   c256[180] = '\0' ;
    98   CDMY1 = string( c256 ) ;
    9995  // DEBUG
    10096  //cout << "CDMY1 = " << CDMY1 << endl ;
Note: See TracChangeset for help on using the changeset viewer.