commit c1a783e568d634ca4830cbd87b2a1962eb3f3068
parent da3671d31b79a827f5c0581d56d55dfa6009ad31
Author: Michael Constantine Dimopoulos <mk@mcdim.xyz>
Date: Wed, 27 Oct 2021 20:15:53 +0000
Updated nlcean
Diffstat:
2 files changed, 46 insertions(+), 35 deletions(-)
diff --git a/clean/nclean.1 b/clean/nclean.1
@@ -1,6 +1,6 @@
.\" Manpage for nclean
-.TH man 8 "10 Oct 2021" "1.1" "nclean manual page"
+.TH man 8 "10 Oct 2021" "1.1.1" "nclean manual page"
.SH NAME
nclean \- Narthex cleaner
.SH SYNOPSIS
diff --git a/clean/nclean.c b/clean/nclean.c
@@ -1,17 +1,28 @@
/*
* nclean - Narthex cleaner
*
- * By Michael Constantine Dimopoulos
- * https://mcdim.xyz <mk@mcdim.xyz>
+ * By Michael Constantine Dimopoulos https://mcdim.xyz <mk@mcdim.xyz>
* License: GNU GPL v3
*
- * nclean will iterate over stdin and
- * print only the lines have met your
- * set criteria.
- * For example, it can print only
- * lines that have both a number and
- * a special character that are more
- * than six chars in length.
+ * nclean will iterate over stdin and print only the lines have met
+ * your set criteria. For example, it can print only lines that have
+ * both a number and a special character that are more than six chars
+ * in length.
+ *
+ * * * * * * * *
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
@@ -21,10 +32,10 @@
#include <ctype.h>
#include <unistd.h>
-#define VERSION "v1.1"
+#define VERSION "v1.1.1"
#define BUFFER_SIZE 256
-static void
+static inline void
usage(char *exename)
{
fprintf(stderr, "Usage: cat [FILENAME]"
@@ -50,15 +61,15 @@ help(char *exename)
exit(EXIT_SUCCESS);
}
-static void
-die(char * str)
+static inline void
+die(char *str)
{
printf("%s\n", str);
exit(EXIT_SUCCESS);
}
static int
-case_check(char * str)
+case_check(char *str)
{
for (int i = 0; str[i] != '\0'; i++) {
if (isupper(str[i]) != 0)
@@ -68,7 +79,7 @@ case_check(char * str)
}
static int
-numb_check(char * str)
+numb_check(char *str)
{
for (int i = 0; str[i] != '\0'; i++) {
if (isdigit(str[i]) != 0)
@@ -78,25 +89,25 @@ numb_check(char * str)
}
static int
-symb_check(char * str)
+symb_check(char *str)
{
for (int i = 0; str[i] != '\0'; i++) {
- if(str[i] == '!' || str[i] == '@' || str[i] == '#'
- || str[i] == '$' || str[i] == '%' || str[i] == '^'
- || str[i] == '&' || str[i] == '*' || str[i] == '('
- || str[i] == ')' || str[i] == '-' || str[i] == '{'
- || str[i] == '}' || str[i] == '[' || str[i] == ']'
- || str[i] == ':' || str[i] == ';' || str[i] == '"'
- || str[i] == '\''|| str[i] == '<' || str[i] == '>'
- || str[i] == '.' || str[i] == '/' || str[i] == '?'
- || str[i] == '~' || str[i] == '`' )
+ if (str[i] == '!' || str[i] == '@' || str[i] == '#'
+ || str[i] == '$' || str[i] == '%' || str[i] == '^'
+ || str[i] == '&' || str[i] == '*' || str[i] == '('
+ || str[i] == ')' || str[i] == '-' || str[i] == '{'
+ || str[i] == '}' || str[i] == '[' || str[i] == ']'
+ || str[i] == ':' || str[i] == ';' || str[i] == '"'
+ || str[i] == '\''|| str[i] == '<' || str[i] == '>'
+ || str[i] == '.' || str[i] == '/' || str[i] == '?'
+ || str[i] == '~' || str[i] == '`' )
return 1;
}
return 0;
}
-static int
-len_check(char * str, int len)
+static inline int
+len_check(char *str, int len)
{
return strlen(str) >= len ? 1 : 0;
}
@@ -105,7 +116,7 @@ static void
clean(FILE *f, int c, int n, int s, int l)
{
char buffer[BUFFER_SIZE];
- while(fgets(buffer, sizeof(buffer), f) != NULL) {
+ while (fgets(buffer, sizeof(buffer), f) != NULL) {
strtok(buffer, "\n");
int fc = 1, fn = 1, fs = 1, fl = 1;
@@ -116,24 +127,24 @@ clean(FILE *f, int c, int n, int s, int l)
/* for troubleshooting:
* printf("fc:%d\nfn:%d\nfs:%d\nfl:%d\n",fc, fn, fs, fl);
- * */
- if (fc==1 && fn==1 && fs==1 && fl==1) {
+ */
+
+ if (fc==1 && fn==1 && fs==1 && fl==1)
printf("%s\n",buffer);
- }
}
}
void
-main(int argc, char * argv[])
+main(int argc, char *argv[])
{
- int c1=0, n=0, s=0, l=0, lvalue=0;
+ int c1, n, s, l, lvalue;
+ c1 = n = s = l = lvalue = 0;
char *cvalue = NULL;
int index;
int c;
extern char *optarg;
int optind = 0;
-
while ( (c = getopt(argc, argv, "cnsvhl:")) != -1 ) {
switch (c) {
case 'v':