diff --git a/hw2/src/main.c b/hw2/src/main.c index b64bf90..7125c48 100644 --- a/hw2/src/main.c +++ b/hw2/src/main.c @@ -3,5 +3,5 @@ extern int original_main(int argc, const char *const *argv); int main(int argc, const char *const *argv) { - original_main(argc, argv); + return original_main(argc, argv); } diff --git a/hw2/src/par.c b/hw2/src/par.c index d2e0043..06026f2 100644 --- a/hw2/src/par.c +++ b/hw2/src/par.c @@ -213,6 +213,7 @@ static void setdefaults( numlines = line - inlines; if (*pprefix < 0) + { if (numlines <= *phang + 1) *pprefix = 0; else { @@ -224,8 +225,10 @@ static void setdefaults( } *pprefix = end - start; } + } if (*psuffix < 0) + { if (numlines <= 1) *psuffix = 0; else { @@ -241,6 +244,7 @@ static void setdefaults( while (end - start >= 2 && isspace(*start) && isspace(start[1])) ++start; *psuffix = end - start; } + } } @@ -257,7 +261,7 @@ static void freelines(char **lines) } -main(int argc, const char * const *argv) +int original_main(int argc, const char * const *argv) { int width, widthbak = -1, prefix, prefixbak = -1, suffix, suffixbak = -1, hang, hangbak = -1, last, lastbak = -1, min, minbak = -1, c; @@ -333,8 +337,8 @@ parcleanup: if (*errmsg) { fprintf(stderr, "%.163s", errmsg); - exit(EXIT_FAILURE); + return(EXIT_FAILURE); } - exit(EXIT_SUCCESS); + return(EXIT_SUCCESS); } diff --git a/hw2/src/reformat.c b/hw2/src/reformat.c index eaf479c..c604a8b 100644 --- a/hw2/src/reformat.c +++ b/hw2/src/reformat.c @@ -12,6 +12,7 @@ #include "buffer.h" /* Also includes . */ #include "errmsg.h" +#include #include #include #include @@ -192,7 +193,7 @@ char **reformat(const char * const *inlines, int width, for (end = *line; *end; ++end); if (end - *line < affix) { sprintf(errmsg, - "Line %d shorter than + = %d + %d = %d\n", + "Line %ld shorter than + = %d + %d = %d\n", line - inlines + 1, prefix, suffix, affix); goto rfcleanup; }