r379: no message
authorKevin M. Rosenberg <kevin@rosenberg.net>
Wed, 10 Jan 2001 21:22:25 +0000 (21:22 +0000)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Wed, 10 Jan 2001 21:22:25 +0000 (21:22 +0000)
ChangeLog
configure.in
libctsim/projections.cpp
libctsupport/syserror.cpp
tools/ctsimtext.cpp
tools/pjinfo.cpp

index 99761453d104134510644ab8f35650185a884491..b961d6861164078f47104a92deedf8f2b7f9d807 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,12 @@
-3.0.0alpha4
+3.0.0alpha5 - Released
+
+       * ctsimtext: Fixed bugs for MSVC and with empty input lines
+
+       * syserror.cpp: fixed reporting for fatal errors
+
+       * projections.cpp: fixed MSVC failure with std:: namespace
+       
+3.0.0alpha4 - Released 1/09/01
 
        * ctsim: Added reset to full-intensity scale menu item
 
 
        * ctsim: Added reset to full-intensity scale menu item
 
index d54cf75bcf2ce4e866ca86547d6ade3c476b1b6d..1843e6a9ac9d9ce8b04817f1350c0c26f0bbef18 100644 (file)
@@ -4,7 +4,7 @@ dnl Must reset CDPATH so that bash's cd does not print to stdout
 dnl CDPATH=
 
 AC_INIT(src/ctsim.cpp)
 dnl CDPATH=
 
 AC_INIT(src/ctsim.cpp)
-AM_INIT_AUTOMAKE(ctsim,3.0.0alpha4)
+AM_INIT_AUTOMAKE(ctsim,3.0.0alpha5)
 AM_CONFIG_HEADER(config.h)
 
 dnl Checks for programs.
 AM_CONFIG_HEADER(config.h)
 
 dnl Checks for programs.
index 846daf3f03ea8f9ef45f67acbe8bd2954f7376d0..e9a57282c6224f5716578b97a43a7e25cdd92cfd 100644 (file)
@@ -8,7 +8,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: projections.cpp,v 1.41 2001/01/07 23:18:13 kevin Exp $
+**  $Id: projections.cpp,v 1.42 2001/01/10 21:21:53 kevin Exp $
 **
 **  This program is free software; you can redistribute it and/or modify
 **  it under the terms of the GNU General Public License (version 2) as
 **
 **  This program is free software; you can redistribute it and/or modify
 **  it under the terms of the GNU General Public License (version 2) as
