summaryrefslogtreecommitdiffstatshomepage
path: root/src/tools/nltool.c
diff options
context:
space:
mode:
author couriersud <couriersud@arcor.de>2015-08-04 21:55:52 +0200
committer couriersud <couriersud@arcor.de>2015-08-10 22:35:18 +0200
commit7b15a99c4b9ee44264a4cb9d719dc0ef3736ce85 (patch)
treebba87cd9c5012cb4871d1649ba7b4f6de0e023c3 /src/tools/nltool.c
parentd6b1cf85c55592f2c1a276b9fd42dfbd639511aa (diff)
utf8 support for pstring. Opted for a scalable solution which should be
easily extensible to utf16 and utf32 as well. All position related operations now operate on char code positions instead of byte positions. [Couriersud]
Diffstat (limited to 'src/tools/nltool.c')
-rw-r--r--src/tools/nltool.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/tools/nltool.c b/src/tools/nltool.c
index a13d7dd183c..0d34eb9d1ae 100644
--- a/src/tools/nltool.c
+++ b/src/tools/nltool.c
@@ -155,7 +155,7 @@ pstring filetobuf(pstring fname)
else
{
FILE *f;
- f = fopen(fname, "rb");
+ f = fopen(fname.cstr(), "rb");
fseek(f, 0, SEEK_END);
long fsize = ftell(f);
fseek(f, 0, SEEK_SET);
@@ -267,11 +267,8 @@ void usage(tool_options_t &opts)
struct input_t
{
- netlist::netlist_time m_time;
- netlist::param_t *m_param;
- double m_value;
-
input_t()
+ : m_param(NULL), m_value(0.0)
{
}
input_t(netlist::netlist_t *netlist, const pstring &line)
@@ -303,6 +300,11 @@ struct input_t
break;
}
}
+
+ netlist::netlist_time m_time;
+ netlist::param_t *m_param;
+ double m_value;
+
};
plist_t<input_t> *read_input(netlist::netlist_t *netlist, pstring fname)
@@ -311,14 +313,15 @@ plist_t<input_t> *read_input(netlist::netlist_t *netlist, pstring fname)
if (fname != "")
{
pifilestream f(fname);
- do {
- pstring l = f.readline();
+ pstring l;
+ while (f.readline(l))
+ {
if (l != "")
{
input_t inp(netlist, l);
ret->add(inp);
}
- } while (!f.eof());
+ }
}
return ret;
}