From 767a0d4f60c273cb65f6f269c072c3f2bb846c68 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 7 Oct 2010 09:58:35 -0400 Subject: [PATCH] some cleanup and fixes for 64-bit machines. --- txt2html/Makefile | 2 +- txt2html/txt2html.cpp | 30 ++++++++++++++---------------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/txt2html/Makefile b/txt2html/Makefile index 3786231f85..46fa5ffe97 100644 --- a/txt2html/Makefile +++ b/txt2html/Makefile @@ -1,7 +1,7 @@ # # -CXXFLAGS=-O +CXXFLAGS=-O2 -Wall -W txt2html: txt2html.cpp $(CXX) -o $@ $(CXXFLAGS) $^ diff --git a/txt2html/txt2html.cpp b/txt2html/txt2html.cpp index 21b4773d90..b08d1cd6c6 100644 --- a/txt2html/txt2html.cpp +++ b/txt2html/txt2html.cpp @@ -26,13 +26,13 @@ using namespace std; // function prototypes -int next_paragraph(FILE *fp, string ¶graph); -int index_of_first_char_of_last_word(string ¶graph); -void process_commands(int flag, string &s, string &pre, string &post); -void substitute(string &s); -string td_tag(int currentc); -int find_n(string &s, int nend, int &n1); -void file_open(int npair, string &infile, FILE **in, FILE **out); +static int next_paragraph(FILE *fp, string ¶graph); +static int index_of_first_char_of_last_word(string ¶graph); +static void process_commands(int flag, string &s, string &pre, string &post); +static void substitute(string &s); +static string td_tag(int currentc); +static long find_n(string &s, int nend, int &n1); +static void file_open(int npair, string &infile, FILE **in, FILE **out); // global variables for links, tables, lists, all command @@ -112,7 +112,7 @@ int main(int narg, char **arg) // read file one paragraph at a time // process commands, looking only for link definitions - while (style = next_paragraph(in,raw)) { + while ((style = next_paragraph(in,raw))) { if (style == 2) { int n = index_of_first_char_of_last_word(raw); @@ -139,10 +139,10 @@ int main(int narg, char **arg) // substitute text for each paragraph // write HTML to output file - while (style = next_paragraph(in,raw)) { + while ((style = next_paragraph(in,raw))) { n = raw.find("\\\n"); - while (n != string::npos) { + while (n < string::npos) { raw.erase(n,2); n = raw.find("\\\n"); } @@ -779,8 +779,6 @@ string td_tag(int currentc) { string DT; // dw is the width for tables. It is also the
tag beginning string dw; - int counter; - // set up alignment for particular columns @@ -842,13 +840,13 @@ string td_tag(int currentc) { // decide which is first // set n = to that position -int find_n(string &s, int nend, int &nsep) +long find_n(string &s, int nend, int &nsep) // nsep is position of the next separator. changes in here. { - int n; + long n; nsep = s.find(tabledelim,nend); - int n2 = s.find('\n',nend); - int m = s.length() - 1; + long n2 = s.find('\n',nend); + long m = s.length() - 1; if (nsep >= 0 && n2 >= 0) { if (nsep <= n2) n = nsep; else n = n2;