From 5ff5b33a6bc64fb804106c4d50b83e4cf0d7b0f4 Mon Sep 17 00:00:00 2001 From: "Kevin M. Rosenberg" Date: Wed, 10 Jan 2001 21:22:25 +0000 Subject: [PATCH] r379: no message --- ChangeLog | 10 ++- configure.in | 2 +- libctsim/projections.cpp | 16 +++-- libctsupport/syserror.cpp | 8 ++- tools/ctsimtext.cpp | 24 ++++---- tools/pjinfo.cpp | 124 +++++++++++++++++++------------------- 6 files changed, 101 insertions(+), 83 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9976145..b961d68 100644 --- 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 diff --git a/configure.in b/configure.in index d54cf75..1843e6a 100644 --- a/configure.in +++ b/configure.in @@ -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) -AM_INIT_AUTOMAKE(ctsim,3.0.0alpha4) +AM_INIT_AUTOMAKE(ctsim,3.0.0alpha5) AM_CONFIG_HEADER(config.h) dnl Checks for programs. diff --git a/libctsim/projections.cpp b/libctsim/projections.cpp index 846daf3..e9a5728 100644 --- a/libctsim/projections.cpp +++ b/libctsim/projections.cpp @@ -8,7 +8,7 @@ ** 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 @@ -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) { - frnetorderstream is (filename, ios::in | ios::binary); + frnetorderstream is (filename, std::ios::in | std::ios::binary); 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); @@ -416,7 +422,7 @@ Projections::copyViewData (const char* const filename, std::ostream& os, int sta 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; } @@ -446,9 +452,9 @@ Projections::copyViewData (const char* const filename, std::ostream& os, int sta delete pViewData; if (is.fail()) - sys_error (ERR_FATAL, "Error reading projection file"); + sys_error (ERR_SEVERE, "Error reading projection file"); if (os.fail()) - sys_error (ERR_FATAL, "Error writing projection file"); + sys_error (ERR_SEVERE, "Error writing projection file"); return (! (is.fail() | os.fail())); } diff --git a/libctsupport/syserror.cpp b/libctsupport/syserror.cpp index f87b82e..ee6980e 100644 --- a/libctsupport/syserror.cpp +++ b/libctsupport/syserror.cpp @@ -2,7 +2,7 @@ ** 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 @@ -115,8 +115,10 @@ void sys_verror (std::string& strOutput, int severity, const char *msg, va_list 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? "; diff --git a/tools/ctsimtext.cpp b/tools/ctsimtext.cpp index 83d75b0..242689a 100644 --- a/tools/ctsimtext.cpp +++ b/tools/ctsimtext.cpp @@ -9,7 +9,7 @@ ** 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 @@ -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. -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[]); @@ -98,14 +98,10 @@ interactive_usage () static bool s_bInteractive = false; - -#define DEBUG 1 - 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]; @@ -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); - + #ifdef DEBUG std::cout << "#" << pszInputLine << "#\n"; #endif @@ -216,14 +212,20 @@ convertStringToArgcv (char* pszLine, int* piArgc, char*** pppArgv) } *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[]) { + if (argc < 1) + return 1; + const char* const pszFunction = fileBasename (argv[0]); if (strcasecmp (pszFunction, "if1") == 0) diff --git a/tools/pjinfo.cpp b/tools/pjinfo.cpp index d5086b9..9be697f 100644 --- a/tools/pjinfo.cpp +++ b/tools/pjinfo.cpp @@ -9,7 +9,7 @@ ** 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 @@ -26,11 +26,11 @@ ******************************************************************************/ /* 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" @@ -50,7 +50,7 @@ static struct option my_options[] = {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) @@ -67,7 +67,7 @@ pjinfo_usage (const char *program) std::cout << " --help Print this help message\n"; } - + 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; - + 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 - std::cout << "Version " << VERSION << std::endl << g_szIdStr << std::endl; + std::cout << "Version " << VERSION << std::endl << g_szIdStr << std::endl; #else - std::cout << "Unknown version number\n"; + std::cout << "Unknown version number\n"; #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); } - + pj_name = argv[optind]; - + 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); } - + if (optDump) { pj.printProjectionData (optStartView, optEndView); } else { @@ -169,15 +169,15 @@ int main (const int argc, char *const argv[]) { int retval = 1; - + try { retval = pjinfo_main(argc, argv); } catch (exception e) { - std::cerr << "Exception: " << e.what() << std::endl; + std::cerr << "Exception: " << e.what() << std::endl; } catch (...) { - std::cerr << "Unknown exception\n"; + std::cerr << "Unknown exception\n"; } - + return (retval); } #endif -- 2.34.1