-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1169968
commit 2520e61
Showing
13 changed files
with
159 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
.\" Manpage for ncom | ||
|
||
.TH man 8 "26 Jul 2021" "1.0" "ncom manual page" | ||
.SH NAME | ||
ncom \- Narthex combinator | ||
.SH SYNOPSIS | ||
cat dictionary.txt | ncom [OPTIONS] > output.txt | ||
.SH DESCRIPTION | ||
ncom iterates over stdin and after printing the dictionary as is, it will print it again but will also append every line of stdin to each iteration creating, that way, a list of combinations (pairs) of the lines. | ||
|
||
.SH OPTIONS | ||
-d use dot separator | ||
|
||
-u use underscore separator | ||
|
||
-m use hyphen separator | ||
|
||
-n exclude numerical bases, so if the base is '2002' and the part to be appended is 'word', the operation will not be executed. | ||
|
||
-b do not operate when the base is the same with the appended part | ||
|
||
-v print version and exit | ||
|
||
-h print help panel and exit | ||
|
||
.SH AUTHOR | ||
Michael Constantine Dimopoulos <[email protected]> | ||
|
||
https://mcdim.xyz | ||
|
||
.SH LICENSE | ||
GNU Public License 3.0 (GPL-3.0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,14 +5,26 @@ | |
#include <ctype.h> | ||
|
||
/* | ||
* Ncom - Narthex combinator (?) | ||
* ncom - Narthex combinator (?) | ||
* | ||
* By Michael Constantine Dimopoulos | ||
* https://mcdim.xyz <[email protected]> | ||
* License: GNU GPL v3 | ||
* | ||
* Currently under development | ||
* :) | ||
* ncom iterates over stdin and after | ||
* printing the dictionary as is, it will | ||
* print it again but will also append | ||
* every line of stdin to each iteration | ||
* creating, that way, a list of combi- | ||
* nations (pairs) of the lines. | ||
* | ||
* By default, it will append when the | ||
* base is the same as the appended part | ||
* (i.e wordword), but that can be | ||
* switched off with the -b flag. It | ||
* can also use other separators, such | ||
* as a hyphen or a dot, all with their | ||
* own flags. | ||
* | ||
*/ | ||
|
||
|
@@ -27,7 +39,6 @@ save_stdin(FILE *f) | |
while(fgets(buffer, sizeof(buffer), f) != NULL) { | ||
fprintf(f2, "%s", buffer); | ||
} | ||
fclose(f); | ||
return f2; | ||
} | ||
|
||
|
@@ -42,7 +53,7 @@ isnumber(char * str) | |
} | ||
|
||
static void | ||
com(FILE *f2, FILE *f3, int d, int u, int m, int n) | ||
com(FILE *f2, FILE *f3, int d, int u, int m, int n, int b) | ||
{ | ||
char buffer[BUFFER_SIZE]; | ||
char buffer2[BUFFER_SIZE]; | ||
|
@@ -51,10 +62,12 @@ com(FILE *f2, FILE *f3, int d, int u, int m, int n) | |
while (fgets(buffer2, sizeof(buffer2), f3) != NULL) { | ||
strtok(buffer2, "\n"); | ||
if ((n == 0 && isnumber(buffer) == 0) || n == 1) { | ||
printf("%s%s\n", buffer, buffer2); | ||
if (d == 1) printf("%s%s%s\n", buffer, ".", buffer2); | ||
if (m == 1) printf("%s%s%s\n", buffer, "-", buffer2); | ||
if (u == 1) printf("%s%s%s\n", buffer, "-", buffer2); | ||
if ((b == 1 && strcmp(buffer,buffer2) != 0) || b == 0) { | ||
printf("%s%s\n", buffer, buffer2); | ||
if (d == 1) printf("%s%s%s\n", buffer, ".", buffer2); | ||
if (m == 1) printf("%s%s%s\n", buffer, "-", buffer2); | ||
if (u == 1) printf("%s%s%s\n", buffer, "-", buffer2); | ||
} | ||
} | ||
} | ||
rewind(f3); | ||
|
@@ -73,13 +86,14 @@ print_only(FILE *f) | |
static void | ||
help(char * exename) | ||
{ | ||
printf( "Ninc - Narthex incrementor %s\n" | ||
printf( "ncom - Narthex combinator %s\n" | ||
"By Michael C. Dim. <[email protected]>\n\n" | ||
|
||
"-d Use dot separator\n" | ||
"-u Use underscore separator\n" | ||
"-m Use hyphen separator\n" | ||
"-n Exclude numerical bases\n" | ||
"-b Exclude base-appended\n" | ||
"-h Print this panel & exit\n" | ||
"-v Print current version & exit\n\n" | ||
|
||
|
@@ -98,14 +112,14 @@ die(char * str) | |
void | ||
main(int argc, char * argv[]) | ||
{ | ||
int d=0, u=0, m=0, n=1; | ||
int d=0, u=0, m=0, b=0, n=1; | ||
char *cvalue = NULL; | ||
int index; | ||
int c; | ||
|
||
opterr = 0; | ||
|
||
while ( (c = getopt (argc, argv, "dumnvhh:")) != -1 ) | ||
while ( (c = getopt(argc, argv, "dumnvbhh:")) != -1 ) | ||
switch (c) { | ||
case 'v': | ||
die(VERSION); | ||
|
@@ -123,10 +137,15 @@ main(int argc, char * argv[]) | |
case 'n': | ||
n=1; | ||
break; | ||
case 'b': | ||
b=1; | ||
break; | ||
case '?': | ||
fprintf (stderr, "Unknown option `\\x%x'.\n", optopt); | ||
exit(EXIT_FAILURE); | ||
/*fprintf (stderr, "Unknown option `%c`\n", c); | ||
exit(EXIT_FAILURE);*/ | ||
break; | ||
} | ||
|
||
FILE * f2, * f3; | ||
f2 = save_stdin(stdin); | ||
rewind(f2); | ||
|
@@ -136,7 +155,7 @@ main(int argc, char * argv[]) | |
print_only(f2); | ||
rewind(f2); | ||
rewind(f3); | ||
com(f2, f3, d, u, m, n); | ||
com(f2, f3, d, u, m, n, b); | ||
|
||
fclose(f2); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,12 +5,20 @@ | |
#include <string.h> | ||
|
||
/* | ||
* Nhance - Narthex enhancer | ||
* nhance - Narthex enhancer | ||
* | ||
* By Michael Constantine Dimopoulos | ||
* https://mcdim.xyz <[email protected]> | ||
* License: GNU GPL v3 | ||
* | ||
* | ||
* nhance iterates over stdin and, | ||
* after printing the dictionary as | ||
* is, it will reprint it this time | ||
* with the first letter capitalized. | ||
* It can also append full capitali- | ||
* zations at the end of the dictio- | ||
* nary with the -f flag. | ||
* | ||
*/ | ||
|
||
|
||
|
@@ -76,7 +84,7 @@ die(char * str) | |
static void | ||
help(char * exename) | ||
{ | ||
printf( "Nhance - Narthex enhancer %s\n" | ||
printf( "nhance - Narthex enhancer %s\n" | ||
"By Michael C. Dim. <[email protected]>\n\n" | ||
|
||
"-f Append full capitalization\n" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,17 +4,40 @@ | |
#include <ctype.h> | ||
|
||
/* | ||
* Ninc - Narthex incrementor | ||
* ninc - Narthex incrementor | ||
* | ||
* By Michael Constantine Dimopoulos | ||
* https://mcdim.xyz <[email protected]> | ||
* License: GNU GPL v3 | ||
* | ||
* ninc will iterate over stdin and | ||
* after printing the dictionary as | ||
* is, it will reprint it but will | ||
* also multiply each line with the | ||
* difference of max-min, and will | ||
* append n to each line, where n is | ||
* increased after every line from | ||
* min to max inclusive. (I know, I | ||
* know. Just try to use it and it | ||
* will make more sense). | ||
* | ||
*/ | ||
|
||
#define VERSION "v1.0" | ||
#define BUFFER_SIZE 256 | ||
|
||
FILE * | ||
save_stdin(FILE *f) | ||
{ | ||
FILE *f2 = tmpfile(); | ||
char buffer[BUFFER_SIZE]; | ||
while(fgets(buffer, sizeof(buffer), f) != NULL) { | ||
fprintf(f2, "%s", buffer); | ||
} | ||
fclose(f); | ||
return f2; | ||
} | ||
|
||
static int | ||
isnumber(char * str) | ||
{ | ||
|
@@ -31,7 +54,6 @@ ninc(FILE *f, int min, int max, int numerical) | |
char buffer[BUFFER_SIZE]; | ||
while (fgets(buffer, sizeof(buffer), f) != NULL) { | ||
strtok(buffer, "\n"); | ||
puts(buffer); | ||
for (int i = min; i <= max; i++) { | ||
if ((numerical == 0 && isnumber(buffer) == 0) || numerical == 1) { | ||
printf("%s%d\n", buffer, i); | ||
|
@@ -40,10 +62,19 @@ ninc(FILE *f, int min, int max, int numerical) | |
} | ||
} | ||
|
||
void | ||
print_only(FILE *f) | ||
{ | ||
char buffer[BUFFER_SIZE]; | ||
while(fgets(buffer, sizeof(buffer), f) != NULL) { | ||
printf("%s",buffer); | ||
} | ||
} | ||
|
||
static void | ||
help(char * exename) | ||
{ | ||
printf( "Ninc - Narthex incrementor %s\n" | ||
printf( "ninc - Narthex incrementor %s\n" | ||
"By Michael C. Dim. <[email protected]>\n\n" | ||
|
||
"-n Increment numerical lines as well\n" | ||
|
@@ -88,7 +119,13 @@ main(int argc, char * argv[]) | |
} | ||
|
||
if (min <= max) { | ||
ninc(stdin, min, max, numerical); | ||
FILE * f; | ||
f = save_stdin(stdin); | ||
rewind(f); | ||
print_only(f); | ||
rewind(f); | ||
ninc(f, min, max, numerical); | ||
} | ||
|
||
exit(EXIT_SUCCESS); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,12 +5,23 @@ | |
#include <string.h> | ||
|
||
/* | ||
* Nhance - Narthex leetifier | ||
* nleet - Narthex leetifier | ||
* | ||
* By Michael Constantine Dimopoulos | ||
* https://mcdim.xyz <[email protected]> | ||
* License: GNU GPL v3 | ||
* | ||
* nleet will iterate over stdin or | ||
* a file and, after printing the | ||
* dictionary as is, it will reprint | ||
* it this time with some characters | ||
* replaced with their leet equiva- | ||
* lents. (hello -> h3ll0) | ||
* | ||
* You are encouraged to edit & | ||
* recompile this file if you want | ||
* to edit the substitution rules. | ||
* | ||
*/ | ||
|
||
|
||
|
@@ -84,7 +95,7 @@ die(char * str) | |
static void | ||
help(char * exename) | ||
{ | ||
printf( "Nhance - Narthex leetfier %s\n" | ||
printf( "nleet - Narthex leetfier %s\n" | ||
"By Michael C. Dim. <[email protected]>\n\n" | ||
|
||
"-h Print this panel & exit\n" | ||
|
Oops, something went wrong.