@@ -404,10 +404,16 @@ Projections::copyViewData (const std::string& filename, std::ostream& os, int st
 bool 
 Projections::copyViewData (const char* const filename, std::ostream& os, int startView, int endView)
 {
 bool 
 Projections::copyViewData (const char* const filename, std::ostream& os, int startView, int endView)
 {
-  frnetorderstream is (filename, ios::in | ios::binary);
+  frnetorderstream is (filename, std::ios::in | std::ios::binary);
   kuint16 sizeHeader, signature;
   kuint32 _nView, _nDet;
   
   kuint16 sizeHeader, signature;
   kuint32 _nView, _nDet;
   
+  is.seekg (0);
+  if (is.fail()) {
+    sys_error (ERR_SEVERE, "Unable to read projection file %s", filename);
+    return false;
+  }
+
   is.readInt16 (sizeHeader);
   is.readInt16 (signature);
   is.readInt32 (_nView);
   is.readInt16 (sizeHeader);
   is.readInt16 (signature);
   is.readInt32 (_nView);
@@ -416,7 +422,7 @@ Projections::copyViewData (const char* const filename, std::ostream& os, int sta
   int nDet = _nDet;
   
   if (signature != m_signature) {
   int nDet = _nDet;
   
   if (signature != m_signature) {
-    sys_error (ERR_FATAL, "Illegal signature in projection file %s", filename);
+    sys_error (ERR_SEVERE, "Illegal signature in projection file %s", filename);
     return false;
   }
   
     return false;
   }
   
@@ -446,9 +452,9 @@ Projections::copyViewData (const char* const filename, std::ostream& os, int sta
   
   delete pViewData;
   if (is.fail()) 
   
   delete pViewData;
   if (is.fail()) 
-    sys_error (ERR_FATAL, "Error reading projection file");
+    sys_error (ERR_SEVERE, "Error reading projection file");
   if (os.fail()) 
   if (os.fail()) 
-    sys_error (ERR_FATAL, "Error writing projection file");
+    sys_error (ERR_SEVERE, "Error writing projection file");
   
   return (! (is.fail() | os.fail()));
 }
   
   return (! (is.fail() | os.fail()));
 }
index f87b82eee3ef08d93d1a31c3699d1d55810c66ad..ee6980e0291779601b774ebda285b0a0807968e2 100644 (file)
@@ -2,7 +2,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: syserror.cpp,v 1.12 2001/01/02 16:02:13 kevin Exp $
+**  $Id: syserror.cpp,v 1.13 2001/01/10 21:21:53 kevin Exp $
 **
 **  This program is free software; you can redistribute it and/or modify
 **  it under the terms of the GNU General Public License (version 2) as
 **
 **  This program is free software; you can redistribute it and/or modify
 **  it under the terms of the GNU General Public License (version 2) as
@@ -115,8 +115,10 @@ void sys_verror (std::string& strOutput, int severity, const char *msg, va_list
   os << errStr << "\n";
   strOutput = os.str();
   
   os << errStr << "\n";
   strOutput = os.str();
   
-  if (severity == ERR_FATAL)
-    throw std::runtime_error (errStr);
+  if (severity == ERR_FATAL) {
+    std::cerr << strOutput;
+    throw std::runtime_error (strOutput); 
+  }
   
 #if INTERACTIVE_ERROR_DISPLAY
   std::cout << "A - Abort  C - Continue  W - Turn off warnings? ";
   
 #if INTERACTIVE_ERROR_DISPLAY
   std::cout << "A - Abort  C - Continue  W - Turn off warnings? ";
index 83d75b0d39d49f33ebe0a366d31dd33d3c200636..242689ab2468213dca5e5b11f015ade33a310dc3 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: ctsimtext.cpp,v 1.7 2001/01/10 21:02:41 kevin Exp $
+**  $Id: ctsimtext.cpp,v 1.8 2001/01/10 21:21:53 kevin Exp $
 **
 **  This program is free software; you can redistribute it and/or modify
 **  it under the terms of the GNU General Public License (version 2) as
 **
 **  This program is free software; you can redistribute it and/or modify
 **  it under the terms of the GNU General Public License (version 2) as
@@ -45,7 +45,7 @@ extern "C" {
 // If linked to ctsimtext, but executed as another name, eg pjrec, then program will use that
 // linked name as name of function.
 
 // If linked to ctsimtext, but executed as another name, eg pjrec, then program will use that
 // linked name as name of function.
 
-static const char* const g_szIdStr = "$Id: ctsimtext.cpp,v 1.7 2001/01/10 21:02:41 kevin Exp $";
+static const char* const g_szIdStr = "$Id: ctsimtext.cpp,v 1.8 2001/01/10 21:21:53 kevin Exp $";
 static const char* const s_szProgramName = "ctsimtext";
 
 extern int if1_main (int argc, char* const argv[]);
 static const char* const s_szProgramName = "ctsimtext";
 
 extern int if1_main (int argc, char* const argv[]);
@@ -98,14 +98,10 @@ interactive_usage ()
 
 static bool s_bInteractive = false;
 
 
 static bool s_bInteractive = false;
 
-
-#define DEBUG 1
-
 int 
 ctsimtext_main (int argc, char * argv[])
 {
 int 
 ctsimtext_main (int argc, char * argv[])
 {
-  int iReturn = 0;
-  
+  int iReturn = 0;  
   
   if (argc > 1 && strcmp(argv[0], fileBasename (s_szProgramName)) == 0) {
     argv = &argv[1];
   
   if (argc > 1 && strcmp(argv[0], fileBasename (s_szProgramName)) == 0) {
     argv = &argv[1];
@@ -132,7 +128,7 @@ ctsimtext_main (int argc, char * argv[])
       char* pszInputLine = new char [s_MaxLineLength+1];
       std::cout << szPrompt;
       std::cin.getline (pszInputLine, s_MaxLineLength);
       char* pszInputLine = new char [s_MaxLineLength+1];
       std::cout << szPrompt;
       std::cin.getline (pszInputLine, s_MaxLineLength);
-      
+
 #ifdef DEBUG
       std::cout << "#" << pszInputLine << "#\n";
 #endif
 #ifdef DEBUG
       std::cout << "#" << pszInputLine << "#\n";
 #endif
@@ -216,14 +212,20 @@ convertStringToArgcv (char* pszLine, int* piArgc, char*** pppArgv)
   }
   
   *piArgc = nTokens;
   }
   
   *piArgc = nTokens;
-  *pppArgv = new char* [nTokens];
-  for (unsigned int iToken = 0; iToken < vecpszToken.size(); iToken++)
-    (*pppArgv)[iToken] = vecpszToken[iToken];
+  if (nTokens > 0) {
+    *pppArgv = new char* [nTokens];
+    for (unsigned int iToken = 0; iToken < vecpszToken.size(); iToken++)
+      (*pppArgv)[iToken] = vecpszToken[iToken];
+  } else
+    *pppArgv = NULL;
 }
 
 static int 
 processCommand (int argc, char* const argv[])
 {
 }
 
 static int 
 processCommand (int argc, char* const argv[])
 {
+  if (argc < 1)
+    return 1;
+
   const char* const pszFunction = fileBasename (argv[0]);
   
   if (strcasecmp (pszFunction, "if1") == 0)
   const char* const pszFunction = fileBasename (argv[0]);
   
   if (strcasecmp (pszFunction, "if1") == 0)
index d5086b9bfe5601f9e01b7c6b7365b3288b6510cb..9be697f1ea3d0a1eafee7e517e62eb1ccef5ee8f 100644 (file)
@@ -9,7 +9,7 @@
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
 **  This is part of the CTSim program
 **  Copyright (C) 1983-2000 Kevin Rosenberg
 **
-**  $Id: pjinfo.cpp,v 1.4 2000/12/17 22:30:34 kevin Exp $
+**  $Id: pjinfo.cpp,v 1.5 2001/01/10 21:21:53 kevin Exp $
 **
 **  This program is free software; you can redistribute it and/or modify
 **  it under the terms of the GNU General Public License (version 2) as
 **
 **  This program is free software; you can redistribute it and/or modify
 **  it under the terms of the GNU General Public License (version 2) as
 ******************************************************************************/
 
 /* FILE
 ******************************************************************************/
 
 /* FILE
- *   pjinfo.c                  Convert Raysum to image
- *
- * DATE
- *   August 2000
- */
+*   pjinfo.c                   Convert Raysum to image
+*
+* DATE
+*   August 2000
+*/
 
 #include "ct.h"
 #include "timer.h"
 
 #include "ct.h"
 #include "timer.h"
@@ -50,7 +50,7 @@ static struct option my_options[] =
   {0, 0, 0, 0}
 };
 
   {0, 0, 0, 0}
 };
 
-static const char* g_szIdStr = "$Id: pjinfo.cpp,v 1.4 2000/12/17 22:30:34 kevin Exp $";
+static const char* g_szIdStr = "$Id: pjinfo.cpp,v 1.5 2001/01/10 21:21:53 kevin Exp $";
 
 void 
 pjinfo_usage (const char *program)
 
 void 
 pjinfo_usage (const char *program)
@@ -67,7 +67,7 @@ pjinfo_usage (const char *program)
   std::cout << "   --help          Print this help message\n";
 }
 
   std::cout << "   --help          Print this help message\n";
 }
 
-         
+
 
 int 
 pjinfo_main (const int argc, char *const argv[])
 
 int 
 pjinfo_main (const int argc, char *const argv[])
@@ -79,67 +79,67 @@ pjinfo_main (const int argc, char *const argv[])
   int optStartView = 0;
   int optEndView = -1;  // tells copyViewData to use default last view
   extern int optind;
   int optStartView = 0;
   int optEndView = -1;  // tells copyViewData to use default last view
   extern int optind;
-
+  
   while (1)
   while (1)
+  {
+    char *endptr, *endstr;
+    int c = getopt_long (argc, argv, "", my_options, NULL);
+    if (c == -1)
+      break;
+    
+    switch (c)
     {
     {
-      char *endptr, *endstr;
-      int c = getopt_long (argc, argv, "", my_options, NULL);
-      if (c == -1)
-       break;
-      
-      switch (c)
-       {
-       case O_DUMP:
-         optDump = true;
-         break;
-        case O_BINARYHEADER:
-           optBinaryHeader = true;
-           break;
-        case O_BINARYVIEWS:
-           optBinaryViews = true;
-           break;
-       case O_STARTVIEW:
-         optStartView = strtol(optarg, &endptr, 10);
-         endstr = optarg + strlen(optarg);
-         if (endptr != endstr) {
-                 std::cerr << "Error setting --startview to %s" << optarg << std::endl;
-           pjinfo_usage(argv[0]);
-           return (1);
-         }
-         break;
-       case O_ENDVIEW:
-         optEndView = strtol(optarg, &endptr, 10);
-         endstr = optarg + strlen(optarg);
-         if (endptr != endstr) {
-                 std::cerr << "Error setting --endview to %s" << optarg << std::endl;
-           pjinfo_usage(argv[0]);
-           return (1);
-         }
-         break;
-        case O_VERSION:
+    case O_DUMP:
+      optDump = true;
+      break;
+    case O_BINARYHEADER:
+      optBinaryHeader = true;
+      break;
+    case O_BINARYVIEWS:
+      optBinaryViews = true;
+      break;
+    case O_STARTVIEW:
+      optStartView = strtol(optarg, &endptr, 10);
+      endstr = optarg + strlen(optarg);
+      if (endptr != endstr) {
+        std::cerr << "Error setting --startview to %s" << optarg << std::endl;
+        pjinfo_usage(argv[0]);
+        return (1);
+      }
+      break;
+    case O_ENDVIEW:
+      optEndView = strtol(optarg, &endptr, 10);
+      endstr = optarg + strlen(optarg);
+      if (endptr != endstr) {
+        std::cerr << "Error setting --endview to %s" << optarg << std::endl;
+        pjinfo_usage(argv[0]);
+        return (1);
+      }
+      break;
+    case O_VERSION:
 #ifdef VERSION
 #ifdef VERSION
-         std::cout << "Version " << VERSION << std::endl << g_szIdStr << std::endl;
+      std::cout << "Version " << VERSION << std::endl << g_szIdStr << std::endl;
 #else
 #else
-          std::cout << "Unknown version number\n";
+      std::cout << "Unknown version number\n";
 #endif
 #endif
-         return (0);
-       case O_HELP:
-       case '?':
-         pjinfo_usage(argv[0]);
-         return (0);
-       default:
-         pjinfo_usage(argv[0]);
-         return (1);
-       }
+      return (0);
+    case O_HELP:
+    case '?':
+      pjinfo_usage(argv[0]);
+      return (0);
+    default:
+      pjinfo_usage(argv[0]);
+      return (1);
     }
     }
+  }
   
   if (argc - optind != 1) {
     pjinfo_usage(argv[0]);
     return (1);
   }
   
   if (argc - optind != 1) {
     pjinfo_usage(argv[0]);
     return (1);
   }
-
+  
   pj_name = argv[optind];
   pj_name = argv[optind];
-
+  
   if (optBinaryHeader)
     Projections::copyHeader (pj_name, std::cout);
   else if (optBinaryViews)
   if (optBinaryHeader)
     Projections::copyHeader (pj_name, std::cout);
   else if (optBinaryViews)
@@ -150,7 +150,7 @@ pjinfo_main (const int argc, char *const argv[])
       sys_error (ERR_SEVERE, "Can not open projection file %s", pj_name.c_str());
       return (1);
     }
       sys_error (ERR_SEVERE, "Can not open projection file %s", pj_name.c_str());
       return (1);
     }
-
+    
     if (optDump) {
       pj.printProjectionData (optStartView, optEndView);
     } else {
     if (optDump) {
       pj.printProjectionData (optStartView, optEndView);
     } else {
@@ -169,15 +169,15 @@ int
 main (const int argc, char *const argv[])
 {
   int retval = 1;
 main (const int argc, char *const argv[])
 {
   int retval = 1;
-
+  
   try {
     retval = pjinfo_main(argc, argv);
   } catch (exception e) {
   try {
     retval = pjinfo_main(argc, argv);
   } catch (exception e) {
-         std::cerr << "Exception: " << e.what() << std::endl;
+    std::cerr << "Exception: " << e.what() << std::endl;
   } catch (...) {
   } catch (...) {
-         std::cerr << "Unknown exception\n";
+    std::cerr << "Unknown exception\n";
   }
   }
-
+  
   return (retval);
 }
 #endif
   return (retval);
 }
 #endif