summaryrefslogtreecommitdiff
path: root/utilities/genbookutil.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'utilities/genbookutil.cpp')
-rw-r--r--utilities/genbookutil.cpp44
1 files changed, 15 insertions, 29 deletions
diff --git a/utilities/genbookutil.cpp b/utilities/genbookutil.cpp
index d547008..24fa4e0 100644
--- a/utilities/genbookutil.cpp
+++ b/utilities/genbookutil.cpp
@@ -2,7 +2,7 @@
*
* genbookutil.cpp -
*
- * $Id: genbookutil.cpp 2833 2013-06-29 06:40:28Z chrislit $
+ * $Id: genbookutil.cpp 3063 2014-03-04 13:04:11Z chrislit $
*
* Copyright 2002-2013 CrossWire Bible Society (http://www.crosswire.org)
* CrossWire Bible Society
@@ -58,11 +58,9 @@ void printLocalName(TreeKeyIdx *treeKey) {
void setLocalName(TreeKeyIdx *treeKey) {
- char buf[1023], *c;
+ char buf[1023];
std::cout << "Enter New Node Name: ";
- c = fgets(buf, 1000, stdin);
- if (c == NULL)
- std::cerr << "ERROR: fgets failed in setLocalName\n";
+ fgets(buf, 1000, stdin);
SWBuf name = buf;
treeKey->setLocalName(name.trim());
treeKey->save();
@@ -70,22 +68,18 @@ void setLocalName(TreeKeyIdx *treeKey) {
void gotoPath(TreeKeyIdx *treeKey) {
- char buf[1023], *c;
+ char buf[1023];
std::cout << "Enter Path: ";
- c = fgets(buf, 1000, stdin);
- if (c == NULL)
- std::cerr << "ERROR: fgets failed in gotoPath\n";
+ fgets(buf, 1000, stdin);
SWBuf path = buf;
(*treeKey) = path.trim();
}
void assurePath(TreeKeyIdx *treeKey) {
- char buf[1023], *c;
+ char buf[1023];
std::cout << "Enter Path: ";
- c = fgets(buf, 1000, stdin);
- if (c == NULL)
- std::cerr << "ERROR: fgets failed in assurePath\n";
+ fgets(buf, 1000, stdin);
SWBuf path = buf;
treeKey->assureKeyPath(path.trim());
}
@@ -102,12 +96,10 @@ void setEntryText(RawGenBook *book) {
SWBuf body;
TreeKeyIdx *treeKey = (TreeKeyIdx *)(SWKey *)(*book);
if (treeKey->getOffset()) {
- char buf[1023], *c;
+ char buf[1023];
std::cout << "Enter New Entry Text ('.' on a line by itself to end): \n";
do {
- c = fgets(buf, 1000, stdin);
- if (c == NULL)
- std::cerr << "ERROR: fgets failed in setEntryText\n";
+ fgets(buf, 1000, stdin);
SWBuf text = buf;
text.trim();
if ((text[0] == '.') && (text[1] == 0))
@@ -124,11 +116,9 @@ void setEntryText(RawGenBook *book) {
void appendSibbling(TreeKeyIdx *treeKey) {
if (treeKey->getOffset()) {
- char buf[1023], *c;
+ char buf[1023];
std::cout << "Enter New Sibbling Name: ";
- c = fgets(buf, 1000, stdin);
- if (c == NULL)
- std::cerr << "ERROR: fgets failed in appendSibbling\n";
+ fgets(buf, 1000, stdin);
SWBuf name = buf;
treeKey->append();
treeKey->setLocalName(name.trim());
@@ -139,11 +129,9 @@ void appendSibbling(TreeKeyIdx *treeKey) {
void appendChild(TreeKeyIdx *treeKey) {
- char buf[1023], *c;
+ char buf[1023];
std::cout << "Enter New Child Name: ";
- c = fgets(buf, 1000, stdin);
- if (c == NULL)
- std::cerr << "ERROR: fgets failed in appendChild\n";
+ fgets(buf, 1000, stdin);
SWBuf name = buf;
treeKey->appendChild();
treeKey->setLocalName(name.trim());
@@ -185,13 +173,11 @@ int main(int argc, char **argv) {
treeKey = (TreeKeyIdx *)(SWKey *)(*book);
SWBuf input;
- char line[1024], *c;
+ char line[1024];
do {
std::cout << "[" << treeKey->getText() << "] > ";
- c = fgets(line, 1000, stdin);
- if (c == NULL)
- std::cerr << "ERROR: fgets failed in main\n";
+ fgets(line, 1000, stdin);
input = line;
input.trim();
if (input.length() > 0) {