Commit 50d2c434 authored by Seth Price's avatar Seth Price

Allow zero-length ejaculation distance

Also, update version to 1.3
parent 6d6db0ba
......@@ -19,6 +19,11 @@ static char *repeat_char(const char ch, unsigned int count)
{
char *ret;
if (count == 0) {
ret = "\0";
return ret;
}
ret = malloc(count + 1);
strncpy(ret, &ch, 1);
......
......@@ -86,7 +86,7 @@ int main(int argc, char *argv[])
options.error_code = ERR_BIGUINT;
options.error_char = 'e';
goto BREAK_FROM_GETOPT;
} else if (strtol_tmp < 1) {
} else if (strtol_tmp < 0) {
options.error_code = ERR_NOTINT;
options.error_char = 'e';
goto BREAK_FROM_GETOPT;
......@@ -145,6 +145,11 @@ int main(int argc, char *argv[])
"must be a positive integer\n",
options.error_char);
return EX_USAGE;
case ERR_NOTINTORZERO:
fprintf(stderr, "Error: argument to option `-%c' "
"must be zero or a positive integer\n",
options.error_char);
return EX_USAGE;
case ERR_BIGUINT:
fprintf(stderr, "Error: argument to option `-%c' "
"is too large (above `UINT_MAX').\n",
......
......@@ -17,11 +17,12 @@ enum OPTIONS_E {
};
enum OPTIONS_ERROR_E {
ERR_OK = 0,
ERR_NOARG = 1,
ERR_NOTINT = 2,
ERR_UNKNOWNCHAR = 3,
ERR_BIGUINT = 4
ERR_OK = 0,
ERR_NOARG = 1,
ERR_NOTINT = 2,
ERR_UNKNOWNCHAR = 3,
ERR_BIGUINT = 4,
ERR_NOTINTORZERO = 5
};
struct OPTIONS_S {
......
......@@ -9,7 +9,7 @@
#define VP_STRINGS_H
#define VP_PROGRAM_NAME "varlpenis"
#define VP_VERSION_STR "1.2"
#define VP_VERSION_STR "1.3"
#define VP_PROGRAM_DESC "Generate an ASCII-art penis of arbitrary length"
#define VP_COPYRIGHT "Copyright 2019 Seth Price. See LICENSE file for details"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment