fix 2 compiler warnings in modelgen
[gnucap-felix.git] / lib / m_base_in.cc
blob15cb5992ad4acf67c43ce37fa554b2bc1d0987be
1 /*$Id: m_base_in.cc,v 1.2 2009-11-18 20:53:18 felix Exp $ -*- C++ -*-
2 * Copyright (C) 2003 Albert Davis
3 * Author: Albert Davis <aldavis@gnu.org>
5 * This file is part of "Gnucap", the Gnu Circuit Analysis Package
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3, or (at your option)
10 * any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 * 02110-1301, USA.
21 *------------------------------------------------------------------
23 //testing=script,sparse 2009.08.13
24 #include "m_base.h"
25 /*--------------------------------------------------------------------------*/
26 void Float::parse(CS& File)
28 if (File >> "NA") {
29 _data = NOT_INPUT;
30 }else{
31 unsigned here = File.cursor();
32 File >> _data;
33 if (File.stuck(&here)) {untested();
34 _data = NOT_INPUT;
35 }else{
39 /*--------------------------------------------------------------------------*/
40 void Name_String::parse(CS& File)
42 File.skipbl();
43 _data = "";
44 if (File.is_pfloat()) {
45 while (File.is_pfloat()) {
46 _data += File.ctoc();
48 if (File.match1("eE")) {
49 _data += File.ctoc();
50 if (File.match1("+-")) {
51 _data += File.ctoc();
52 }else{
54 while (File.is_digit()) {
55 _data += File.ctoc();
57 }else{
59 while (File.is_alpha()) {
60 _data += File.ctoc();
62 }else{
63 while (File.is_alpha() || File.is_pfloat() || File.match1("_[]")) {
64 _data += File.ctoc();
67 File.skipbl();
69 /*--------------------------------------------------------------------------*/
70 void Quoted_String::parse(CS& File)
71 {untested();
72 File.skipbl();
73 unsigned here = File.cursor();
74 char quote = File.ctoc();
75 _data = "";
76 for (;;) {untested();
77 if (File.skip1(quote)) {untested();
78 break;
79 }else if (!File.more()) {untested();
80 File.warn(0, "end of file in quoted string");
81 File.warn(0, here, "string begins here");
82 break;
83 }else{untested();
84 _data += File.ctoc();
87 File.skipbl();
89 /*--------------------------------------------------------------------------*/
90 void Tail_String::parse(CS& File)
91 {untested(); // c_str
92 static char end_marks[] = "\n";
94 const char* begin = File.tail().c_str();
95 File.skipto1(end_marks);
96 const char* end = File.tail().c_str();
97 assert(end >= begin);
99 while ((--end >= begin) && (isspace(*end))) {untested();
101 ++end;
102 assert(end >= begin);
104 _data = std::string(begin, static_cast<size_t>(end-begin));
106 /*--------------------------------------------------------------------------*/
107 #if 0
108 void Text_Block::parse(CS& File)
109 {untested(); // c_str
110 const char* begin = File.tail().c_str();
111 for (;;) {untested();
112 File.skipto1("\n").skip();
113 if (File.peek() == '[') {untested();
114 break;
115 }else{untested();
118 const char* end = File.tail().c_str();
119 _data = std::string(begin, static_cast<size_t>(end-begin));
121 #endif
122 /*--------------------------------------------------------------------------*/
123 /*--------------------------------------------------------------------------*/
124 // vim:ts=8:sw=2:noet: